Merge pull request #8982 from MrPetovan/task/8918-move-mod-common
Move mod/common.php to src/ Part 3: Add Module\Contact\Contacts class
This commit is contained in:
commit
f0a0c6b822
18 changed files with 329 additions and 494 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($a, $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;
|
|
||||||
}
|
|
|
@ -171,4 +171,40 @@ abstract class BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function getContactFilterTabs(string $baseUrl, string $current, bool $displayCommonTab)
|
||||||
|
{
|
||||||
|
$tabs = [
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('All contacts'),
|
||||||
|
'url' => $baseUrl . '/contacts',
|
||||||
|
'sel' => !$current || $current == 'all' ? 'active' : '',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('Followers'),
|
||||||
|
'url' => $baseUrl . '/contacts/followers',
|
||||||
|
'sel' => $current == 'followers' ? 'active' : '',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('Following'),
|
||||||
|
'url' => $baseUrl . '/contacts/following',
|
||||||
|
'sel' => $current == 'following' ? 'active' : '',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('Mutual friends'),
|
||||||
|
'url' => $baseUrl . '/contacts/mutuals',
|
||||||
|
'sel' => $current == 'mutuals' ? 'active' : '',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($displayCommonTab) {
|
||||||
|
$tabs[] = [
|
||||||
|
'label' => DI::l10n()->t('Common'),
|
||||||
|
'url' => $baseUrl . '/contacts/common',
|
||||||
|
'sel' => $current == 'common' ? 'active' : '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tabs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,4 +53,9 @@ class Native extends AbstractSession implements ISession
|
||||||
session_start();
|
session_start();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
session_destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,6 @@ class Relation
|
||||||
* Returns a paginated list of contacts that are followed the provided public contact.
|
* Returns a paginated list of contacts that are followed the provided public contact.
|
||||||
*
|
*
|
||||||
* @param int $cid Public contact id
|
* @param int $cid Public contact id
|
||||||
* @param array $field Field list
|
|
||||||
* @param array $condition Additional condition on the contact table
|
* @param array $condition Additional condition on the contact table
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
|
@ -343,14 +342,14 @@ class Relation
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function listFollows(int $cid, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
public static function listFollows(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
{
|
{
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
||||||
$cid]
|
$cid]
|
||||||
);
|
);
|
||||||
|
|
||||||
return DI::dba()->selectToArray('contact', $fields, $condition,
|
return DI::dba()->selectToArray('contact', [], $condition,
|
||||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -377,7 +376,6 @@ class Relation
|
||||||
* Returns a paginated list of contacts that follow the provided public contact.
|
* Returns a paginated list of contacts that follow the provided public contact.
|
||||||
*
|
*
|
||||||
* @param int $cid Public contact id
|
* @param int $cid Public contact id
|
||||||
* @param array $field Field list
|
|
||||||
* @param array $condition Additional condition on the contact table
|
* @param array $condition Additional condition on the contact table
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
|
@ -385,17 +383,104 @@ class Relation
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function listFollowers(int $cid, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
public static function listFollowers(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
{
|
{
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
['`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)', $cid]
|
['`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)', $cid]
|
||||||
);
|
);
|
||||||
|
|
||||||
return DI::dba()->selectToArray('contact', $fields, $condition,
|
return DI::dba()->selectToArray('contact', [], $condition,
|
||||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the number of contacts that are known mutuals with the provided public contact.
|
||||||
|
*
|
||||||
|
* @param int $cid Public contact id
|
||||||
|
* @param array $condition Additional condition array on the contact table
|
||||||
|
* @return int
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function countMutuals(int $cid, array $condition = [])
|
||||||
|
{
|
||||||
|
$condition = DBA::mergeConditions($condition,
|
||||||
|
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||||
|
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
|
||||||
|
$cid, $cid]
|
||||||
|
);
|
||||||
|
|
||||||
|
return DI::dba()->count('contact', $condition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a paginated list of contacts that are known mutuals with the provided public contact.
|
||||||
|
*
|
||||||
|
* @param int $cid Public contact id
|
||||||
|
* @param array $condition Additional condition on the contact table
|
||||||
|
* @param int $count
|
||||||
|
* @param int $offset
|
||||||
|
* @param bool $shuffle
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function listMutuals(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
|
{
|
||||||
|
$condition = DBA::mergeConditions($condition,
|
||||||
|
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||||
|
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
|
||||||
|
$cid, $cid]
|
||||||
|
);
|
||||||
|
|
||||||
|
return DI::dba()->selectToArray('contact', [], $condition,
|
||||||
|
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the number of contacts with any relationship with the provided public contact.
|
||||||
|
*
|
||||||
|
* @param int $cid Public contact id
|
||||||
|
* @param array $condition Additional condition array on the contact table
|
||||||
|
* @return int
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function countAll(int $cid, array $condition = [])
|
||||||
|
{
|
||||||
|
$condition = DBA::mergeConditions($condition,
|
||||||
|
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||||
|
OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
|
||||||
|
$cid, $cid]
|
||||||
|
);
|
||||||
|
|
||||||
|
return DI::dba()->count('contact', $condition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a paginated list of contacts with any relationship with the provided public contact.
|
||||||
|
*
|
||||||
|
* @param int $cid Public contact id
|
||||||
|
* @param array $condition Additional condition on the contact table
|
||||||
|
* @param int $count
|
||||||
|
* @param int $offset
|
||||||
|
* @param bool $shuffle
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function listAll(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
|
{
|
||||||
|
$condition = DBA::mergeConditions($condition,
|
||||||
|
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||||
|
OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
|
||||||
|
$cid, $cid]
|
||||||
|
);
|
||||||
|
|
||||||
|
return DI::dba()->selectToArray('contact', [], $condition,
|
||||||
|
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts the number of contacts that both provided public contacts have interacted with at least once.
|
* Counts the number of contacts that both provided public contacts have interacted with at least once.
|
||||||
* Interactions include follows and likes and comments on public posts.
|
* Interactions include follows and likes and comments on public posts.
|
||||||
|
@ -423,7 +508,6 @@ class Relation
|
||||||
*
|
*
|
||||||
* @param int $sourceId Public contact id
|
* @param int $sourceId Public contact id
|
||||||
* @param int $targetId Public contact id
|
* @param int $targetId Public contact id
|
||||||
* @param array $field Field list
|
|
||||||
* @param array $condition Additional condition on the contact table
|
* @param array $condition Additional condition on the contact table
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
|
@ -434,8 +518,8 @@ class Relation
|
||||||
public static function listCommon(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
public static function listCommon(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
{
|
{
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)
|
||||||
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)",
|
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)",
|
||||||
$sourceId, $targetId]
|
$sourceId, $targetId]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -444,7 +528,6 @@ class Relation
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts the number of contacts that are followed by both provided public contacts.
|
* Counts the number of contacts that are followed by both provided public contacts.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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($app, $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),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -47,6 +47,12 @@ use Friendica\Util\Strings;
|
||||||
*/
|
*/
|
||||||
class Contact extends BaseModule
|
class Contact extends BaseModule
|
||||||
{
|
{
|
||||||
|
const TAB_CONVERSATIONS = 1;
|
||||||
|
const TAB_POSTS = 2;
|
||||||
|
const TAB_PROFILE = 3;
|
||||||
|
const TAB_CONTACTS = 4;
|
||||||
|
const TAB_ADVANCED = 5;
|
||||||
|
|
||||||
private static function batchActions()
|
private static function batchActions()
|
||||||
{
|
{
|
||||||
if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) {
|
if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) {
|
||||||
|
@ -531,7 +537,7 @@ class Contact extends BaseModule
|
||||||
$nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']));
|
$nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']));
|
||||||
|
|
||||||
// tabs
|
// tabs
|
||||||
$tab_str = self::getTabsHTML($a, $contact, 3);
|
$tab_str = self::getTabsHTML($contact, self::TAB_PROFILE);
|
||||||
|
|
||||||
$lost_contact = (($contact['archive'] && $contact['term-date'] > DBA::NULL_DATETIME && $contact['term-date'] < DateTimeFormat::utcNow()) ? DI::l10n()->t('Communications lost with this contact!') : '');
|
$lost_contact = (($contact['archive'] && $contact['term-date'] > DBA::NULL_DATETIME && $contact['term-date'] < DateTimeFormat::utcNow()) ? DI::l10n()->t('Communications lost with this contact!') : '');
|
||||||
|
|
||||||
|
@ -576,7 +582,7 @@ class Contact extends BaseModule
|
||||||
'$lbl_info2' => DI::l10n()->t('Their personal note'),
|
'$lbl_info2' => DI::l10n()->t('Their personal note'),
|
||||||
'$reason' => trim(Strings::escapeTags($contact['reason'])),
|
'$reason' => trim(Strings::escapeTags($contact['reason'])),
|
||||||
'$infedit' => DI::l10n()->t('Edit contact notes'),
|
'$infedit' => DI::l10n()->t('Edit contact notes'),
|
||||||
'$common_link' => 'common/loc/' . local_user() . '/' . $contact['id'],
|
'$common_link' => 'contact/' . $contact['id'] . '/contacts/common',
|
||||||
'$relation_text' => $relation_text,
|
'$relation_text' => $relation_text,
|
||||||
'$visit' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
|
'$visit' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
|
||||||
'$blockunblock' => DI::l10n()->t('Block/Unblock contact'),
|
'$blockunblock' => DI::l10n()->t('Block/Unblock contact'),
|
||||||
|
@ -855,14 +861,14 @@ class Contact extends BaseModule
|
||||||
*
|
*
|
||||||
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
|
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
|
||||||
*
|
*
|
||||||
* @param App $a
|
|
||||||
* @param array $contact The contact array
|
* @param array $contact The contact array
|
||||||
* @param int $active_tab 1 if tab should be marked as active
|
* @param int $active_tab 1 if tab should be marked as active
|
||||||
*
|
*
|
||||||
* @return string HTML string of the contact page tabs buttons.
|
* @return string HTML string of the contact page tabs buttons.
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
public static function getTabsHTML($a, $contact, $active_tab)
|
public static function getTabsHTML(array $contact, int $active_tab)
|
||||||
{
|
{
|
||||||
$cid = $pcid = $contact['id'];
|
$cid = $pcid = $contact['id'];
|
||||||
$data = Model\Contact::getPublicAndUserContacID($contact['id'], local_user());
|
$data = Model\Contact::getPublicAndUserContacID($contact['id'], local_user());
|
||||||
|
@ -876,57 +882,41 @@ class Contact extends BaseModule
|
||||||
$tabs = [
|
$tabs = [
|
||||||
[
|
[
|
||||||
'label' => DI::l10n()->t('Status'),
|
'label' => DI::l10n()->t('Status'),
|
||||||
'url' => "contact/" . $pcid . "/conversations",
|
'url' => 'contact/' . $pcid . '/conversations',
|
||||||
'sel' => (($active_tab == 1) ? 'active' : ''),
|
'sel' => (($active_tab == self::TAB_CONVERSATIONS) ? 'active' : ''),
|
||||||
'title' => DI::l10n()->t('Conversations started by this contact'),
|
'title' => DI::l10n()->t('Conversations started by this contact'),
|
||||||
'id' => 'status-tab',
|
'id' => 'status-tab',
|
||||||
'accesskey' => 'm',
|
'accesskey' => 'm',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => DI::l10n()->t('Posts and Comments'),
|
'label' => DI::l10n()->t('Posts and Comments'),
|
||||||
'url' => "contact/" . $pcid . "/posts",
|
'url' => 'contact/' . $pcid . '/posts',
|
||||||
'sel' => (($active_tab == 2) ? 'active' : ''),
|
'sel' => (($active_tab == self::TAB_POSTS) ? 'active' : ''),
|
||||||
'title' => DI::l10n()->t('Status Messages and Posts'),
|
'title' => DI::l10n()->t('Status Messages and Posts'),
|
||||||
'id' => 'posts-tab',
|
'id' => 'posts-tab',
|
||||||
'accesskey' => 'p',
|
'accesskey' => 'p',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => DI::l10n()->t('Profile'),
|
'label' => DI::l10n()->t('Profile'),
|
||||||
'url' => "contact/" . $cid,
|
'url' => 'contact/' . $cid,
|
||||||
'sel' => (($active_tab == 3) ? 'active' : ''),
|
'sel' => (($active_tab == self::TAB_PROFILE) ? 'active' : ''),
|
||||||
'title' => DI::l10n()->t('Profile Details'),
|
'title' => DI::l10n()->t('Profile Details'),
|
||||||
'id' => 'profile-tab',
|
'id' => 'profile-tab',
|
||||||
'accesskey' => 'o',
|
'accesskey' => 'o',
|
||||||
]
|
],
|
||||||
|
['label' => DI::l10n()->t('Contacts'),
|
||||||
|
'url' => 'contact/' . $pcid . '/contacts',
|
||||||
|
'sel' => (($active_tab == self::TAB_CONTACTS) ? 'active' : ''),
|
||||||
|
'title' => DI::l10n()->t('View all known contacts'),
|
||||||
|
'id' => 'contacts-tab',
|
||||||
|
'accesskey' => 't'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Show this tab only if there is visible friend list
|
|
||||||
$x = Model\Contact\Relation::countFollows($pcid);
|
|
||||||
if ($x) {
|
|
||||||
$tabs[] = ['label' => DI::l10n()->t('Contacts'),
|
|
||||||
'url' => "allfriends/" . $pcid,
|
|
||||||
'sel' => (($active_tab == 4) ? 'active' : ''),
|
|
||||||
'title' => DI::l10n()->t('View all contacts'),
|
|
||||||
'id' => 'allfriends-tab',
|
|
||||||
'accesskey' => 't'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show this tab only if there is visible common friend list
|
|
||||||
$common = Model\GContact::countCommonFriends(local_user(), $cid);
|
|
||||||
if ($common) {
|
|
||||||
$tabs[] = ['label' => DI::l10n()->t('Common Friends'),
|
|
||||||
'url' => "common/loc/" . local_user() . "/" . $cid,
|
|
||||||
'sel' => (($active_tab == 5) ? 'active' : ''),
|
|
||||||
'title' => DI::l10n()->t('View all common friends'),
|
|
||||||
'id' => 'common-loc-tab',
|
|
||||||
'accesskey' => 'd'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cid != $pcid) {
|
if ($cid != $pcid) {
|
||||||
$tabs[] = ['label' => DI::l10n()->t('Advanced'),
|
$tabs[] = ['label' => DI::l10n()->t('Advanced'),
|
||||||
'url' => 'contact/' . $cid . '/advanced/',
|
'url' => 'contact/' . $cid . '/advanced/',
|
||||||
'sel' => (($active_tab == 6) ? 'active' : ''),
|
'sel' => (($active_tab == self::TAB_ADVANCED) ? 'active' : ''),
|
||||||
'title' => DI::l10n()->t('Advanced Contact Settings'),
|
'title' => DI::l10n()->t('Advanced Contact Settings'),
|
||||||
'id' => 'advanced-tab',
|
'id' => 'advanced-tab',
|
||||||
'accesskey' => 'r'
|
'accesskey' => 'r'
|
||||||
|
@ -964,7 +954,7 @@ class Contact extends BaseModule
|
||||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id, 'deleted' => false]);
|
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id, 'deleted' => false]);
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
$o .= self::getTabsHTML($a, $contact, 1);
|
$o .= self::getTabsHTML($contact, self::TAB_CONVERSATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
|
@ -988,7 +978,7 @@ class Contact extends BaseModule
|
||||||
{
|
{
|
||||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id, 'deleted' => false]);
|
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id, 'deleted' => false]);
|
||||||
|
|
||||||
$o = self::getTabsHTML($a, $contact, 2);
|
$o = self::getTabsHTML($contact, self::TAB_POSTS);
|
||||||
|
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
DI::page()['aside'] = '';
|
DI::page()['aside'] = '';
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Advanced extends BaseModule
|
||||||
$remote_self_options = ['0' => DI::l10n()->t('No mirroring'), '2' => DI::l10n()->t('Mirror as my own posting')];
|
$remote_self_options = ['0' => DI::l10n()->t('No mirroring'), '2' => DI::l10n()->t('Mirror as my own posting')];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab_str = Contact::getTabsHTML(DI::app(), $contact, 6);
|
$tab_str = Contact::getTabsHTML($contact, Contact::TAB_ADVANCED);
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('contact/advanced.tpl');
|
$tpl = Renderer::getMarkupTemplate('contact/advanced.tpl');
|
||||||
return Renderer::replaceMacros($tpl, [
|
return Renderer::replaceMacros($tpl, [
|
||||||
|
|
123
src/Module/Contact/Contacts.php
Normal file
123
src/Module/Contact/Contacts.php
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Module\Contact;
|
||||||
|
|
||||||
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Content\Pager;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
|
use Friendica\DI;
|
||||||
|
use Friendica\Model;
|
||||||
|
use Friendica\Module;
|
||||||
|
use Friendica\Network\HTTPException;
|
||||||
|
|
||||||
|
class Contacts extends BaseModule
|
||||||
|
{
|
||||||
|
public static function content(array $parameters = [])
|
||||||
|
{
|
||||||
|
$app = DI::app();
|
||||||
|
|
||||||
|
if (!local_user()) {
|
||||||
|
throw new HTTPException\ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$cid = $parameters['id'];
|
||||||
|
$type = $parameters['type'] ?? 'all';
|
||||||
|
|
||||||
|
if (!$cid) {
|
||||||
|
throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$contact = Model\Contact::getById($cid, []);
|
||||||
|
if (empty($contact)) {
|
||||||
|
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$localContactId = Model\Contact::getPublicIdByUserId(local_user());
|
||||||
|
|
||||||
|
Model\Profile::load($app, '', $contact);
|
||||||
|
|
||||||
|
$condition = [
|
||||||
|
'blocked' => false,
|
||||||
|
'self' => false,
|
||||||
|
'hidden' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
$noresult_label = DI::l10n()->t('No known contacts.');
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'followers':
|
||||||
|
$total = Model\Contact\Relation::countFollowers($cid, $condition);
|
||||||
|
break;
|
||||||
|
case 'following':
|
||||||
|
$total = Model\Contact\Relation::countFollows($cid, $condition);
|
||||||
|
break;
|
||||||
|
case 'mutuals':
|
||||||
|
$total = Model\Contact\Relation::countMutuals($cid, $condition);
|
||||||
|
break;
|
||||||
|
case 'common':
|
||||||
|
$condition = [
|
||||||
|
'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?',
|
||||||
|
$localContactId,
|
||||||
|
];
|
||||||
|
$total = Model\Contact\Relation::countCommon($localContactId, $cid, $condition);
|
||||||
|
$noresult_label = DI::l10n()->t('No common contacts.');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$total = Model\Contact\Relation::countAll($cid, $condition);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||||
|
$desc = '';
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'followers':
|
||||||
|
$friends = Model\Contact\Relation::listFollowers($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||||
|
$title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total);
|
||||||
|
break;
|
||||||
|
case 'following':
|
||||||
|
$friends = Model\Contact\Relation::listFollows($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||||
|
$title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total);
|
||||||
|
break;
|
||||||
|
case 'mutuals':
|
||||||
|
$friends = Model\Contact\Relation::listMutuals($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||||
|
$title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
|
||||||
|
$desc = DI::l10n()->t(
|
||||||
|
'These contacts both follow and are followed by <strong>%s</strong>.',
|
||||||
|
htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'common':
|
||||||
|
$friends = Model\Contact\Relation::listCommon($localContactId, $cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||||
|
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
|
||||||
|
$desc = DI::l10n()->t(
|
||||||
|
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
|
||||||
|
htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$friends = Model\Contact\Relation::listAll($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||||
|
$title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total);
|
||||||
|
}
|
||||||
|
|
||||||
|
$o = Module\Contact::getTabsHTML($contact, Module\Contact::TAB_CONTACTS);
|
||||||
|
|
||||||
|
$tabs = self::getContactFilterTabs('contact/' . $cid, $type, true);
|
||||||
|
|
||||||
|
$contacts = array_map([Module\Contact::class, 'getContactTemplateVars'], $friends);
|
||||||
|
|
||||||
|
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
|
||||||
|
$o .= Renderer::replaceMacros($tpl, [
|
||||||
|
'$title' => $title,
|
||||||
|
'$desc' => $desc,
|
||||||
|
'$tabs' => $tabs,
|
||||||
|
|
||||||
|
'$noresult_label' => $noresult_label,
|
||||||
|
|
||||||
|
'$contacts' => $contacts,
|
||||||
|
'$paginate' => $pager->renderFull($total),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,8 +53,6 @@ class Common extends BaseProfile
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$o = self::getTabsHTML($a, 'contacts', false, $nickname);
|
|
||||||
|
|
||||||
if (!empty($a->profile['hide-friends'])) {
|
if (!empty($a->profile['hide-friends'])) {
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
@ -65,6 +63,10 @@ class Common extends BaseProfile
|
||||||
$a->redirect('profile/' . $nickname . '/contacts');
|
$a->redirect('profile/' . $nickname . '/contacts');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$o = self::getTabsHTML($a, 'contacts', false, $nickname);
|
||||||
|
|
||||||
|
$tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab);
|
||||||
|
|
||||||
$sourceId = Contact::getIdForURL(Profile::getMyURL());
|
$sourceId = Contact::getIdForURL(Profile::getMyURL());
|
||||||
$targetId = Contact::getPublicIdByUserId($a->profile['uid']);
|
$targetId = Contact::getPublicIdByUserId($a->profile['uid']);
|
||||||
|
|
||||||
|
@ -92,15 +94,8 @@ class Common extends BaseProfile
|
||||||
$o .= Renderer::replaceMacros($tpl, [
|
$o .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $title,
|
'$title' => $title,
|
||||||
'$desc' => $desc,
|
'$desc' => $desc,
|
||||||
'$nickname' => $nickname,
|
'$tabs' => $tabs,
|
||||||
'$type' => 'common',
|
|
||||||
'$displayCommonTab' => $displayCommonTab,
|
|
||||||
|
|
||||||
'$all_label' => DI::l10n()->t('All contacts'),
|
|
||||||
'$followers_label' => DI::l10n()->t('Followers'),
|
|
||||||
'$following_label' => DI::l10n()->t('Following'),
|
|
||||||
'$mutuals_label' => DI::l10n()->t('Mutual friends'),
|
|
||||||
'$common_label' => DI::l10n()->t('Common'),
|
|
||||||
'$noresult_label' => DI::l10n()->t('No common contacts.'),
|
'$noresult_label' => DI::l10n()->t('No common contacts.'),
|
||||||
|
|
||||||
'$contacts' => $contacts,
|
'$contacts' => $contacts,
|
||||||
|
|
|
@ -61,6 +61,8 @@ class Contacts extends Module\BaseProfile
|
||||||
|
|
||||||
$o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname);
|
$o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname);
|
||||||
|
|
||||||
|
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $a->profile['uid'] != local_user());
|
||||||
|
|
||||||
$condition = [
|
$condition = [
|
||||||
'uid' => $a->profile['uid'],
|
'uid' => $a->profile['uid'],
|
||||||
'blocked' => false,
|
'blocked' => false,
|
||||||
|
@ -113,15 +115,8 @@ class Contacts extends Module\BaseProfile
|
||||||
$o .= Renderer::replaceMacros($tpl, [
|
$o .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $title,
|
'$title' => $title,
|
||||||
'$desc' => $desc,
|
'$desc' => $desc,
|
||||||
'$nickname' => $nickname,
|
'$tabs' => $tabs,
|
||||||
'$type' => $type,
|
|
||||||
'$displayCommonTab' => Session::isAuthenticated() && $a->profile['uid'] != local_user(),
|
|
||||||
|
|
||||||
'$all_label' => DI::l10n()->t('All contacts'),
|
|
||||||
'$followers_label' => DI::l10n()->t('Followers'),
|
|
||||||
'$following_label' => DI::l10n()->t('Following'),
|
|
||||||
'$mutuals_label' => DI::l10n()->t('Mutual friends'),
|
|
||||||
'$common_label' => DI::l10n()->t('Common'),
|
|
||||||
'$noresult_label' => DI::l10n()->t('No contacts.'),
|
'$noresult_label' => DI::l10n()->t('No contacts.'),
|
||||||
|
|
||||||
'$contacts' => $contacts,
|
'$contacts' => $contacts,
|
||||||
|
|
|
@ -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]],
|
||||||
|
@ -115,25 +114,26 @@ return [
|
||||||
'/compose[/{type}]' => [Module\Item\Compose::class, [R::GET, R::POST]],
|
'/compose[/{type}]' => [Module\Item\Compose::class, [R::GET, R::POST]],
|
||||||
|
|
||||||
'/contact' => [
|
'/contact' => [
|
||||||
'[/]' => [Module\Contact::class, [R::GET]],
|
'[/]' => [Module\Contact::class, [R::GET]],
|
||||||
'/{id:\d+}[/]' => [Module\Contact::class, [R::GET, R::POST]],
|
'/{id:\d+}[/]' => [Module\Contact::class, [R::GET, R::POST]],
|
||||||
'/{id:\d+}/archive' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/archive' => [Module\Contact::class, [R::GET]],
|
||||||
'/{id:\d+}/advanced' => [Module\Contact\Advanced::class, [R::GET, R::POST]],
|
'/{id:\d+}/advanced' => [Module\Contact\Advanced::class, [R::GET, R::POST]],
|
||||||
'/{id:\d+}/block' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/block' => [Module\Contact::class, [R::GET]],
|
||||||
'/{id:\d+}/conversations' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/conversations' => [Module\Contact::class, [R::GET]],
|
||||||
'/{id:\d+}/drop' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/contacts[/{type}]' => [Module\Contact\Contacts::class, [R::GET]],
|
||||||
'/{id:\d+}/ignore' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/drop' => [Module\Contact::class, [R::GET]],
|
||||||
'/{id:\d+}/poke' => [Module\Contact\Poke::class, [R::GET, R::POST]],
|
'/{id:\d+}/ignore' => [Module\Contact::class, [R::GET]],
|
||||||
'/{id:\d+}/posts' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/poke' => [Module\Contact\Poke::class, [R::GET, R::POST]],
|
||||||
'/{id:\d+}/update' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/posts' => [Module\Contact::class, [R::GET]],
|
||||||
'/{id:\d+}/updateprofile' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/update' => [Module\Contact::class, [R::GET]],
|
||||||
'/archived' => [Module\Contact::class, [R::GET]],
|
'/{id:\d+}/updateprofile' => [Module\Contact::class, [R::GET]],
|
||||||
'/batch' => [Module\Contact::class, [R::GET, R::POST]],
|
'/archived' => [Module\Contact::class, [R::GET]],
|
||||||
'/pending' => [Module\Contact::class, [R::GET]],
|
'/batch' => [Module\Contact::class, [R::GET, R::POST]],
|
||||||
'/blocked' => [Module\Contact::class, [R::GET]],
|
'/pending' => [Module\Contact::class, [R::GET]],
|
||||||
'/hidden' => [Module\Contact::class, [R::GET]],
|
'/blocked' => [Module\Contact::class, [R::GET]],
|
||||||
'/ignored' => [Module\Contact::class, [R::GET]],
|
'/hidden' => [Module\Contact::class, [R::GET]],
|
||||||
'/hovercard' => [Module\Contact\Hovercard::class, [R::GET]],
|
'/ignored' => [Module\Contact::class, [R::GET]],
|
||||||
|
'/hovercard' => [Module\Contact\Hovercard::class, [R::GET]],
|
||||||
],
|
],
|
||||||
|
|
||||||
'/credits' => [Module\Credits::class, [R::GET]],
|
'/credits' => [Module\Credits::class, [R::GET]],
|
||||||
|
|
1
view/templates/page_tabs.tpl
Normal file
1
view/templates/page_tabs.tpl
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{include file="common_tabs.tpl" tabs=$tabs}}
|
|
@ -5,15 +5,8 @@
|
||||||
<p>{{$desc nofilter}}</p>
|
<p>{{$desc nofilter}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<ul role="menubar" class="tabs">
|
{{include file="page_tabs.tpl" tabs=$tabs}}
|
||||||
<li role="menuitem"><a href="profile/{{$nickname}}/contacts" class="tab button{{if !$type || $type == 'all'}} active{{/if}}">{{$all_label}}</a></li>
|
|
||||||
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/followers" class="tab button{{if $type == 'followers'}} active{{/if}}">{{$followers_label}}</a></li>
|
|
||||||
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/following" class="tab button{{if $type == 'following'}} active{{/if}}">{{$following_label}}</a></li>
|
|
||||||
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/mutuals" class="tab button{{if $type == 'mutuals'}} active{{/if}}">{{$mutuals_label}}</a></li>
|
|
||||||
{{if $displayCommonTab}}
|
|
||||||
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/common" class="tab button{{if $type == 'common'}} active{{/if}}{{if !$common_count}} disabled{{/if}}">{{$common_label}}</a></li>
|
|
||||||
{{/if}}
|
|
||||||
</ul>
|
|
||||||
{{if $contacts}}
|
{{if $contacts}}
|
||||||
<div id="viewcontact_wrapper-{{$id}}">
|
<div id="viewcontact_wrapper-{{$id}}">
|
||||||
{{foreach $contacts as $contact}}
|
{{foreach $contacts as $contact}}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<ul role="menubar" class="tabbar list-inline visible-lg visible-md visible-sm hidden-xs">
|
<ul role="menubar" class="tabbar list-inline visible-lg visible-md visible-sm hidden-xs">
|
||||||
{{* The normal tabbar *}}
|
{{* The normal tabbar *}}
|
||||||
<li>
|
<li>
|
||||||
<ul class="tabs flex-nav" role="menu" >
|
<ul class="tabs flex-nav" role="menu" >
|
||||||
{{foreach $tabs as $tab}}
|
{{foreach $tabs as $tab}}
|
||||||
<li id="{{$tab.id}}" role="presentation" {{if $tab.sel}} class="{{$tab.sel}}" {{/if}}><a role="menuitem" href="{{$tab.url}}" {{if $tab.accesskey}}accesskey="{{$tab.accesskey}}"{{/if}} {{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a></li>
|
<li id="{{$tab.id}}" role="presentation" {{if $tab.sel}} class="{{$tab.sel}}" {{/if}}><a role="menuitem" href="{{$tab.url}}" {{if $tab.accesskey}}accesskey="{{$tab.accesskey}}"{{/if}} {{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a></li>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
@ -36,8 +36,6 @@
|
||||||
{{$exttabs[]=$tab}}
|
{{$exttabs[]=$tab}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
7
view/theme/frio/templates/page_tabs.tpl
Normal file
7
view/theme/frio/templates/page_tabs.tpl
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
{{foreach $tabs as $tab}}
|
||||||
|
<li id="{{$tab.id}}" role="presentation"{{if $tab.sel}} class="{{$tab.sel}}"{{/if}}>
|
||||||
|
<a role="menuitem" href="{{$tab.url}}"{{if $tab.accesskey}} accesskey="{{$tab.accesskey}}"{{/if}}{{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a>
|
||||||
|
</li>
|
||||||
|
{{/foreach}}
|
||||||
|
</ul>
|
|
@ -5,25 +5,8 @@
|
||||||
<p>{{$desc nofilter}}</p>
|
<p>{{$desc nofilter}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<ul class="nav nav-tabs">
|
{{include file="page_tabs.tpl" tabs=$tabs}}
|
||||||
<li role="presentation"{{if !$type || $type == 'all'}} class="active"{{/if}}>
|
|
||||||
<a href="profile/{{$nickname}}/contacts">{{$all_label}}</a>
|
|
||||||
</li>
|
|
||||||
<li role="presentation"{{if $type == 'followers'}} class="active"{{/if}}>
|
|
||||||
<a href="profile/{{$nickname}}/contacts/followers">{{$followers_label}}</a>
|
|
||||||
</li>
|
|
||||||
<li role="presentation"{{if $type == 'following'}} class="active"{{/if}}>
|
|
||||||
<a href="profile/{{$nickname}}/contacts/following">{{$following_label}}</a>
|
|
||||||
</li>
|
|
||||||
<li role="presentation"{{if $type == 'mutuals'}} class="active"{{/if}}>
|
|
||||||
<a href="profile/{{$nickname}}/contacts/mutuals">{{$mutuals_label}}</a>
|
|
||||||
</li>
|
|
||||||
{{if $displayCommonTab}}
|
|
||||||
<li role="presentation"{{if $type == 'common'}} class="active"{{/if}}>
|
|
||||||
<a href="profile/{{$nickname}}/contacts/common" class="tab button">{{$common_label}}</a>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
</ul>
|
|
||||||
{{if $contacts}}
|
{{if $contacts}}
|
||||||
<ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
|
<ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
|
||||||
{{foreach $contacts as $contact}}
|
{{foreach $contacts as $contact}}
|
||||||
|
|
Loading…
Reference in a new issue