mirror of
https://github.com/friendica/friendica
synced 2024-12-23 03:20:15 +00:00
Remove obsolete modules common and allfriends
- Delete obsolete Model\GContact class
This commit is contained in:
parent
18cd4f7412
commit
e64dcc5b5b
5 changed files with 3 additions and 378 deletions
146
mod/common.php
146
mod/common.php
|
@ -1,146 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (C) 2020, Friendica
|
|
||||||
*
|
|
||||||
* @license GNU AGPL version 3 or any later version
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
|
@ -1,139 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (C) 2020, Friendica
|
|
||||||
*
|
|
||||||
* @license GNU AGPL version 3 or any later version
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (C) 2020, Friendica
|
|
||||||
*
|
|
||||||
* @license GNU AGPL version 3 or any later version
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
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),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -103,7 +103,6 @@ return [
|
||||||
],
|
],
|
||||||
'/amcd' => [Module\AccountManagementControlDocument::class, [R::GET]],
|
'/amcd' => [Module\AccountManagementControlDocument::class, [R::GET]],
|
||||||
'/acctlink' => [Module\Acctlink::class, [R::GET]],
|
'/acctlink' => [Module\Acctlink::class, [R::GET]],
|
||||||
'/allfriends/{id:\d+}' => [Module\AllFriends::class, [R::GET]],
|
|
||||||
'/apps' => [Module\Apps::class, [R::GET]],
|
'/apps' => [Module\Apps::class, [R::GET]],
|
||||||
'/attach/{item:\d+}' => [Module\Attach::class, [R::GET]],
|
'/attach/{item:\d+}' => [Module\Attach::class, [R::GET]],
|
||||||
'/babel' => [Module\Debug\Babel::class, [R::GET, R::POST]],
|
'/babel' => [Module\Debug\Babel::class, [R::GET, R::POST]],
|
||||||
|
|
|
@ -2248,8 +2248,8 @@ ul.dropdown-menu li:hover {
|
||||||
*********/
|
*********/
|
||||||
|
|
||||||
section > .generic-page-wrapper, .videos-content-wrapper,
|
section > .generic-page-wrapper, .videos-content-wrapper,
|
||||||
.suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper,
|
.suggest-content-wrapper, .help-content-wrapper,
|
||||||
.allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper,
|
.match-content-wrapper, .dirfind-content-wrapper,
|
||||||
.delegation-content-wrapper, .notes-content-wrapper,
|
.delegation-content-wrapper, .notes-content-wrapper,
|
||||||
.message-content-wrapper, .apps-content-wrapper,
|
.message-content-wrapper, .apps-content-wrapper,
|
||||||
#adminpage, .delegate-content-wrapper, .uexport-content-wrapper,
|
#adminpage, .delegate-content-wrapper, .uexport-content-wrapper,
|
||||||
|
@ -3487,7 +3487,7 @@ section .profile-match-wrapper {
|
||||||
right: 10px;
|
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;
|
border-radius: 0;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue