From e64dcc5b5bac42e4752d6c1e8ad8ed86f56b7d20 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 6 Aug 2020 22:49:41 -0400 Subject: [PATCH] Remove obsolete modules common and allfriends - Delete obsolete Model\GContact class --- mod/common.php | 146 ---------------------------------- src/Model/GContact.php | 139 -------------------------------- src/Module/AllFriends.php | 89 --------------------- static/routes.config.php | 1 - view/theme/frio/css/style.css | 6 +- 5 files changed, 3 insertions(+), 378 deletions(-) delete mode 100644 mod/common.php delete mode 100644 src/Model/GContact.php delete mode 100644 src/Module/AllFriends.php diff --git a/mod/common.php b/mod/common.php deleted file mode 100644 index fe63a653b..000000000 --- a/mod/common.php +++ /dev/null @@ -1,146 +0,0 @@ -. - * - */ - -use Friendica\App; -use Friendica\Content\Pager; -use Friendica\Core\Renderer; -use Friendica\Database\DBA; -use Friendica\DI; -use Friendica\Model; -use Friendica\Module; -use Friendica\Util\Strings; - -function common_content(App $a) -{ - $o = ''; - - $cmd = $a->argv[1]; - $uid = intval($a->argv[2]); - $cid = intval($a->argv[3]); - $zcid = 0; - - if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); - return; - } - - if ($cmd !== 'loc' && $cmd != 'rem') { - return; - } - - if (!$uid) { - return; - } - - if ($cmd === 'loc' && $cid) { - $contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['id' => $cid, 'uid' => $uid]); - - if (DBA::isResult($contact)) { - DI::page()['aside'] = ""; - Model\Profile::load($a, "", Model\Contact::getByURL($contact["url"], false)); - } - } else { - $contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['self' => true, 'uid' => $uid]); - - if (DBA::isResult($contact)) { - $vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [ - '$name' => $contact['name'], - '$photo' => $contact['photo'], - 'url' => 'contact/' . $cid - ]); - - if (empty(DI::page()['aside'])) { - DI::page()['aside'] = ''; - } - DI::page()['aside'] .= $vcard_widget; - } - } - - if (!DBA::isResult($contact)) { - return; - } - - if (!$cid && Model\Profile::getMyURL()) { - $contact = DBA::selectFirst('contact', ['id'], ['nurl' => Strings::normaliseLink(Model\Profile::getMyURL()), 'uid' => $uid]); - if (DBA::isResult($contact)) { - $cid = $contact['id']; - } else { - $gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => Strings::normaliseLink(Model\Profile::getMyURL())]); - if (DBA::isResult($gcontact)) { - $zcid = $gcontact['id']; - } - } - } - - if ($cid == 0 && $zcid == 0) { - return; - } - - if ($cid) { - $total = Model\GContact::countCommonFriends($uid, $cid); - } else { - $total = Model\GContact::countCommonFriendsZcid($uid, $zcid); - } - - if ($total < 1) { - notice(DI::l10n()->t('No contacts in common.')); - return $o; - } - - $pager = new Pager(DI::l10n(), DI::args()->getQueryString()); - - if ($cid) { - $common_friends = Model\GContact::commonFriends($uid, $cid, $pager->getStart(), $pager->getItemsPerPage()); - } else { - $common_friends = Model\GContact::commonFriendsZcid($uid, $zcid, $pager->getStart(), $pager->getItemsPerPage()); - } - - if (!DBA::isResult($common_friends)) { - return $o; - } - - $title = ''; - $tab_str = ''; - if ($cmd === 'loc' && $cid && local_user() == $uid) { - $tab_str = Module\Contact::getTabsHTML($contact, 5); - } else { - $title = DI::l10n()->t('Common Friends'); - } - - $entries = []; - foreach ($common_friends as $common_friend) { - $contact = Model\Contact::getByURLForUser($common_friend['url'], local_user()); - if (!empty($contact)) { - $entries[] = Module\Contact::getContactTemplateVars($contact); - } - } - - $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); - - $o .= Renderer::replaceMacros($tpl, [ - '$title' => $title, - '$tab_str' => $tab_str, - '$contacts' => $entries, - '$paginate' => $pager->renderFull($total), - ]); - - return $o; -} diff --git a/src/Model/GContact.php b/src/Model/GContact.php deleted file mode 100644 index 3fe123e15..000000000 --- a/src/Model/GContact.php +++ /dev/null @@ -1,139 +0,0 @@ -. - * - */ - -namespace Friendica\Model; - -use Exception; -use Friendica\DI; - -/** - * This class handles GlobalContact related functions - */ -class GContact -{ - /** - * @param integer $uid id - * @param integer $cid id - * @return integer - * @throws Exception - */ - public static function countCommonFriends($uid, $cid) - { - $sourceId = Contact::getPublicIdByUserId($uid); - - $targetIds = Contact::getPublicAndUserContacID($cid, $uid); - - $condition = [ - 'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?', - $sourceId, - ]; - - return Contact\Relation::countCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition); - } - - /** - * @param integer $uid id - * @param integer $zcid zcid - * @return integer - * @throws Exception - */ - public static function countCommonFriendsZcid($uid, $zcid) - { - $sourceId = Contact::getPublicIdByUserId($uid); - - $targetPublicContact = DI::dba()->fetchFirst(" -SELECT `id` -FROM `contact` c -JOIN `gcontact` z ON z.`nurl` = c.`nurl` -AND z.`id` = ? -AND c.`uid` = 0 -LIMIT 1", - $zcid - ); - - $condition = [ - 'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?', - $sourceId, - ]; - - return Contact\Relation::countCommonFollowers($sourceId, $targetPublicContact['id'] ?? 0, $condition); - } - - /** - * Returns the cross-section between the local user contacts and one of their contact's own relationships - * as known by the local node. - * - * @param integer $uid local user id - * @param integer $cid user contact id to compare friends with - * @param integer $start optional, default 0 - * @param integer $limit optional, default 9999 - * @param boolean $shuffle optional, default false - * @return array - * @throws Exception - */ - public static function commonFriends($uid, $cid, $start = 0, $limit = 9999, $shuffle = false) - { - $sourceId = Contact::getPublicIdByUserId($uid); - - $targetIds = Contact::getPublicAndUserContacID($cid, $uid); - - $condition = [ - 'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?', - $sourceId, - ]; - - return Contact\Relation::listCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition, $limit, $start, $shuffle); - } - - /** - * Returns the cross-section between a local user and a remote visitor contact's own relationships - * as known by the local node. - * - * @param integer $uid local user id - * @param integer $zcid remote visitor contact zcid - * @param integer $start optional, default 0 - * @param integer $limit optional, default 9999 - * @param boolean $shuffle optional, default false - * @return array - * @throws Exception - */ - public static function commonFriendsZcid($uid, $zcid, $start = 0, $limit = 9999, $shuffle = false) - { - $sourceId = Contact::getPublicIdByUserId($uid); - - $targetPublicContact = DI::dba()->fetchFirst(" -SELECT c.`id` -FROM `contact` c -JOIN `gcontact` z ON z.`nurl` = c.`nurl` -AND z.`id` = ? -AND c.`uid` = 0 -LIMIT 1", - $zcid - ); - - $condition = [ - 'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?', - $sourceId, - ]; - - return Contact\Relation::listCommonFollows($sourceId, $targetPublicContact['id'] ?? 0, $condition, $limit, $start, $shuffle); - } -} diff --git a/src/Module/AllFriends.php b/src/Module/AllFriends.php deleted file mode 100644 index 9f1152f26..000000000 --- a/src/Module/AllFriends.php +++ /dev/null @@ -1,89 +0,0 @@ -. - * - */ - -namespace Friendica\Module; - -use Friendica\BaseModule; -use Friendica\Content\Pager; -use Friendica\Core\Renderer; -use Friendica\DI; -use Friendica\Model; -use Friendica\Network\HTTPException; - -/** - * This module shows all public friends of the selected contact - */ -class AllFriends extends BaseModule -{ - public static function content(array $parameters = []) - { - $app = DI::app(); - - if (!local_user()) { - throw new HTTPException\ForbiddenException(); - } - - $cid = 0; - - // @TODO: Replace with parameter from router - if ($app->argc > 1) { - $cid = intval($app->argv[1]); - } - - if (!$cid) { - throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.')); - } - - $uid = $app->user['uid']; - - $contact = Model\Contact::getById($cid, []); - - if (empty($contact)) { - throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.')); - } - - DI::page()['aside'] = ""; - Model\Profile::load($app, "", $contact); - - $total = Model\Contact\Relation::countFollows($cid); - - $pager = new Pager(DI::l10n(), DI::args()->getQueryString()); - - $friends = Model\Contact\Relation::listFollows($cid, [], [], $pager->getItemsPerPage(), $pager->getStart()); - if (empty($friends)) { - return DI::l10n()->t('No friends to display.'); - } - - $tab_str = Contact::getTabsHTML($contact, 4); - - $entries = []; - foreach ($friends as $friend) { - $entries[] = Contact::getContactTemplateVars($friend); - } - - $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); - return Renderer::replaceMacros($tpl, [ - '$tab_str' => $tab_str, - '$contacts' => $entries, - '$paginate' => $pager->renderFull($total), - ]); - } -} diff --git a/static/routes.config.php b/static/routes.config.php index e81a988c4..3991ec4e3 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -103,7 +103,6 @@ return [ ], '/amcd' => [Module\AccountManagementControlDocument::class, [R::GET]], '/acctlink' => [Module\Acctlink::class, [R::GET]], - '/allfriends/{id:\d+}' => [Module\AllFriends::class, [R::GET]], '/apps' => [Module\Apps::class, [R::GET]], '/attach/{item:\d+}' => [Module\Attach::class, [R::GET]], '/babel' => [Module\Debug\Babel::class, [R::GET, R::POST]], diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 853fb057a..84779c36a 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -2248,8 +2248,8 @@ ul.dropdown-menu li:hover { *********/ section > .generic-page-wrapper, .videos-content-wrapper, - .suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper, -.allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, +.suggest-content-wrapper, .help-content-wrapper, +.match-content-wrapper, .dirfind-content-wrapper, .delegation-content-wrapper, .notes-content-wrapper, .message-content-wrapper, .apps-content-wrapper, #adminpage, .delegate-content-wrapper, .uexport-content-wrapper, @@ -3487,7 +3487,7 @@ section .profile-match-wrapper { right: 10px; } - .generic-page-wrapper, .videos-content-wrapper, .suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper, .allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .delegation-content-wrapper, .notes-content-wrapper, .message-content-wrapper, .apps-content-wrapper, #adminpage, .delegate-content-wrapper, .uexport-content-wrapper, .dfrn_request-content-wrapper, .friendica-content-wrapper, .credits-content-wrapper, .nogroup-content-wrapper, .profperm-content-wrapper, .invite-content-wrapper, .tos-content-wrapper, .fsuggest-content-wrapper { + .generic-page-wrapper, .videos-content-wrapper, .suggest-content-wrapper, .help-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .delegation-content-wrapper, .notes-content-wrapper, .message-content-wrapper, .apps-content-wrapper, #adminpage, .delegate-content-wrapper, .uexport-content-wrapper, .dfrn_request-content-wrapper, .friendica-content-wrapper, .credits-content-wrapper, .nogroup-content-wrapper, .profperm-content-wrapper, .invite-content-wrapper, .tos-content-wrapper, .fsuggest-content-wrapper { border-radius: 0; padding: 10px; }