mirror of
https://github.com/friendica/friendica
synced 2025-04-26 02:30:11 +00:00
Get rid of App->user completely
This commit is contained in:
parent
fc283ab928
commit
28090bd793
39 changed files with 158 additions and 234 deletions
|
@ -38,7 +38,7 @@ class Delegation extends BaseSettings
|
|||
{
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
if (!local_user() || empty(DI::app()->getUserId()) || DI::app()->getUserId() != local_user()) {
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Core\Session;
|
|||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseSettings;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -38,13 +39,15 @@ class Display extends BaseSettings
|
|||
{
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
if (!local_user() || empty(DI::app()->getUserId()) || DI::app()->getUserId() != local_user()) {
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
|
||||
|
||||
$theme = !empty($_POST['theme']) ? Strings::escapeTags(trim($_POST['theme'])) : DI::app()->getUserValue('theme');
|
||||
$user = User::getById(local_user());
|
||||
|
||||
$theme = !empty($_POST['theme']) ? Strings::escapeTags(trim($_POST['theme'])) : $user['theme'];
|
||||
$mobile_theme = !empty($_POST['mobile_theme']) ? Strings::escapeTags(trim($_POST['mobile_theme'])) : '';
|
||||
$nosmile = !empty($_POST['nosmile']) ? intval($_POST['nosmile']) : 0;
|
||||
$first_day_of_week = !empty($_POST['first_day_of_week']) ? intval($_POST['first_day_of_week']) : 0;
|
||||
|
@ -92,7 +95,7 @@ class Display extends BaseSettings
|
|||
DI::pConfig()->set(local_user(), 'system', 'first_day_of_week' , $first_day_of_week);
|
||||
|
||||
if (in_array($theme, Theme::getAllowedList())) {
|
||||
if ($theme == DI::app()->getUserValue('theme')) {
|
||||
if ($theme == $user['theme']) {
|
||||
// call theme_post only if theme has not been changed
|
||||
if (($themeconfigfile = Theme::getConfigFile($theme)) !== null) {
|
||||
require_once $themeconfigfile;
|
||||
|
@ -128,6 +131,8 @@ class Display extends BaseSettings
|
|||
$default_mobile_theme = 'none';
|
||||
}
|
||||
|
||||
$user = User::getById(local_user());
|
||||
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
|
||||
$themes = [];
|
||||
|
@ -152,7 +157,7 @@ class Display extends BaseSettings
|
|||
}
|
||||
}
|
||||
|
||||
$theme_selected = DI::app()->getUserValue('theme') ?: $default_theme;
|
||||
$theme_selected = $user['theme'] ?: $default_theme;
|
||||
$mobile_theme_selected = Session::get('mobile-theme', $default_mobile_theme);
|
||||
|
||||
$itemspage_network = intval(DI::pConfig()->get(local_user(), 'system', 'itemspage_network'));
|
||||
|
|
|
@ -172,7 +172,7 @@ class Index extends BaseSettings
|
|||
'value' => ['profile_field[' . $profileField->id . '][value]', DI::l10n()->t('Value:'), $profileField->value],
|
||||
'acl' => ACL::getFullSelectorHTML(
|
||||
DI::page(),
|
||||
$a->user,
|
||||
$a->getUserId(),
|
||||
false,
|
||||
$defaultPermissions,
|
||||
['network' => Protocol::DFRN],
|
||||
|
@ -192,7 +192,7 @@ class Index extends BaseSettings
|
|||
'value' => ['profile_field[new][value]', DI::l10n()->t('Value:')],
|
||||
'acl' => ACL::getFullSelectorHTML(
|
||||
DI::page(),
|
||||
$a->user,
|
||||
$a->getUserId(),
|
||||
false,
|
||||
['allow_cid' => []],
|
||||
['network' => Protocol::DFRN],
|
||||
|
|
|
@ -90,7 +90,7 @@ class UserExport extends BaseSettings
|
|||
*/
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
if (!local_user() || empty(DI::app()->getUserId()) || DI::app()->getUserId() != local_user()) {
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -98,21 +98,20 @@ class UserExport extends BaseSettings
|
|||
if ($args->getArgc() == 3) {
|
||||
// @TODO Replace with router-provided arguments
|
||||
$action = $args->get(2);
|
||||
$user = DI::app()->user;
|
||||
switch ($action) {
|
||||
case "backup":
|
||||
header("Content-type: application/json");
|
||||
header('Content-Disposition: attachment; filename="' . $user['nickname'] . '.' . $action . '"');
|
||||
header('Content-Disposition: attachment; filename="' . DI::app()->getNickname() . '.' . $action . '"');
|
||||
self::exportAll(local_user());
|
||||
break;
|
||||
case "account":
|
||||
header("Content-type: application/json");
|
||||
header('Content-Disposition: attachment; filename="' . $user['nickname'] . '.' . $action . '"');
|
||||
header('Content-Disposition: attachment; filename="' . DI::app()->getNickname() . '.' . $action . '"');
|
||||
self::exportAccount(local_user());
|
||||
break;
|
||||
case "contact":
|
||||
header("Content-type: application/csv");
|
||||
header('Content-Disposition: attachment; filename="' . $user['nickname'] . '-contacts.csv' . '"');
|
||||
header('Content-Disposition: attachment; filename="' . DI::app()->getNickname() . '-contacts.csv' . '"');
|
||||
self::exportContactsAsCSV(local_user());
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue