Add routes for current BaseModules
This commit is contained in:
parent
b6b9e57488
commit
07ba1b200c
|
@ -47,9 +47,67 @@ class Router
|
||||||
$this->routeCollector->addRoute(['GET'], '/attach/{item:\d+}', Module\Attach::class);
|
$this->routeCollector->addRoute(['GET'], '/attach/{item:\d+}', Module\Attach::class);
|
||||||
$this->routeCollector->addRoute(['GET'], '/babel', Module\Babel::class);
|
$this->routeCollector->addRoute(['GET'], '/babel', Module\Babel::class);
|
||||||
$this->routeCollector->addGroup('/contact', function (RouteCollector $collector) {
|
$this->routeCollector->addGroup('/contact', function (RouteCollector $collector) {
|
||||||
$collector->addRoute(['GET'], '[/]', Module\Contact::class);
|
$collector->addRoute(['GET'], '[/]', Module\Contact::class);
|
||||||
$collector->addRoute(['GET'], '/{id:\d+}[/posts|conversations]', 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)
|
public function __construct(RouteCollector $routeCollector = null)
|
||||||
|
|
|
@ -31,11 +31,13 @@ class Feed extends BaseModule
|
||||||
$last_update = defaults($_GET, 'last_update', '');
|
$last_update = defaults($_GET, 'last_update', '');
|
||||||
$nocache = !empty($_GET['nocache']) && local_user();
|
$nocache = !empty($_GET['nocache']) && local_user();
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if ($a->argc < 2) {
|
if ($a->argc < 2) {
|
||||||
System::httpExit(400);
|
System::httpExit(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = null;
|
$type = null;
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if ($a->argc > 2) {
|
if ($a->argc > 2) {
|
||||||
$type = $a->argv[2];
|
$type = $a->argv[2];
|
||||||
}
|
}
|
||||||
|
@ -53,6 +55,7 @@ class Feed extends BaseModule
|
||||||
$type = 'posts';
|
$type = 'posts';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
$nickname = $a->argv[1];
|
$nickname = $a->argv[1];
|
||||||
header("Content-type: application/atom+xml; charset=utf-8");
|
header("Content-type: application/atom+xml; charset=utf-8");
|
||||||
echo OStatus::feed($nickname, $last_update, 10, $type, $nocache, true);
|
echo OStatus::feed($nickname, $last_update, 10, $type, $nocache, true);
|
||||||
|
|
|
@ -28,6 +28,7 @@ class Filer extends BaseModule
|
||||||
$logger = $a->getLogger();
|
$logger = $a->getLogger();
|
||||||
|
|
||||||
$term = XML::unescape(trim(defaults($_GET, 'term', '')));
|
$term = XML::unescape(trim(defaults($_GET, 'term', '')));
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||||
|
|
||||||
$logger->info('filer', ['tag' => $term, 'item' => $item_id]);
|
$logger->info('filer', ['tag' => $term, 'item' => $item_id]);
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Protocol\ActivityPub;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Followers
|
* ActivityPub Followers
|
||||||
|
@ -18,10 +18,12 @@ class Followers extends BaseModule
|
||||||
{
|
{
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if (empty($a->argv[1])) {
|
if (empty($a->argv[1])) {
|
||||||
System::httpExit(404);
|
System::httpExit(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
$owner = User::getOwnerDataByNick($a->argv[1]);
|
$owner = User::getOwnerDataByNick($a->argv[1]);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
System::httpExit(404);
|
System::httpExit(404);
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Protocol\ActivityPub;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Following
|
* ActivityPub Following
|
||||||
|
@ -18,10 +18,12 @@ class Following extends BaseModule
|
||||||
{
|
{
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if (empty($a->argv[1])) {
|
if (empty($a->argv[1])) {
|
||||||
System::httpExit(404);
|
System::httpExit(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
$owner = User::getOwnerDataByNick($a->argv[1]);
|
$owner = User::getOwnerDataByNick($a->argv[1]);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
System::httpExit(404);
|
System::httpExit(404);
|
||||||
|
|
|
@ -1,350 +1,359 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file src/Module/Group.php
|
* @file src/Module/Group.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
require_once 'boot.php';
|
require_once 'boot.php';
|
||||||
|
|
||||||
class Group extends BaseModule
|
class Group extends BaseModule
|
||||||
{
|
{
|
||||||
public static function post()
|
public static function post()
|
||||||
{
|
{
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
|
||||||
if ($a->isAjax()) {
|
if ($a->isAjax()) {
|
||||||
self::ajaxPost();
|
self::ajaxPost();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
notice(L10n::t('Permission denied.'));
|
notice(L10n::t('Permission denied.'));
|
||||||
$a->internalRedirect();
|
$a->internalRedirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($a->argc == 2) && ($a->argv[1] === 'new')) {
|
// @TODO: Replace with parameter from router
|
||||||
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
|
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);
|
$name = Strings::escapeTags(trim($_POST['groupname']));
|
||||||
if ($r) {
|
$r = Model\Group::create(local_user(), $name);
|
||||||
info(L10n::t('Group created.'));
|
if ($r) {
|
||||||
$r = Model\Group::getIdByName(local_user(), $name);
|
info(L10n::t('Group created.'));
|
||||||
if ($r) {
|
$r = Model\Group::getIdByName(local_user(), $name);
|
||||||
$a->internalRedirect('group/' . $r);
|
if ($r) {
|
||||||
}
|
$a->internalRedirect('group/' . $r);
|
||||||
} else {
|
}
|
||||||
notice(L10n::t('Could not create group.'));
|
} else {
|
||||||
}
|
notice(L10n::t('Could not create group.'));
|
||||||
$a->internalRedirect('group');
|
}
|
||||||
}
|
$a->internalRedirect('group');
|
||||||
|
}
|
||||||
if (($a->argc == 2) && intval($a->argv[1])) {
|
|
||||||
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
|
// @TODO: Replace with parameter from router
|
||||||
|
if (($a->argc == 2) && intval($a->argv[1])) {
|
||||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user()]);
|
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
|
||||||
if (!DBA::isResult($group)) {
|
|
||||||
notice(L10n::t('Group not found.'));
|
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user()]);
|
||||||
$a->internalRedirect('contact');
|
if (!DBA::isResult($group)) {
|
||||||
}
|
notice(L10n::t('Group not found.'));
|
||||||
$groupname = Strings::escapeTags(trim($_POST['groupname']));
|
$a->internalRedirect('contact');
|
||||||
if (strlen($groupname) && ($groupname != $group['name'])) {
|
}
|
||||||
if (Model\Group::update($group['id'], $groupname)) {
|
$groupname = Strings::escapeTags(trim($_POST['groupname']));
|
||||||
info(L10n::t('Group name changed.'));
|
if (strlen($groupname) && ($groupname != $group['name'])) {
|
||||||
}
|
if (Model\Group::update($group['id'], $groupname)) {
|
||||||
}
|
info(L10n::t('Group name changed.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static function ajaxPost()
|
}
|
||||||
{
|
|
||||||
try {
|
public static function ajaxPost()
|
||||||
$a = self::getApp();
|
{
|
||||||
|
try {
|
||||||
if (!local_user()) {
|
$a = self::getApp();
|
||||||
throw new \Exception(L10n::t('Permission denied.'), 403);
|
|
||||||
}
|
if (!local_user()) {
|
||||||
|
throw new \Exception(L10n::t('Permission denied.'), 403);
|
||||||
// POST /group/123/add/123
|
}
|
||||||
// POST /group/123/remove/123
|
|
||||||
if ($a->argc == 4) {
|
// POST /group/123/add/123
|
||||||
list($group_id, $command, $contact_id) = array_slice($a->argv, 1);
|
// POST /group/123/remove/123
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if (!Model\Group::exists($group_id, local_user())) {
|
if ($a->argc == 4) {
|
||||||
throw new \Exception(L10n::t('Unknown group.'), 404);
|
list($group_id, $command, $contact_id) = array_slice($a->argv, 1);
|
||||||
}
|
|
||||||
|
if (!Model\Group::exists($group_id, local_user())) {
|
||||||
$contact = DBA::selectFirst('contact', ['pending', 'blocked', 'deleted'], ['id' => $contact_id, 'uid' => local_user()]);
|
throw new \Exception(L10n::t('Unknown group.'), 404);
|
||||||
if (!DBA::isResult($contact)) {
|
}
|
||||||
throw new \Exception(L10n::t('Contact not found.'), 404);
|
|
||||||
}
|
$contact = DBA::selectFirst('contact', ['pending', 'blocked', 'deleted'], ['id' => $contact_id, 'uid' => local_user()]);
|
||||||
|
if (!DBA::isResult($contact)) {
|
||||||
if ($contact['pending']) {
|
throw new \Exception(L10n::t('Contact not found.'), 404);
|
||||||
throw new \Exception(L10n::t('Contact is unavailable.'), 400);
|
}
|
||||||
}
|
|
||||||
|
if ($contact['pending']) {
|
||||||
if ($contact['deleted']) {
|
throw new \Exception(L10n::t('Contact is unavailable.'), 400);
|
||||||
throw new \Exception(L10n::t('Contact is deleted.'), 410);
|
}
|
||||||
}
|
|
||||||
|
if ($contact['deleted']) {
|
||||||
switch($command) {
|
throw new \Exception(L10n::t('Contact is deleted.'), 410);
|
||||||
case 'add':
|
}
|
||||||
if ($contact['blocked']) {
|
|
||||||
throw new \Exception(L10n::t('Contact is blocked, unable to add it to a group.'), 400);
|
switch($command) {
|
||||||
}
|
case 'add':
|
||||||
|
if ($contact['blocked']) {
|
||||||
if (!Model\Group::addMember($group_id, $contact_id)) {
|
throw new \Exception(L10n::t('Contact is blocked, unable to add it to a group.'), 400);
|
||||||
throw new \Exception(L10n::t('Unable to add the contact to the group.'), 500);
|
}
|
||||||
}
|
|
||||||
$message = L10n::t('Contact successfully added to group.');
|
if (!Model\Group::addMember($group_id, $contact_id)) {
|
||||||
break;
|
throw new \Exception(L10n::t('Unable to add the contact to the group.'), 500);
|
||||||
case 'remove':
|
}
|
||||||
if (!Model\Group::removeMember($group_id, $contact_id)) {
|
$message = L10n::t('Contact successfully added to group.');
|
||||||
throw new \Exception(L10n::t('Unable to remove the contact from the group.'), 500);
|
break;
|
||||||
}
|
case 'remove':
|
||||||
$message = L10n::t('Contact successfully removed from group.');
|
if (!Model\Group::removeMember($group_id, $contact_id)) {
|
||||||
break;
|
throw new \Exception(L10n::t('Unable to remove the contact from the group.'), 500);
|
||||||
default:
|
}
|
||||||
throw new \Exception(L10n::t('Unknown group command.'), 400);
|
$message = L10n::t('Contact successfully removed from group.');
|
||||||
}
|
break;
|
||||||
} else {
|
default:
|
||||||
throw new \Exception(L10n::t('Bad request.'), 400);
|
throw new \Exception(L10n::t('Unknown group command.'), 400);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
notice($message);
|
throw new \Exception(L10n::t('Bad request.'), 400);
|
||||||
System::jsonExit(['status' => 'OK', 'message' => $message]);
|
}
|
||||||
} catch (\Exception $e) {
|
|
||||||
notice($e->getMessage());
|
notice($message);
|
||||||
System::jsonError($e->getCode(), ['status' => 'error', 'message' => $e->getMessage()]);
|
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;
|
|
||||||
|
public static function content()
|
||||||
if (!local_user()) {
|
{
|
||||||
System::httpExit(403);
|
$change = false;
|
||||||
}
|
|
||||||
|
if (!local_user()) {
|
||||||
$a = self::getApp();
|
System::httpExit(403);
|
||||||
|
}
|
||||||
$a->page['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));
|
|
||||||
|
$a = self::getApp();
|
||||||
// With no group number provided we jump to the unassigned contacts as a starting point
|
|
||||||
if ($a->argc == 1) {
|
$a->page['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));
|
||||||
$a->internalRedirect('group/none');
|
|
||||||
}
|
// With no group number provided we jump to the unassigned contacts as a starting point
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
// Switch to text mode interface if we have more than 'n' contacts or group members
|
if ($a->argc == 1) {
|
||||||
$switchtotext = PConfig::get(local_user(), 'system', 'groupedit_image_limit');
|
$a->internalRedirect('group/none');
|
||||||
if (is_null($switchtotext)) {
|
}
|
||||||
$switchtotext = Config::get('system', 'groupedit_image_limit', 200);
|
|
||||||
}
|
// Switch to text mode interface if we have more than 'n' contacts or group members
|
||||||
|
$switchtotext = PConfig::get(local_user(), 'system', 'groupedit_image_limit');
|
||||||
$tpl = Renderer::getMarkupTemplate('group_edit.tpl');
|
if (is_null($switchtotext)) {
|
||||||
|
$switchtotext = Config::get('system', 'groupedit_image_limit', 200);
|
||||||
|
}
|
||||||
$context = [
|
|
||||||
'$submit' => L10n::t('Save Group'),
|
$tpl = Renderer::getMarkupTemplate('group_edit.tpl');
|
||||||
'$submit_filter' => L10n::t('Filter'),
|
|
||||||
];
|
|
||||||
|
$context = [
|
||||||
if (($a->argc == 2) && ($a->argv[1] === 'new')) {
|
'$submit' => L10n::t('Save Group'),
|
||||||
return Renderer::replaceMacros($tpl, $context + [
|
'$submit_filter' => L10n::t('Filter'),
|
||||||
'$title' => L10n::t('Create a group of contacts/friends.'),
|
];
|
||||||
'$gname' => ['groupname', L10n::t('Group Name: '), '', ''],
|
|
||||||
'$gid' => 'new',
|
// @TODO: Replace with parameter from router
|
||||||
'$form_security_token' => BaseModule::getFormSecurityToken("group_edit"),
|
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: '), '', ''],
|
||||||
$nogroup = false;
|
'$gid' => 'new',
|
||||||
|
'$form_security_token' => BaseModule::getFormSecurityToken("group_edit"),
|
||||||
if (($a->argc == 2) && ($a->argv[1] === 'none')) {
|
]);
|
||||||
$id = -1;
|
}
|
||||||
$nogroup = true;
|
|
||||||
$group = [
|
$nogroup = false;
|
||||||
'id' => $id,
|
|
||||||
'name' => L10n::t('Contacts not in any group'),
|
if (($a->argc == 2) && ($a->argv[1] === 'none')) {
|
||||||
];
|
$id = -1;
|
||||||
|
$nogroup = true;
|
||||||
$members = [];
|
$group = [
|
||||||
$preselected = [];
|
'id' => $id,
|
||||||
|
'name' => L10n::t('Contacts not in any group'),
|
||||||
$context = $context + [
|
];
|
||||||
'$title' => $group['name'],
|
|
||||||
'$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],
|
$members = [];
|
||||||
'$gid' => $id,
|
$preselected = [];
|
||||||
'$editable' => 0,
|
|
||||||
];
|
$context = $context + [
|
||||||
}
|
'$title' => $group['name'],
|
||||||
|
'$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],
|
||||||
if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
|
'$gid' => $id,
|
||||||
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');
|
'$editable' => 0,
|
||||||
|
];
|
||||||
if (intval($a->argv[2])) {
|
}
|
||||||
if (!Model\Group::exists($a->argv[2], local_user())) {
|
|
||||||
notice(L10n::t('Group not found.'));
|
// @TODO: Replace with parameter from router
|
||||||
$a->internalRedirect('contact');
|
if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
|
||||||
}
|
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');
|
||||||
|
|
||||||
if (Model\Group::remove($a->argv[2])) {
|
// @TODO: Replace with parameter from router
|
||||||
info(L10n::t('Group removed.'));
|
if (intval($a->argv[2])) {
|
||||||
} else {
|
if (!Model\Group::exists($a->argv[2], local_user())) {
|
||||||
notice(L10n::t('Unable to remove group.'));
|
notice(L10n::t('Group not found.'));
|
||||||
}
|
$a->internalRedirect('contact');
|
||||||
}
|
}
|
||||||
$a->internalRedirect('group');
|
|
||||||
}
|
if (Model\Group::remove($a->argv[2])) {
|
||||||
|
info(L10n::t('Group removed.'));
|
||||||
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
|
} else {
|
||||||
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
|
notice(L10n::t('Unable to remove group.'));
|
||||||
|
}
|
||||||
if (DBA::exists('contact', ['id' => $a->argv[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
|
}
|
||||||
$change = intval($a->argv[2]);
|
$a->internalRedirect('group');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if (($a->argc > 1) && intval($a->argv[1])) {
|
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
|
||||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user(), 'deleted' => false]);
|
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
|
||||||
if (!DBA::isResult($group)) {
|
|
||||||
notice(L10n::t('Group not found.'));
|
if (DBA::exists('contact', ['id' => $a->argv[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
|
||||||
$a->internalRedirect('contact');
|
$change = intval($a->argv[2]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$members = Model\Contact::getByGroupId($group['id']);
|
|
||||||
$preselected = [];
|
// @TODO: Replace with parameter from router
|
||||||
|
if (($a->argc > 1) && intval($a->argv[1])) {
|
||||||
if (count($members)) {
|
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user(), 'deleted' => false]);
|
||||||
foreach ($members as $member) {
|
if (!DBA::isResult($group)) {
|
||||||
$preselected[] = $member['id'];
|
notice(L10n::t('Group not found.'));
|
||||||
}
|
$a->internalRedirect('contact');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($change) {
|
$members = Model\Contact::getByGroupId($group['id']);
|
||||||
if (in_array($change, $preselected)) {
|
$preselected = [];
|
||||||
Model\Group::removeMember($group['id'], $change);
|
|
||||||
} else {
|
if (count($members)) {
|
||||||
Model\Group::addMember($group['id'], $change);
|
foreach ($members as $member) {
|
||||||
}
|
$preselected[] = $member['id'];
|
||||||
|
}
|
||||||
$members = Model\Contact::getByGroupId($group['id']);
|
}
|
||||||
$preselected = [];
|
|
||||||
if (count($members)) {
|
if ($change) {
|
||||||
foreach ($members as $member) {
|
if (in_array($change, $preselected)) {
|
||||||
$preselected[] = $member['id'];
|
Model\Group::removeMember($group['id'], $change);
|
||||||
}
|
} else {
|
||||||
}
|
Model\Group::addMember($group['id'], $change);
|
||||||
}
|
}
|
||||||
|
|
||||||
$drop_tpl = Renderer::getMarkupTemplate('group_drop.tpl');
|
$members = Model\Contact::getByGroupId($group['id']);
|
||||||
$drop_txt = Renderer::replaceMacros($drop_tpl, [
|
$preselected = [];
|
||||||
'$id' => $group['id'],
|
if (count($members)) {
|
||||||
'$delete' => L10n::t('Delete Group'),
|
foreach ($members as $member) {
|
||||||
'$form_security_token' => BaseModule::getFormSecurityToken("group_drop"),
|
$preselected[] = $member['id'];
|
||||||
]);
|
}
|
||||||
|
}
|
||||||
$context = $context + [
|
}
|
||||||
'$title' => $group['name'],
|
|
||||||
'$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],
|
$drop_tpl = Renderer::getMarkupTemplate('group_drop.tpl');
|
||||||
'$gid' => $group['id'],
|
$drop_txt = Renderer::replaceMacros($drop_tpl, [
|
||||||
'$drop' => $drop_txt,
|
'$id' => $group['id'],
|
||||||
'$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),
|
'$delete' => L10n::t('Delete Group'),
|
||||||
'$edit_name' => L10n::t('Edit Group Name'),
|
'$form_security_token' => BaseModule::getFormSecurityToken("group_drop"),
|
||||||
'$editable' => 1,
|
]);
|
||||||
];
|
|
||||||
}
|
$context = $context + [
|
||||||
|
'$title' => $group['name'],
|
||||||
if (!isset($group)) {
|
'$gname' => ['groupname', L10n::t('Group Name: '), $group['name'], ''],
|
||||||
System::httpExit(400);
|
'$gid' => $group['id'],
|
||||||
}
|
'$drop' => $drop_txt,
|
||||||
|
'$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),
|
||||||
$groupeditor = [
|
'$edit_name' => L10n::t('Edit Group Name'),
|
||||||
'label_members' => L10n::t('Members'),
|
'$editable' => 1,
|
||||||
'members' => [],
|
];
|
||||||
'label_contacts' => L10n::t('All Contacts'),
|
}
|
||||||
'group_is_empty' => L10n::t('Group is empty'),
|
|
||||||
'contacts' => [],
|
if (!isset($group)) {
|
||||||
];
|
System::httpExit(400);
|
||||||
|
}
|
||||||
$sec_token = addslashes(BaseModule::getFormSecurityToken('group_member_change'));
|
|
||||||
|
$groupeditor = [
|
||||||
// Format the data of the group members
|
'label_members' => L10n::t('Members'),
|
||||||
foreach ($members as $member) {
|
'members' => [],
|
||||||
if ($member['url']) {
|
'label_contacts' => L10n::t('All Contacts'),
|
||||||
$entry = Contact::getContactTemplateVars($member);
|
'group_is_empty' => L10n::t('Group is empty'),
|
||||||
$entry['label'] = 'members';
|
'contacts' => [],
|
||||||
$entry['photo_menu'] = '';
|
];
|
||||||
$entry['change_member'] = [
|
|
||||||
'title' => L10n::t("Remove contact from group"),
|
$sec_token = addslashes(BaseModule::getFormSecurityToken('group_member_change'));
|
||||||
'gid' => $group['id'],
|
|
||||||
'cid' => $member['id'],
|
// Format the data of the group members
|
||||||
'sec_token' => $sec_token
|
foreach ($members as $member) {
|
||||||
];
|
if ($member['url']) {
|
||||||
|
$entry = Contact::getContactTemplateVars($member);
|
||||||
$groupeditor['members'][] = $entry;
|
$entry['label'] = 'members';
|
||||||
} else {
|
$entry['photo_menu'] = '';
|
||||||
Model\Group::removeMember($group['id'], $member['id']);
|
$entry['change_member'] = [
|
||||||
}
|
'title' => L10n::t("Remove contact from group"),
|
||||||
}
|
'gid' => $group['id'],
|
||||||
|
'cid' => $member['id'],
|
||||||
if ($nogroup) {
|
'sec_token' => $sec_token
|
||||||
$contacts = Model\Contact::getUngroupedList(local_user());
|
];
|
||||||
} else {
|
|
||||||
$contacts_stmt = DBA::select('contact', [],
|
$groupeditor['members'][] = $entry;
|
||||||
['uid' => local_user(), 'pending' => false, 'blocked' => false, 'self' => false],
|
} else {
|
||||||
['order' => ['name']]
|
Model\Group::removeMember($group['id'], $member['id']);
|
||||||
);
|
}
|
||||||
$contacts = DBA::toArray($contacts_stmt);
|
}
|
||||||
$context['$desc'] = L10n::t('Click on a contact to add or remove.');
|
|
||||||
}
|
if ($nogroup) {
|
||||||
|
$contacts = Model\Contact::getUngroupedList(local_user());
|
||||||
if (DBA::isResult($contacts)) {
|
} else {
|
||||||
// Format the data of the contacts who aren't in the contact group
|
$contacts_stmt = DBA::select('contact', [],
|
||||||
foreach ($contacts as $member) {
|
['uid' => local_user(), 'pending' => false, 'blocked' => false, 'self' => false],
|
||||||
if (!in_array($member['id'], $preselected)) {
|
['order' => ['name']]
|
||||||
$entry = Contact::getContactTemplateVars($member);
|
);
|
||||||
$entry['label'] = 'contacts';
|
$contacts = DBA::toArray($contacts_stmt);
|
||||||
if (!$nogroup)
|
$context['$desc'] = L10n::t('Click on a contact to add or remove.');
|
||||||
$entry['photo_menu'] = [];
|
}
|
||||||
|
|
||||||
if (!$nogroup) {
|
if (DBA::isResult($contacts)) {
|
||||||
$entry['change_member'] = [
|
// Format the data of the contacts who aren't in the contact group
|
||||||
'title' => L10n::t("Add contact to group"),
|
foreach ($contacts as $member) {
|
||||||
'gid' => $group['id'],
|
if (!in_array($member['id'], $preselected)) {
|
||||||
'cid' => $member['id'],
|
$entry = Contact::getContactTemplateVars($member);
|
||||||
'sec_token' => $sec_token
|
$entry['label'] = 'contacts';
|
||||||
];
|
if (!$nogroup)
|
||||||
}
|
$entry['photo_menu'] = [];
|
||||||
|
|
||||||
$groupeditor['contacts'][] = $entry;
|
if (!$nogroup) {
|
||||||
}
|
$entry['change_member'] = [
|
||||||
}
|
'title' => L10n::t("Add contact to group"),
|
||||||
}
|
'gid' => $group['id'],
|
||||||
|
'cid' => $member['id'],
|
||||||
$context['$groupeditor'] = $groupeditor;
|
'sec_token' => $sec_token
|
||||||
|
];
|
||||||
// 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);
|
$groupeditor['contacts'][] = $entry;
|
||||||
|
}
|
||||||
if ($change) {
|
}
|
||||||
$tpl = Renderer::getMarkupTemplate('groupeditor.tpl');
|
}
|
||||||
echo Renderer::replaceMacros($tpl, $context);
|
|
||||||
exit();
|
$context['$groupeditor'] = $groupeditor;
|
||||||
}
|
|
||||||
|
// If there are to many contacts we could provide an alternative view mode
|
||||||
return Renderer::replaceMacros($tpl, $context);
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -6,12 +6,12 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Protocol\ActivityPub;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Core\Config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Inbox
|
* ActivityPub Inbox
|
||||||
|
@ -39,6 +39,7 @@ class Inbox extends BaseModule
|
||||||
Logger::log('Incoming message stored under ' . $tempfile);
|
Logger::log('Incoming message stored under ' . $tempfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if (!empty($a->argv[1])) {
|
if (!empty($a->argv[1])) {
|
||||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
|
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
|
||||||
if (!DBA::isResult($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ class Install extends BaseModule
|
||||||
|
|
||||||
// route: install/testrwrite
|
// route: install/testrwrite
|
||||||
// $baseurl/install/testrwrite to test if rewrite in .htaccess is working
|
// $baseurl/install/testrwrite to test if rewrite in .htaccess is working
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if ($a->getArgumentValue(1, '') == 'testrewrite') {
|
if ($a->getArgumentValue(1, '') == 'testrewrite') {
|
||||||
// Status Code 204 means that it worked without content
|
// Status Code 204 means that it worked without content
|
||||||
Core\System::httpExit(204);
|
Core\System::httpExit(204);
|
||||||
|
|
|
@ -5,11 +5,10 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Protocol\ActivityPub;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\Item;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Objects
|
* ActivityPub Objects
|
||||||
|
@ -32,9 +31,11 @@ class Objects extends BaseModule
|
||||||
// $requester = HTTPSignature::getSigner('', $_SERVER);
|
// $requester = HTTPSignature::getSigner('', $_SERVER);
|
||||||
|
|
||||||
// At first we try the original post with that guid
|
// 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]);
|
$item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'origin' => true, 'private' => false]);
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
// If no original post could be found, it could possibly be a forum post, there we remove the "origin" field.
|
// 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]);
|
$item = Item::selectFirst(['id', 'author-link'], ['guid' => $a->argv[1], 'private' => false]);
|
||||||
if (!DBA::isResult($item) || !strstr($item['author-link'], System::baseUrl())) {
|
if (!DBA::isResult($item) || !strstr($item['author-link'], System::baseUrl())) {
|
||||||
System::httpExit(404);
|
System::httpExit(404);
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Oembed extends BaseModule
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if ($a->argc == 2) {
|
if ($a->argc == 2) {
|
||||||
echo '<html><body>';
|
echo '<html><body>';
|
||||||
$url = Strings::base64UrlDecode($a->argv[1]);
|
$url = Strings::base64UrlDecode($a->argv[1]);
|
||||||
|
|
|
@ -5,10 +5,9 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Protocol\ActivityPub;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Outbox
|
* ActivityPub Outbox
|
||||||
|
@ -19,6 +18,7 @@ class Outbox extends BaseModule
|
||||||
{
|
{
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if (empty($a->argv[1])) {
|
if (empty($a->argv[1])) {
|
||||||
System::httpExit(404);
|
System::httpExit(404);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Photo extends BaseModule
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if ($a->argc <= 1 || $a->argc > 4) {
|
if ($a->argc <= 1 || $a->argc > 4) {
|
||||||
System::httpExit(400);
|
System::httpExit(400);
|
||||||
}
|
}
|
||||||
|
@ -47,6 +48,7 @@ class Photo extends BaseModule
|
||||||
|
|
||||||
$customsize = 0;
|
$customsize = 0;
|
||||||
$photo = false;
|
$photo = false;
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
switch($a->argc) {
|
switch($a->argc) {
|
||||||
case 4:
|
case 4:
|
||||||
$customsize = intval($a->argv[2]);
|
$customsize = intval($a->argv[2]);
|
||||||
|
|
|
@ -1,359 +1,361 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\ACL;
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact as ContactModel;
|
use Friendica\Model\Contact as ContactModel;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Profile AS ProfileModel;
|
use Friendica\Model\Profile as ProfileModel;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Protocol\DFRN;
|
use Friendica\Protocol\DFRN;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Security;
|
use Friendica\Util\Security;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
require_once 'boot.php';
|
require_once 'boot.php';
|
||||||
|
|
||||||
class Profile extends BaseModule
|
class Profile extends BaseModule
|
||||||
{
|
{
|
||||||
public static $which = '';
|
public static $which = '';
|
||||||
public static $profile = 0;
|
public static $profile = 0;
|
||||||
|
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
|
||||||
if ($a->argc < 2) {
|
// @TODO: Replace with parameter from router
|
||||||
System::httpExit(400);
|
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);
|
|
||||||
|
self::$which = filter_var($a->argv[1], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK);
|
||||||
if (local_user() && $a->argc > 2 && $a->argv[2] === 'view') {
|
|
||||||
self::$which = $a->user['nickname'];
|
// @TODO: Replace with parameter from router
|
||||||
self::$profile = filter_var($a->argv[1], FILTER_SANITIZE_NUMBER_INT);
|
if (local_user() && $a->argc > 2 && $a->argv[2] === 'view') {
|
||||||
} else {
|
self::$which = $a->user['nickname'];
|
||||||
DFRN::autoRedir($a, self::$which);
|
self::$profile = filter_var($a->argv[1], FILTER_SANITIZE_NUMBER_INT);
|
||||||
}
|
} else {
|
||||||
}
|
DFRN::autoRedir($a, self::$which);
|
||||||
|
}
|
||||||
public static function rawContent()
|
}
|
||||||
{
|
|
||||||
if (ActivityPub::isRequest()) {
|
public static function rawContent()
|
||||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);
|
{
|
||||||
$data = [];
|
if (ActivityPub::isRequest()) {
|
||||||
if (DBA::isResult($user)) {
|
$user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);
|
||||||
$data = ActivityPub\Transmitter::getProfile($user['uid']);
|
$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])) {
|
if (!empty($data)) {
|
||||||
// Known deleted user
|
System::jsonExit($data, 'application/activity+json');
|
||||||
$data = ActivityPub\Transmitter::getDeletedUser(self::$which);
|
} elseif (DBA::exists('userd', ['username' => self::$which])) {
|
||||||
|
// Known deleted user
|
||||||
System::jsonError(410, $data);
|
$data = ActivityPub\Transmitter::getDeletedUser(self::$which);
|
||||||
} else {
|
|
||||||
// Any other case (unknown, blocked, unverified, expired, no profile, no self contact)
|
System::jsonError(410, $data);
|
||||||
System::jsonError(404, $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();
|
public static function content($update = 0)
|
||||||
|
{
|
||||||
if (!$update) {
|
$a = self::getApp();
|
||||||
ProfileModel::load($a, self::$which, self::$profile);
|
|
||||||
|
if (!$update) {
|
||||||
$blocked = !local_user() && !remote_user() && Config::get('system', 'block_public');
|
ProfileModel::load($a, self::$which, self::$profile);
|
||||||
$userblock = !local_user() && !remote_user() && $a->profile['hidewall'];
|
|
||||||
|
$blocked = !local_user() && !remote_user() && Config::get('system', 'block_public');
|
||||||
if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
$userblock = !local_user() && !remote_user() && $a->profile['hidewall'];
|
||||||
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
|
|
||||||
}
|
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['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";
|
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', ''));
|
// site block
|
||||||
if (strlen($keywords)) {
|
if (!$blocked && !$userblock) {
|
||||||
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
|
$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'] .= '<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() . '/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() . '/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 . '/activity" title="' . 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";
|
||||||
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''));
|
$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="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\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";
|
||||||
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
$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";
|
||||||
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
|
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||||
foreach ($dfrn_pages as $dfrn) {
|
|
||||||
$a->page['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . System::baseUrl() . '/dfrn_' . $dfrn . '/' . self::$which . '" />' . "\n";
|
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
|
||||||
}
|
foreach ($dfrn_pages as $dfrn) {
|
||||||
$a->page['htmlhead'] .= '<link rel="dfrn-poco" href="' . System::baseUrl() . '/poco/' . self::$which . '" />' . "\n";
|
$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) {
|
$category = $datequery = $datequery2 = '';
|
||||||
for ($x = 2; $x < $a->argc; $x ++) {
|
|
||||||
if (is_a_date_arg($a->argv[$x])) {
|
if ($a->argc > 2) {
|
||||||
if ($datequery) {
|
for ($x = 2; $x < $a->argc; $x ++) {
|
||||||
$datequery2 = Strings::escapeHtml($a->argv[$x]);
|
if (is_a_date_arg($a->argv[$x])) {
|
||||||
} else {
|
if ($datequery) {
|
||||||
$datequery = Strings::escapeHtml($a->argv[$x]);
|
$datequery2 = Strings::escapeHtml($a->argv[$x]);
|
||||||
}
|
} else {
|
||||||
} else {
|
$datequery = Strings::escapeHtml($a->argv[$x]);
|
||||||
$category = $a->argv[$x];
|
}
|
||||||
}
|
} else {
|
||||||
}
|
$category = $a->argv[$x];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (empty($category)) {
|
}
|
||||||
$category = defaults($_GET, 'category', '');
|
|
||||||
}
|
if (empty($category)) {
|
||||||
|
$category = defaults($_GET, 'category', '');
|
||||||
$hashtags = defaults($_GET, 'tag', '');
|
}
|
||||||
|
|
||||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
$hashtags = defaults($_GET, 'tag', '');
|
||||||
return Login::form();
|
|
||||||
}
|
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||||
|
return Login::form();
|
||||||
$groups = [];
|
}
|
||||||
$remote_cid = null;
|
|
||||||
|
$groups = [];
|
||||||
$o = '';
|
$remote_cid = null;
|
||||||
|
|
||||||
if ($update) {
|
$o = '';
|
||||||
// Ensure we've got a profile owner if updating.
|
|
||||||
$a->profile['profile_uid'] = $update;
|
if ($update) {
|
||||||
} elseif ($a->profile['profile_uid'] == local_user()) {
|
// Ensure we've got a profile owner if updating.
|
||||||
Nav::setSelected('home');
|
$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();
|
$remote_contact = ContactModel::isFollower(remote_user(), $a->profile['profile_uid']);
|
||||||
|
$is_owner = local_user() == $a->profile['profile_uid'];
|
||||||
if ($remote_contact) {
|
$last_updated_key = "profile:" . $a->profile['profile_uid'] . ":" . local_user() . ":" . remote_user();
|
||||||
$cdata = ContactModel::getPublicAndUserContacID(remote_user(), $a->profile['profile_uid']);
|
|
||||||
if (!empty($cdata['user'])) {
|
if ($remote_contact) {
|
||||||
$groups = Group::getIdsByContactId($cdata['user']);
|
$cdata = ContactModel::getPublicAndUserContacID(remote_user(), $a->profile['profile_uid']);
|
||||||
$remote_cid = $cdata['user'];
|
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 (!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'])) {
|
if (!$update) {
|
||||||
$tab = Strings::escapeTags(trim($_GET['tab']));
|
$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::getTabs($a, $is_owner, $a->profile['nickname']);
|
||||||
$o .= ProfileModel::getAdvanced($a);
|
|
||||||
Hook::callAll('profile_advanced', $o);
|
if ($tab === 'profile') {
|
||||||
return $o;
|
$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;
|
$o .= Widget::commonFriendsVisitor($a->profile['profile_uid']);
|
||||||
$commvisitor = $commpage && $remote_contact;
|
|
||||||
|
$commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||||
$a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
|
$commvisitor = $commpage && $remote_contact;
|
||||||
$a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? XML::escape($category) : ''));
|
|
||||||
$a->page['aside'] .= Widget::tagCloud();
|
$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) : ''));
|
||||||
if (Security::canWriteToUserWall($a->profile['profile_uid'])) {
|
$a->page['aside'] .= Widget::tagCloud();
|
||||||
$x = [
|
|
||||||
'is_owner' => $is_owner,
|
if (Security::canWriteToUserWall($a->profile['profile_uid'])) {
|
||||||
'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
|
$x = [
|
||||||
'default_location' => $is_owner ? $a->user['default-location'] : '',
|
'is_owner' => $is_owner,
|
||||||
'nickname' => $a->profile['nickname'],
|
'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
|
||||||
'lockstate' => is_array($a->user)
|
'default_location' => $is_owner ? $a->user['default-location'] : '',
|
||||||
&& (strlen($a->user['allow_cid'])
|
'nickname' => $a->profile['nickname'],
|
||||||
|| strlen($a->user['allow_gid'])
|
'lockstate' => is_array($a->user)
|
||||||
|| strlen($a->user['deny_cid'])
|
&& (strlen($a->user['allow_cid'])
|
||||||
|| strlen($a->user['deny_gid'])
|
|| strlen($a->user['allow_gid'])
|
||||||
) ? 'lock' : 'unlock',
|
|| strlen($a->user['deny_cid'])
|
||||||
'acl' => $is_owner ? ACL::getFullSelectorHTML($a->user, true) : '',
|
|| strlen($a->user['deny_gid'])
|
||||||
'bang' => '',
|
) ? 'lock' : 'unlock',
|
||||||
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
'acl' => $is_owner ? ACL::getFullSelectorHTML($a->user, true) : '',
|
||||||
'profile_uid' => $a->profile['profile_uid'],
|
'bang' => '',
|
||||||
];
|
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
||||||
|
'profile_uid' => $a->profile['profile_uid'],
|
||||||
$o .= status_editor($a, $x);
|
];
|
||||||
}
|
|
||||||
}
|
$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 = '';
|
// 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);
|
||||||
if ($update) {
|
$sql_extra2 = '';
|
||||||
$last_updated = (defaults($_SESSION['last_updated'], $last_updated_key, 0));
|
|
||||||
|
if ($update) {
|
||||||
// If the page user is the owner of the page we should query for unseen
|
$last_updated = (defaults($_SESSION['last_updated'], $last_updated_key, 0));
|
||||||
// items. Otherwise use a timestamp of the last succesful update request.
|
|
||||||
if ($is_owner || !$last_updated) {
|
// If the page user is the owner of the page we should query for unseen
|
||||||
$sql_extra4 = " AND `item`.`unseen`";
|
// items. Otherwise use a timestamp of the last succesful update request.
|
||||||
} else {
|
if ($is_owner || !$last_updated) {
|
||||||
$gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
|
$sql_extra4 = " AND `item`.`unseen`";
|
||||||
$sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";
|
} 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`
|
$items_stmt = DBA::p(
|
||||||
INNER JOIN `contact`
|
"SELECT DISTINCT(`parent-uri`) AS `uri`, `item`.`created`
|
||||||
ON `contact`.`id` = `item`.`contact-id`
|
FROM `item`
|
||||||
AND NOT `contact`.`blocked`
|
INNER JOIN `contact`
|
||||||
AND NOT `contact`.`pending`
|
ON `contact`.`id` = `item`.`contact-id`
|
||||||
WHERE `item`.`uid` = ?
|
AND NOT `contact`.`blocked`
|
||||||
AND `item`.`visible`
|
AND NOT `contact`.`pending`
|
||||||
AND (NOT `item`.`deleted` OR `item`.`gravity` = ?)
|
WHERE `item`.`uid` = ?
|
||||||
AND NOT `item`.`moderated`
|
AND `item`.`visible`
|
||||||
AND `item`.`wall`
|
AND (NOT `item`.`deleted` OR `item`.`gravity` = ?)
|
||||||
$sql_extra4
|
AND NOT `item`.`moderated`
|
||||||
$sql_extra
|
AND `item`.`wall`
|
||||||
ORDER BY `item`.`created` DESC",
|
$sql_extra4
|
||||||
$a->profile['profile_uid'],
|
$sql_extra
|
||||||
GRAVITY_ACTIVITY
|
ORDER BY `item`.`created` DESC",
|
||||||
);
|
$a->profile['profile_uid'],
|
||||||
|
GRAVITY_ACTIVITY
|
||||||
if (!DBA::isResult($items_stmt)) {
|
);
|
||||||
return '';
|
|
||||||
}
|
if (!DBA::isResult($items_stmt)) {
|
||||||
|
return '';
|
||||||
$pager = new Pager($a->query_string);
|
}
|
||||||
} else {
|
|
||||||
$sql_post_table = "";
|
$pager = new Pager($a->query_string);
|
||||||
|
} else {
|
||||||
if (!empty($category)) {
|
$sql_post_table = "";
|
||||||
$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($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($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($datequery)) {
|
||||||
if (!empty($datequery2)) {
|
$sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
|
||||||
$sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, '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]];
|
// Does the profile page belong to a forum?
|
||||||
if (!DBA::exists('user', $condition)) {
|
// If not then we can improve the performance with an additional condition
|
||||||
$sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
|
$condition = ['uid' => $a->profile['profile_uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];
|
||||||
} else {
|
if (!DBA::exists('user', $condition)) {
|
||||||
$sql_extra3 = "";
|
$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) {
|
// check if we serve a mobile device and get the user settings
|
||||||
$itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 10);
|
// accordingly
|
||||||
} else {
|
if ($a->is_mobile) {
|
||||||
$itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 20);
|
$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)) {
|
// now that we have the user settings, see if the theme forces
|
||||||
$itemspage_network = $a->force_max_items;
|
// 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());
|
$pager = new Pager($a->query_string, $itemspage_network);
|
||||||
|
|
||||||
$items_stmt = DBA::p(
|
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||||
"SELECT `item`.`uri`
|
|
||||||
FROM `thread`
|
$items_stmt = DBA::p(
|
||||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
"SELECT `item`.`uri`
|
||||||
$sql_post_table
|
FROM `thread`
|
||||||
STRAIGHT_JOIN `contact`
|
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||||
ON `contact`.`id` = `thread`.`contact-id`
|
$sql_post_table
|
||||||
AND NOT `contact`.`blocked`
|
STRAIGHT_JOIN `contact`
|
||||||
AND NOT `contact`.`pending`
|
ON `contact`.`id` = `thread`.`contact-id`
|
||||||
WHERE `thread`.`uid` = ?
|
AND NOT `contact`.`blocked`
|
||||||
AND `thread`.`visible`
|
AND NOT `contact`.`pending`
|
||||||
AND NOT `thread`.`deleted`
|
WHERE `thread`.`uid` = ?
|
||||||
AND NOT `thread`.`moderated`
|
AND `thread`.`visible`
|
||||||
AND `thread`.`wall`
|
AND NOT `thread`.`deleted`
|
||||||
$sql_extra3
|
AND NOT `thread`.`moderated`
|
||||||
$sql_extra
|
AND `thread`.`wall`
|
||||||
$sql_extra2
|
$sql_extra3
|
||||||
ORDER BY `thread`.`created` DESC
|
$sql_extra
|
||||||
$pager_sql",
|
$sql_extra2
|
||||||
$a->profile['profile_uid']
|
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();
|
// Set a time stamp for this page. We will make use of it when we
|
||||||
|
// search for new items (update routine)
|
||||||
if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) {
|
$_SESSION['last_updated'][$last_updated_key] = time();
|
||||||
$o .= ProfileModel::getBirthdays();
|
|
||||||
$o .= ProfileModel::getEventsReminderHTML();
|
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) {
|
if ($is_owner) {
|
||||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
$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']);
|
$items = DBA::toArray($items_stmt);
|
||||||
|
|
||||||
if (!$update) {
|
$o .= conversation($a, $items, $pager, 'profile', $update, false, 'created', $a->profile['profile_uid']);
|
||||||
$o .= $pager->renderMinimal(count($items));
|
|
||||||
}
|
if (!$update) {
|
||||||
|
$o .= $pager->renderMinimal(count($items));
|
||||||
return $o;
|
}
|
||||||
}
|
|
||||||
}
|
return $o;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\Model\Photo;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Module Proxy
|
* @brief Module Proxy
|
||||||
|
@ -159,6 +158,7 @@ class Proxy extends BaseModule
|
||||||
$sizetype = '';
|
$sizetype = '';
|
||||||
|
|
||||||
// Look for filename in the arguments
|
// Look for filename in the arguments
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
if (($a->argc > 1) && !isset($_REQUEST['url'])) {
|
if (($a->argc > 1) && !isset($_REQUEST['url'])) {
|
||||||
if (isset($a->argv[3])) {
|
if (isset($a->argv[3])) {
|
||||||
$url = $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: Why? And what about $url in this case?
|
||||||
|
/// @TODO: Replace with parameter from router
|
||||||
if (isset($a->argv[3]) && ($a->argv[3] == 'thumb')) {
|
if (isset($a->argv[3]) && ($a->argv[3] == 'thumb')) {
|
||||||
$size = 200;
|
$size = 200;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ use Friendica\Util\Strings;
|
||||||
/**
|
/**
|
||||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||||
*/
|
*/
|
||||||
abstract class Register extends BaseModule
|
class Register extends BaseModule
|
||||||
{
|
{
|
||||||
const CLOSED = 0;
|
const CLOSED = 0;
|
||||||
const APPROVE = 1;
|
const APPROVE = 1;
|
||||||
|
|
|
@ -6,7 +6,7 @@ use Friendica\BaseModule;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
|
||||||
class Statistics_json extends BaseModule
|
class Statistics extends BaseModule
|
||||||
{
|
{
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
Loading…
Reference in a new issue