X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fcontacts.php;h=682d427c6d175fdfbdc22fcd4d9e54e7912c2dbb;hb=0f546f7f0f8b41bd7510bd3644419c002746ce34;hp=90c4af7d1bcbe967d4cd2fd267245dfdc6969fd4;hpb=ae66bcaff3c01d10fb8bee04201b692c1fae9032;p=friendica.git diff --git a/mod/contacts.php b/mod/contacts.php index 90c4af7d1b..682d427c6d 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -4,15 +4,17 @@ */ use Friendica\App; use Friendica\Content\ContactSelector; +use Friendica\Content\Nav; +use Friendica\Content\Widget; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Model\Group; +use Friendica\Model\Profile; use Friendica\Network\Probe; -require_once 'include/contact_widgets.php'; require_once 'mod/proxy.php'; function contacts_init(App $a) @@ -30,7 +32,8 @@ function contacts_init(App $a) $a->page['aside'] = ''; } - $contact = []; + $contact_id = null; + $contact = null; if ((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) { $contact_id = intval($a->argv[1]); $contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]); @@ -46,7 +49,7 @@ function contacts_init(App $a) } /// @TODO Add nice spaces - $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array( + $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [ '$name' => htmlentities($a->data['contact']['name']), '$photo' => $a->data['contact']['photo'], '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/" . $a->data['contact']['id'] : $a->data['contact']['url'], @@ -54,45 +57,45 @@ function contacts_init(App $a) '$network_name' => $networkname, '$network' => t('Network:'), '$account_type' => Contact::getAccountType($a->data['contact']) - )); + ]); $findpeople_widget = ''; $follow_widget = ''; $networks_widget = ''; } else { $vcard_widget = ''; - $networks_widget = networks_widget('contacts', $nets); + $networks_widget = Widget::networks('contacts', $nets); if (isset($_GET['add'])) { - $follow_widget = follow_widget($_GET['add']); + $follow_widget = Widget::follow($_GET['add']); } else { - $follow_widget = follow_widget(); + $follow_widget = Widget::follow(); } - $findpeople_widget = findpeople_widget(); + $findpeople_widget = Widget::findPeople(); } $groups_widget = Group::sidebarWidget('contacts', 'group', 'full', 0, $contact_id); - $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), array( + $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), [ '$vcard_widget' => $vcard_widget, '$findpeople_widget' => $findpeople_widget, '$follow_widget' => $follow_widget, '$groups_widget' => $groups_widget, '$networks_widget' => $networks_widget - )); + ]); $base = System::baseUrl(); $tpl = get_markup_template("contacts-head.tpl"); - $a->page['htmlhead'] .= replace_macros($tpl, array( + $a->page['htmlhead'] .= replace_macros($tpl, [ '$baseurl' => System::baseUrl(true), '$base' => $base - )); + ]); $tpl = get_markup_template("contacts-end.tpl"); - $a->page['end'] .= replace_macros($tpl, array( + $a->page['end'] .= replace_macros($tpl, [ '$baseurl' => System::baseUrl(true), '$base' => $base - )); + ]); } function contacts_batch_actions(App $a) @@ -164,11 +167,7 @@ function contacts_post(App $a) return; } - $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval(local_user()) - ); - if (!DBM::is_result($orig_record)) { + if (!dba::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) { notice(t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED @@ -178,11 +177,7 @@ function contacts_post(App $a) $profile_id = intval($_POST['profile-assign']); if ($profile_id) { - $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($profile_id), - intval(local_user()) - ); - if (!DBM::is_result($r)) { + if (!dba::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) { notice(t('Could not locate selected profile.') . EOL); return; } @@ -229,6 +224,7 @@ function contacts_post(App $a) return; } + /* contact actions */ function _contact_update($contact_id) @@ -240,7 +236,7 @@ function _contact_update($contact_id) $uid = $contact["uid"]; - if ($r[0]["network"] == NETWORK_OSTATUS) { + if ($contact["network"] == NETWORK_OSTATUS) { $result = Contact::createFromProbe($uid, $contact["url"], false, $contact["network"]); if ($result['success']) { @@ -264,13 +260,13 @@ function _contact_update_profile($contact_id) $data = Probe::uri($contact["url"], "", 0, false); // "Feed" or "Unknown" is mostly a sign of communication problems - if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) && ($data["network"] != $contact["network"])) { + if ((in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM])) && ($data["network"] != $contact["network"])) { return; } - $updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", - "poco", "network", "alias"); - $update = array(); + $updatefields = ["name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", + "poco", "network", "alias"]; + $update = []; if ($data["network"] == NETWORK_OSTATUS) { $result = Contact::createFromProbe($uid, $data["url"], false); @@ -374,7 +370,7 @@ function contacts_content(App $a) { $sort_type = 0; $o = ''; - nav_set_selected('contacts'); + Nav::setSelected('contacts'); if (!local_user()) { notice(t('Permission denied.') . EOL); @@ -447,17 +443,17 @@ function contacts_content(App $a) //