diff --git a/src/App/Module.php b/src/App/Module.php index 0ed4b53e5..eb1621b8b 100644 --- a/src/App/Module.php +++ b/src/App/Module.php @@ -182,7 +182,7 @@ class Module **/ try { $module_class = $router->getModuleClass($args->getCommand()); - $module_parameters = $router->getModuleParameters(); + $module_parameters[] = $router->getModuleParameters(); } catch (MethodNotAllowedException $e) { $module_class = MethodNotAllowed::class; } catch (NotFoundException $e) { @@ -195,8 +195,8 @@ class Module } else { include_once "addon/{$this->module}/{$this->module}.php"; if (function_exists($this->module . '_module')) { - LegacyModule::setModuleFile("addon/{$this->module}/{$this->module}.php"); - $module_class = LegacyModule::class; + $module_parameters[] = "addon/{$this->module}/{$this->module}.php"; + $module_class = LegacyModule::class; } } } @@ -205,15 +205,15 @@ class Module * We emulate a Module class through the LegacyModule class */ if (!$module_class && file_exists("mod/{$this->module}.php")) { - LegacyModule::setModuleFile("mod/{$this->module}.php"); - $module_class = LegacyModule::class; + $module_parameters[] = "mod/{$this->module}.php"; + $module_class = LegacyModule::class; } $module_class = $module_class ?: PageNotFound::class; } /** @var ICanHandleRequests $module */ - $module = $dice->create($module_class, [$module_parameters]); + $module = $dice->create($module_class, $module_parameters); return new Module($this->module, $module, $this->isBackend, $printNotAllowedAddon); } diff --git a/src/BaseModule.php b/src/BaseModule.php index 76458c6c6..2873357fd 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -37,11 +37,11 @@ use Friendica\Model\User; abstract class BaseModule implements ICanHandleRequests { /** @var array */ - protected static $parameters = []; + protected $parameters = []; public function __construct(array $parameters = []) { - static::$parameters = $parameters; + $this->parameters = $parameters; } /** diff --git a/src/LegacyModule.php b/src/LegacyModule.php index e90b004bc..5f0cc3103 100644 --- a/src/LegacyModule.php +++ b/src/LegacyModule.php @@ -35,7 +35,14 @@ class LegacyModule extends BaseModule * * @var string */ - private static $moduleName = ''; + private $moduleName = ''; + + public function __construct(string $file_path = '', array $parameters = []) + { + parent::__construct($parameters); + + $this->setModuleFile($file_path); + } /** * The only method that needs to be called, with the module/addon file name. @@ -43,35 +50,35 @@ class LegacyModule extends BaseModule * @param string $file_path * @throws \Exception */ - public static function setModuleFile($file_path) + private function setModuleFile($file_path) { if (!is_readable($file_path)) { throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path)); } - self::$moduleName = basename($file_path, '.php'); + $this->moduleName = basename($file_path, '.php'); require_once $file_path; } public function init() { - self::runModuleFunction('init', static::$parameters); + $this->runModuleFunction('init'); } public function content(): string { - return self::runModuleFunction('content', static::$parameters); + return $this->runModuleFunction('content'); } public function post() { - self::runModuleFunction('post', static::$parameters); + $this->runModuleFunction('post'); } public function afterpost() { - self::runModuleFunction('afterpost', static::$parameters); + $this->runModuleFunction('afterpost'); } /** @@ -81,15 +88,15 @@ class LegacyModule extends BaseModule * @return string * @throws \Exception */ - private static function runModuleFunction($function_suffix, array $parameters = []) + private function runModuleFunction(string $function_suffix) { - $function_name = static::$moduleName . '_' . $function_suffix; + $function_name = $this->moduleName . '_' . $function_suffix; if (\function_exists($function_name)) { $a = DI::app(); return $function_name($a); } else { - return parent::{$function_suffix}($parameters); + return parent::{$function_suffix}($this->parameters); } } } diff --git a/src/Module/ActivityPub/Followers.php b/src/Module/ActivityPub/Followers.php index e19e7eacf..d25e4693c 100644 --- a/src/Module/ActivityPub/Followers.php +++ b/src/Module/ActivityPub/Followers.php @@ -33,12 +33,12 @@ class Followers extends BaseModule { public function rawContent() { - if (empty(static::$parameters['nickname'])) { + if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); } // @TODO: Replace with parameter from router - $owner = User::getOwnerDataByNick(static::$parameters['nickname']); + $owner = User::getOwnerDataByNick($this->parameters['nickname']); if (empty($owner)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/ActivityPub/Following.php b/src/Module/ActivityPub/Following.php index 2fa2d640f..3b45cf09a 100644 --- a/src/Module/ActivityPub/Following.php +++ b/src/Module/ActivityPub/Following.php @@ -33,11 +33,11 @@ class Following extends BaseModule { public function rawContent() { - if (empty(static::$parameters['nickname'])) { + if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); } - $owner = User::getOwnerDataByNick(static::$parameters['nickname']); + $owner = User::getOwnerDataByNick($this->parameters['nickname']); if (empty($owner)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/ActivityPub/Inbox.php b/src/Module/ActivityPub/Inbox.php index 4056a7de3..149e51106 100644 --- a/src/Module/ActivityPub/Inbox.php +++ b/src/Module/ActivityPub/Inbox.php @@ -50,12 +50,12 @@ class Inbox extends BaseModule $filename = 'failed-activitypub'; } $tempfile = tempnam(System::getTempPath(), $filename); - file_put_contents($tempfile, json_encode(['parameters' => static::$parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + file_put_contents($tempfile, json_encode(['parameters' => $this->parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); Logger::notice('Incoming message stored', ['file' => $tempfile]); } - if (!empty(static::$parameters['nickname'])) { - $user = DBA::selectFirst('user', ['uid'], ['nickname' => static::$parameters['nickname']]); + if (!empty($this->parameters['nickname'])) { + $user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]); if (!DBA::isResult($user)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/ActivityPub/Objects.php b/src/Module/ActivityPub/Objects.php index eedcb0bd4..5798c5685 100644 --- a/src/Module/ActivityPub/Objects.php +++ b/src/Module/ActivityPub/Objects.php @@ -43,7 +43,7 @@ class Objects extends BaseModule { public function rawContent() { - if (empty(static::$parameters['guid'])) { + if (empty($this->parameters['guid'])) { throw new HTTPException\BadRequestException(); } @@ -51,10 +51,10 @@ class Objects extends BaseModule DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString())); } - $itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => static::$parameters['guid']]); + $itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $this->parameters['guid']]); if (DBA::isResult($itemuri)) { - Logger::info('Provided GUID found.', ['guid' => static::$parameters['guid'], 'uri-id' => $itemuri['id']]); + Logger::info('Provided GUID found.', ['guid' => $this->parameters['guid'], 'uri-id' => $itemuri['id']]); } else { // The item URI does not always contain the GUID. This means that we have to search the URL instead $url = DI::baseUrl()->get() . '/' . DI::args()->getQueryString(); @@ -104,11 +104,11 @@ class Objects extends BaseModule throw new HTTPException\NotFoundException(); } - $etag = md5(static::$parameters['guid'] . '-' . $item['changed']); + $etag = md5($this->parameters['guid'] . '-' . $item['changed']); $last_modified = $item['changed']; Network::checkEtagModified($etag, $last_modified); - if (empty(static::$parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) { + if (empty($this->parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) { $activity = ActivityPub\Transmitter::createActivityFromItem($item['id'], true); if (empty($activity['type'])) { throw new HTTPException\NotFoundException(); @@ -123,16 +123,16 @@ class Objects extends BaseModule $data = ['@context' => ActivityPub::CONTEXT]; $data = array_merge($data, $activity['object']); - } elseif (empty(static::$parameters['activity']) || in_array(static::$parameters['activity'], + } elseif (empty($this->parameters['activity']) || in_array($this->parameters['activity'], ['Create', 'Announce', 'Update', 'Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept', 'Follow', 'Add'])) { $data = ActivityPub\Transmitter::createActivityFromItem($item['id']); if (empty($data)) { throw new HTTPException\NotFoundException(); } - if (!empty(static::$parameters['activity']) && (static::$parameters['activity'] != 'Create')) { - $data['type'] = static::$parameters['activity']; - $data['id'] = str_replace('/Create', '/' . static::$parameters['activity'], $data['id']); + if (!empty($this->parameters['activity']) && ($this->parameters['activity'] != 'Create')) { + $data['type'] = $this->parameters['activity']; + $data['id'] = str_replace('/Create', '/' . $this->parameters['activity'], $data['id']); } } else { throw new HTTPException\NotFoundException(); diff --git a/src/Module/ActivityPub/Outbox.php b/src/Module/ActivityPub/Outbox.php index 55144ce1b..c459a55e3 100644 --- a/src/Module/ActivityPub/Outbox.php +++ b/src/Module/ActivityPub/Outbox.php @@ -33,11 +33,11 @@ class Outbox extends BaseModule { public function rawContent() { - if (empty(static::$parameters['nickname'])) { + if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); } - $owner = User::getOwnerDataByNick(static::$parameters['nickname']); + $owner = User::getOwnerDataByNick($this->parameters['nickname']); if (empty($owner)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index 7748926cc..bab52fb0d 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -34,7 +34,7 @@ class Details extends BaseAdmin { self::checkAdminAccess(); - $addon = Strings::sanitizeFilePathItem(static::$parameters['addon']); + $addon = Strings::sanitizeFilePathItem($this->parameters['addon']); $redirect = 'admin/addons/' . $addon; @@ -60,7 +60,7 @@ class Details extends BaseAdmin $addons_admin = Addon::getAdminList(); - $addon = Strings::sanitizeFilePathItem(static::$parameters['addon']); + $addon = Strings::sanitizeFilePathItem($this->parameters['addon']); if (!is_file("addon/$addon/$addon.php")) { notice(DI::l10n()->t('Addon not found.')); Addon::uninstall($addon); diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php index 90588cfa9..6ef8d804a 100644 --- a/src/Module/Admin/DBSync.php +++ b/src/Module/Admin/DBSync.php @@ -36,8 +36,8 @@ class DBSync extends BaseAdmin $a = DI::app(); - $action = static::$parameters['action'] ?? ''; - $update = static::$parameters['update'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $update = $this->parameters['update'] ?? 0; switch ($action) { case 'mark': diff --git a/src/Module/Admin/Item/Source.php b/src/Module/Admin/Item/Source.php index 9b81d9e76..c1edabf60 100644 --- a/src/Module/Admin/Item/Source.php +++ b/src/Module/Admin/Item/Source.php @@ -33,7 +33,7 @@ class Source extends BaseAdmin { parent::content(); - $guid = basename($_REQUEST['guid'] ?? static::$parameters['guid'] ?? ''); + $guid = basename($_REQUEST['guid'] ?? $this->parameters['guid'] ?? ''); $source = ''; $item_uri = ''; diff --git a/src/Module/Admin/Queue.php b/src/Module/Admin/Queue.php index b3460c9aa..f43dfdc09 100644 --- a/src/Module/Admin/Queue.php +++ b/src/Module/Admin/Queue.php @@ -42,7 +42,7 @@ class Queue extends BaseAdmin { parent::content(); - $status = static::$parameters['status'] ?? ''; + $status = $this->parameters['status'] ?? ''; // get jobs from the workerqueue table if ($status == 'deferred') { diff --git a/src/Module/Admin/Storage.php b/src/Module/Admin/Storage.php index d0d9c3aa4..68d7d065d 100644 --- a/src/Module/Admin/Storage.php +++ b/src/Module/Admin/Storage.php @@ -37,7 +37,7 @@ class Storage extends BaseAdmin self::checkFormSecurityTokenRedirectOnError('/admin/storage', 'admin_storage'); - $storagebackend = trim(static::$parameters['name'] ?? ''); + $storagebackend = trim($this->parameters['name'] ?? ''); try { /** @var ICanConfigureStorage|false $newStorageConfig */ diff --git a/src/Module/Admin/Themes/Details.php b/src/Module/Admin/Themes/Details.php index b81b76ab3..b7161d1b9 100644 --- a/src/Module/Admin/Themes/Details.php +++ b/src/Module/Admin/Themes/Details.php @@ -34,7 +34,7 @@ class Details extends BaseAdmin { parent::content(); - $theme = Strings::sanitizeFilePathItem(static::$parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (!is_dir("view/theme/$theme")) { notice(DI::l10n()->t("Item not found.")); return ''; diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 277933802..bf4e5b556 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -30,7 +30,7 @@ class Embed extends BaseAdmin { public function init() { - $theme = Strings::sanitizeFilePathItem(static::$parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (is_file("view/theme/$theme/config.php")) { DI::app()->setCurrentTheme($theme); } @@ -40,7 +40,7 @@ class Embed extends BaseAdmin { self::checkAdminAccess(); - $theme = Strings::sanitizeFilePathItem(static::$parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (is_file("view/theme/$theme/config.php")) { require_once "view/theme/$theme/config.php"; if (function_exists('theme_admin_post')) { @@ -60,7 +60,7 @@ class Embed extends BaseAdmin { parent::content(); - $theme = Strings::sanitizeFilePathItem(static::$parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (!is_dir("view/theme/$theme")) { notice(DI::l10n()->t('Unknown theme.')); return ''; diff --git a/src/Module/Admin/Tos.php b/src/Module/Admin/Tos.php index 3c0b00deb..17c8372b0 100644 --- a/src/Module/Admin/Tos.php +++ b/src/Module/Admin/Tos.php @@ -52,7 +52,7 @@ class Tos extends BaseAdmin { parent::content(); - $tos = new \Friendica\Module\Tos(static::$parameters); + $tos = new \Friendica\Module\Tos($this->parameters); $t = Renderer::getMarkupTemplate('admin/tos.tpl'); return Renderer::replaceMacros($t, [ '$title' => DI::l10n()->t('Administration'), diff --git a/src/Module/Admin/Users/Active.php b/src/Module/Admin/Users/Active.php index 613c89764..6bcd22be4 100644 --- a/src/Module/Admin/Users/Active.php +++ b/src/Module/Admin/Users/Active.php @@ -64,8 +64,8 @@ class Active extends BaseUsers { parent::content(); - $action = static::$parameters['action'] ?? ''; - $uid = static::$parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Admin/Users/Blocked.php b/src/Module/Admin/Users/Blocked.php index 9ef6dab87..a24c95df0 100644 --- a/src/Module/Admin/Users/Blocked.php +++ b/src/Module/Admin/Users/Blocked.php @@ -65,8 +65,8 @@ class Blocked extends BaseUsers { parent::content(); - $action = static::$parameters['action'] ?? ''; - $uid = static::$parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Admin/Users/Index.php b/src/Module/Admin/Users/Index.php index dff00083b..eb7b57c25 100644 --- a/src/Module/Admin/Users/Index.php +++ b/src/Module/Admin/Users/Index.php @@ -71,8 +71,8 @@ class Index extends BaseUsers { parent::content(); - $action = static::$parameters['action'] ?? ''; - $uid = static::$parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Admin/Users/Pending.php b/src/Module/Admin/Users/Pending.php index eb90db7b9..801c15974 100644 --- a/src/Module/Admin/Users/Pending.php +++ b/src/Module/Admin/Users/Pending.php @@ -62,8 +62,8 @@ class Pending extends BaseUsers { parent::content(); - $action = static::$parameters['action'] ?? ''; - $uid = static::$parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Api/Friendica/Activity.php b/src/Module/Api/Friendica/Activity.php index 5f28297b4..1b2b95d06 100644 --- a/src/Module/Api/Friendica/Activity.php +++ b/src/Module/Api/Friendica/Activity.php @@ -49,17 +49,17 @@ class Activity extends BaseApi 'id' => 0, // Id of the post ]); - $res = Item::performActivity($request['id'], static::$parameters['verb'], $uid); + $res = Item::performActivity($request['id'], $this->parameters['verb'], $uid); if ($res) { - if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $ok = 'true'; } else { $ok = 'ok'; } - DI::apiResponse()->exit('ok', ['ok' => $ok], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); } else { - DI::apiResponse()->error(500, 'Error adding activity', '', static::$parameters['extension'] ?? null); + DI::apiResponse()->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null); } } } diff --git a/src/Module/Api/Friendica/DirectMessages/Setseen.php b/src/Module/Api/Friendica/DirectMessages/Setseen.php index 944376aad..600d5fe17 100644 --- a/src/Module/Api/Friendica/DirectMessages/Setseen.php +++ b/src/Module/Api/Friendica/DirectMessages/Setseen.php @@ -42,13 +42,13 @@ class Setseen extends BaseApi // return error if id is zero if (empty($request['id'])) { $answer = ['result' => 'error', 'message' => 'message id not specified']; - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); } // error message if specified id is not in database if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) { $answer = ['result' => 'error', 'message' => 'message id not in database']; - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); } // update seen indicator @@ -58,6 +58,6 @@ class Setseen extends BaseApi $answer = ['result' => 'error', 'message' => 'unknown error']; } - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Events/Index.php b/src/Module/Api/Friendica/Events/Index.php index 439e021f3..b6cfdd098 100644 --- a/src/Module/Api/Friendica/Events/Index.php +++ b/src/Module/Api/Friendica/Events/Index.php @@ -70,6 +70,6 @@ class Index extends BaseApi ]; } - DI::apiResponse()->exit('events', ['events' => $items], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('events', ['events' => $items], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Notification.php b/src/Module/Api/Friendica/Notification.php index 3057c8cb7..9d316d94d 100644 --- a/src/Module/Api/Friendica/Notification.php +++ b/src/Module/Api/Friendica/Notification.php @@ -43,7 +43,7 @@ class Notification extends BaseApi $notifications[] = new ApiNotification($Notify); } - if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $xmlnotes = []; foreach ($notifications as $notification) { $xmlnotes[] = ['@attributes' => $notification->toArray()]; @@ -56,6 +56,6 @@ class Notification extends BaseApi $result = false; } - DI::apiResponse()->exit('notes', ['note' => $result], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Photo/Delete.php b/src/Module/Api/Friendica/Photo/Delete.php index d98296625..ab749b4e8 100644 --- a/src/Module/Api/Friendica/Photo/Delete.php +++ b/src/Module/Api/Friendica/Photo/Delete.php @@ -64,7 +64,7 @@ class Delete extends BaseApi Item::deleteForUser($condition, $uid); $result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.']; - DI::apiResponse()->exit('photo_delete', ['$result' => $result], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error on deleting photo from database table"); } diff --git a/src/Module/Api/Friendica/Photoalbum/Delete.php b/src/Module/Api/Friendica/Photoalbum/Delete.php index 01d05f44b..0a403270d 100644 --- a/src/Module/Api/Friendica/Photoalbum/Delete.php +++ b/src/Module/Api/Friendica/Photoalbum/Delete.php @@ -67,7 +67,7 @@ class Delete extends BaseApi // return success of deletion or error message if ($result) { $answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.']; - DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error - deleting from database failed"); } diff --git a/src/Module/Api/Friendica/Photoalbum/Update.php b/src/Module/Api/Friendica/Photoalbum/Update.php index b45f6ced4..9fc89dbf6 100644 --- a/src/Module/Api/Friendica/Photoalbum/Update.php +++ b/src/Module/Api/Friendica/Photoalbum/Update.php @@ -59,7 +59,7 @@ class Update extends BaseApi // return success of updating or error message if ($result) { $answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.']; - DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error - updating in database failed"); } diff --git a/src/Module/Api/Friendica/Profile/Show.php b/src/Module/Api/Friendica/Profile/Show.php index a1280eb7c..fe0315a84 100644 --- a/src/Module/Api/Friendica/Profile/Show.php +++ b/src/Module/Api/Friendica/Profile/Show.php @@ -49,7 +49,7 @@ class Show extends BaseApi $profile = self::formatProfile($profile, $profileFields); $profiles = []; - if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $profiles['0:profile'] = $profile; } else { $profiles[] = $profile; @@ -65,7 +65,7 @@ class Show extends BaseApi 'profiles' => $profiles ]; - DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null); } /** diff --git a/src/Module/Api/GNUSocial/GNUSocial/Version.php b/src/Module/Api/GNUSocial/GNUSocial/Version.php index d8ff5c95f..c9c7b98fd 100644 --- a/src/Module/Api/GNUSocial/GNUSocial/Version.php +++ b/src/Module/Api/GNUSocial/GNUSocial/Version.php @@ -31,6 +31,6 @@ class Version extends BaseApi { public function rawContent() { - DI::apiResponse()->exit('version', ['version' => '0.9.7'], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/GNUSocial/Help/Test.php b/src/Module/Api/GNUSocial/Help/Test.php index d15782286..78f18c3e6 100644 --- a/src/Module/Api/GNUSocial/Help/Test.php +++ b/src/Module/Api/GNUSocial/Help/Test.php @@ -31,12 +31,12 @@ class Test extends BaseApi { public function rawContent() { - if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $ok = 'true'; } else { $ok = 'ok'; } - DI::apiResponse()->exit('ok', ['ok' => $ok], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Mastodon/Accounts.php b/src/Module/Api/Mastodon/Accounts.php index 13981684f..552889661 100644 --- a/src/Module/Api/Mastodon/Accounts.php +++ b/src/Module/Api/Mastodon/Accounts.php @@ -39,20 +39,20 @@ class Accounts extends BaseApi { $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id']) && empty(static::$parameters['name'])) { + if (empty($this->parameters['id']) && empty($this->parameters['name'])) { DI::mstdnError()->UnprocessableEntity(); } - if (!empty(static::$parameters['id'])) { - $id = static::$parameters['id']; + if (!empty($this->parameters['id'])) { + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } } else { - $contact = Contact::selectFirst(['id'], ['nick' => static::$parameters['name'], 'uid' => 0]); + $contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]); if (!empty($contact['id'])) { $id = $contact['id']; - } elseif (!($id = Contact::getIdForURL(static::$parameters['name'], 0, false))) { + } elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) { DI::mstdnError()->RecordNotFound(); } } diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index 522eeb11f..b2ae98bd5 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -37,7 +37,7 @@ class Block extends BaseApi self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -46,7 +46,7 @@ class Block extends BaseApi DI::mstdnError()->Forbidden(); } - $cdata = Contact::getPublicAndUserContactID(static::$parameters['id'], $uid); + $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { DI::mstdnError()->RecordNotFound(); } @@ -62,6 +62,6 @@ class Block extends BaseApi Contact::terminateFriendship($owner, $contact); Contact::revokeFollow($contact); - System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Follow.php b/src/Module/Api/Mastodon/Accounts/Follow.php index 3ed761172..86b932421 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -36,11 +36,11 @@ class Follow extends BaseApi self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $cid = Contact::follow(static::$parameters['id'], $uid); + $cid = Contact::follow($this->parameters['id'], $uid); System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray()); } diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index 3270da828..981d2c715 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -39,11 +39,11 @@ class Followers extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -72,7 +72,7 @@ class Followers extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('contact-relation', ['relation-cid'], $condition, static::$parameters); + $followers = DBA::select('contact-relation', ['relation-cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['relation-cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid); diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index 9768d2a03..41352ddaf 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -39,11 +39,11 @@ class Following extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -72,7 +72,7 @@ class Following extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('contact-relation', ['cid'], $condition, static::$parameters); + $followers = DBA::select('contact-relation', ['cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); diff --git a/src/Module/Api/Mastodon/Accounts/Lists.php b/src/Module/Api/Mastodon/Accounts/Lists.php index 4860c4fe5..f34b961b6 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -40,11 +40,11 @@ class Lists extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Accounts/Mute.php b/src/Module/Api/Mastodon/Accounts/Mute.php index 159afdfd9..1c711db75 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -36,12 +36,12 @@ class Mute extends BaseApi self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact\User::setIgnored(static::$parameters['id'], $uid, true); + Contact\User::setIgnored($this->parameters['id'], $uid, true); - System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index d14afbb48..fe4611754 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -37,7 +37,7 @@ class Note extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -45,13 +45,13 @@ class Note extends BaseApi 'comment' => '', ]); - $cdata = Contact::getPublicAndUserContactID(static::$parameters['id'], $uid); + $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { DI::mstdnError()->RecordNotFound(); } Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]); - System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index 1c95d74c7..5bf7b4934 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -43,11 +43,11 @@ class Statuses extends BaseApi { $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Accounts/Unblock.php b/src/Module/Api/Mastodon/Accounts/Unblock.php index aed46c332..ae2414b8a 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -36,12 +36,12 @@ class Unblock extends BaseApi self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact\User::setBlocked(static::$parameters['id'], $uid, false); + Contact\User::setBlocked($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index 78b6bad62..a15c946bb 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -36,12 +36,12 @@ class Unfollow extends BaseApi self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact::unfollow(static::$parameters['id'], $uid); + Contact::unfollow($this->parameters['id'], $uid); - System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Unmute.php b/src/Module/Api/Mastodon/Accounts/Unmute.php index 3e9146f21..d1410f782 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -36,12 +36,12 @@ class Unmute extends BaseApi self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact\User::setIgnored(static::$parameters['id'], $uid, false); + Contact\User::setIgnored($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Blocks.php b/src/Module/Api/Mastodon/Blocks.php index c141b0482..b6a26d973 100644 --- a/src/Module/Api/Mastodon/Blocks.php +++ b/src/Module/Api/Mastodon/Blocks.php @@ -39,11 +39,11 @@ class Blocks extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -72,7 +72,7 @@ class Blocks extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('user-contact', ['cid'], $condition, static::$parameters); + $followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index fbee5672e..a3f6a26a2 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -36,12 +36,12 @@ class Conversations extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (!empty(static::$parameters['id'])) { + if (!empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - DBA::delete('conv', ['id' => static::$parameters['id'], 'uid' => $uid]); - DBA::delete('mail', ['convid' => static::$parameters['id'], 'uid' => $uid]); + DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]); + DBA::delete('mail', ['convid' => $this->parameters['id'], 'uid' => $uid]); System::jsonExit([]); } diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index 27f012c01..1eadc671c 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -36,12 +36,12 @@ class Read extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (!empty(static::$parameters['id'])) { + if (!empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - DBA::update('mail', ['seen' => true], ['convid' => static::$parameters['id'], 'uid' => $uid]); + DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]); - System::jsonExit(DI::mstdnConversation()->CreateFromConvId(static::$parameters['id'])->toArray()); + System::jsonExit(DI::mstdnConversation()->CreateFromConvId($this->parameters['id'])->toArray()); } } diff --git a/src/Module/Api/Mastodon/FollowRequests.php b/src/Module/Api/Mastodon/FollowRequests.php index a334b897a..af4ac5771 100644 --- a/src/Module/Api/Mastodon/FollowRequests.php +++ b/src/Module/Api/Mastodon/FollowRequests.php @@ -47,11 +47,11 @@ class FollowRequests extends BaseApi self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - $introduction = DI::intro()->selectOneById(static::$parameters['id'], $uid); + $introduction = DI::intro()->selectOneById($this->parameters['id'], $uid); $contactId = $introduction->cid; - switch (static::$parameters['action']) { + switch ($this->parameters['action']) { case 'authorize': Contact\Introduction::confirm($introduction); $relationship = DI::mstdnRelationship()->createFromContactId($contactId, $uid); diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index 8a3f7a0ad..e7a66f04d 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -36,15 +36,15 @@ class Lists extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - if (!Group::exists(static::$parameters['id'], $uid)) { + if (!Group::exists($this->parameters['id'], $uid)) { DI::mstdnError()->RecordNotFound(); } - if (!Group::remove(static::$parameters['id'])) { + if (!Group::remove($this->parameters['id'])) { DI::mstdnError()->InternalError(); } @@ -81,11 +81,11 @@ class Lists extends BaseApi 'replies_policy' => '', // One of: "followed", "list", or "none". ]); - if (empty($request['title']) || empty(static::$parameters['id'])) { + if (empty($request['title']) || empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Group::update(static::$parameters['id'], $request['title']); + Group::update($this->parameters['id'], $request['title']); } /** @@ -96,7 +96,7 @@ class Lists extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { $lists = []; $groups = Group::getByUserId($uid); @@ -105,7 +105,7 @@ class Lists extends BaseApi $lists[] = DI::mstdnList()->createFromGroupId($group['id']); } } else { - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!Group::exists($id, $uid)) { DI::mstdnError()->RecordNotFound(); diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index cdc75b6d4..c70e20349 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -53,11 +53,11 @@ class Accounts extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index cd858f5ee..dc31bdec6 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -65,18 +65,18 @@ class Media extends BaseApi 'focus' => '', // Two floating points (x,y), comma-delimited ranging from -1.0 to 1.0 ]); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $photo = Photo::selectFirst(['resource-id'], ['id' => static::$parameters['id'], 'uid' => $uid]); + $photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]); if (empty($photo['resource-id'])) { DI::mstdnError()->RecordNotFound(); } Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]); - System::jsonExit(DI::mstdnAttachment()->createFromPhoto(static::$parameters['id'])); + System::jsonExit(DI::mstdnAttachment()->createFromPhoto($this->parameters['id'])); } /** @@ -87,11 +87,11 @@ class Media extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!Photo::exists(['id' => $id, 'uid' => $uid])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Mutes.php b/src/Module/Api/Mastodon/Mutes.php index b5ba3fcfd..3c24071f0 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -39,11 +39,11 @@ class Mutes extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -72,7 +72,7 @@ class Mutes extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('user-contact', ['cid'], $condition, static::$parameters); + $followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index c2ddf2a4d..274a85786 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -45,8 +45,8 @@ class Notifications extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (!empty(static::$parameters['id'])) { - $id = static::$parameters['id']; + if (!empty($this->parameters['id'])) { + $id = $this->parameters['id']; try { $notification = DI::notification()->selectOneForUser($uid, ['id' => $id]); System::jsonExit(DI::mstdnNotification()->createFromNotification($notification)); diff --git a/src/Module/Api/Mastodon/Notifications/Dismiss.php b/src/Module/Api/Mastodon/Notifications/Dismiss.php index b135b5bbf..b978e46ee 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -37,11 +37,11 @@ class Dismiss extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $Notification = DI::notification()->selectOneForUser($uid, static::$parameters['id']); + $Notification = DI::notification()->selectOneForUser($uid, $this->parameters['id']); $Notification->setSeen(); DI::notification()->save($Notification); diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index b22929381..bfb2cff45 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -47,15 +47,15 @@ class ScheduledStatuses extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - if (!DBA::exists('delayed-post', ['id' => static::$parameters['id'], 'uid' => $uid])) { + if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) { DI::mstdnError()->RecordNotFound(); } - Post\Delayed::deleteById(static::$parameters['id']); + Post\Delayed::deleteById($this->parameters['id']); System::jsonExit([]); } @@ -68,8 +68,8 @@ class ScheduledStatuses extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (isset(static::$parameters['id'])) { - System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId(static::$parameters['id'], $uid)->toArray()); + if (isset($this->parameters['id'])) { + System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($this->parameters['id'], $uid)->toArray()); } $request = self::getRequest([ diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index dc7c856ac..6753b0909 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -73,7 +73,7 @@ class Search extends BaseApi $result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']); } if ((empty($request['type']) || ($request['type'] == 'hashtags')) && (strpos($request['q'], '@') == false)) { - $result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], static::$parameters['version']); + $result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']); } System::jsonExit($result); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 8ffeef07a..50c35f347 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -212,11 +212,11 @@ class Statuses extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => static::$parameters['id'], 'uid' => $uid]); + $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]); if (empty($item['id'])) { DI::mstdnError()->RecordNotFound(); } @@ -235,10 +235,10 @@ class Statuses extends BaseApi { $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)); } } diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index 4d2f096cd..de0ef641d 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -38,11 +38,11 @@ class Bookmark extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -53,6 +53,6 @@ class Bookmark extends BaseApi Item::update(['starred' => true], ['id' => $item['id']]); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Card.php b/src/Module/Api/Mastodon/Statuses/Card.php index 698dfab8c..d3c1801a2 100644 --- a/src/Module/Api/Mastodon/Statuses/Card.php +++ b/src/Module/Api/Mastodon/Statuses/Card.php @@ -39,11 +39,11 @@ class Card extends BaseApi { $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { throw new HTTPException\NotFoundException('Item with URI ID ' . $id . ' not found' . ($uid ? ' for user ' . $uid : '.')); diff --git a/src/Module/Api/Mastodon/Statuses/Context.php b/src/Module/Api/Mastodon/Statuses/Context.php index da59bb1d9..03782ef1c 100644 --- a/src/Module/Api/Mastodon/Statuses/Context.php +++ b/src/Module/Api/Mastodon/Statuses/Context.php @@ -39,7 +39,7 @@ class Context extends BaseApi { $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -47,7 +47,7 @@ class Context extends BaseApi 'limit' => 40, // Maximum number of results to return. Defaults to 40. ]); - $id = static::$parameters['id']; + $id = $this->parameters['id']; $parents = []; $children = []; diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index 3fe55807b..8ec818a8f 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -38,17 +38,17 @@ class Favourite extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } Item::performActivity($item['id'], 'like', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php index b6726cc54..37d9e7521 100644 --- a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php +++ b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php @@ -39,11 +39,11 @@ class FavouritedBy extends BaseApi { $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 739126d58..4a0e943f3 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -37,11 +37,11 @@ class Mute extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Mute extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted')); } - Post\ThreadUser::setIgnored(static::$parameters['id'], $uid, true); + Post\ThreadUser::setIgnored($this->parameters['id'], $uid, true); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index b7573fd9d..7648d12a0 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -37,11 +37,11 @@ class Pin extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Pin extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned')); } - Post\ThreadUser::setPinned(static::$parameters['id'], $uid, true); + Post\ThreadUser::setPinned($this->parameters['id'], $uid, true); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index 136491bf2..d10149616 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -40,11 +40,11 @@ class Reblog extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -55,6 +55,6 @@ class Reblog extends BaseApi Item::performActivity($item['id'], 'announce', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php index de2004b86..52f1e2f67 100644 --- a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php +++ b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php @@ -39,11 +39,11 @@ class RebloggedBy extends BaseApi { $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = static::$parameters['id']; + $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index d6bd6fcc8..9279fec60 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -38,11 +38,11 @@ class Unbookmark extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -53,6 +53,6 @@ class Unbookmark extends BaseApi Item::update(['starred' => false], ['id' => $item['id']]); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index 244b38cd1..7898647ac 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -38,17 +38,17 @@ class Unfavourite extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } Item::performActivity($item['id'], 'unlike', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index a659b5b07..80b9c2c54 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -37,11 +37,11 @@ class Unmute extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Unmute extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted')); } - Post\ThreadUser::setIgnored(static::$parameters['id'], $uid, false); + Post\ThreadUser::setIgnored($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index 1eaf73409..21f44b7cb 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -37,11 +37,11 @@ class Unpin extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Unpin extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned')); } - Post\ThreadUser::setPinned(static::$parameters['id'], $uid, false); + Post\ThreadUser::setPinned($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 234d1058f..972a6aa1a 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -40,11 +40,11 @@ class Unreblog extends BaseApi self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -55,6 +55,6 @@ class Unreblog extends BaseApi Item::performActivity($item['id'], 'unannounce', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index 6d5815311..c9316fdf5 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -41,7 +41,7 @@ class ListTimeline extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -60,7 +60,7 @@ class ListTimeline extends BaseApi $params = ['order' => ['uri-id' => true], 'limit' => $request['limit']]; $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", - $uid, GRAVITY_PARENT, GRAVITY_COMMENT, static::$parameters['id']]; + $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $this->parameters['id']]; if (!empty($request['max_id'])) { $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]); diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 80ccf5a9c..3571dd733 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -42,7 +42,7 @@ class Tag extends BaseApi self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty(static::$parameters['hashtag'])) { + if (empty($this->parameters['hashtag'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -69,7 +69,7 @@ class Tag extends BaseApi $condition = ["`name` = ? AND (`uid` = ? OR (`uid` = ? AND NOT `global`)) AND (`network` IN (?, ?, ?, ?) OR (`uid` = ? AND `uid` != ?))", - static::$parameters['hashtag'], 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0]; + $this->parameters['hashtag'], 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0]; if ($request['local']) { $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]); diff --git a/src/Module/Api/Twitter/Account/RateLimitStatus.php b/src/Module/Api/Twitter/Account/RateLimitStatus.php index fa1383b8e..e38ffb061 100644 --- a/src/Module/Api/Twitter/Account/RateLimitStatus.php +++ b/src/Module/Api/Twitter/Account/RateLimitStatus.php @@ -32,7 +32,7 @@ class RateLimitStatus extends BaseApi { public function rawContent() { - if (!empty(static::$parameters['extension']) && (static::$parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $hash = [ 'remaining-hits' => '150', '@attributes' => ["type" => "integer"], @@ -52,6 +52,6 @@ class RateLimitStatus extends BaseApi ]; } - DI::apiResponse()->exit('hash', ['hash' => $hash], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('hash', ['hash' => $hash], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Twitter/SavedSearches.php b/src/Module/Api/Twitter/SavedSearches.php index 8c513a960..ac7531671 100644 --- a/src/Module/Api/Twitter/SavedSearches.php +++ b/src/Module/Api/Twitter/SavedSearches.php @@ -45,6 +45,6 @@ class SavedSearches extends BaseApi DBA::close($terms); - DI::apiResponse()->exit('terms', ['terms' => $result], static::$parameters['extension'] ?? null); + DI::apiResponse()->exit('terms', ['terms' => $result], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Attach.php b/src/Module/Attach.php index 84961ca27..c35e6b9ba 100644 --- a/src/Module/Attach.php +++ b/src/Module/Attach.php @@ -37,11 +37,11 @@ class Attach extends BaseModule public function rawContent() { $a = DI::app(); - if (empty(static::$parameters['item'])) { + if (empty($this->parameters['item'])) { throw new \Friendica\Network\HTTPException\BadRequestException(); } - $item_id = intval(static::$parameters['item']); + $item_id = intval($this->parameters['item']); // Check for existence $item = MAttach::exists(['id' => $item_id]); diff --git a/src/Module/Contact/Advanced.php b/src/Module/Contact/Advanced.php index 53ab31d1a..fb3aa62f4 100644 --- a/src/Module/Contact/Advanced.php +++ b/src/Module/Contact/Advanced.php @@ -47,7 +47,7 @@ class Advanced extends BaseModule public function post() { - $cid = static::$parameters['id']; + $cid = $this->parameters['id']; $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]); if (empty($contact)) { @@ -98,7 +98,7 @@ class Advanced extends BaseModule public function content(): string { - $cid = static::$parameters['id']; + $cid = $this->parameters['id']; $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]); if (empty($contact)) { diff --git a/src/Module/Contact/Contacts.php b/src/Module/Contact/Contacts.php index b5b501d6e..bfe689c1e 100644 --- a/src/Module/Contact/Contacts.php +++ b/src/Module/Contact/Contacts.php @@ -22,8 +22,8 @@ class Contacts extends BaseModule throw new HTTPException\ForbiddenException(); } - $cid = static::$parameters['id']; - $type = static::$parameters['type'] ?? 'all'; + $cid = $this->parameters['id']; + $type = $this->parameters['type'] ?? 'all'; $accounttype = $_GET['accounttype'] ?? ''; $accounttypeid = User::getAccountTypeByString($accounttype); diff --git a/src/Module/Contact/Media.php b/src/Module/Contact/Media.php index d9a039957..a3a498b6d 100644 --- a/src/Module/Contact/Media.php +++ b/src/Module/Contact/Media.php @@ -36,7 +36,7 @@ class Media extends BaseModule { public function content(): string { - $cid = static::$parameters['id']; + $cid = $this->parameters['id']; $contact = Model\Contact::selectFirst([], ['id' => $cid]); if (empty($contact)) { diff --git a/src/Module/Contact/Poke.php b/src/Module/Contact/Poke.php index 215e32258..23ec95a43 100644 --- a/src/Module/Contact/Poke.php +++ b/src/Module/Contact/Poke.php @@ -20,7 +20,7 @@ class Poke extends BaseModule { public function post() { - if (!local_user() || empty(static::$parameters['id'])) { + if (!local_user() || empty($this->parameters['id'])) { return self::postReturn(false); } @@ -39,14 +39,14 @@ class Poke extends BaseModule $activity = Activity::POKE . '#' . urlencode($verbs[$verb][0]); - $contact_id = intval(static::$parameters['id']); + $contact_id = intval($this->parameters['id']); if (!$contact_id) { return self::postReturn(false); } Logger::info('verb ' . $verb . ' contact ' . $contact_id); - $contact = DBA::selectFirst('contact', ['id', 'name', 'url', 'photo'], ['id' => static::$parameters['id'], 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', ['id', 'name', 'url', 'photo'], ['id' => $this->parameters['id'], 'uid' => local_user()]); if (!DBA::isResult($contact)) { return self::postReturn(false); } @@ -129,11 +129,11 @@ class Poke extends BaseModule throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.')); } - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => static::$parameters['id'], 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => $this->parameters['id'], 'uid' => local_user()]); if (!DBA::isResult($contact)) { throw new HTTPException\NotFoundException(); } diff --git a/src/Module/Contact/Revoke.php b/src/Module/Contact/Revoke.php index 1cace6255..07fe7779b 100644 --- a/src/Module/Contact/Revoke.php +++ b/src/Module/Contact/Revoke.php @@ -43,7 +43,7 @@ class Revoke extends BaseModule return; } - $data = Model\Contact::getPublicAndUserContactID(static::$parameters['id'], local_user()); + $data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], local_user()); if (!DBA::isResult($data)) { throw new HTTPException\NotFoundException(DI::l10n()->t('Unknown contact.')); } @@ -69,7 +69,7 @@ class Revoke extends BaseModule throw new HTTPException\UnauthorizedException(); } - self::checkFormSecurityTokenRedirectOnError('contact/' . static::$parameters['id'], 'contact_revoke'); + self::checkFormSecurityTokenRedirectOnError('contact/' . $this->parameters['id'], 'contact_revoke'); $result = Model\Contact::revokeFollow(self::$contact); if ($result === true) { @@ -80,7 +80,7 @@ class Revoke extends BaseModule notice(DI::l10n()->t('Unable to revoke follow, please try again later or contact the administrator.')); } - DI::baseUrl()->redirect('contact/' . static::$parameters['id']); + DI::baseUrl()->redirect('contact/' . $this->parameters['id']); } public function content(): string diff --git a/src/Module/Conversation/Community.php b/src/Module/Conversation/Community.php index 58a0c5750..d954ef8f3 100644 --- a/src/Module/Conversation/Community.php +++ b/src/Module/Conversation/Community.php @@ -51,7 +51,7 @@ class Community extends BaseModule public function content(): string { - self::parseRequest(); + $this->parseRequest(); if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl'); @@ -94,8 +94,8 @@ class Community extends BaseModule if (local_user() && DI::config()->get('system', 'community_no_sharer')) { $path = self::$content; - if (!empty(static::$parameters['accounttype'])) { - $path .= '/' . static::$parameters['accounttype']; + if (!empty($this->parameters['accounttype'])) { + $path .= '/' . $this->parameters['accounttype']; } $query_parameters = []; @@ -169,7 +169,7 @@ class Community extends BaseModule * @throws HTTPException\BadRequestException * @throws HTTPException\ForbiddenException */ - protected static function parseRequest() + protected function parseRequest() { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.')); @@ -181,10 +181,10 @@ class Community extends BaseModule throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); } - self::$accountTypeString = $_GET['accounttype'] ?? static::$parameters['accounttype'] ?? ''; + self::$accountTypeString = $_GET['accounttype'] ?? $this->parameters['accounttype'] ?? ''; self::$accountType = User::getAccountTypeByString(self::$accountTypeString); - self::$content = static::$parameters['content'] ?? ''; + self::$content = $this->parameters['content'] ?? ''; if (!self::$content) { if (!empty(DI::config()->get('system', 'singleuser'))) { // On single user systems only the global page does make sense diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index 06fec9ee7..0f2d9cd6f 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -63,7 +63,7 @@ class Network extends BaseModule return Login::form(); } - self::parseRequest($_GET); + $this->parseRequest($_GET); $module = 'network'; @@ -272,11 +272,11 @@ class Network extends BaseModule return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]); } - protected static function parseRequest(array $get) + protected function parseRequest(array $get) { - self::$groupId = static::$parameters['group_id'] ?? 0; + self::$groupId = $this->parameters['group_id'] ?? 0; - self::$forumContactId = static::$parameters['contact_id'] ?? 0; + self::$forumContactId = $this->parameters['contact_id'] ?? 0; self::$selectedTab = Session::get('network-tab', DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', '')); @@ -317,13 +317,13 @@ class Network extends BaseModule Session::set('network-tab', self::$selectedTab); DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab); - self::$accountTypeString = $get['accounttype'] ?? static::$parameters['accounttype'] ?? ''; + self::$accountTypeString = $get['accounttype'] ?? $this->parameters['accounttype'] ?? ''; self::$accountType = User::getAccountTypeByString(self::$accountTypeString); self::$network = $get['nets'] ?? ''; - self::$dateFrom = static::$parameters['from'] ?? ''; - self::$dateTo = static::$parameters['to'] ?? ''; + self::$dateFrom = $this->parameters['from'] ?? ''; + self::$dateTo = $this->parameters['to'] ?? ''; if (DI::mode()->isMobile()) { self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', diff --git a/src/Module/DFRN/Notify.php b/src/Module/DFRN/Notify.php index cbd658fc9..eda5da936 100644 --- a/src/Module/DFRN/Notify.php +++ b/src/Module/DFRN/Notify.php @@ -47,8 +47,8 @@ class Notify extends BaseModule } $data = json_decode($postdata); - if (is_object($data) && !empty(static::$parameters['nickname'])) { - $user = User::getByNickname(static::$parameters['nickname']); + if (is_object($data) && !empty($this->parameters['nickname'])) { + $user = User::getByNickname($this->parameters['nickname']); if (empty($user)) { throw new \Friendica\Network\HTTPException\InternalServerErrorException(); } diff --git a/src/Module/DFRN/Poll.php b/src/Module/DFRN/Poll.php index 3c4becdd6..0cf43f2a7 100644 --- a/src/Module/DFRN/Poll.php +++ b/src/Module/DFRN/Poll.php @@ -33,7 +33,7 @@ class Poll extends BaseModule { header("Content-type: application/atom+xml"); $last_update = $_GET['last_update'] ?? ''; - echo OStatus::feed(static::$parameters['nickname'], $last_update, 10); + echo OStatus::feed($this->parameters['nickname'], $last_update, 10); exit(); } } diff --git a/src/Module/Debug/ItemBody.php b/src/Module/Debug/ItemBody.php index 04dab22c6..375993114 100644 --- a/src/Module/Debug/ItemBody.php +++ b/src/Module/Debug/ItemBody.php @@ -37,11 +37,11 @@ class ItemBody extends BaseModule throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.')); } - if (empty(static::$parameters['item'])) { + if (empty($this->parameters['item'])) { throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); } - $itemId = intval(static::$parameters['item']); + $itemId = intval($this->parameters['item']); $item = Post::selectFirst(['body'], ['uid' => [0, local_user()], 'uri-id' => $itemId]); diff --git a/src/Module/Diaspora/Fetch.php b/src/Module/Diaspora/Fetch.php index aa582558f..e3d6f4616 100644 --- a/src/Module/Diaspora/Fetch.php +++ b/src/Module/Diaspora/Fetch.php @@ -40,11 +40,11 @@ class Fetch extends BaseModule { public function rawContent() { - if (empty(static::$parameters['guid'])) { + if (empty($this->parameters['guid'])) { throw new HTTPException\NotFoundException(); } - $guid = static::$parameters['guid']; + $guid = $this->parameters['guid']; // Fetch the item $condition = ['origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid, diff --git a/src/Module/Diaspora/Receive.php b/src/Module/Diaspora/Receive.php index 9ac89cc6e..14ad5c391 100644 --- a/src/Module/Diaspora/Receive.php +++ b/src/Module/Diaspora/Receive.php @@ -51,10 +51,10 @@ class Receive extends BaseModule throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); } - if (static::$parameters['type'] === 'public') { + if ($this->parameters['type'] === 'public') { self::receivePublic(); - } else if (static::$parameters['type'] === 'users') { - self::receiveUser(static::$parameters['guid']); + } else if ($this->parameters['type'] === 'users') { + self::receiveUser($this->parameters['guid']); } } diff --git a/src/Module/Feed.php b/src/Module/Feed.php index 94908abe2..6470ab5c3 100644 --- a/src/Module/Feed.php +++ b/src/Module/Feed.php @@ -68,7 +68,7 @@ class Feed extends BaseModule } header("Content-type: application/atom+xml; charset=utf-8"); - echo ProtocolFeed::atom(static::$parameters['nickname'], $last_update, 10, $type, $nocache, true); + echo ProtocolFeed::atom($this->parameters['nickname'], $last_update, 10, $type, $nocache, true); exit(); } } diff --git a/src/Module/Filer/RemoveTag.php b/src/Module/Filer/RemoveTag.php index 43a0ff1fb..e6749de02 100644 --- a/src/Module/Filer/RemoveTag.php +++ b/src/Module/Filer/RemoveTag.php @@ -41,7 +41,7 @@ class RemoveTag extends BaseModule $logger = DI::logger(); - $item_id = static::$parameters['id'] ?? 0; + $item_id = $this->parameters['id'] ?? 0; $term = XML::unescape(trim($_GET['term'] ?? '')); $cat = XML::unescape(trim($_GET['cat'] ?? '')); diff --git a/src/Module/Filer/SaveTag.php b/src/Module/Filer/SaveTag.php index ee620f54c..b1742c8a6 100644 --- a/src/Module/Filer/SaveTag.php +++ b/src/Module/Filer/SaveTag.php @@ -48,7 +48,7 @@ class SaveTag extends BaseModule $term = XML::unescape(trim($_GET['term'] ?? '')); - $item_id = static::$parameters['id'] ?? 0; + $item_id = $this->parameters['id'] ?? 0; $logger->info('filer', ['tag' => $term, 'item' => $item_id]); diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index cc4041a6f..b0456377f 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -47,7 +47,7 @@ class FriendSuggest extends BaseModule public function post() { - $cid = intval(static::$parameters['contact']); + $cid = intval($this->parameters['contact']); // We do query the "uid" as well to ensure that it is our contact if (!DI::dba()->exists('contact', ['id' => $cid, 'uid' => local_user()])) { @@ -85,7 +85,7 @@ class FriendSuggest extends BaseModule public function content(): string { - $cid = intval(static::$parameters['contact']); + $cid = intval($this->parameters['contact']); $contact = DI::dba()->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]); if (empty($contact)) { diff --git a/src/Module/HCard.php b/src/Module/HCard.php index 7dabf6c69..110371ee9 100644 --- a/src/Module/HCard.php +++ b/src/Module/HCard.php @@ -36,12 +36,12 @@ class HCard extends BaseModule { public function content(): string { - if ((local_user()) && (static::$parameters['action'] ?? '') === 'view') { + if ((local_user()) && ($this->parameters['action'] ?? '') === 'view') { // A logged in user views a profile of a user $nickname = DI::app()->getLoggedInUserNickname(); - } elseif (empty(static::$parameters['action'])) { + } elseif (empty($this->parameters['action'])) { // Show the profile hCard - $nickname = static::$parameters['profile']; + $nickname = $this->parameters['profile']; } else { throw new HTTPException\NotFoundException(DI::l10n()->t('No profile')); } diff --git a/src/Module/Item/Activity.php b/src/Module/Item/Activity.php index b92b0acf6..3936aa2bc 100644 --- a/src/Module/Item/Activity.php +++ b/src/Module/Item/Activity.php @@ -44,12 +44,12 @@ class Activity extends BaseModule throw new HTTPException\ForbiddenException(); } - if (empty(static::$parameters['id']) || empty(static::$parameters['verb'])) { + if (empty($this->parameters['id']) || empty($this->parameters['verb'])) { throw new HTTPException\BadRequestException(); } - $verb = static::$parameters['verb']; - $itemId = static::$parameters['id']; + $verb = $this->parameters['verb']; + $itemId = $this->parameters['id']; if (in_array($verb, ['announce', 'unannounce'])) { $item = Post::selectFirst(['network'], ['id' => $itemId]); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 7867b9858..6521ddc91 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -64,7 +64,7 @@ class Compose extends BaseModule } /// @TODO Retrieve parameter from router - $posttype = static::$parameters['type'] ?? Item::PT_ARTICLE; + $posttype = $this->parameters['type'] ?? Item::PT_ARTICLE; if (!in_array($posttype, [Item::PT_ARTICLE, Item::PT_PERSONAL_NOTE])) { switch ($posttype) { case 'note': diff --git a/src/Module/Item/Follow.php b/src/Module/Item/Follow.php index baa99c21e..f89353170 100644 --- a/src/Module/Item/Follow.php +++ b/src/Module/Item/Follow.php @@ -42,11 +42,11 @@ class Follow extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval(static::$parameters['id']); + $itemId = intval($this->parameters['id']); if (!Item::performActivity($itemId, 'follow', local_user())) { throw new HTTPException\BadRequestException($l10n->t('Unable to follow this item.')); diff --git a/src/Module/Item/Ignore.php b/src/Module/Item/Ignore.php index e38dd46bc..33481fd2e 100644 --- a/src/Module/Item/Ignore.php +++ b/src/Module/Item/Ignore.php @@ -41,11 +41,11 @@ class Ignore extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval(static::$parameters['id']); + $itemId = intval($this->parameters['id']); $dba = DI::dba(); diff --git a/src/Module/Item/Pin.php b/src/Module/Item/Pin.php index 185b418bb..12ff94655 100644 --- a/src/Module/Item/Pin.php +++ b/src/Module/Item/Pin.php @@ -42,11 +42,11 @@ class Pin extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval(static::$parameters['id']); + $itemId = intval($this->parameters['id']); $item = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId]); if (!DBA::isResult($item)) { diff --git a/src/Module/Item/Star.php b/src/Module/Item/Star.php index 336207718..b3e4ed2a1 100644 --- a/src/Module/Item/Star.php +++ b/src/Module/Item/Star.php @@ -43,11 +43,11 @@ class Star extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty(static::$parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval(static::$parameters['id']); + $itemId = intval($this->parameters['id']); $item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]); diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index c5a66c9bb..06bce3e24 100644 --- a/src/Module/NoScrape.php +++ b/src/Module/NoScrape.php @@ -39,10 +39,10 @@ class NoScrape extends BaseModule { $a = DI::app(); - if (isset(static::$parameters['nick'])) { + if (isset($this->parameters['nick'])) { // Get infos about a specific nick (public) - $which = static::$parameters['nick']; - } elseif (local_user() && isset(static::$parameters['profile']) && DI::args()->get(2) == 'view') { + $which = $this->parameters['nick']; + } elseif (local_user() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') { // view infos about a known profile (needs a login) $which = $a->getLoggedInUserNickname(); } else { diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index 1ceafc105..486054f98 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -48,7 +48,7 @@ class Notification extends BaseModule throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); } - $request_id = static::$parameters['id'] ?? false; + $request_id = $this->parameters['id'] ?? false; if ($request_id) { $intro = DI::intro()->selectOneById($request_id, local_user()); @@ -108,7 +108,7 @@ class Notification extends BaseModule return Login::form(); } - $request_id = static::$parameters['id'] ?? false; + $request_id = $this->parameters['id'] ?? false; if ($request_id) { $Notify = DI::notify()->selectOneById($request_id); diff --git a/src/Module/PermissionTooltip.php b/src/Module/PermissionTooltip.php index bf0cc0d63..1f6b58e4a 100644 --- a/src/Module/PermissionTooltip.php +++ b/src/Module/PermissionTooltip.php @@ -17,8 +17,8 @@ class PermissionTooltip extends \Friendica\BaseModule { public function rawContent() { - $type = static::$parameters['type']; - $referenceId = static::$parameters['id']; + $type = $this->parameters['type']; + $referenceId = $this->parameters['id']; $expectedTypes = ['item', 'photo', 'event']; if (!in_array($type, $expectedTypes)) { diff --git a/src/Module/Photo.php b/src/Module/Photo.php index 4ea3617ac..824edeb6a 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -77,14 +77,14 @@ class Photo extends BaseModule $scale = null; $stamp = microtime(true); // User avatar - if (!empty(static::$parameters['type'])) { - if (!empty(static::$parameters['customsize'])) { - $customsize = intval(static::$parameters['customsize']); - $square_resize = !in_array(static::$parameters['type'], ['media', 'preview']); + if (!empty($this->parameters['type'])) { + if (!empty($this->parameters['customsize'])) { + $customsize = intval($this->parameters['customsize']); + $square_resize = !in_array($this->parameters['type'], ['media', 'preview']); } - if (!empty(static::$parameters['guid'])) { - $guid = static::$parameters['guid']; + if (!empty($this->parameters['guid'])) { + $guid = $this->parameters['guid']; $account = DBA::selectFirst('account-user-view', ['id'], ['guid' => $guid], ['order' => ['uid' => true]]); if (empty($account)) { throw new HTTPException\NotFoundException(); @@ -94,12 +94,12 @@ class Photo extends BaseModule } // Contact Id Fallback, to remove after version 2021.12 - if (isset(static::$parameters['contact_id'])) { - $id = intval(static::$parameters['contact_id']); + if (isset($this->parameters['contact_id'])) { + $id = intval($this->parameters['contact_id']); } - if (!empty(static::$parameters['nickname_ext'])) { - $nickname = pathinfo(static::$parameters['nickname_ext'], PATHINFO_FILENAME); + if (!empty($this->parameters['nickname_ext'])) { + $nickname = pathinfo($this->parameters['nickname_ext'], PATHINFO_FILENAME); $user = User::getByNickname($nickname, ['uid']); if (empty($user)) { throw new HTTPException\NotFoundException(); @@ -109,23 +109,23 @@ class Photo extends BaseModule } // User Id Fallback, to remove after version 2021.12 - if (!empty(static::$parameters['uid_ext'])) { - $id = intval(pathinfo(static::$parameters['uid_ext'], PATHINFO_FILENAME)); + if (!empty($this->parameters['uid_ext'])) { + $id = intval(pathinfo($this->parameters['uid_ext'], PATHINFO_FILENAME)); } // Please refactor this for the love of everything that's good - if (isset(static::$parameters['id'])) { - $id = static::$parameters['id']; + if (isset($this->parameters['id'])) { + $id = $this->parameters['id']; } if (empty($id)) { - Logger::notice('No picture id was detected', ['parameters' => static::$parameters, 'query' => DI::args()->getQueryString()]); + Logger::notice('No picture id was detected', ['parameters' => $this->parameters, 'query' => DI::args()->getQueryString()]); throw new HTTPException\NotFoundException(DI::l10n()->t('The Photo is not available.')); } - $photo = self::getPhotoByid($id, static::$parameters['type'], $customsize ?: Proxy::PIXEL_SMALL); + $photo = self::getPhotoByid($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL); } else { - $photoid = pathinfo(static::$parameters['name'], PATHINFO_FILENAME); + $photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME); $scale = 0; if (substr($photoid, -2, 1) == "-") { $scale = intval(substr($photoid, -1, 1)); diff --git a/src/Module/Profile/Common.php b/src/Module/Profile/Common.php index d95f2b01e..4a335ddf7 100644 --- a/src/Module/Profile/Common.php +++ b/src/Module/Profile/Common.php @@ -45,7 +45,7 @@ class Common extends BaseProfile Nav::setSelected('home'); - $nickname = static::$parameters['nickname']; + $nickname = $this->parameters['nickname']; $profile = Profile::load($a, $nickname); if (empty($profile)) { diff --git a/src/Module/Profile/Contacts.php b/src/Module/Profile/Contacts.php index d849d5778..e20fd3f2d 100644 --- a/src/Module/Profile/Contacts.php +++ b/src/Module/Profile/Contacts.php @@ -42,8 +42,8 @@ class Contacts extends Module\BaseProfile $a = DI::app(); - $nickname = static::$parameters['nickname']; - $type = static::$parameters['type'] ?? 'all'; + $nickname = $this->parameters['nickname']; + $type = $this->parameters['type'] ?? 'all'; $profile = Model\Profile::load($a, $nickname); if (empty($profile)) { diff --git a/src/Module/Profile/Index.php b/src/Module/Profile/Index.php index e6249f90e..75d467f54 100644 --- a/src/Module/Profile/Index.php +++ b/src/Module/Profile/Index.php @@ -36,11 +36,11 @@ class Index extends BaseModule { public function rawContent() { - (new Profile(static::$parameters))->rawContent(); + (new Profile($this->parameters))->rawContent(); } public function content(): string { - return (new Status(static::$parameters))->content(); + return (new Status($this->parameters))->content(); } } diff --git a/src/Module/Profile/Media.php b/src/Module/Profile/Media.php index 0f34b267d..74af5f95e 100644 --- a/src/Module/Profile/Media.php +++ b/src/Module/Profile/Media.php @@ -33,7 +33,7 @@ class Media extends BaseProfile { $a = DI::app(); - $profile = ProfileModel::load($a, static::$parameters['nickname']); + $profile = ProfileModel::load($a, $this->parameters['nickname']); if (empty($profile)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index 32d3aae70..a497fc4dd 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -49,7 +49,7 @@ class Profile extends BaseProfile public function rawContent() { if (ActivityPub::isRequest()) { - $user = DBA::selectFirst('user', ['uid'], ['nickname' => static::$parameters['nickname']]); + $user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]); if (DBA::isResult($user)) { try { $data = ActivityPub\Transmitter::getProfile($user['uid']); @@ -61,9 +61,9 @@ class Profile extends BaseProfile } } - if (DBA::exists('userd', ['username' => static::$parameters['nickname']])) { + if (DBA::exists('userd', ['username' => $this->parameters['nickname']])) { // Known deleted user - $data = ActivityPub\Transmitter::getDeletedUser(static::$parameters['nickname']); + $data = ActivityPub\Transmitter::getDeletedUser($this->parameters['nickname']); System::jsonError(410, $data); } else { @@ -77,7 +77,7 @@ class Profile extends BaseProfile { $a = DI::app(); - $profile = ProfileModel::load($a, static::$parameters['nickname']); + $profile = ProfileModel::load($a, $this->parameters['nickname']); if (!$profile) { throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.')); } @@ -98,7 +98,7 @@ class Profile extends BaseProfile DI::page()['htmlhead'] .= '' . "\n"; } - DI::page()['htmlhead'] .= self::buildHtmlHead($profile, static::$parameters['nickname'], $remote_contact_id); + DI::page()['htmlhead'] .= self::buildHtmlHead($profile, $this->parameters['nickname'], $remote_contact_id); Nav::setSelected('home'); @@ -134,7 +134,7 @@ class Profile extends BaseProfile $view_as_contact_alert = DI::l10n()->t( 'You\'re currently viewing your profile as %s Cancel', htmlentities($view_as_contacts[$key]['name'], ENT_COMPAT, 'UTF-8'), - 'profile/' . static::$parameters['nickname'] . '/profile' + 'profile/' . $this->parameters['nickname'] . '/profile' ); } } diff --git a/src/Module/Profile/Schedule.php b/src/Module/Profile/Schedule.php index 72208fe79..1e9cd5fa5 100644 --- a/src/Module/Profile/Schedule.php +++ b/src/Module/Profile/Schedule.php @@ -80,7 +80,7 @@ class Schedule extends BaseProfile '$form_security_token' => BaseModule::getFormSecurityToken("profile_schedule"), '$baseurl' => DI::baseUrl()->get(true), '$title' => DI::l10n()->t('Scheduled Posts'), - '$nickname' => static::$parameters['nickname'] ?? '', + '$nickname' => $this->parameters['nickname'] ?? '', '$scheduled_at' => DI::l10n()->t('Scheduled'), '$content' => DI::l10n()->t('Content'), '$delete' => DI::l10n()->t('Remove post'), diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index db5400bff..ad9a4acde 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -52,7 +52,7 @@ class Status extends BaseProfile $a = DI::app(); - $profile = ProfileModel::load($a, static::$parameters['nickname']); + $profile = ProfileModel::load($a, $this->parameters['nickname']); if (empty($profile)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); @@ -62,10 +62,10 @@ class Status extends BaseProfile DI::page()['htmlhead'] .= '' . "\n"; } - DI::page()['htmlhead'] .= '' . "\n"; - DI::page()['htmlhead'] .= '' . "\n"; - DI::page()['htmlhead'] .= '' . "\n"; - DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; $category = $datequery = $datequery2 = ''; diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index 7a7c7b082..abe9a8c2e 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -46,7 +46,7 @@ class Proxy extends BaseModule */ public function rawContent() { - $request = self::getRequestInfo(); + $request = $this->getRequestInfo(); if (!DI::config()->get('system', 'proxify_content')) { Logger::notice('Proxy access is forbidden', ['request' => $request, 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '', 'accept' => $_SERVER['HTTP_ACCEPT'] ?? '']); @@ -119,13 +119,13 @@ class Proxy extends BaseModule * ] * @throws \Exception */ - private static function getRequestInfo() + private function getRequestInfo() { $size = ProxyUtils::PIXEL_LARGE; $sizetype = ''; - if (!empty(static::$parameters['url']) && empty($_REQUEST['url'])) { - $url = static::$parameters['url']; + if (!empty($this->parameters['url']) && empty($_REQUEST['url'])) { + $url = $this->parameters['url']; // thumb, small, medium and large. if (substr($url, -6) == ':micro') { diff --git a/src/Module/PublicRSAKey.php b/src/Module/PublicRSAKey.php index 9df9f5857..d159255ee 100644 --- a/src/Module/PublicRSAKey.php +++ b/src/Module/PublicRSAKey.php @@ -35,11 +35,11 @@ class PublicRSAKey extends BaseModule { public function rawContent() { - if (empty(static::$parameters['nick'])) { + if (empty($this->parameters['nick'])) { throw new BadRequestException(); } - $nick = static::$parameters['nick']; + $nick = $this->parameters['nick']; $user = User::getByNickname($nick, ['spubkey']); if (empty($user) || empty($user['spubkey'])) { diff --git a/src/Module/Register.php b/src/Module/Register.php index 42b95e78e..fca59a2c8 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -129,7 +129,7 @@ class Register extends BaseModule $tpl = $arr['template']; - $tos = new Tos(static::$parameters); + $tos = new Tos($this->parameters); $o = Renderer::replaceMacros($tpl, [ '$invitations' => DI::config()->get('system', 'invitation_only'), diff --git a/src/Module/RemoteFollow.php b/src/Module/RemoteFollow.php index b6b0255fc..6fedc1393 100644 --- a/src/Module/RemoteFollow.php +++ b/src/Module/RemoteFollow.php @@ -44,7 +44,7 @@ class RemoteFollow extends BaseModule public function init() { - self::$owner = User::getOwnerDataByNick(static::$parameters['profile']); + self::$owner = User::getOwnerDataByNick($this->parameters['profile']); if (!self::$owner) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } @@ -115,7 +115,7 @@ class RemoteFollow extends BaseModule '$submit' => DI::l10n()->t('Submit Request'), '$cancel' => DI::l10n()->t('Cancel'), - '$request' => 'remote_follow/' . static::$parameters['profile'], + '$request' => 'remote_follow/' . $this->parameters['profile'], '$name' => self::$owner['name'], '$myaddr' => Profile::getMyURL(), ]); diff --git a/src/Module/Settings/Profile/Photo/Crop.php b/src/Module/Settings/Profile/Photo/Crop.php index c23361cf8..3b5f109d7 100644 --- a/src/Module/Settings/Profile/Photo/Crop.php +++ b/src/Module/Settings/Profile/Photo/Crop.php @@ -39,7 +39,7 @@ class Crop extends BaseSettings return; } - $photo_prefix = static::$parameters['guid']; + $photo_prefix = $this->parameters['guid']; $resource_id = $photo_prefix; $scale = 0; if (substr($photo_prefix, -2, 1) == '-') { @@ -168,7 +168,7 @@ class Crop extends BaseSettings parent::content(); - $resource_id = static::$parameters['guid']; + $resource_id = $this->parameters['guid']; $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => local_user()], ['order' => ['scale' => false]]); if (!DBA::isResult($photos)) { diff --git a/src/Module/Theme.php b/src/Module/Theme.php index cd393d641..6c164b5ba 100644 --- a/src/Module/Theme.php +++ b/src/Module/Theme.php @@ -34,7 +34,7 @@ class Theme extends BaseModule { header('Content-Type: text/css'); - $theme = Strings::sanitizeFilePathItem(static::$parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (file_exists("view/theme/$theme/theme.php")) { require_once "view/theme/$theme/theme.php"; diff --git a/src/Module/Update/Community.php b/src/Module/Update/Community.php index f42274953..07ed5a610 100644 --- a/src/Module/Update/Community.php +++ b/src/Module/Update/Community.php @@ -35,7 +35,7 @@ class Community extends CommunityModule { public function rawContent() { - self::parseRequest(); + $this->parseRequest(); $o = ''; if (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update')) { diff --git a/src/Module/Update/Network.php b/src/Module/Update/Network.php index a1a120ea2..3652b1126 100644 --- a/src/Module/Update/Network.php +++ b/src/Module/Update/Network.php @@ -15,7 +15,7 @@ class Network extends NetworkModule exit(); } - self::parseRequest($_GET); + $this->parseRequest($_GET); $profile_uid = intval($_GET['p']);