X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fcontacts.php;h=dba7680bad17bc357278b5320bcb307fb0b1fb6e;hb=b92fc24ff06681f445edff0d45f8f81a7e25ebe6;hp=6b40f045522cda4037492c99f2dc003fbb3d0829;hpb=b7fb43484e5bde2d69c4b988c35939bd6ab6712e;p=friendica.git diff --git a/mod/contacts.php b/mod/contacts.php index 6b40f04552..dba7680bad 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -1,12 +1,15 @@ $networks_widget )); - $base = z_root(); + $base = System::baseUrl(); $tpl = get_markup_template("contacts-head.tpl"); $a->page['htmlhead'] .= replace_macros($tpl,array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), '$base' => $base )); $tpl = get_markup_template("contacts-end.tpl"); $a->page['end'] .= replace_macros($tpl,array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), '$base' => $base )); @@ -182,7 +185,7 @@ function contacts_post(App $a) { intval($profile_id), intval(local_user()) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { notice( t('Could not locate selected profile.') . EOL); return; } @@ -224,7 +227,7 @@ function contacts_post(App $a) { intval($contact_id), intval(local_user()) ); - if($r && dbm::is_result($r)) + if($r && DBM::is_result($r)) $a->data['contact'] = $r[0]; return; @@ -243,14 +246,14 @@ function _contact_update($contact_id) { return; if ($r[0]["network"] == NETWORK_OSTATUS) { - $result = new_contact($uid, $r[0]["url"], false); + $result = new_contact($uid, $r[0]["url"], false, $r[0]["network"]); if ($result['success']) $r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d", intval($contact_id)); } else // pull feed and consume it, which should subscribe to the hub. - proc_run(PRIORITY_HIGH, "include/onepoll.php", $contact_id, "force"); + Worker::add(PRIORITY_HIGH, "OnePoll", $contact_id, "force"); } function _contact_update_profile($contact_id) { @@ -310,7 +313,7 @@ function _contact_update_profile($contact_id) { update_contact_avatar($data['photo'], local_user(), $contact_id, true); // Update the entry in the gcontact table - update_gcontact_from_probe($data["url"]); + GlobalContact::updateFromProbe($data["url"]); } function _contact_block($contact_id, $orig_record) { @@ -347,7 +350,16 @@ function _contact_archive($contact_id, $orig_record) { function _contact_drop($contact_id, $orig_record) { $a = get_app(); - terminate_friendship($a->user,$a->contact,$orig_record); + $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` + WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", + intval($a->user['uid']) + ); + if (!DBM::is_result($r)) { + return; + } + + $self = ""; // Unused parameter + terminate_friendship($r[0], $self, $orig_record); contact_remove($orig_record['id']); } @@ -493,10 +505,10 @@ function contacts_content(App $a) { $contact = $a->data['contact']; $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), )); $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), )); require_once 'include/contact_selectors.php'; @@ -550,12 +562,12 @@ function contacts_content(App $a) { $nettype = sprintf( t('Network type: %s'),network_to_name($contact['network'], $contact["url"])); - //$common = count_common_friends(local_user(),$contact['id']); + //$common = GlobalContact::countCommonFriends(local_user(),$contact['id']); //$common_text = (($common) ? sprintf( tt('%d contact in common','%d contacts in common', $common),$common) : ''); $polling = (($contact['network'] === NETWORK_MAIL | $contact['network'] === NETWORK_FEED) ? 'polling' : ''); - //$x = count_all_friends(local_user(), $contact['id']); + //$x = GlobalContact::countAllFriends(local_user(), $contact['id']); //$all_friends = (($x) ? t('View all contacts') : ''); // tabs @@ -573,9 +585,15 @@ function contacts_content(App $a) { if ($contact['network'] == NETWORK_DFRN) $profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)); - if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) && - ($contact['rel'] == CONTACT_IS_FOLLOWER)) - $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]); + if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) { + if ($contact['rel'] == CONTACT_IS_FOLLOWER) { + $follow = System::baseUrl(true)."/follow?url=".urlencode($contact["url"]); + $follow_text = t("Connect/Follow"); + } elseif ($contact['rel'] == CONTACT_IS_FRIEND) { + $follow = System::baseUrl(true)."/unfollow?url=".urlencode($contact["url"]); + $follow_text = t("Disconnect/Unfollow"); + } + } // Load contactact related actions like hide, suggest, delete and others $contact_actions = contact_actions($contact); @@ -612,7 +630,7 @@ function contacts_content(App $a) { '$last_update' => $last_update, '$udnow' => t('Update now'), '$follow' => $follow, - '$follow_text' => t("Connect/Follow"), + '$follow_text' => $follow_text, '$profile_select' => $profile_select, '$contact_id' => $contact['id'], '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ), @@ -778,7 +796,7 @@ function contacts_content(App $a) { $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ", intval($_SESSION['uid'])); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $a->set_pager_total($r[0]['total']); $total = $r[0]['total']; } @@ -793,7 +811,7 @@ function contacts_content(App $a) { $contacts = array(); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { foreach ($r as $rr) { $contacts[] = _contact_detail_for_template($rr); } @@ -801,7 +819,7 @@ function contacts_content(App $a) { $tpl = get_markup_template("contacts-template.tpl"); $o .= replace_macros($tpl, array( - '$baseurl' => z_root(), + '$baseurl' => System::baseUrl(), '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''), '$tabs' => $t, '$total' => $total, @@ -855,13 +873,13 @@ function contacts_tab($a, $contact_id, $active_tab) { 'url' => "contacts/".$contact_id, 'sel' => (($active_tab == 2)?'active':''), 'title' => t('Profile Details'), - 'id' => 'status-tab', + 'id' => 'profile-tab', 'accesskey' => 'o', ) ); // Show this tab only if there is visible friend list - $x = count_all_friends(local_user(), $contact_id); + $x = GlobalContact::countAllFriends(local_user(), $contact_id); if ($x) $tabs[] = array('label'=>t('Contacts'), 'url' => "allfriends/".$contact_id, @@ -871,7 +889,7 @@ function contacts_tab($a, $contact_id, $active_tab) { 'accesskey' => 't'); // Show this tab only if there is visible common friend list - $common = count_common_friends(local_user(),$contact_id); + $common = GlobalContact::countCommonFriends(local_user(), $contact_id); if ($common) $tabs[] = array('label'=>t('Common Friends'), 'url' => "common/loc/".local_user()."/".$contact_id,