Renaming functions and class
This commit is contained in:
parent
93ab82b7f0
commit
cdbddd0103
8 changed files with 84 additions and 1212 deletions
|
@ -8,11 +8,10 @@ use Friendica\Content\ContactSelector;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model;\
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Module\Contact;
|
||||||
use Friendica\Model\Profile;
|
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
use Friendica\Module\Contacts;
|
|
||||||
|
|
||||||
require_once 'include/dba.php';
|
require_once 'include/dba.php';
|
||||||
|
|
||||||
|
@ -42,13 +41,13 @@ function allfriends_content(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->page['aside'] = "";
|
$a->page['aside'] = "";
|
||||||
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
Model\Profile::load($a, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
|
||||||
|
|
||||||
$total = GContact::countAllFriends(local_user(), $cid);
|
$total = Model\GContact::countAllFriends(local_user(), $cid);
|
||||||
|
|
||||||
$a->setPagerTotal($total);
|
$a->setPagerTotal($total);
|
||||||
|
|
||||||
$r = GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
|
$r = Model\GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||||
if (!DBA::isResult($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
$o .= L10n::t('No friends to display.');
|
$o .= L10n::t('No friends to display.');
|
||||||
return $o;
|
return $o;
|
||||||
|
@ -59,7 +58,7 @@ function allfriends_content(App $a)
|
||||||
$entries = [];
|
$entries = [];
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
//get further details of the contact
|
//get further details of the contact
|
||||||
$contact_details = Contact::getDetailsByURL($rr['url'], $uid, $rr);
|
$contact_details = Model\Contact::getDetailsByURL($rr['url'], $uid, $rr);
|
||||||
|
|
||||||
$photo_menu = '';
|
$photo_menu = '';
|
||||||
|
|
||||||
|
@ -68,11 +67,11 @@ function allfriends_content(App $a)
|
||||||
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
||||||
if ($rr['cid']) {
|
if ($rr['cid']) {
|
||||||
$rr['id'] = $rr['cid'];
|
$rr['id'] = $rr['cid'];
|
||||||
$photo_menu = Contact::photoMenu($rr);
|
$photo_menu = Model\Contact::photoMenu($rr);
|
||||||
} else {
|
} else {
|
||||||
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
|
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
|
||||||
$photo_menu = [
|
$photo_menu = [
|
||||||
'profile' => [L10n::t("View Profile"), Contact::magicLink($rr['url'])],
|
'profile' => [L10n::t("View Profile"), Model\Contact::magicLink($rr['url'])],
|
||||||
'follow' => [L10n::t("Connect/Follow"), $connlnk]
|
'follow' => [L10n::t("Connect/Follow"), $connlnk]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -86,7 +85,7 @@ function allfriends_content(App $a)
|
||||||
'details' => $contact_details['location'],
|
'details' => $contact_details['location'],
|
||||||
'tags' => $contact_details['keywords'],
|
'tags' => $contact_details['keywords'],
|
||||||
'about' => $contact_details['about'],
|
'about' => $contact_details['about'],
|
||||||
'account_type' => Contact::getAccountType($contact_details),
|
'account_type' => Model\Contact::getAccountType($contact_details),
|
||||||
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
|
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
|
||||||
'photo_menu' => $photo_menu,
|
'photo_menu' => $photo_menu,
|
||||||
'conntxt' => L10n::t('Connect'),
|
'conntxt' => L10n::t('Connect'),
|
||||||
|
@ -96,7 +95,7 @@ function allfriends_content(App $a)
|
||||||
$entries[] = $entry;
|
$entries[] = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab_str = Contacts::contacts_tab($a, $contact, 4);
|
$tab_str = Contact::getTabsHTML($a, $contact, 4);
|
||||||
|
|
||||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,10 @@ use Friendica\App;
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Module\Contact;
|
||||||
use Friendica\Model\Profile;
|
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
use Friendica\Module\Contacts;
|
|
||||||
|
|
||||||
require_once 'include/dba.php';
|
require_once 'include/dba.php';
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ function common_content(App $a)
|
||||||
|
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
$a->page['aside'] = "";
|
$a->page['aside'] = "";
|
||||||
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
Model\Profile::load($a, "", 0,Model\Contact::getDetailsByURL($contact["url"]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['self' => true, 'uid' => $uid]);
|
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['self' => true, 'uid' => $uid]);
|
||||||
|
@ -65,12 +64,12 @@ function common_content(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$cid && Profile::getMyURL()) {
|
if (!$cid &&Model\Profile::getMyURL()) {
|
||||||
$contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
|
$contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Model\Profile::getMyURL()), 'uid' => $uid]);
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
$cid = $contact['id'];
|
$cid = $contact['id'];
|
||||||
} else {
|
} else {
|
||||||
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
|
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Model\Profile::getMyURL())]);
|
||||||
if (DBA::isResult($gcontact)) {
|
if (DBA::isResult($gcontact)) {
|
||||||
$zcid = $gcontact['id'];
|
$zcid = $gcontact['id'];
|
||||||
}
|
}
|
||||||
|
@ -82,9 +81,9 @@ function common_content(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cid) {
|
if ($cid) {
|
||||||
$t = GContact::countCommonFriends($uid, $cid);
|
$t =Model\GContact::countCommonFriends($uid, $cid);
|
||||||
} else {
|
} else {
|
||||||
$t = GContact::countCommonFriendsZcid($uid, $zcid);
|
$t =Model\GContact::countCommonFriendsZcid($uid, $zcid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($t > 0) {
|
if ($t > 0) {
|
||||||
|
@ -95,9 +94,9 @@ function common_content(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cid) {
|
if ($cid) {
|
||||||
$r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
|
$r =Model\GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||||
} else {
|
} else {
|
||||||
$r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
|
$r =Model\GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBA::isResult($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
|
@ -109,13 +108,13 @@ function common_content(App $a)
|
||||||
$entries = [];
|
$entries = [];
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
//get further details of the contact
|
//get further details of the contact
|
||||||
$contact_details = Contact::getDetailsByURL($rr['url'], $uid);
|
$contact_details =Model\Contact::getDetailsByURL($rr['url'], $uid);
|
||||||
|
|
||||||
// $rr['id'] is needed to use contact_photo_menu()
|
// $rr['id'] is needed to use contact_photo_menu()
|
||||||
/// @TODO Adding '/" here avoids E_NOTICE on missing constants
|
/// @TODO Adding '/" here avoids E_NOTICE on missing constants
|
||||||
$rr['id'] = $rr['cid'];
|
$rr['id'] = $rr['cid'];
|
||||||
|
|
||||||
$photo_menu = Contact::photoMenu($rr);
|
$photo_menu =Model\Contact::photoMenu($rr);
|
||||||
|
|
||||||
$entry = [
|
$entry = [
|
||||||
'url' => $rr['url'],
|
'url' => $rr['url'],
|
||||||
|
@ -126,7 +125,7 @@ function common_content(App $a)
|
||||||
'details' => $contact_details['location'],
|
'details' => $contact_details['location'],
|
||||||
'tags' => $contact_details['keywords'],
|
'tags' => $contact_details['keywords'],
|
||||||
'about' => $contact_details['about'],
|
'about' => $contact_details['about'],
|
||||||
'account_type' => Contact::getAccountType($contact_details),
|
'account_type' =>Model\Contact::getAccountType($contact_details),
|
||||||
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
|
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
|
||||||
'photo_menu' => $photo_menu,
|
'photo_menu' => $photo_menu,
|
||||||
'id' => ++$id,
|
'id' => ++$id,
|
||||||
|
@ -137,7 +136,7 @@ function common_content(App $a)
|
||||||
$title = '';
|
$title = '';
|
||||||
$tab_str = '';
|
$tab_str = '';
|
||||||
if ($cmd === 'loc' && $cid && local_user() == $uid) {
|
if ($cmd === 'loc' && $cid && local_user() == $uid) {
|
||||||
$tab_str = Contacts::contacts_tab($a, $contact, 4);
|
$tab_str = Contact::getTabsHTML($a, $contact, 4);
|
||||||
} else {
|
} else {
|
||||||
$title = L10n::t('Common Friends');
|
$title = L10n::t('Common Friends');
|
||||||
}
|
}
|
||||||
|
|
1123
mod/contacts.php
1123
mod/contacts.php
File diff suppressed because it is too large
Load diff
|
@ -8,9 +8,8 @@ use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Module\Contact;
|
||||||
use Friendica\Module\Contacts;
|
|
||||||
|
|
||||||
require_once 'mod/contacts.php';
|
require_once 'mod/contacts.php';
|
||||||
|
|
||||||
|
@ -83,7 +82,7 @@ function crepair_post(App $a)
|
||||||
if ($photo) {
|
if ($photo) {
|
||||||
logger('mod-crepair: updating photo from ' . $photo);
|
logger('mod-crepair: updating photo from ' . $photo);
|
||||||
|
|
||||||
Contact::updateAvatar($photo, local_user(), $contact['id']);
|
Model\Contact::updateAvatar($photo, local_user(), $contact['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($r) {
|
if ($r) {
|
||||||
|
@ -136,7 +135,7 @@ function crepair_content(App $a)
|
||||||
|
|
||||||
$update_profile = in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]);
|
$update_profile = in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]);
|
||||||
|
|
||||||
$tab_str = Contacts::contacts_tab($a, $contact, 5);
|
$tab_str = Contact::getTabsHTML($a, $contact, 5);
|
||||||
|
|
||||||
$tpl = get_markup_template('crepair.tpl');
|
$tpl = get_markup_template('crepair.tpl');
|
||||||
$o = replace_macros($tpl, [
|
$o = replace_macros($tpl, [
|
||||||
|
|
|
@ -12,13 +12,13 @@ use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Module\Contact;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Protocol\PortableContact;
|
use Friendica\Protocol\PortableContact;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
use Friendica\Module\Contacts;
|
|
||||||
|
|
||||||
function dirfind_init(App $a) {
|
function dirfind_init(App $a) {
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
$objresult->tags = "";
|
$objresult->tags = "";
|
||||||
$objresult->network = $user_data["network"];
|
$objresult->network = $user_data["network"];
|
||||||
|
|
||||||
$contact = Contact::getDetailsByURL($user_data["url"], local_user());
|
$contact = Model\Contact::getDetailsByURL($user_data["url"], local_user());
|
||||||
$objresult->cid = $contact["cid"];
|
$objresult->cid = $contact["cid"];
|
||||||
$objresult->pcid = $contact["zid"];
|
$objresult->pcid = $contact["zid"];
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
|
|
||||||
// Add the contact to the global contacts if it isn't already in our system
|
// Add the contact to the global contacts if it isn't already in our system
|
||||||
if (($contact["cid"] == 0) && ($contact["zid"] == 0) && ($contact["gid"] == 0)) {
|
if (($contact["cid"] == 0) && ($contact["zid"] == 0) && ($contact["gid"] == 0)) {
|
||||||
GContact::update($user_data);
|
Model\GContact::update($user_data);
|
||||||
}
|
}
|
||||||
} elseif ($local) {
|
} elseif ($local) {
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Contact::getDetailsByURL($result["nurl"], local_user());
|
$result = Model\Contact::getDetailsByURL($result["nurl"], local_user());
|
||||||
|
|
||||||
if ($result["name"] == "") {
|
if ($result["name"] == "") {
|
||||||
$result["name"] = end(explode("/", $urlparts["path"]));
|
$result["name"] = end(explode("/", $urlparts["path"]));
|
||||||
|
@ -199,7 +199,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
|
|
||||||
$alt_text = "";
|
$alt_text = "";
|
||||||
|
|
||||||
$contact_details = Contact::getDetailsByURL($jj->url, local_user());
|
$contact_details = Model\Contact::getDetailsByURL($jj->url, local_user());
|
||||||
|
|
||||||
$itemurl = (($contact_details["addr"] != "") ? $contact_details["addr"] : $jj->url);
|
$itemurl = (($contact_details["addr"] != "") ? $contact_details["addr"] : $jj->url);
|
||||||
|
|
||||||
|
@ -209,8 +209,8 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
$conntxt = "";
|
$conntxt = "";
|
||||||
$contact = DBA::selectFirst('contact', [], ['id' => $jj->cid]);
|
$contact = DBA::selectFirst('contact', [], ['id' => $jj->cid]);
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
$photo_menu = Contact::photoMenu($contact);
|
$photo_menu =Model\Contact::photoMenu($contact);
|
||||||
$details = Contacts::_contact_detail_for_template($contact);
|
$details = Contact::getContactTemplateVars($contact);
|
||||||
$alt_text = $details['alt_text'];
|
$alt_text = $details['alt_text'];
|
||||||
} else {
|
} else {
|
||||||
$photo_menu = [];
|
$photo_menu = [];
|
||||||
|
@ -221,7 +221,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
|
|
||||||
$contact = DBA::selectFirst('contact', [], ['id' => $jj->pcid]);
|
$contact = DBA::selectFirst('contact', [], ['id' => $jj->pcid]);
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
$photo_menu = Contact::photoMenu($contact);
|
$photo_menu = Model\Contact::photoMenu($contact);
|
||||||
} else {
|
} else {
|
||||||
$photo_menu = [];
|
$photo_menu = [];
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
|
|
||||||
$entry = [
|
$entry = [
|
||||||
'alt_text' => $alt_text,
|
'alt_text' => $alt_text,
|
||||||
'url' => Contact::magicLink($jj->url),
|
'url' => Model\Contact::magicLink($jj->url),
|
||||||
'itemurl' => $itemurl,
|
'itemurl' => $itemurl,
|
||||||
'name' => htmlentities($jj->name),
|
'name' => htmlentities($jj->name),
|
||||||
'thumb' => ProxyUtils::proxifyUrl($jj->photo, false, ProxyUtils::SIZE_THUMB),
|
'thumb' => ProxyUtils::proxifyUrl($jj->photo, false, ProxyUtils::SIZE_THUMB),
|
||||||
|
@ -245,7 +245,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
'details' => $contact_details['location'],
|
'details' => $contact_details['location'],
|
||||||
'tags' => $contact_details['keywords'],
|
'tags' => $contact_details['keywords'],
|
||||||
'about' => $contact_details['about'],
|
'about' => $contact_details['about'],
|
||||||
'account_type' => Contact::getAccountType($contact_details),
|
'account_type' => Model\Contact::getAccountType($contact_details),
|
||||||
'network' => ContactSelector::networkToName($jj->network, $jj->url),
|
'network' => ContactSelector::networkToName($jj->network, $jj->url),
|
||||||
'id' => ++$id,
|
'id' => ++$id,
|
||||||
];
|
];
|
||||||
|
|
|
@ -11,9 +11,8 @@ 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;
|
use Friendica\Model;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Module\Contact;
|
||||||
use Friendica\Module\Contacts;
|
|
||||||
|
|
||||||
function group_init(App $a) {
|
function group_init(App $a) {
|
||||||
if (local_user()) {
|
if (local_user()) {
|
||||||
|
@ -186,7 +185,7 @@ function group_content(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = $r[0];
|
$group = $r[0];
|
||||||
$members = Contact::getByGroupId($group['id']);
|
$members = Model\Contact::getByGroupId($group['id']);
|
||||||
$preselected = [];
|
$preselected = [];
|
||||||
$entry = [];
|
$entry = [];
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
@ -204,7 +203,7 @@ function group_content(App $a) {
|
||||||
Group::addMember($group['id'], $change);
|
Group::addMember($group['id'], $change);
|
||||||
}
|
}
|
||||||
|
|
||||||
$members = Contact::getByGroupId($group['id']);
|
$members = Model\Contact::getByGroupId($group['id']);
|
||||||
$preselected = [];
|
$preselected = [];
|
||||||
if (count($members)) {
|
if (count($members)) {
|
||||||
foreach ($members as $member) {
|
foreach ($members as $member) {
|
||||||
|
@ -250,7 +249,7 @@ function group_content(App $a) {
|
||||||
// Format the data of the group members
|
// Format the data of the group members
|
||||||
foreach ($members as $member) {
|
foreach ($members as $member) {
|
||||||
if ($member['url']) {
|
if ($member['url']) {
|
||||||
$entry = Contacts::_contact_detail_for_template($member);
|
$entry = Contact::getContactTemplateVars($member);
|
||||||
$entry['label'] = 'members';
|
$entry['label'] = 'members';
|
||||||
$entry['photo_menu'] = '';
|
$entry['photo_menu'] = '';
|
||||||
$entry['change_member'] = [
|
$entry['change_member'] = [
|
||||||
|
@ -267,7 +266,7 @@ function group_content(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($nogroup) {
|
if ($nogroup) {
|
||||||
$r = Contact::getUngroupedList(local_user());
|
$r = Model\Contact::getUngroupedList(local_user());
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC",
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
|
@ -279,7 +278,7 @@ function group_content(App $a) {
|
||||||
// Format the data of the contacts who aren't in the contact group
|
// Format the data of the contacts who aren't in the contact group
|
||||||
foreach ($r as $member) {
|
foreach ($r as $member) {
|
||||||
if (!in_array($member['id'], $preselected)) {
|
if (!in_array($member['id'], $preselected)) {
|
||||||
$entry = Contacts::_contact_detail_for_template($member);
|
$entry = Contact::getContactTemplateVars($member);
|
||||||
$entry['label'] = 'contacts';
|
$entry['label'] = 'contacts';
|
||||||
if (!$nogroup)
|
if (!$nogroup)
|
||||||
$entry['photo_menu'] = [];
|
$entry['photo_menu'] = [];
|
||||||
|
|
|
@ -29,7 +29,7 @@ use Friendica\Module\Login;
|
||||||
*
|
*
|
||||||
* @brief manages contacts
|
* @brief manages contacts
|
||||||
*/
|
*/
|
||||||
class Contacts extends BaseModule
|
class Contact extends BaseModule
|
||||||
{
|
{
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ class Contacts extends BaseModule
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function contacts_batch_actions(App $a)
|
private static function batchActions(App $a)
|
||||||
{
|
{
|
||||||
if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) {
|
if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) {
|
||||||
return;
|
return;
|
||||||
|
@ -146,25 +146,25 @@ class Contacts extends BaseModule
|
||||||
foreach ($orig_records as $orig_record) {
|
foreach ($orig_records as $orig_record) {
|
||||||
$contact_id = $orig_record['id'];
|
$contact_id = $orig_record['id'];
|
||||||
if (x($_POST, 'contacts_batch_update')) {
|
if (x($_POST, 'contacts_batch_update')) {
|
||||||
self::_contact_update($contact_id);
|
self::updateContactFromPoll($contact_id);
|
||||||
$count_actions++;
|
$count_actions++;
|
||||||
}
|
}
|
||||||
if (x($_POST, 'contacts_batch_block')) {
|
if (x($_POST, 'contacts_batch_block')) {
|
||||||
self::_contact_block($contact_id);
|
self::blockContact($contact_id);
|
||||||
$count_actions++;
|
$count_actions++;
|
||||||
}
|
}
|
||||||
if (x($_POST, 'contacts_batch_ignore')) {
|
if (x($_POST, 'contacts_batch_ignore')) {
|
||||||
self::_contact_ignore($contact_id);
|
self::ignoreContact($contact_id);
|
||||||
$count_actions++;
|
$count_actions++;
|
||||||
}
|
}
|
||||||
if (x($_POST, 'contacts_batch_archive')) {
|
if (x($_POST, 'contacts_batch_archive')) {
|
||||||
$r = self::_contact_archive($contact_id, $orig_record);
|
$r = self::archiveContact($contact_id, $orig_record);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$count_actions++;
|
$count_actions++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x($_POST, 'contacts_batch_drop')) {
|
if (x($_POST, 'contacts_batch_drop')) {
|
||||||
self::_contact_drop($orig_record);
|
self::dropContact($orig_record);
|
||||||
$count_actions++;
|
$count_actions++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ class Contacts extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($a->argv[1] === "batch") {
|
if ($a->argv[1] === "batch") {
|
||||||
self::contacts_batch_actions($a);
|
self::batchActions($a);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ class Contacts extends BaseModule
|
||||||
|
|
||||||
/* contact actions */
|
/* contact actions */
|
||||||
|
|
||||||
private static function _contact_update($contact_id)
|
private static function updateContactFromPoll($contact_id)
|
||||||
{
|
{
|
||||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
|
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
|
@ -274,7 +274,7 @@ class Contacts extends BaseModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _contact_update_profile($contact_id)
|
private static function updateContactFromProbe($contact_id)
|
||||||
{
|
{
|
||||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
|
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
|
@ -340,19 +340,19 @@ class Contacts extends BaseModule
|
||||||
GContact::updateFromProbe($data["url"]);
|
GContact::updateFromProbe($data["url"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _contact_block($contact_id)
|
private static function blockContact($contact_id)
|
||||||
{
|
{
|
||||||
$blocked = !Contact::isBlockedByUser($contact_id, local_user());
|
$blocked = !Contact::isBlockedByUser($contact_id, local_user());
|
||||||
Contact::setBlockedForUser($contact_id, local_user(), $blocked);
|
Contact::setBlockedForUser($contact_id, local_user(), $blocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _contact_ignore($contact_id)
|
private static function ignoreContact($contact_id)
|
||||||
{
|
{
|
||||||
$ignored = !Contact::isIgnoredByUser($contact_id, local_user());
|
$ignored = !Contact::isIgnoredByUser($contact_id, local_user());
|
||||||
Contact::setIgnoredForUser($contact_id, local_user(), $ignored);
|
Contact::setIgnoredForUser($contact_id, local_user(), $ignored);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _contact_archive($contact_id, $orig_record)
|
private static function archiveContact($contact_id, $orig_record)
|
||||||
{
|
{
|
||||||
$archived = (($orig_record['archive']) ? 0 : 1);
|
$archived = (($orig_record['archive']) ? 0 : 1);
|
||||||
$r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d",
|
$r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d",
|
||||||
|
@ -363,7 +363,7 @@ class Contacts extends BaseModule
|
||||||
return DBA::isResult($r);
|
return DBA::isResult($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _contact_drop($orig_record)
|
private static function dropContact($orig_record)
|
||||||
{
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
@ -407,19 +407,19 @@ class Contacts extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd === 'update' && ($orig_record['uid'] != 0)) {
|
if ($cmd === 'update' && ($orig_record['uid'] != 0)) {
|
||||||
self::_contact_update($contact_id);
|
self::updateContactFromPoll($contact_id);
|
||||||
goaway('contacts/' . $contact_id);
|
goaway('contacts/' . $contact_id);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) {
|
if ($cmd === 'updateprofile' && ($orig_record['uid'] != 0)) {
|
||||||
self::_contact_update_profile($contact_id);
|
self::updateContactFromProbe($contact_id);
|
||||||
goaway('crepair/' . $contact_id);
|
goaway('crepair/' . $contact_id);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd === 'block') {
|
if ($cmd === 'block') {
|
||||||
self::_contact_block($contact_id);
|
self::blockContact($contact_id);
|
||||||
|
|
||||||
$blocked = Contact::isBlockedByUser($contact_id, local_user());
|
$blocked = Contact::isBlockedByUser($contact_id, local_user());
|
||||||
info(($blocked ? L10n::t('Contact has been blocked') : L10n::t('Contact has been unblocked')) . EOL);
|
info(($blocked ? L10n::t('Contact has been blocked') : L10n::t('Contact has been unblocked')) . EOL);
|
||||||
|
@ -429,7 +429,7 @@ class Contacts extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd === 'ignore') {
|
if ($cmd === 'ignore') {
|
||||||
self::_contact_ignore($contact_id);
|
self::ignoreContact($contact_id);
|
||||||
|
|
||||||
$ignored = Contact::isIgnoredByUser($contact_id, local_user());
|
$ignored = Contact::isIgnoredByUser($contact_id, local_user());
|
||||||
info(($ignored ? L10n::t('Contact has been ignored') : L10n::t('Contact has been unignored')) . EOL);
|
info(($ignored ? L10n::t('Contact has been ignored') : L10n::t('Contact has been unignored')) . EOL);
|
||||||
|
@ -439,7 +439,7 @@ class Contacts extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd === 'archive' && ($orig_record['uid'] != 0)) {
|
if ($cmd === 'archive' && ($orig_record['uid'] != 0)) {
|
||||||
$r = self::_contact_archive($contact_id, $orig_record);
|
$r = self::archiveContact($contact_id, $orig_record);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$archived = (($orig_record['archive']) ? 0 : 1);
|
$archived = (($orig_record['archive']) ? 0 : 1);
|
||||||
info((($archived) ? L10n::t('Contact has been archived') : L10n::t('Contact has been unarchived')) . EOL);
|
info((($archived) ? L10n::t('Contact has been archived') : L10n::t('Contact has been unarchived')) . EOL);
|
||||||
|
@ -467,7 +467,7 @@ class Contacts extends BaseModule
|
||||||
|
|
||||||
return replace_macros(get_markup_template('contact_drop_confirm.tpl'), [
|
return replace_macros(get_markup_template('contact_drop_confirm.tpl'), [
|
||||||
'$header' => L10n::t('Drop contact'),
|
'$header' => L10n::t('Drop contact'),
|
||||||
'$contact' => self::_contact_detail_for_template($orig_record),
|
'$contact' => self::getContactTemplateVars($orig_record),
|
||||||
'$method' => 'get',
|
'$method' => 'get',
|
||||||
'$message' => L10n::t('Do you really want to delete this contact?'),
|
'$message' => L10n::t('Do you really want to delete this contact?'),
|
||||||
'$extra_inputs' => $inputs,
|
'$extra_inputs' => $inputs,
|
||||||
|
@ -482,17 +482,17 @@ class Contacts extends BaseModule
|
||||||
goaway('contacts');
|
goaway('contacts');
|
||||||
}
|
}
|
||||||
|
|
||||||
self::_contact_drop($orig_record);
|
self::dropContact($orig_record);
|
||||||
info(L10n::t('Contact has been removed.') . EOL);
|
info(L10n::t('Contact has been removed.') . EOL);
|
||||||
|
|
||||||
goaway('contacts');
|
goaway('contacts');
|
||||||
return; // NOTREACHED
|
return; // NOTREACHED
|
||||||
}
|
}
|
||||||
if ($cmd === 'posts') {
|
if ($cmd === 'posts') {
|
||||||
return self::contact_posts($a, $contact_id);
|
return self::getPostsHTML($a, $contact_id);
|
||||||
}
|
}
|
||||||
if ($cmd === 'conversations') {
|
if ($cmd === 'conversations') {
|
||||||
return self::contact_conversations($a, $contact_id, $update);
|
return self::getConversationsHMTL($a, $contact_id, $update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ class Contacts extends BaseModule
|
||||||
$nettype = L10n::t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
|
$nettype = L10n::t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
|
||||||
|
|
||||||
// tabs
|
// tabs
|
||||||
$tab_str = self::contacts_tab($a, $contact, 3);
|
$tab_str = self::getTabsHTML($a, $contact, 3);
|
||||||
|
|
||||||
$lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : '');
|
$lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : '');
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ class Contacts extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load contactact related actions like hide, suggest, delete and others
|
// Load contactact related actions like hide, suggest, delete and others
|
||||||
$contact_actions = self::contact_actions($contact);
|
$contact_actions = self::getContactActions($contact);
|
||||||
|
|
||||||
if ($contact['uid'] != 0) {
|
if ($contact['uid'] != 0) {
|
||||||
$lbl_vis1 = L10n::t('Profile Visibility');
|
$lbl_vis1 = L10n::t('Profile Visibility');
|
||||||
|
@ -822,7 +822,7 @@ class Contacts extends BaseModule
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$rr['blocked'] = Contact::isBlockedByUser($rr['id'], local_user());
|
$rr['blocked'] = Contact::isBlockedByUser($rr['id'], local_user());
|
||||||
$rr['readonly'] = Contact::isIgnoredByUser($rr['id'], local_user());
|
$rr['readonly'] = Contact::isIgnoredByUser($rr['id'], local_user());
|
||||||
$contacts[] = self::_contact_detail_for_template($rr);
|
$contacts[] = self::getContactTemplateVars($rr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +865,7 @@ class Contacts extends BaseModule
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function contacts_tab($a, $contact, $active_tab)
|
public static function getTabsHTML($a, $contact, $active_tab)
|
||||||
{
|
{
|
||||||
// tabs
|
// tabs
|
||||||
$tabs = [
|
$tabs = [
|
||||||
|
@ -934,7 +934,7 @@ class Contacts extends BaseModule
|
||||||
return $tab_str;
|
return $tab_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function contact_conversations($a, $contact_id, $update)
|
private static function getConversationsHMTL($a, $contact_id, $update)
|
||||||
{
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
|
@ -959,7 +959,7 @@ class Contacts extends BaseModule
|
||||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id]);
|
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id]);
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
$o .= self::contacts_tab($a, $contact, 1);
|
$o .= self::getTabsHTML($a, $contact, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
|
@ -980,11 +980,11 @@ class Contacts extends BaseModule
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function contact_posts($a, $contact_id)
|
private static function getPostsHTML($a, $contact_id)
|
||||||
{
|
{
|
||||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id]);
|
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id]);
|
||||||
|
|
||||||
$o = self::contacts_tab($a, $contact, 2);
|
$o = self::getTabsHTML($a, $contact, 2);
|
||||||
|
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
$a->page['aside'] = "";
|
$a->page['aside'] = "";
|
||||||
|
@ -1004,7 +1004,7 @@ class Contacts extends BaseModule
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function _contact_detail_for_template(array $rr)
|
public static function getContactTemplateVars(array $rr)
|
||||||
{
|
{
|
||||||
$dir_icon = '';
|
$dir_icon = '';
|
||||||
$alt_text = '';
|
$alt_text = '';
|
||||||
|
@ -1071,7 +1071,7 @@ class Contacts extends BaseModule
|
||||||
* @param array $contact Data about the Contact
|
* @param array $contact Data about the Contact
|
||||||
* @return array with contact related actions
|
* @return array with contact related actions
|
||||||
*/
|
*/
|
||||||
private static function contact_actions($contact)
|
private static function getContactActions($contact)
|
||||||
{
|
{
|
||||||
$poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
|
$poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
|
||||||
$contact_actions = [];
|
$contact_actions = [];
|
||||||
|
@ -1133,5 +1133,4 @@ class Contacts extends BaseModule
|
||||||
|
|
||||||
return $contact_actions;
|
return $contact_actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -333,7 +333,7 @@ function frio_acl_lookup(App $a, &$results)
|
||||||
|
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$contacts[] = Contacts::_contact_detail_for_template($rr);
|
$contacts[] = Contacts::getContactTemplateVars($rr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue