From abe6724629b851c6cce965a0aa03658b9dae8c62 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 5 Nov 2019 19:16:26 +0000 Subject: [PATCH] Added parameter to rawContent --- src/BaseModule.php | 2 +- .../AccountManagementControlDocument.php | 2 +- src/Module/Admin/PhpInfo.php | 4 +- src/Module/Attach.php | 2 +- src/Module/BaseAdminModule.php | 2 +- src/Module/Contact/Hovercard.php | 2 +- src/Module/Diaspora/Fetch.php | 2 +- src/Module/Filer/SaveTag.php | 2 +- src/Module/Followers.php | 2 +- src/Module/Following.php | 2 +- src/Module/Friendica.php | 2 +- src/Module/Inbox.php | 2 +- src/Module/Item/Ignore.php | 2 +- src/Module/Like.php | 2 +- src/Module/Manifest.php | 2 +- src/Module/NodeInfo.php | 2 +- src/Module/Notifications/Notify.php | 2 +- src/Module/Objects.php | 2 +- src/Module/OpenSearch.php | 2 +- src/Module/Outbox.php | 2 +- src/Module/Profile.php | 2 +- src/Module/PublicRSAKey.php | 2 +- src/Module/ReallySimpleDiscovery.php | 2 +- src/Module/RobotsTxt.php | 2 +- src/Module/Search/Acl.php | 2 +- src/Module/Settings/UserExport.php | 2 +- src/Module/Smilies.php | 2 +- src/Module/Starred.php | 37 ++++++------------- src/Module/Statistics.php | 2 +- src/Module/Theme.php | 2 +- src/Module/ThemeDetails.php | 2 +- src/Module/WellKnown/HostMeta.php | 2 +- src/Module/WellKnown/XSocialRelay.php | 2 +- src/Module/Xrd.php | 2 +- static/dbstructure.config.php | 5 ++- static/routes.config.php | 5 ++- 36 files changed, 51 insertions(+), 64 deletions(-) diff --git a/src/BaseModule.php b/src/BaseModule.php index 5185771d1c..e049e9a944 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -32,7 +32,7 @@ abstract class BaseModule extends BaseObject * Extend this method if the module is supposed to return communication data, * e.g. from protocol implementations. */ - public static function rawContent() + public static function rawContent($parameters) { // echo ''; // exit; diff --git a/src/Module/AccountManagementControlDocument.php b/src/Module/AccountManagementControlDocument.php index 2e2a9e496d..0cf1de6f15 100644 --- a/src/Module/AccountManagementControlDocument.php +++ b/src/Module/AccountManagementControlDocument.php @@ -11,7 +11,7 @@ use Friendica\BaseModule; */ class AccountManagementControlDocument extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $output = [ 'version' => 1, diff --git a/src/Module/Admin/PhpInfo.php b/src/Module/Admin/PhpInfo.php index b912117dc1..9c7b597514 100644 --- a/src/Module/Admin/PhpInfo.php +++ b/src/Module/Admin/PhpInfo.php @@ -6,9 +6,9 @@ use Friendica\Module\BaseAdminModule; class PhpInfo extends BaseAdminModule { - public static function rawContent() + public static function rawContent($parameters) { - parent::rawContent(); + parent::rawContent($parameters); phpinfo(); exit(); diff --git a/src/Module/Attach.php b/src/Module/Attach.php index e9af90facc..fe0e063b02 100644 --- a/src/Module/Attach.php +++ b/src/Module/Attach.php @@ -20,7 +20,7 @@ class Attach extends BaseModule /** * @brief Return to user an attached file given the id */ - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); if ($a->argc != 2) { diff --git a/src/Module/BaseAdminModule.php b/src/Module/BaseAdminModule.php index 6802d09c18..61b3b4ff9f 100644 --- a/src/Module/BaseAdminModule.php +++ b/src/Module/BaseAdminModule.php @@ -35,7 +35,7 @@ abstract class BaseAdminModule extends BaseModule } } - public static function rawContent() + public static function rawContent($parameters) { if (!is_site_admin()) { return ''; diff --git a/src/Module/Contact/Hovercard.php b/src/Module/Contact/Hovercard.php index 20290e0aca..7f314d361a 100644 --- a/src/Module/Contact/Hovercard.php +++ b/src/Module/Contact/Hovercard.php @@ -18,7 +18,7 @@ use Friendica\Util\Proxy; */ class Hovercard extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $contact_url = $_REQUEST['url'] ?? ''; diff --git a/src/Module/Diaspora/Fetch.php b/src/Module/Diaspora/Fetch.php index 467d64566b..b69cd1f12b 100644 --- a/src/Module/Diaspora/Fetch.php +++ b/src/Module/Diaspora/Fetch.php @@ -17,7 +17,7 @@ use Friendica\Util\Strings; */ class Fetch extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); diff --git a/src/Module/Filer/SaveTag.php b/src/Module/Filer/SaveTag.php index e8e3112681..14eb368baa 100644 --- a/src/Module/Filer/SaveTag.php +++ b/src/Module/Filer/SaveTag.php @@ -22,7 +22,7 @@ class SaveTag extends BaseModule } } - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); $logger = $a->getLogger(); diff --git a/src/Module/Followers.php b/src/Module/Followers.php index 5bd3fe0ce2..34cb0cdbf9 100644 --- a/src/Module/Followers.php +++ b/src/Module/Followers.php @@ -14,7 +14,7 @@ use Friendica\Protocol\ActivityPub; */ class Followers extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); diff --git a/src/Module/Following.php b/src/Module/Following.php index 5b5f4dc986..cbf33d50f0 100644 --- a/src/Module/Following.php +++ b/src/Module/Following.php @@ -14,7 +14,7 @@ use Friendica\Protocol\ActivityPub; */ class Following extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index ae8ea14968..cadacb48b3 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -88,7 +88,7 @@ class Friendica extends BaseModule ]); } - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); diff --git a/src/Module/Inbox.php b/src/Module/Inbox.php index 2cc273b139..ac99327735 100644 --- a/src/Module/Inbox.php +++ b/src/Module/Inbox.php @@ -19,7 +19,7 @@ use Friendica\Util\Network; */ class Inbox extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); diff --git a/src/Module/Item/Ignore.php b/src/Module/Item/Ignore.php index 6a28310b40..662148076c 100644 --- a/src/Module/Item/Ignore.php +++ b/src/Module/Item/Ignore.php @@ -16,7 +16,7 @@ use Friendica\Network\HTTPException; */ class Ignore extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { /** @var L10n $l10n */ $l10n = self::getClass(L10n::class); diff --git a/src/Module/Like.php b/src/Module/Like.php index cc450dd9d0..3243a12cb9 100644 --- a/src/Module/Like.php +++ b/src/Module/Like.php @@ -13,7 +13,7 @@ use Friendica\Util\Strings; */ class Like extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { if (!Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(); diff --git a/src/Module/Manifest.php b/src/Module/Manifest.php index 9dadcf0f76..2fe432a5f4 100644 --- a/src/Module/Manifest.php +++ b/src/Module/Manifest.php @@ -7,7 +7,7 @@ use Friendica\Core\Renderer; class Manifest extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); $config = $app->getConfig(); diff --git a/src/Module/NodeInfo.php b/src/Module/NodeInfo.php index 3261ef6902..f4ecc5da68 100644 --- a/src/Module/NodeInfo.php +++ b/src/Module/NodeInfo.php @@ -22,7 +22,7 @@ class NodeInfo extends BaseModule } } - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); diff --git a/src/Module/Notifications/Notify.php b/src/Module/Notifications/Notify.php index bad0900ea2..360204d94b 100644 --- a/src/Module/Notifications/Notify.php +++ b/src/Module/Notifications/Notify.php @@ -21,7 +21,7 @@ class Notify extends BaseModule } } - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); diff --git a/src/Module/Objects.php b/src/Module/Objects.php index 2104e8042f..528b20a86c 100644 --- a/src/Module/Objects.php +++ b/src/Module/Objects.php @@ -15,7 +15,7 @@ use Friendica\Protocol\ActivityPub; */ class Objects extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); diff --git a/src/Module/OpenSearch.php b/src/Module/OpenSearch.php index ff005bd56b..89cf53055d 100644 --- a/src/Module/OpenSearch.php +++ b/src/Module/OpenSearch.php @@ -16,7 +16,7 @@ class OpenSearch extends BaseModule /** * @throws \Exception */ - public static function rawContent() + public static function rawContent($parameters) { header('Content-type: application/opensearchdescription+xml'); diff --git a/src/Module/Outbox.php b/src/Module/Outbox.php index 4fc0507631..334e7af718 100644 --- a/src/Module/Outbox.php +++ b/src/Module/Outbox.php @@ -14,7 +14,7 @@ use Friendica\Protocol\ActivityPub; */ class Outbox extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $a = self::getApp(); diff --git a/src/Module/Profile.php b/src/Module/Profile.php index f38c77f2cd..ab2fad2e2f 100644 --- a/src/Module/Profile.php +++ b/src/Module/Profile.php @@ -51,7 +51,7 @@ class Profile extends BaseModule } } - public static function rawContent() + public static function rawContent($parameters) { if (ActivityPub::isRequest()) { $user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]); diff --git a/src/Module/PublicRSAKey.php b/src/Module/PublicRSAKey.php index ed099616ad..36502cc86b 100644 --- a/src/Module/PublicRSAKey.php +++ b/src/Module/PublicRSAKey.php @@ -12,7 +12,7 @@ use Friendica\Network\HTTPException\BadRequestException; */ class PublicRSAKey extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); diff --git a/src/Module/ReallySimpleDiscovery.php b/src/Module/ReallySimpleDiscovery.php index 515285dbfc..838843fbf0 100644 --- a/src/Module/ReallySimpleDiscovery.php +++ b/src/Module/ReallySimpleDiscovery.php @@ -11,7 +11,7 @@ use Friendica\Util\XML; */ class ReallySimpleDiscovery extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { header('Content-Type: text/xml'); diff --git a/src/Module/RobotsTxt.php b/src/Module/RobotsTxt.php index 635056a0ad..47e11201d9 100644 --- a/src/Module/RobotsTxt.php +++ b/src/Module/RobotsTxt.php @@ -9,7 +9,7 @@ use Friendica\BaseModule; */ class RobotsTxt extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $allDisalloweds = [ '/settings/', diff --git a/src/Module/Search/Acl.php b/src/Module/Search/Acl.php index 1016756008..e886a8fdb9 100644 --- a/src/Module/Search/Acl.php +++ b/src/Module/Search/Acl.php @@ -31,7 +31,7 @@ class Acl extends BaseModule const TYPE_PRIVATE_MESSAGE = 'm'; const TYPE_ANY_CONTACT = 'a'; - public static function rawContent() + public static function rawContent($parameters) { if (!local_user()) { throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this module.')); diff --git a/src/Module/Settings/UserExport.php b/src/Module/Settings/UserExport.php index d5b8f88ec1..9c4e4913cf 100644 --- a/src/Module/Settings/UserExport.php +++ b/src/Module/Settings/UserExport.php @@ -59,7 +59,7 @@ class UserExport extends BaseSettingsModule * to the browser which then offers a save / open dialog * to the user. **/ - public static function rawContent() + public static function rawContent($parameters) { $args = self::getClass(Arguments::class); if ($args->getArgc() == 3) { diff --git a/src/Module/Smilies.php b/src/Module/Smilies.php index ded58768fe..9a81a888e9 100644 --- a/src/Module/Smilies.php +++ b/src/Module/Smilies.php @@ -12,7 +12,7 @@ use Friendica\Core\System; */ class Smilies extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); diff --git a/src/Module/Starred.php b/src/Module/Starred.php index 70cd397351..5c79c4fac8 100644 --- a/src/Module/Starred.php +++ b/src/Module/Starred.php @@ -4,29 +4,23 @@ namespace Friendica\Module; use Friendica\BaseModule; use Friendica\Model\Item; +use Friendica\Core\System; /** * Toggle starred items */ class Starred extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { - $a = self::getApp(); - $starred = 0; - $itemId = null; - if (!local_user()) { exit(); } - // @TODO: Replace with parameter from router - if ($a->argc > 1) { - $itemId = intval($a->argv[1]); - } - - if (!$itemId) { - exit(); + if (empty($parameters['item'])) { + exit; + } else { + $itemId = intval($parameters['item']); } $item = Item::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]); @@ -34,27 +28,18 @@ class Starred extends BaseModule exit(); } - if (!intval($item['starred'])) { - $starred = 1; - } + $starred = !$item['starred']; Item::update(['starred' => $starred], ['id' => $itemId]); // See if we've been passed a return path to redirect to $returnPath = $_REQUEST['return'] ?? ''; - if ($returnPath) { - $rand = '_=' . time(); - if (strpos($returnPath, '?')) { - $rand = "&$rand"; - } else { - $rand = "?$rand"; - } - - $a->internalRedirect($returnPath . $rand); + if (!empty($returnPath)) { + $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand'; + self::getApp()->internalRedirect($returnPath . $rand); } // the json doesn't really matter, it will either be 0 or 1 - echo json_encode($starred); - exit(); + System::jsonExit($starred); } } diff --git a/src/Module/Statistics.php b/src/Module/Statistics.php index 3e64828e7b..7400943237 100644 --- a/src/Module/Statistics.php +++ b/src/Module/Statistics.php @@ -17,7 +17,7 @@ class Statistics extends BaseModule } } - public static function rawContent() + public static function rawContent($parameters) { $config = self::getApp()->getConfig(); $logger = self::getApp()->getLogger(); diff --git a/src/Module/Theme.php b/src/Module/Theme.php index 0540267af7..762e398556 100644 --- a/src/Module/Theme.php +++ b/src/Module/Theme.php @@ -10,7 +10,7 @@ use Friendica\Util\Strings; */ class Theme extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { header("Content-Type: text/css"); diff --git a/src/Module/ThemeDetails.php b/src/Module/ThemeDetails.php index 9a2e913bca..611134d638 100644 --- a/src/Module/ThemeDetails.php +++ b/src/Module/ThemeDetails.php @@ -10,7 +10,7 @@ use Friendica\Core\Theme; */ class ThemeDetails extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { if (!empty($_REQUEST['theme'])) { $theme = $_REQUEST['theme']; diff --git a/src/Module/WellKnown/HostMeta.php b/src/Module/WellKnown/HostMeta.php index fd04467f75..acf2cca866 100644 --- a/src/Module/WellKnown/HostMeta.php +++ b/src/Module/WellKnown/HostMeta.php @@ -13,7 +13,7 @@ use Friendica\Util\Crypto; */ class HostMeta extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); $config = $app->getConfig(); diff --git a/src/Module/WellKnown/XSocialRelay.php b/src/Module/WellKnown/XSocialRelay.php index a1bbeb78aa..bbd51069d9 100644 --- a/src/Module/WellKnown/XSocialRelay.php +++ b/src/Module/WellKnown/XSocialRelay.php @@ -11,7 +11,7 @@ use Friendica\Model\Search; */ class XSocialRelay extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); $config = $app->getConfig(); diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 1028bfd531..4bad558a4e 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -17,7 +17,7 @@ use Friendica\Util\Strings; */ class Xrd extends BaseModule { - public static function rawContent() + public static function rawContent($parameters) { $app = self::getApp(); diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 53f8a8ed44..65e0b26a6a 100755 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -34,7 +34,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1323); + define('DB_UPDATE_VERSION', 1324); } return [ @@ -1384,7 +1384,8 @@ return [ "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"], "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide an item from the user"], - "ignored" => ["type" => "boolean", "comment" => "Ignore this thread if set"] + "ignored" => ["type" => "boolean", "comment" => "Ignore this thread if set"], + "pinned" => ["type" => "boolean", "comment" => "The item is pinned on the profile page"] ], "indexes" => [ "PRIMARY" => ["uid", "iid"] diff --git a/static/routes.config.php b/static/routes.config.php index 1f2fe0ad1b..339860afe6 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -179,8 +179,9 @@ return [ '/{type}/{customize}/{name}' => [Module\Photo::class, [R::GET]], ], - '/pretheme' => [Module\ThemeDetails::class, [R::GET]], - '/probe' => [Module\Debug\Probe::class, [R::GET]], + '/pinned/{item:\d+}' => [Module\Pinned::class, [R::GET]], + '/pretheme' => [Module\ThemeDetails::class, [R::GET]], + '/probe' => [Module\Debug\Probe::class, [R::GET]], '/profile' => [ '/{nickname}' => [Module\Profile::class, [R::GET]], -- 2.39.5