]> git.mxchange.org Git - friendica.git/commitdiff
Add routes for current BaseModules
authorPhilipp Holzer <admin@philipp.info>
Wed, 1 May 2019 19:29:04 +0000 (21:29 +0200)
committerPhilipp Holzer <admin@philipp.info>
Wed, 1 May 2019 19:29:04 +0000 (21:29 +0200)
17 files changed:
src/App/Router.php
src/Module/Feed.php
src/Module/Filer.php
src/Module/Followers.php
src/Module/Following.php
src/Module/Group.php
src/Module/Inbox.php
src/Module/Install.php
src/Module/Objects.php
src/Module/Oembed.php
src/Module/Outbox.php
src/Module/Photo.php
src/Module/Profile.php
src/Module/Proxy.php
src/Module/Register.php
src/Module/Statistics.php [new file with mode: 0644]
src/Module/Statistics_json.php [deleted file]

index b54d5202b5334be47966898a9a880c2015c8718c..5b9d59f56d14f4b1eb1282db72087a8415e162f4 100644 (file)
@@ -47,9 +47,67 @@ class Router
                $this->routeCollector->addRoute(['GET'],         '/attach/{item:\d+}',   Module\Attach::class);
                $this->routeCollector->addRoute(['GET'],         '/babel',               Module\Babel::class);
                $this->routeCollector->addGroup('/contact', function (RouteCollector $collector) {
-                       $collector->addRoute(['GET'], '[/]',                                  Module\Contact::class);
-                       $collector->addRoute(['GET'], '/{id:\d+}[/posts|conversations]', Module\Contact::class);
+                       $collector->addRoute(['GET'], '[/]',                                 Module\Contact::class);
+                       $collector->addRoute(['GET'], '/{id:\d+}[/posts|conversations]',     Module\Contact::class);
                });
+               $this->routeCollector->addRoute(['GET'],         '/credits',             Module\Credits::class);
+               $this->routeCollector->addGroup('/feed', function (RouteCollector $collector) {
+                       $collector->addRoute(['GET'], '/{nickname}',                         Module\Feed::class);
+                       $collector->addRoute(['GET'], '/{nickname}/posts',                   Module\Feed::class);
+                       $collector->addRoute(['GET'], '/{nickname}/comments',                Module\Feed::class);
+                       $collector->addRoute(['GET'], '/{nickname}/replies',                 Module\Feed::class);
+                       $collector->addRoute(['GET'], '/{nickname}/activity',                Module\Feed::class);
+               });
+               $this->routeCollector->addRoute(['GET'],         '/feedtest',            Module\Feedtest::class);
+               $this->routeCollector->addRoute(['GET'],         '/filer[/{id:\d+}]',    Module\Filer::class);
+               $this->routeCollector->addRoute(['GET'],         '/followers/{owner}',   Module\Followers::class);
+               $this->routeCollector->addRoute(['GET'],         '/following/{owner}',   Module\Following::class);
+               $this->routeCollector->addGroup('/group', function (RouteCollector $collector) {
+                       $collector->addRoute(['GET', 'POST'], '[/]',                         Module\Group::class);
+                       $collector->addRoute(['GET', 'POST'], '/{group:\d+}',                Module\Group::class);
+                       $collector->addRoute(['GET', 'POST'], '/none',                       Module\Group::class);
+                       $collector->addRoute(['GET', 'POST'], '/new',                        Module\Group::class);
+                       $collector->addRoute(['GET', 'POST'], '/drop/{group:\d+}',           Module\Group::class);
+                       $collector->addRoute(['GET', 'POST'], '/{group:\d+}/{contact:\d+}',  Module\Group::class);
+
+                       $collector->addRoute(['POST'], '/{group:\d+}/add/{contact:\d+}',     Module\Group::class);
+                       $collector->addRoute(['POST'], '/{group:\d+}/remove/{contact:\d+}',  Module\Group::class);
+               });
+               $this->routeCollector->addRoute(['GET'],         '/hashtag',             Module\Hashtag::class);
+               $this->routeCollector->addRoute(['GET'],         '/inbox[/{nickname}]',  Module\Inbox::class);
+               $this->routeCollector->addGroup('/install', function (RouteCollector $collector) {
+                       $collector->addRoute(['GET', 'POST'], '[/]',                         Module\Install::class);
+                       $collector->addRoute(['GET'],         '/testrewrite',                Module\Install::class);
+               });
+               $this->routeCollector->addRoute(['GET', 'POST'], '/localtime',           Module\Localtime::class);
+               $this->routeCollector->addRoute(['GET', 'POST'], '/login',               Module\Login::class);
+               $this->routeCollector->addRoute(['GET'],         '/magic',               Module\Magic::class);
+               $this->routeCollector->addRoute(['GET'],         '/manifest',            Module\Manifest::class);
+               $this->routeCollector->addRoute(['GET'],         '/objects/{guid}',      Module\Objects::class);
+               $this->routeCollector->addGroup('/oembed', function (RouteCollector $collector) {
+                       $collector->addRoute(['GET'], '/[b2h|h2b]',                          Module\Oembed::class);
+                       $collector->addRoute(['GET'], '/{hash}',                             Module\Oembed::class);
+               });
+               $this->routeCollector->addRoute(['GET'],         '/outbox/{owner}',      Module\Outbox::class);
+               $this->routeCollector->addRoute(['GET'],         '/owa',                 Module\Owa::class);
+               $this->routeCollector->addGroup('/photo', function (RouteCollector $collector) {
+                       $collector->addRoute(['GET'], '/{name}',                             Module\Photo::class);
+                       $collector->addRoute(['GET'], '/{type}/{name}',                      Module\Photo::class);
+                       $collector->addRoute(['GET'], '/{type}/{customize}/{name}',          Module\Photo::class);
+               });
+               $this->routeCollector->addGroup('/profile', function (RouteCollector $collector) {
+                       $collector->addRoute(['GET'], '/{nickname}',                         Module\Profile::class);
+                       $collector->addRoute(['GET'], '/{profile:\d+}/view',                 Module\Profile::class);
+               });
+               $this->routeCollector->addGroup('/proxy', function (RouteCollector $collector) {
+                       $collector->addRoute(['GET'], '[/]',                                 Module\Proxy::class);
+                       $collector->addRoute(['GET'], '/{url}',                              Module\Proxy::class);
+                       $collector->addRoute(['GET'], '/sub1/{url}',                         Module\Proxy::class);
+                       $collector->addRoute(['GET'], '/sub1/sub2/{url}',                    Module\Proxy::class);
+               });
+               $this->routeCollector->addRoute(['GET', 'POST'], '/register',            Module\Register::class);
+               $this->routeCollector->addRoute(['GET'],         '/statistics.json',     Module\Statistics::class);
+               $this->routeCollector->addRoute(['GET'],         '/tos',                 Module\Tos::class);
        }
 
        public function __construct(RouteCollector $routeCollector = null)
index e5ebe2a4d66239e4551232fb68c49b3fe639e05a..eabd45da23eef073fef2af295390a2b3bdd4fa0a 100644 (file)
@@ -31,11 +31,13 @@ class Feed extends BaseModule
                $last_update = defaults($_GET, 'last_update', '');
                $nocache     = !empty($_GET['nocache']) && local_user();
 
+               // @TODO: Replace with parameter from router
                if ($a->argc < 2) {
                        System::httpExit(400);
                }
 
                $type = null;
+               // @TODO: Replace with parameter from router
                if ($a->argc > 2) {
                        $type = $a->argv[2];
                }
@@ -53,6 +55,7 @@ class Feed extends BaseModule
                                $type = 'posts';
                }
 
+               // @TODO: Replace with parameter from router
                $nickname = $a->argv[1];
                header("Content-type: application/atom+xml; charset=utf-8");
                echo OStatus::feed($nickname, $last_update, 10, $type, $nocache, true);
index 08c656ed388151665aa17c30b42716c4e0c51e83..da59084da090c911ec1014e901cd43316a2b58b5 100644 (file)
@@ -28,6 +28,7 @@ class Filer extends BaseModule
                $logger = $a->getLogger();
 
                $term = XML::unescape(trim(defaults($_GET, 'term', '')));
+               // @TODO: Replace with parameter from router
                $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
 
                $logger->info('filer', ['tag' => $term, 'item' => $item_id]);
index 56160aecf81a10f8df4e857561ee99b1992302c5..9906dfc33e3b2882ee0da885a523da6ad97fd354 100644 (file)
@@ -5,9 +5,9 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\Protocol\ActivityPub;
 use Friendica\Core\System;
 use Friendica\Model\User;
+use Friendica\Protocol\ActivityPub;
 
 /**
  * ActivityPub Followers
@@ -18,10 +18,12 @@ class Followers extends BaseModule
        {
                $a = self::getApp();
 
+               // @TODO: Replace with parameter from router
                if (empty($a->argv[1])) {
                        System::httpExit(404);
                }
 
+               // @TODO: Replace with parameter from router
                $owner = User::getOwnerDataByNick($a->argv[1]);
                if (empty($owner)) {
                        System::httpExit(404);
index 71e6613f0c19629810a7b7d0cd26ccb8f0da51b1..670142c4897ad0c261c9853aef6cbdeff3a82f72 100644 (file)
@@ -5,9 +5,9 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\Protocol\ActivityPub;
 use Friendica\Core\System;
 use Friendica\Model\User;
+use Friendica\Protocol\ActivityPub;
 
 /**
  * ActivityPub Following
@@ -18,10 +18,12 @@ class Following extends BaseModule
        {
                $a = self::getApp();
 
+               // @TODO: Replace with parameter from router
                if (empty($a->argv[1])) {
                        System::httpExit(404);
                }
 
+               // @TODO: Replace with parameter from router
                $owner = User::getOwnerDataByNick($a->argv[1]);
                if (empty($owner)) {
                        System::httpExit(404);
index 747ec1e56d8224f8ae71e7930e38242fefba9773..eb1389d799e33d5c27d2d15f1264306ba0dd5cba 100644 (file)
-<?php\r
-/**\r
- * @file src/Module/Group.php\r
- */\r
-\r
-namespace Friendica\Module;\r
-\r
-use Friendica\BaseModule;\r
-use Friendica\Core\Config;\r
-use Friendica\Core\L10n;\r
-use Friendica\Core\PConfig;\r
-use Friendica\Core\Renderer;\r
-use Friendica\Core\System;\r
-use Friendica\Database\DBA;\r
-use Friendica\Model;\r
-use Friendica\Util\Strings;\r
-\r
-require_once 'boot.php';\r
-\r
-class Group extends BaseModule\r
-{\r
-       public static function post()\r
-       {\r
-               $a = self::getApp();\r
-\r
-               if ($a->isAjax()) {\r
-                       self::ajaxPost();\r
-               }\r
-\r
-               if (!local_user()) {\r
-                       notice(L10n::t('Permission denied.'));\r
-                       $a->internalRedirect();\r
-               }\r
-\r
-               if (($a->argc == 2) && ($a->argv[1] === 'new')) {\r
-                       BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');\r
-\r
-                       $name = Strings::escapeTags(trim($_POST['groupname']));\r
-                       $r = Model\Group::create(local_user(), $name);\r
-                       if ($r) {\r
-                               info(L10n::t('Group created.'));\r
-                               $r = Model\Group::getIdByName(local_user(), $name);\r
-                               if ($r) {\r
-                                       $a->internalRedirect('group/' . $r);\r
-                               }\r
-                       } else {\r
-                               notice(L10n::t('Could not create group.'));\r
-                       }\r
-                       $a->internalRedirect('group');\r
-               }\r
-\r
-               if (($a->argc == 2) && intval($a->argv[1])) {\r
-                       BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');\r
-\r
-                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user()]);\r
-                       if (!DBA::isResult($group)) {\r
-                               notice(L10n::t('Group not found.'));\r
-                               $a->internalRedirect('contact');\r
-                       }\r
-                       $groupname = Strings::escapeTags(trim($_POST['groupname']));\r
-                       if (strlen($groupname) && ($groupname != $group['name'])) {\r
-                               if (Model\Group::update($group['id'], $groupname)) {\r
-                                       info(L10n::t('Group name changed.'));\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       public static function ajaxPost()\r
-       {\r
-               try {\r
-                       $a = self::getApp();\r
-\r
-                       if (!local_user()) {\r
-                               throw new \Exception(L10n::t('Permission denied.'), 403);\r
-                       }\r
-\r
-                       // POST /group/123/add/123\r
-                       // POST /group/123/remove/123\r
-                       if ($a->argc == 4) {\r
-                               list($group_id, $command, $contact_id) = array_slice($a->argv, 1);\r
-\r
-                               if (!Model\Group::exists($group_id, local_user())) {\r
-                                       throw new \Exception(L10n::t('Unknown group.'), 404);\r
-                               }\r
-\r
-                               $contact = DBA::selectFirst('contact', ['pending', 'blocked', 'deleted'], ['id' => $contact_id, 'uid' => local_user()]);\r
-                               if (!DBA::isResult($contact)) {\r
-                                       throw new \Exception(L10n::t('Contact not found.'), 404);\r
-                               }\r
-\r
-                               if ($contact['pending']) {\r
-                                       throw new \Exception(L10n::t('Contact is unavailable.'), 400);\r
-                               }\r
-\r
-                               if ($contact['deleted']) {\r
-                                       throw new \Exception(L10n::t('Contact is deleted.'), 410);\r
-                               }\r
-\r
-                               switch($command) {\r
-                                       case 'add':\r
-                                               if ($contact['blocked']) {\r
-                                                       throw new \Exception(L10n::t('Contact is blocked, unable to add it to a group.'), 400);\r
-                                               }\r
-\r
-                                               if (!Model\Group::addMember($group_id, $contact_id)) {\r
-                                                       throw new \Exception(L10n::t('Unable to add the contact to the group.'), 500);\r
-                                               }\r
-                                               $message = L10n::t('Contact successfully added to group.');\r
-                                               break;\r
-                                       case 'remove':\r
-                                               if (!Model\Group::removeMember($group_id, $contact_id)) {\r
-                                                       throw new \Exception(L10n::t('Unable to remove the contact from the group.'), 500);\r
-                                               }\r
-                                               $message = L10n::t('Contact successfully removed from group.');\r
-                                               break;\r
-                                       default:\r
-                                               throw new \Exception(L10n::t('Unknown group command.'), 400);\r
-                               }\r
-                       } else {\r
-                               throw new \Exception(L10n::t('Bad request.'), 400);\r
-                       }\r
-\r
-                       notice($message);\r
-                       System::jsonExit(['status' => 'OK', 'message' => $message]);\r
-               } catch (\Exception $e) {\r
-                       notice($e->getMessage());\r
-                       System::jsonError($e->getCode(), ['status' => 'error', 'message' => $e->getMessage()]);\r
-               }\r
-       }\r
-\r
-       public static function content()\r
-       {\r
-               $change = false;\r
-\r
-               if (!local_user()) {\r
-                       System::httpExit(403);\r
-               }\r
-\r
-               $a = self::getApp();\r
-\r
-               $a->page['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));\r
-\r
-               // With no group number provided we jump to the unassigned contacts as a starting point\r
-               if ($a->argc == 1) {\r
-                       $a->internalRedirect('group/none');\r
-               }\r
-\r
-               // Switch to text mode interface if we have more than 'n' contacts or group members\r
-               $switchtotext = PConfig::get(local_user(), 'system', 'groupedit_image_limit');\r
-               if (is_null($switchtotext)) {\r
-                       $switchtotext = Config::get('system', 'groupedit_image_limit', 200);\r
-               }\r
-\r
-               $tpl = Renderer::getMarkupTemplate('group_edit.tpl');\r
-\r
-\r
-               $context = [\r
-                       '$submit' => L10n::t('Save Group'),\r
-                       '$submit_filter' => L10n::t('Filter'),\r
-               ];\r
-\r
-               if (($a->argc == 2) && ($a->argv[1] === 'new')) {\r
-                       return Renderer::replaceMacros($tpl, $context + [\r
-                               '$title' => L10n::t('Create a group of contacts/friends.'),\r
-                               '$gname' => ['groupname', L10n::t('Group Name: '), '', ''],\r
-                               '$gid' => 'new',\r
-                               '$form_security_token' => BaseModule::getFormSecurityToken("group_edit"),\r
-                       ]);\r
-               }\r
-\r
-               $nogroup = false;\r
-\r
-               if (($a->argc == 2) && ($a->argv[1] === 'none')) {\r
-                       $id = -1;\r
-                       $nogroup = true;\r
-                       $group = [\r
-                               'id' => $id,\r
-                               'name' => L10n::t('Contacts not in any group'),\r
-                       ];\r
-\r
-                       $members = [];\r
-                       $preselected = [];\r
-\r
-                       $context = $context + [\r
-                               '$title' => $group['name'],\r
-                               '$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],\r
-                               '$gid' => $id,\r
-                               '$editable' => 0,\r
-                       ];\r
-               }\r
-\r
-               if (($a->argc == 3) && ($a->argv[1] === 'drop')) {\r
-                       BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');\r
-\r
-                       if (intval($a->argv[2])) {\r
-                               if (!Model\Group::exists($a->argv[2], local_user())) {\r
-                                       notice(L10n::t('Group not found.'));\r
-                                       $a->internalRedirect('contact');\r
-                               }\r
-\r
-                               if (Model\Group::remove($a->argv[2])) {\r
-                                       info(L10n::t('Group removed.'));\r
-                               } else {\r
-                                       notice(L10n::t('Unable to remove group.'));\r
-                               }\r
-                       }\r
-                       $a->internalRedirect('group');\r
-               }\r
-\r
-               if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {\r
-                       BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');\r
-\r
-                       if (DBA::exists('contact', ['id' => $a->argv[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {\r
-                               $change = intval($a->argv[2]);\r
-                       }\r
-               }\r
-\r
-               if (($a->argc > 1) && intval($a->argv[1])) {\r
-                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user(), 'deleted' => false]);\r
-                       if (!DBA::isResult($group)) {\r
-                               notice(L10n::t('Group not found.'));\r
-                               $a->internalRedirect('contact');\r
-                       }\r
-\r
-                       $members = Model\Contact::getByGroupId($group['id']);\r
-                       $preselected = [];\r
-\r
-                       if (count($members)) {\r
-                               foreach ($members as $member) {\r
-                                       $preselected[] = $member['id'];\r
-                               }\r
-                       }\r
-\r
-                       if ($change) {\r
-                               if (in_array($change, $preselected)) {\r
-                                       Model\Group::removeMember($group['id'], $change);\r
-                               } else {\r
-                                       Model\Group::addMember($group['id'], $change);\r
-                               }\r
-\r
-                               $members = Model\Contact::getByGroupId($group['id']);\r
-                               $preselected = [];\r
-                               if (count($members)) {\r
-                                       foreach ($members as $member) {\r
-                                               $preselected[] = $member['id'];\r
-                                       }\r
-                               }\r
-                       }\r
-\r
-                       $drop_tpl = Renderer::getMarkupTemplate('group_drop.tpl');\r
-                       $drop_txt = Renderer::replaceMacros($drop_tpl, [\r
-                               '$id' => $group['id'],\r
-                               '$delete' => L10n::t('Delete Group'),\r
-                               '$form_security_token' => BaseModule::getFormSecurityToken("group_drop"),\r
-                       ]);\r
-\r
-                       $context = $context + [\r
-                               '$title' => $group['name'],\r
-                               '$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],\r
-                               '$gid' => $group['id'],\r
-                               '$drop' => $drop_txt,\r
-                               '$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),\r
-                               '$edit_name' => L10n::t('Edit Group Name'),\r
-                               '$editable' => 1,\r
-                       ];\r
-               }\r
-\r
-               if (!isset($group)) {\r
-                       System::httpExit(400);\r
-               }\r
-\r
-               $groupeditor = [\r
-                       'label_members' => L10n::t('Members'),\r
-                       'members' => [],\r
-                       'label_contacts' => L10n::t('All Contacts'),\r
-                       'group_is_empty' => L10n::t('Group is empty'),\r
-                       'contacts' => [],\r
-               ];\r
-\r
-               $sec_token = addslashes(BaseModule::getFormSecurityToken('group_member_change'));\r
-\r
-               // Format the data of the group members\r
-               foreach ($members as $member) {\r
-                       if ($member['url']) {\r
-                               $entry = Contact::getContactTemplateVars($member);\r
-                               $entry['label'] = 'members';\r
-                               $entry['photo_menu'] = '';\r
-                               $entry['change_member'] = [\r
-                                       'title'     => L10n::t("Remove contact from group"),\r
-                                       'gid'       => $group['id'],\r
-                                       'cid'       => $member['id'],\r
-                                       'sec_token' => $sec_token\r
-                               ];\r
-\r
-                               $groupeditor['members'][] = $entry;\r
-                       } else {\r
-                               Model\Group::removeMember($group['id'], $member['id']);\r
-                       }\r
-               }\r
-\r
-               if ($nogroup) {\r
-                       $contacts = Model\Contact::getUngroupedList(local_user());\r
-               } else {\r
-                       $contacts_stmt = DBA::select('contact', [],\r
-                               ['uid' => local_user(), 'pending' => false, 'blocked' => false, 'self' => false],\r
-                               ['order' => ['name']]\r
-                       );\r
-                       $contacts = DBA::toArray($contacts_stmt);\r
-                       $context['$desc'] = L10n::t('Click on a contact to add or remove.');\r
-               }\r
-\r
-               if (DBA::isResult($contacts)) {\r
-                       // Format the data of the contacts who aren't in the contact group\r
-                       foreach ($contacts as $member) {\r
-                               if (!in_array($member['id'], $preselected)) {\r
-                                       $entry = Contact::getContactTemplateVars($member);\r
-                                       $entry['label'] = 'contacts';\r
-                                       if (!$nogroup)\r
-                                               $entry['photo_menu'] = [];\r
-\r
-                                       if (!$nogroup) {\r
-                                               $entry['change_member'] = [\r
-                                                       'title'     => L10n::t("Add contact to group"),\r
-                                                       'gid'       => $group['id'],\r
-                                                       'cid'       => $member['id'],\r
-                                                       'sec_token' => $sec_token\r
-                                               ];\r
-                                       }\r
-\r
-                                       $groupeditor['contacts'][] = $entry;\r
-                               }\r
-                       }\r
-               }\r
-\r
-               $context['$groupeditor'] = $groupeditor;\r
-\r
-               // If there are to many contacts we could provide an alternative view mode\r
-               $total = count($groupeditor['members']) + count($groupeditor['contacts']);\r
-               $context['$shortmode'] = (($switchtotext && ($total > $switchtotext)) ? true : false);\r
-\r
-               if ($change) {\r
-                       $tpl = Renderer::getMarkupTemplate('groupeditor.tpl');\r
-                       echo Renderer::replaceMacros($tpl, $context);\r
-                       exit();\r
-               }\r
-\r
-               return Renderer::replaceMacros($tpl, $context);\r
-       }\r
+<?php
+/**
+ * @file src/Module/Group.php
+ */
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\Config;
+use Friendica\Core\L10n;
+use Friendica\Core\PConfig;
+use Friendica\Core\Renderer;
+use Friendica\Core\System;
+use Friendica\Database\DBA;
+use Friendica\Model;
+use Friendica\Util\Strings;
+
+require_once 'boot.php';
+
+class Group extends BaseModule
+{
+       public static function post()
+       {
+               $a = self::getApp();
+
+               if ($a->isAjax()) {
+                       self::ajaxPost();
+               }
+
+               if (!local_user()) {
+                       notice(L10n::t('Permission denied.'));
+                       $a->internalRedirect();
+               }
+
+               // @TODO: Replace with parameter from router
+               if (($a->argc == 2) && ($a->argv[1] === 'new')) {
+                       BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
+
+                       $name = Strings::escapeTags(trim($_POST['groupname']));
+                       $r = Model\Group::create(local_user(), $name);
+                       if ($r) {
+                               info(L10n::t('Group created.'));
+                               $r = Model\Group::getIdByName(local_user(), $name);
+                               if ($r) {
+                                       $a->internalRedirect('group/' . $r);
+                               }
+                       } else {
+                               notice(L10n::t('Could not create group.'));
+                       }
+                       $a->internalRedirect('group');
+               }
+
+               // @TODO: Replace with parameter from router
+               if (($a->argc == 2) && intval($a->argv[1])) {
+                       BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
+
+                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user()]);
+                       if (!DBA::isResult($group)) {
+                               notice(L10n::t('Group not found.'));
+                               $a->internalRedirect('contact');
+                       }
+                       $groupname = Strings::escapeTags(trim($_POST['groupname']));
+                       if (strlen($groupname) && ($groupname != $group['name'])) {
+                               if (Model\Group::update($group['id'], $groupname)) {
+                                       info(L10n::t('Group name changed.'));
+                               }
+                       }
+               }
+       }
+
+       public static function ajaxPost()
+       {
+               try {
+                       $a = self::getApp();
+
+                       if (!local_user()) {
+                               throw new \Exception(L10n::t('Permission denied.'), 403);
+                       }
+
+                       // POST /group/123/add/123
+                       // POST /group/123/remove/123
+                       // @TODO: Replace with parameter from router
+                       if ($a->argc == 4) {
+                               list($group_id, $command, $contact_id) = array_slice($a->argv, 1);
+
+                               if (!Model\Group::exists($group_id, local_user())) {
+                                       throw new \Exception(L10n::t('Unknown group.'), 404);
+                               }
+
+                               $contact = DBA::selectFirst('contact', ['pending', 'blocked', 'deleted'], ['id' => $contact_id, 'uid' => local_user()]);
+                               if (!DBA::isResult($contact)) {
+                                       throw new \Exception(L10n::t('Contact not found.'), 404);
+                               }
+
+                               if ($contact['pending']) {
+                                       throw new \Exception(L10n::t('Contact is unavailable.'), 400);
+                               }
+
+                               if ($contact['deleted']) {
+                                       throw new \Exception(L10n::t('Contact is deleted.'), 410);
+                               }
+
+                               switch($command) {
+                                       case 'add':
+                                               if ($contact['blocked']) {
+                                                       throw new \Exception(L10n::t('Contact is blocked, unable to add it to a group.'), 400);
+                                               }
+
+                                               if (!Model\Group::addMember($group_id, $contact_id)) {
+                                                       throw new \Exception(L10n::t('Unable to add the contact to the group.'), 500);
+                                               }
+                                               $message = L10n::t('Contact successfully added to group.');
+                                               break;
+                                       case 'remove':
+                                               if (!Model\Group::removeMember($group_id, $contact_id)) {
+                                                       throw new \Exception(L10n::t('Unable to remove the contact from the group.'), 500);
+                                               }
+                                               $message = L10n::t('Contact successfully removed from group.');
+                                               break;
+                                       default:
+                                               throw new \Exception(L10n::t('Unknown group command.'), 400);
+                               }
+                       } else {
+                               throw new \Exception(L10n::t('Bad request.'), 400);
+                       }
+
+                       notice($message);
+                       System::jsonExit(['status' => 'OK', 'message' => $message]);
+               } catch (\Exception $e) {
+                       notice($e->getMessage());
+                       System::jsonError($e->getCode(), ['status' => 'error', 'message' => $e->getMessage()]);
+               }
+       }
+
+       public static function content()
+       {
+               $change = false;
+
+               if (!local_user()) {
+                       System::httpExit(403);
+               }
+
+               $a = self::getApp();
+
+               $a->page['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));
+
+               // With no group number provided we jump to the unassigned contacts as a starting point
+               // @TODO: Replace with parameter from router
+               if ($a->argc == 1) {
+                       $a->internalRedirect('group/none');
+               }
+
+               // Switch to text mode interface if we have more than 'n' contacts or group members
+               $switchtotext = PConfig::get(local_user(), 'system', 'groupedit_image_limit');
+               if (is_null($switchtotext)) {
+                       $switchtotext = Config::get('system', 'groupedit_image_limit', 200);
+               }
+
+               $tpl = Renderer::getMarkupTemplate('group_edit.tpl');
+
+
+               $context = [
+                       '$submit' => L10n::t('Save Group'),
+                       '$submit_filter' => L10n::t('Filter'),
+               ];
+
+               // @TODO: Replace with parameter from router
+               if (($a->argc == 2) && ($a->argv[1] === 'new')) {
+                       return Renderer::replaceMacros($tpl, $context + [
+                               '$title' => L10n::t('Create a group of contacts/friends.'),
+                               '$gname' => ['groupname', L10n::t('Group Name: '), '', ''],
+                               '$gid' => 'new',
+                               '$form_security_token' => BaseModule::getFormSecurityToken("group_edit"),
+                       ]);
+               }
+
+               $nogroup = false;
+
+               if (($a->argc == 2) && ($a->argv[1] === 'none')) {
+                       $id = -1;
+                       $nogroup = true;
+                       $group = [
+                               'id' => $id,
+                               'name' => L10n::t('Contacts not in any group'),
+                       ];
+
+                       $members = [];
+                       $preselected = [];
+
+                       $context = $context + [
+                               '$title' => $group['name'],
+                               '$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],
+                               '$gid' => $id,
+                               '$editable' => 0,
+                       ];
+               }
+
+               // @TODO: Replace with parameter from router
+               if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
+                       BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');
+
+                       // @TODO: Replace with parameter from router
+                       if (intval($a->argv[2])) {
+                               if (!Model\Group::exists($a->argv[2], local_user())) {
+                                       notice(L10n::t('Group not found.'));
+                                       $a->internalRedirect('contact');
+                               }
+
+                               if (Model\Group::remove($a->argv[2])) {
+                                       info(L10n::t('Group removed.'));
+                               } else {
+                                       notice(L10n::t('Unable to remove group.'));
+                               }
+                       }
+                       $a->internalRedirect('group');
+               }
+
+               // @TODO: Replace with parameter from router
+               if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
+                       BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
+
+                       if (DBA::exists('contact', ['id' => $a->argv[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
+                               $change = intval($a->argv[2]);
+                       }
+               }
+
+               // @TODO: Replace with parameter from router
+               if (($a->argc > 1) && intval($a->argv[1])) {
+                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user(), 'deleted' => false]);
+                       if (!DBA::isResult($group)) {
+                               notice(L10n::t('Group not found.'));
+                               $a->internalRedirect('contact');
+                       }
+
+                       $members = Model\Contact::getByGroupId($group['id']);
+                       $preselected = [];
+
+                       if (count($members)) {
+                               foreach ($members as $member) {
+                                       $preselected[] = $member['id'];
+                               }
+                       }
+
+                       if ($change) {
+                               if (in_array($change, $preselected)) {
+                                       Model\Group::removeMember($group['id'], $change);
+                               } else {
+                                       Model\Group::addMember($group['id'], $change);
+                               }
+
+                               $members = Model\Contact::getByGroupId($group['id']);
+                               $preselected = [];
+                               if (count($members)) {
+                                       foreach ($members as $member) {
+                                               $preselected[] = $member['id'];
+                                       }
+                               }
+                       }
+
+                       $drop_tpl = Renderer::getMarkupTemplate('group_drop.tpl');
+                       $drop_txt = Renderer::replaceMacros($drop_tpl, [
+                               '$id' => $group['id'],
+                               '$delete' => L10n::t('Delete Group'),
+                               '$form_security_token' => BaseModule::getFormSecurityToken("group_drop"),
+                       ]);
+
+                       $context = $context + [
+                               '$title' => $group['name'],
+                               '$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],
+                               '$gid' => $group['id'],
+                               '$drop' => $drop_txt,
+                               '$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),
+                               '$edit_name' => L10n::t('Edit Group Name'),
+                               '$editable' => 1,
+                       ];
+               }
+
+               if (!isset($group)) {
+                       System::httpExit(400);
+               }
+
+               $groupeditor = [
+                       'label_members' => L10n::t('Members'),
+                       'members' => [],
+                       'label_contacts' => L10n::t('All Contacts'),
+                       'group_is_empty' => L10n::t('Group is empty'),
+                       'contacts' => [],
+               ];
+
+               $sec_token = addslashes(BaseModule::getFormSecurityToken('group_member_change'));
+
+               // Format the data of the group members
+               foreach ($members as $member) {
+                       if ($member['url']) {
+                               $entry = Contact::getContactTemplateVars($member);
+                               $entry['label'] = 'members';
+                               $entry['photo_menu'] = '';
+                               $entry['change_member'] = [
+                                       'title'     => L10n::t("Remove contact from group"),
+                                       'gid'       => $group['id'],
+                                       'cid'       => $member['id'],
+                                       'sec_token' => $sec_token
+                               ];
+
+                               $groupeditor['members'][] = $entry;
+                       } else {
+                               Model\Group::removeMember($group['id'], $member['id']);
+                       }
+               }
+
+               if ($nogroup) {
+                       $contacts = Model\Contact::getUngroupedList(local_user());
+               } else {
+                       $contacts_stmt = DBA::select('contact', [],
+                               ['uid' => local_user(), 'pending' => false, 'blocked' => false, 'self' => false],
+                               ['order' => ['name']]
+                       );
+                       $contacts = DBA::toArray($contacts_stmt);
+                       $context['$desc'] = L10n::t('Click on a contact to add or remove.');
+               }
+
+               if (DBA::isResult($contacts)) {
+                       // Format the data of the contacts who aren't in the contact group
+                       foreach ($contacts as $member) {
+                               if (!in_array($member['id'], $preselected)) {
+                                       $entry = Contact::getContactTemplateVars($member);
+                                       $entry['label'] = 'contacts';
+                                       if (!$nogroup)
+                                               $entry['photo_menu'] = [];
+
+                                       if (!$nogroup) {
+                                               $entry['change_member'] = [
+                                                       'title'     => L10n::t("Add contact to group"),
+                                                       'gid'       => $group['id'],
+                                                       'cid'       => $member['id'],
+                                                       'sec_token' => $sec_token
+                                               ];
+                                       }
+
+                                       $groupeditor['contacts'][] = $entry;
+                               }
+                       }
+               }
+
+               $context['$groupeditor'] = $groupeditor;
+
+               // If there are to many contacts we could provide an alternative view mode
+               $total = count($groupeditor['members']) + count($groupeditor['contacts']);
+               $context['$shortmode'] = (($switchtotext && ($total > $switchtotext)) ? true : false);
+
+               if ($change) {
+                       $tpl = Renderer::getMarkupTemplate('groupeditor.tpl');
+                       echo Renderer::replaceMacros($tpl, $context);
+                       exit();
+               }
+
+               return Renderer::replaceMacros($tpl, $context);
+       }
 }
\ No newline at end of file
index 1bc127b7c9a76c65c2188a402d3b5a80ef28271a..35160bd88d03a4e92f0ae8afec80187e732a00d5 100644 (file)
@@ -6,12 +6,12 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Core\Config;
 use Friendica\Core\Logger;
-use Friendica\Protocol\ActivityPub;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
+use Friendica\Protocol\ActivityPub;
 use Friendica\Util\HTTPSignature;
-use Friendica\Core\Config;
 
 /**
  * ActivityPub Inbox
@@ -39,6 +39,7 @@ class Inbox extends BaseModule
                        Logger::log('Incoming message stored under ' . $tempfile);
                }
 
+               // @TODO: Replace with parameter from router
                if (!empty($a->argv[1])) {
                        $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
                        if (!DBA::isResult($user)) {
index 65a30e894bed610c356318699910d7f1bc0b2f03..1cef8fbafa5ac63a24d2693d8311e9abb6020eff 100644 (file)
@@ -56,6 +56,7 @@ class Install extends BaseModule
 
                // route: install/testrwrite
                // $baseurl/install/testrwrite to test if rewrite in .htaccess is working
+               // @TODO: Replace with parameter from router
                if ($a->getArgumentValue(1, '') == 'testrewrite') {
                        // Status Code 204 means that it worked without content
                        Core\System::httpExit(204);
index 558b274919ce33bad609074dec5aac569ceca9e0..f34af3a08044af329836ff00b937bf93b92a8c4e 100644 (file)
@@ -5,11 +5,10 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\Protocol\ActivityPub;
 use Friendica\Core\System;
-use Friendica\Model\Item;
 use Friendica\Database\DBA;
-use Friendica\Util\HTTPSignature;
+use Friendica\Model\Item;
+use Friendica\Protocol\ActivityPub;
 
 /**
  * ActivityPub Objects
@@ -32,9 +31,11 @@ class Objects extends BaseModule
                // $requester = HTTPSignature::getSigner('', $_SERVER);
 
                // At first we try the original post with that guid
+               // @TODO: Replace with parameter from router
                $item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'origin' => true, 'private' => false]);
                if (!DBA::isResult($item)) {
                        // If no original post could be found, it could possibly be a forum post, there we remove the "origin" field.
+                       // @TODO: Replace with parameter from router
                        $item = Item::selectFirst(['id', 'author-link'], ['guid' => $a->argv[1], 'private' => false]);
                        if (!DBA::isResult($item) || !strstr($item['author-link'], System::baseUrl())) {
                                System::httpExit(404);
index d5ff62dac9c5a91aca8ef7e2d0cb5a4514e41a34..0107782122b5c0c877025d09805eca4a22794315 100644 (file)
@@ -35,6 +35,7 @@ class Oembed extends BaseModule
                        exit();
                }
 
+               // @TODO: Replace with parameter from router
                if ($a->argc == 2) {
                        echo '<html><body>';
                        $url = Strings::base64UrlDecode($a->argv[1]);
index 41e10757f1231ae90a10138fe49cc09cc4ef722b..27dcd5c1f44b905b51423e6f3cccc3bfe8e43e6b 100644 (file)
@@ -5,10 +5,9 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\Protocol\ActivityPub;
 use Friendica\Core\System;
 use Friendica\Model\User;
-use Friendica\Util\HTTPSignature;
+use Friendica\Protocol\ActivityPub;
 
 /**
  * ActivityPub Outbox
@@ -19,6 +18,7 @@ class Outbox extends BaseModule
        {
                $a = self::getApp();
 
+               // @TODO: Replace with parameter from router
                if (empty($a->argv[1])) {
                        System::httpExit(404);
                }
index ed5609640c34eb4d9f9da17e15ffd0c2355fff8e..9165af8bedbbaad213c98833563887df25849d64 100644 (file)
@@ -25,6 +25,7 @@ class Photo extends BaseModule
        public static function init()
        {
                $a = self::getApp();
+               // @TODO: Replace with parameter from router
                if ($a->argc <= 1 || $a->argc > 4) {
                        System::httpExit(400);
                }
@@ -47,6 +48,7 @@ class Photo extends BaseModule
 
                $customsize = 0;
                $photo = false;
+               // @TODO: Replace with parameter from router
                switch($a->argc) {
                        case 4:
                                $customsize = intval($a->argv[2]);
index 55150a9649d8d1d741008945d041c95e419e5bfe..c3297d261a295ec9a8abc368f983aa1833f30d71 100644 (file)
-<?php\r
-\r
-namespace Friendica\Module;\r
-\r
-use Friendica\BaseModule;\r
-use Friendica\Content\Nav;\r
-use Friendica\Content\Pager;\r
-use Friendica\Content\Widget;\r
-use Friendica\Core\ACL;\r
-use Friendica\Core\Config;\r
-use Friendica\Core\Hook;\r
-use Friendica\Core\L10n;\r
-use Friendica\Core\PConfig;\r
-use Friendica\Core\System;\r
-use Friendica\Database\DBA;\r
-use Friendica\Model\Contact as ContactModel;\r
-use Friendica\Model\Group;\r
-use Friendica\Model\Item;\r
-use Friendica\Model\Profile AS ProfileModel;\r
-use Friendica\Model\User;\r
-use Friendica\Protocol\ActivityPub;\r
-use Friendica\Protocol\DFRN;\r
-use Friendica\Util\DateTimeFormat;\r
-use Friendica\Util\Security;\r
-use Friendica\Util\Strings;\r
-use Friendica\Util\XML;\r
-\r
-require_once 'boot.php';\r
-\r
-class Profile extends BaseModule\r
-{\r
-       public static $which = '';\r
-       public static $profile = 0;\r
-\r
-       public static function init()\r
-       {\r
-               $a = self::getApp();\r
-\r
-               if ($a->argc < 2) {\r
-                       System::httpExit(400);\r
-               }\r
-\r
-               self::$which = filter_var($a->argv[1], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK);\r
-\r
-               if (local_user() && $a->argc > 2 && $a->argv[2] === 'view') {\r
-                       self::$which = $a->user['nickname'];\r
-                       self::$profile = filter_var($a->argv[1], FILTER_SANITIZE_NUMBER_INT);\r
-               } else {\r
-                       DFRN::autoRedir($a, self::$which);\r
-               }\r
-       }\r
-\r
-       public static function rawContent()\r
-       {\r
-               if (ActivityPub::isRequest()) {\r
-                       $user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);\r
-                       $data = [];\r
-                       if (DBA::isResult($user)) {\r
-                               $data = ActivityPub\Transmitter::getProfile($user['uid']);\r
-                       }\r
-\r
-                       if (!empty($data)) {\r
-                               System::jsonExit($data, 'application/activity+json');\r
-                       } elseif (DBA::exists('userd', ['username' => self::$which])) {\r
-                               // Known deleted user\r
-                               $data = ActivityPub\Transmitter::getDeletedUser(self::$which);\r
-\r
-                               System::jsonError(410, $data);\r
-                       } else {\r
-                               // Any other case (unknown, blocked, unverified, expired, no profile, no self contact)\r
-                               System::jsonError(404, $data);\r
-                       }\r
-               }\r
-       }\r
-\r
-       public static function content($update = 0)\r
-       {\r
-               $a = self::getApp();\r
-\r
-               if (!$update) {\r
-                       ProfileModel::load($a, self::$which, self::$profile);\r
-\r
-                       $blocked   = !local_user() && !remote_user() && Config::get('system', 'block_public');\r
-                       $userblock = !local_user() && !remote_user() && $a->profile['hidewall'];\r
-\r
-                       if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {\r
-                               $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';\r
-                       }\r
-\r
-                       if (!empty($a->profile['openidserver'])) {\r
-                               $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\n";\r
-                       }\r
-\r
-                       if (!empty($a->profile['openid'])) {\r
-                               $delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];\r
-                               $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";\r
-                       }\r
-\r
-                       // site block\r
-                       if (!$blocked && !$userblock) {\r
-                               $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], defaults($a->profile, 'pub_keywords', ''));\r
-                               if (strlen($keywords)) {\r
-                                       $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";\r
-                               }\r
-                       }\r
-\r
-                       $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";\r
-                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . self::$which . '" title="DFRN: ' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";\r
-                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/" title="' . L10n::t('%s\'s posts', $a->profile['username']) . '"/>' . "\n";\r
-                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/comments" title="' . L10n::t('%s\'s comments', $a->profile['username']) . '"/>' . "\n";\r
-                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/activity" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";\r
-                       $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''));\r
-                       $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\n";\r
-                       header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);\r
-\r
-                       $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];\r
-                       foreach ($dfrn_pages as $dfrn) {\r
-                               $a->page['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . System::baseUrl() . '/dfrn_' . $dfrn . '/' . self::$which . '" />' . "\n";\r
-                       }\r
-                       $a->page['htmlhead'] .= '<link rel="dfrn-poco" href="' . System::baseUrl() . '/poco/' . self::$which . '" />' . "\n";\r
-               }\r
-\r
-               $category = $datequery = $datequery2 = '';\r
-\r
-               if ($a->argc > 2) {\r
-                       for ($x = 2; $x < $a->argc; $x ++) {\r
-                               if (is_a_date_arg($a->argv[$x])) {\r
-                                       if ($datequery) {\r
-                                               $datequery2 = Strings::escapeHtml($a->argv[$x]);\r
-                                       } else {\r
-                                               $datequery = Strings::escapeHtml($a->argv[$x]);\r
-                                       }\r
-                               } else {\r
-                                       $category = $a->argv[$x];\r
-                               }\r
-                       }\r
-               }\r
-\r
-               if (empty($category)) {\r
-                       $category = defaults($_GET, 'category', '');\r
-               }\r
-\r
-               $hashtags = defaults($_GET, 'tag', '');\r
-\r
-               if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {\r
-                       return Login::form();\r
-               }\r
-\r
-               $groups = [];\r
-               $remote_cid = null;\r
-\r
-               $o = '';\r
-\r
-               if ($update) {\r
-                       // Ensure we've got a profile owner if updating.\r
-                       $a->profile['profile_uid'] = $update;\r
-               } elseif ($a->profile['profile_uid'] == local_user()) {\r
-                       Nav::setSelected('home');\r
-               }\r
-\r
-               $remote_contact = ContactModel::isFollower(remote_user(), $a->profile['profile_uid']);\r
-               $is_owner = local_user() == $a->profile['profile_uid'];\r
-               $last_updated_key = "profile:" . $a->profile['profile_uid'] . ":" . local_user() . ":" . remote_user();\r
-\r
-               if ($remote_contact) {\r
-                       $cdata = ContactModel::getPublicAndUserContacID(remote_user(), $a->profile['profile_uid']);\r
-                       if (!empty($cdata['user'])) {\r
-                               $groups = Group::getIdsByContactId($cdata['user']);\r
-                               $remote_cid = $cdata['user'];\r
-                       }\r
-               }\r
-\r
-               if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {\r
-                       notice(L10n::t('Access to this profile has been restricted.') . EOL);\r
-                       return '';\r
-               }\r
-\r
-               if (!$update) {\r
-                       $tab = false;\r
-                       if (!empty($_GET['tab'])) {\r
-                               $tab = Strings::escapeTags(trim($_GET['tab']));\r
-                       }\r
-\r
-                       $o .= ProfileModel::getTabs($a, $is_owner, $a->profile['nickname']);\r
-\r
-                       if ($tab === 'profile') {\r
-                               $o .= ProfileModel::getAdvanced($a);\r
-                               Hook::callAll('profile_advanced', $o);\r
-                               return $o;\r
-                       }\r
-\r
-                       $o .= Widget::commonFriendsVisitor($a->profile['profile_uid']);\r
-\r
-                       $commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;\r
-                       $commvisitor = $commpage && $remote_contact;\r
-\r
-                       $a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);\r
-                       $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? XML::escape($category) : ''));\r
-                       $a->page['aside'] .= Widget::tagCloud();\r
-\r
-                       if (Security::canWriteToUserWall($a->profile['profile_uid'])) {\r
-                               $x = [\r
-                                       'is_owner' => $is_owner,\r
-                                       'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],\r
-                                       'default_location' => $is_owner ? $a->user['default-location'] : '',\r
-                                       'nickname' => $a->profile['nickname'],\r
-                                       'lockstate' => is_array($a->user)\r
-                                       && (strlen($a->user['allow_cid'])\r
-                                               || strlen($a->user['allow_gid'])\r
-                                               || strlen($a->user['deny_cid'])\r
-                                               || strlen($a->user['deny_gid'])\r
-                                       ) ? 'lock' : 'unlock',\r
-                                       'acl' => $is_owner ? ACL::getFullSelectorHTML($a->user, true) : '',\r
-                                       'bang' => '',\r
-                                       'visitor' => $is_owner || $commvisitor ? 'block' : 'none',\r
-                                       'profile_uid' => $a->profile['profile_uid'],\r
-                               ];\r
-\r
-                               $o .= status_editor($a, $x);\r
-                       }\r
-               }\r
-\r
-               // Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups\r
-               $sql_extra = Item::getPermissionsSQLByUserId($a->profile['profile_uid'], $remote_contact, $groups, $remote_cid);\r
-               $sql_extra2 = '';\r
-\r
-               if ($update) {\r
-                       $last_updated = (defaults($_SESSION['last_updated'], $last_updated_key, 0));\r
-\r
-                       // If the page user is the owner of the page we should query for unseen\r
-                       // items. Otherwise use a timestamp of the last succesful update request.\r
-                       if ($is_owner || !$last_updated) {\r
-                               $sql_extra4 = " AND `item`.`unseen`";\r
-                       } else {\r
-                               $gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);\r
-                               $sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";\r
-                       }\r
-\r
-                       $items_stmt = DBA::p(\r
-                               "SELECT DISTINCT(`parent-uri`) AS `uri`, `item`.`created`\r
-                               FROM `item`\r
-                               INNER JOIN `contact`\r
-                               ON `contact`.`id` = `item`.`contact-id`\r
-                                       AND NOT `contact`.`blocked`\r
-                                       AND NOT `contact`.`pending`\r
-                               WHERE `item`.`uid` = ?\r
-                                       AND `item`.`visible`\r
-                                       AND     (NOT `item`.`deleted` OR `item`.`gravity` = ?)\r
-                                       AND NOT `item`.`moderated`\r
-                                       AND `item`.`wall`\r
-                                       $sql_extra4\r
-                                       $sql_extra\r
-                               ORDER BY `item`.`created` DESC",\r
-                               $a->profile['profile_uid'],\r
-                               GRAVITY_ACTIVITY\r
-                       );\r
-\r
-                       if (!DBA::isResult($items_stmt)) {\r
-                               return '';\r
-                       }\r
-\r
-                       $pager = new Pager($a->query_string);\r
-               } else {\r
-                       $sql_post_table = "";\r
-\r
-                       if (!empty($category)) {\r
-                               $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",\r
-                                       DBA::escape(Strings::protectSprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));\r
-                       }\r
-\r
-                       if (!empty($hashtags)) {\r
-                               $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",\r
-                                       DBA::escape(Strings::protectSprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['profile_uid']));\r
-                       }\r
-\r
-                       if (!empty($datequery)) {\r
-                               $sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));\r
-                       }\r
-                       if (!empty($datequery2)) {\r
-                               $sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));\r
-                       }\r
-\r
-                       // Does the profile page belong to a forum?\r
-                       // If not then we can improve the performance with an additional condition\r
-                       $condition = ['uid' => $a->profile['profile_uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];\r
-                       if (!DBA::exists('user', $condition)) {\r
-                               $sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));\r
-                       } else {\r
-                               $sql_extra3 = "";\r
-                       }\r
-\r
-                       //  check if we serve a mobile device and get the user settings\r
-                       //  accordingly\r
-                       if ($a->is_mobile) {\r
-                               $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 10);\r
-                       } else {\r
-                               $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 20);\r
-                       }\r
-\r
-                       //  now that we have the user settings, see if the theme forces\r
-                       //  a maximum item number which is lower then the user choice\r
-                       if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) {\r
-                               $itemspage_network = $a->force_max_items;\r
-                       }\r
-\r
-                       $pager = new Pager($a->query_string, $itemspage_network);\r
-\r
-                       $pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());\r
-\r
-                       $items_stmt = DBA::p(\r
-                               "SELECT `item`.`uri`\r
-                               FROM `thread`\r
-                               STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`\r
-                               $sql_post_table\r
-                               STRAIGHT_JOIN `contact`\r
-                               ON `contact`.`id` = `thread`.`contact-id`\r
-                                       AND NOT `contact`.`blocked`\r
-                                       AND NOT `contact`.`pending`\r
-                               WHERE `thread`.`uid` = ?\r
-                                       AND `thread`.`visible`\r
-                                       AND NOT `thread`.`deleted`\r
-                                       AND NOT `thread`.`moderated`\r
-                                       AND `thread`.`wall`\r
-                                       $sql_extra3\r
-                                       $sql_extra\r
-                                       $sql_extra2\r
-                               ORDER BY `thread`.`created` DESC\r
-                               $pager_sql",\r
-                               $a->profile['profile_uid']\r
-                       );\r
-               }\r
-\r
-               // Set a time stamp for this page. We will make use of it when we\r
-               // search for new items (update routine)\r
-               $_SESSION['last_updated'][$last_updated_key] = time();\r
-\r
-               if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) {\r
-                       $o .= ProfileModel::getBirthdays();\r
-                       $o .= ProfileModel::getEventsReminderHTML();\r
-               }\r
-\r
-               if ($is_owner) {\r
-                       $unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);\r
-                       if ($unseen) {\r
-                               Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);\r
-                       }\r
-               }\r
-\r
-               $items = DBA::toArray($items_stmt);\r
-\r
-               $o .= conversation($a, $items, $pager, 'profile', $update, false, 'created', $a->profile['profile_uid']);\r
-\r
-               if (!$update) {\r
-                       $o .= $pager->renderMinimal(count($items));\r
-               }\r
-\r
-               return $o;\r
-       }\r
-}\r
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Content\Nav;
+use Friendica\Content\Pager;
+use Friendica\Content\Widget;
+use Friendica\Core\ACL;
+use Friendica\Core\Config;
+use Friendica\Core\Hook;
+use Friendica\Core\L10n;
+use Friendica\Core\PConfig;
+use Friendica\Core\System;
+use Friendica\Database\DBA;
+use Friendica\Model\Contact as ContactModel;
+use Friendica\Model\Group;
+use Friendica\Model\Item;
+use Friendica\Model\Profile as ProfileModel;
+use Friendica\Model\User;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Protocol\DFRN;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Security;
+use Friendica\Util\Strings;
+use Friendica\Util\XML;
+
+require_once 'boot.php';
+
+class Profile extends BaseModule
+{
+       public static $which = '';
+       public static $profile = 0;
+
+       public static function init()
+       {
+               $a = self::getApp();
+
+               // @TODO: Replace with parameter from router
+               if ($a->argc < 2) {
+                       System::httpExit(400);
+               }
+
+               self::$which = filter_var($a->argv[1], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK);
+
+               // @TODO: Replace with parameter from router
+               if (local_user() && $a->argc > 2 && $a->argv[2] === 'view') {
+                       self::$which = $a->user['nickname'];
+                       self::$profile = filter_var($a->argv[1], FILTER_SANITIZE_NUMBER_INT);
+               } else {
+                       DFRN::autoRedir($a, self::$which);
+               }
+       }
+
+       public static function rawContent()
+       {
+               if (ActivityPub::isRequest()) {
+                       $user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);
+                       $data = [];
+                       if (DBA::isResult($user)) {
+                               $data = ActivityPub\Transmitter::getProfile($user['uid']);
+                       }
+
+                       if (!empty($data)) {
+                               System::jsonExit($data, 'application/activity+json');
+                       } elseif (DBA::exists('userd', ['username' => self::$which])) {
+                               // Known deleted user
+                               $data = ActivityPub\Transmitter::getDeletedUser(self::$which);
+
+                               System::jsonError(410, $data);
+                       } else {
+                               // Any other case (unknown, blocked, unverified, expired, no profile, no self contact)
+                               System::jsonError(404, $data);
+                       }
+               }
+       }
+
+       public static function content($update = 0)
+       {
+               $a = self::getApp();
+
+               if (!$update) {
+                       ProfileModel::load($a, self::$which, self::$profile);
+
+                       $blocked   = !local_user() && !remote_user() && Config::get('system', 'block_public');
+                       $userblock = !local_user() && !remote_user() && $a->profile['hidewall'];
+
+                       if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
+                               $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
+                       }
+
+                       if (!empty($a->profile['openidserver'])) {
+                               $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\n";
+                       }
+
+                       if (!empty($a->profile['openid'])) {
+                               $delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
+                               $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
+                       }
+
+                       // site block
+                       if (!$blocked && !$userblock) {
+                               $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], defaults($a->profile, 'pub_keywords', ''));
+                               if (strlen($keywords)) {
+                                       $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
+                               }
+                       }
+
+                       $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
+                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . self::$which . '" title="DFRN: ' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
+                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/" title="' . L10n::t('%s\'s posts', $a->profile['username']) . '"/>' . "\n";
+                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/comments" title="' . L10n::t('%s\'s comments', $a->profile['username']) . '"/>' . "\n";
+                       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/activity" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
+                       $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''));
+                       $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\n";
+                       header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
+
+                       $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
+                       foreach ($dfrn_pages as $dfrn) {
+                               $a->page['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . System::baseUrl() . '/dfrn_' . $dfrn . '/' . self::$which . '" />' . "\n";
+                       }
+                       $a->page['htmlhead'] .= '<link rel="dfrn-poco" href="' . System::baseUrl() . '/poco/' . self::$which . '" />' . "\n";
+               }
+
+               $category = $datequery = $datequery2 = '';
+
+               if ($a->argc > 2) {
+                       for ($x = 2; $x < $a->argc; $x ++) {
+                               if (is_a_date_arg($a->argv[$x])) {
+                                       if ($datequery) {
+                                               $datequery2 = Strings::escapeHtml($a->argv[$x]);
+                                       } else {
+                                               $datequery = Strings::escapeHtml($a->argv[$x]);
+                                       }
+                               } else {
+                                       $category = $a->argv[$x];
+                               }
+                       }
+               }
+
+               if (empty($category)) {
+                       $category = defaults($_GET, 'category', '');
+               }
+
+               $hashtags = defaults($_GET, 'tag', '');
+
+               if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+                       return Login::form();
+               }
+
+               $groups = [];
+               $remote_cid = null;
+
+               $o = '';
+
+               if ($update) {
+                       // Ensure we've got a profile owner if updating.
+                       $a->profile['profile_uid'] = $update;
+               } elseif ($a->profile['profile_uid'] == local_user()) {
+                       Nav::setSelected('home');
+               }
+
+               $remote_contact = ContactModel::isFollower(remote_user(), $a->profile['profile_uid']);
+               $is_owner = local_user() == $a->profile['profile_uid'];
+               $last_updated_key = "profile:" . $a->profile['profile_uid'] . ":" . local_user() . ":" . remote_user();
+
+               if ($remote_contact) {
+                       $cdata = ContactModel::getPublicAndUserContacID(remote_user(), $a->profile['profile_uid']);
+                       if (!empty($cdata['user'])) {
+                               $groups = Group::getIdsByContactId($cdata['user']);
+                               $remote_cid = $cdata['user'];
+                       }
+               }
+
+               if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
+                       notice(L10n::t('Access to this profile has been restricted.') . EOL);
+                       return '';
+               }
+
+               if (!$update) {
+                       $tab = false;
+                       if (!empty($_GET['tab'])) {
+                               $tab = Strings::escapeTags(trim($_GET['tab']));
+                       }
+
+                       $o .= ProfileModel::getTabs($a, $is_owner, $a->profile['nickname']);
+
+                       if ($tab === 'profile') {
+                               $o .= ProfileModel::getAdvanced($a);
+                               Hook::callAll('profile_advanced', $o);
+                               return $o;
+                       }
+
+                       $o .= Widget::commonFriendsVisitor($a->profile['profile_uid']);
+
+                       $commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
+                       $commvisitor = $commpage && $remote_contact;
+
+                       $a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
+                       $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? XML::escape($category) : ''));
+                       $a->page['aside'] .= Widget::tagCloud();
+
+                       if (Security::canWriteToUserWall($a->profile['profile_uid'])) {
+                               $x = [
+                                       'is_owner' => $is_owner,
+                                       'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
+                                       'default_location' => $is_owner ? $a->user['default-location'] : '',
+                                       'nickname' => $a->profile['nickname'],
+                                       'lockstate' => is_array($a->user)
+                                       && (strlen($a->user['allow_cid'])
+                                               || strlen($a->user['allow_gid'])
+                                               || strlen($a->user['deny_cid'])
+                                               || strlen($a->user['deny_gid'])
+                                       ) ? 'lock' : 'unlock',
+                                       'acl' => $is_owner ? ACL::getFullSelectorHTML($a->user, true) : '',
+                                       'bang' => '',
+                                       'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
+                                       'profile_uid' => $a->profile['profile_uid'],
+                               ];
+
+                               $o .= status_editor($a, $x);
+                       }
+               }
+
+               // Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
+               $sql_extra = Item::getPermissionsSQLByUserId($a->profile['profile_uid'], $remote_contact, $groups, $remote_cid);
+               $sql_extra2 = '';
+
+               if ($update) {
+                       $last_updated = (defaults($_SESSION['last_updated'], $last_updated_key, 0));
+
+                       // If the page user is the owner of the page we should query for unseen
+                       // items. Otherwise use a timestamp of the last succesful update request.
+                       if ($is_owner || !$last_updated) {
+                               $sql_extra4 = " AND `item`.`unseen`";
+                       } else {
+                               $gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
+                               $sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";
+                       }
+
+                       $items_stmt = DBA::p(
+                               "SELECT DISTINCT(`parent-uri`) AS `uri`, `item`.`created`
+                               FROM `item`
+                               INNER JOIN `contact`
+                               ON `contact`.`id` = `item`.`contact-id`
+                                       AND NOT `contact`.`blocked`
+                                       AND NOT `contact`.`pending`
+                               WHERE `item`.`uid` = ?
+                                       AND `item`.`visible`
+                                       AND     (NOT `item`.`deleted` OR `item`.`gravity` = ?)
+                                       AND NOT `item`.`moderated`
+                                       AND `item`.`wall`
+                                       $sql_extra4
+                                       $sql_extra
+                               ORDER BY `item`.`created` DESC",
+                               $a->profile['profile_uid'],
+                               GRAVITY_ACTIVITY
+                       );
+
+                       if (!DBA::isResult($items_stmt)) {
+                               return '';
+                       }
+
+                       $pager = new Pager($a->query_string);
+               } else {
+                       $sql_post_table = "";
+
+                       if (!empty($category)) {
+                               $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
+                                       DBA::escape(Strings::protectSprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
+                       }
+
+                       if (!empty($hashtags)) {
+                               $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
+                                       DBA::escape(Strings::protectSprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['profile_uid']));
+                       }
+
+                       if (!empty($datequery)) {
+                               $sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
+                       }
+                       if (!empty($datequery2)) {
+                               $sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
+                       }
+
+                       // Does the profile page belong to a forum?
+                       // If not then we can improve the performance with an additional condition
+                       $condition = ['uid' => $a->profile['profile_uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];
+                       if (!DBA::exists('user', $condition)) {
+                               $sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
+                       } else {
+                               $sql_extra3 = "";
+                       }
+
+                       //  check if we serve a mobile device and get the user settings
+                       //  accordingly
+                       if ($a->is_mobile) {
+                               $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 10);
+                       } else {
+                               $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 20);
+                       }
+
+                       //  now that we have the user settings, see if the theme forces
+                       //  a maximum item number which is lower then the user choice
+                       if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) {
+                               $itemspage_network = $a->force_max_items;
+                       }
+
+                       $pager = new Pager($a->query_string, $itemspage_network);
+
+                       $pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
+
+                       $items_stmt = DBA::p(
+                               "SELECT `item`.`uri`
+                               FROM `thread`
+                               STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
+                               $sql_post_table
+                               STRAIGHT_JOIN `contact`
+                               ON `contact`.`id` = `thread`.`contact-id`
+                                       AND NOT `contact`.`blocked`
+                                       AND NOT `contact`.`pending`
+                               WHERE `thread`.`uid` = ?
+                                       AND `thread`.`visible`
+                                       AND NOT `thread`.`deleted`
+                                       AND NOT `thread`.`moderated`
+                                       AND `thread`.`wall`
+                                       $sql_extra3
+                                       $sql_extra
+                                       $sql_extra2
+                               ORDER BY `thread`.`created` DESC
+                               $pager_sql",
+                               $a->profile['profile_uid']
+                       );
+               }
+
+               // Set a time stamp for this page. We will make use of it when we
+               // search for new items (update routine)
+               $_SESSION['last_updated'][$last_updated_key] = time();
+
+               if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) {
+                       $o .= ProfileModel::getBirthdays();
+                       $o .= ProfileModel::getEventsReminderHTML();
+               }
+
+               if ($is_owner) {
+                       $unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
+                       if ($unseen) {
+                               Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
+                       }
+               }
+
+               $items = DBA::toArray($items_stmt);
+
+               $o .= conversation($a, $items, $pager, 'profile', $update, false, 'created', $a->profile['profile_uid']);
+
+               if (!$update) {
+                       $o .= $pager->renderMinimal(count($items));
+               }
+
+               return $o;
+       }
+}
index 54870abe055469e20e715b269281644d539b5de3..387667a1a5a20c58e9cc6d246b3e501a7af620e7 100644 (file)
@@ -12,7 +12,6 @@ use Friendica\Model\Photo;
 use Friendica\Object\Image;
 use Friendica\Util\HTTPSignature;
 use Friendica\Util\Proxy as ProxyUtils;
-use Friendica\Core\Logger;
 
 /**
  * @brief Module Proxy
@@ -159,6 +158,7 @@ class Proxy extends BaseModule
                $sizetype = '';
 
                // Look for filename in the arguments
+               // @TODO: Replace with parameter from router
                if (($a->argc > 1) && !isset($_REQUEST['url'])) {
                        if (isset($a->argv[3])) {
                                $url = $a->argv[3];
@@ -169,6 +169,7 @@ class Proxy extends BaseModule
                        }
 
                        /// @TODO: Why? And what about $url in this case?
+                       /// @TODO: Replace with parameter from router
                        if (isset($a->argv[3]) && ($a->argv[3] == 'thumb')) {
                                $size = 200;
                        }
index 6744a0a5f34040ca1a2e02b7968dfdc4353d701f..202cf948e001289938175fea1eaa8c4cad946a8d 100644 (file)
@@ -19,7 +19,7 @@ use Friendica\Util\Strings;
 /**
  * @author Hypolite Petovan <hypolite@mrpetovan.com>
  */
-abstract class Register extends BaseModule
+class Register extends BaseModule
 {
        const CLOSED  = 0;
        const APPROVE = 1;
diff --git a/src/Module/Statistics.php b/src/Module/Statistics.php
new file mode 100644 (file)
index 0000000..566ace3
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\Addon;
+use Friendica\Core\System;
+
+class Statistics extends BaseModule
+{
+       public static function init()
+       {
+               $config = self::getApp()->getConfig();
+
+               if (!$config->get("system", "nodeinfo")) {
+                       System::httpExit(404);
+               }
+       }
+
+       public static function rawContent()
+       {
+               $config = self::getApp()->getConfig();
+               $logger = self::getApp()->getLogger();
+
+               $registration_open =
+                       intval($config->get('config', 'register_policy')) !== Register::CLOSED
+                       && !$config->get('config', 'invitation_only');
+
+               /// @todo mark the "service" addons and load them dynamically here
+               $services = [
+                       'appnet'      => Addon::isEnabled('appnet'),
+                       'buffer'      => Addon::isEnabled('buffer'),
+                       'dreamwidth'  => Addon::isEnabled('dreamwidth'),
+                       'gnusocial'   => Addon::isEnabled('gnusocial'),
+                       'libertree'   => Addon::isEnabled('libertree'),
+                       'livejournal' => Addon::isEnabled('livejournal'),
+                       'pumpio'      => Addon::isEnabled('pumpio'),
+                       'twitter'     => Addon::isEnabled('twitter'),
+                       'tumblr'      => Addon::isEnabled('tumblr'),
+                       'wordpress'   => Addon::isEnabled('wordpress'),
+               ];
+
+               $statistics = array_merge([
+                       'name'                  => $config->get('config', 'sitename'),
+                       'network'               => FRIENDICA_PLATFORM,
+                       'version'               => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
+                       'registrations_open'    => $registration_open,
+                       'total_users'           => $config->get('nodeinfo', 'total_users'),
+                       'active_users_halfyear' => $config->get('nodeinfo', 'active_users_halfyear'),
+                       'active_users_monthly'  => $config->get('nodeinfo', 'active_users_monthly'),
+                       'local_posts'           => $config->get('nodeinfo', 'local_posts'),
+                       'services'              => $services,
+               ], $services);
+
+               header("Content-Type: application/json");
+               echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
+               $logger->debug("statistics.", ['statistics' => $statistics]);
+               exit();
+       }
+}
diff --git a/src/Module/Statistics_json.php b/src/Module/Statistics_json.php
deleted file mode 100644 (file)
index aca204b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Core\Addon;
-use Friendica\Core\System;
-
-class Statistics_json extends BaseModule
-{
-       public static function init()
-       {
-               $config = self::getApp()->getConfig();
-
-               if (!$config->get("system", "nodeinfo")) {
-                       System::httpExit(404);
-               }
-       }
-
-       public static function rawContent()
-       {
-               $config = self::getApp()->getConfig();
-               $logger = self::getApp()->getLogger();
-
-               $registration_open =
-                       intval($config->get('config', 'register_policy')) !== Register::CLOSED
-                       && !$config->get('config', 'invitation_only');
-
-               /// @todo mark the "service" addons and load them dynamically here
-               $services = [
-                       'appnet'      => Addon::isEnabled('appnet'),
-                       'buffer'      => Addon::isEnabled('buffer'),
-                       'dreamwidth'  => Addon::isEnabled('dreamwidth'),
-                       'gnusocial'   => Addon::isEnabled('gnusocial'),
-                       'libertree'   => Addon::isEnabled('libertree'),
-                       'livejournal' => Addon::isEnabled('livejournal'),
-                       'pumpio'      => Addon::isEnabled('pumpio'),
-                       'twitter'     => Addon::isEnabled('twitter'),
-                       'tumblr'      => Addon::isEnabled('tumblr'),
-                       'wordpress'   => Addon::isEnabled('wordpress'),
-               ];
-
-               $statistics = array_merge([
-                       'name'                  => $config->get('config', 'sitename'),
-                       'network'               => FRIENDICA_PLATFORM,
-                       'version'               => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
-                       'registrations_open'    => $registration_open,
-                       'total_users'           => $config->get('nodeinfo', 'total_users'),
-                       'active_users_halfyear' => $config->get('nodeinfo', 'active_users_halfyear'),
-                       'active_users_monthly'  => $config->get('nodeinfo', 'active_users_monthly'),
-                       'local_posts'           => $config->get('nodeinfo', 'local_posts'),
-                       'services'              => $services,
-               ], $services);
-
-               header("Content-Type: application/json");
-               echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
-               $logger->debug("statistics.", ['statistics' => $statistics]);
-               exit();
-       }
-}