X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FContact.php;h=245e5f0b226d00f8c0ed50c53c1dfd2dbf7e7f06;hb=07d358adc1658c54fcdefb42110fd1dd72609043;hp=810d5550cacb7af7cb55bb2f4e3507f0c8b9531a;hpb=4894e89f036be1f8a82523ac69d56ae36e7685df;p=friendica.git diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 810d5550ca..245e5f0b22 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -40,11 +40,8 @@ class Contact extends BaseModule } $nets = defaults($_GET, 'nets', ''); - if ($nets == 'all') { - $nets = ''; - } - if (!x($a->page, 'aside')) { + if (empty($a->page['aside'])) { $a->page['aside'] = ''; } @@ -54,10 +51,10 @@ class Contact extends BaseModule || $a->argc == 3 && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations']) ) { $contact_id = intval($a->argv[1]); - $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]); if (!DBA::isResult($contact)) { - $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]); + $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0, 'deleted' => false]); } // Don't display contacts that are about to be deleted @@ -78,18 +75,17 @@ class Contact extends BaseModule $a->data['contact'] = $contact; if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) { - $networkname = Strings::formatNetworkName($contact['network'], $contact['url']); + $network_link = Strings::formatNetworkName($contact['network'], $contact['url']); } else { - $networkname = ''; + $network_link = ''; } - /// @TODO Add nice spaces $vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('vcard-widget.tpl'), [ - '$name' => htmlentities($contact['name']), + '$name' => $contact['name'], '$photo' => $contact['photo'], '$url' => Model\Contact::MagicLink($contact['url']), '$addr' => defaults($contact, 'addr', ''), - '$network_name' => $networkname, + '$network_link' => $network_link, '$network' => L10n::t('Network:'), '$account_type' => Model\Contact::getAccountType($contact) ]); @@ -139,7 +135,7 @@ class Contact extends BaseModule $contacts_id = $_POST['contact_batch']; - $stmt = DBA::select('contact', ['id', 'archive'], ['id' => $contacts_id, 'uid' => local_user(), 'self' => false]); + $stmt = DBA::select('contact', ['id', 'archive'], ['id' => $contacts_id, 'uid' => local_user(), 'self' => false, 'deleted' => false]); $orig_records = DBA::toArray($stmt); $count_actions = 0; @@ -192,7 +188,7 @@ class Contact extends BaseModule return; } - if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) { + if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false])) { notice(L10n::t('Could not access contact record.') . EOL); $a->internalRedirect('contact'); return; // NOTREACHED @@ -202,7 +198,7 @@ class Contact extends BaseModule $profile_id = intval(defaults($_POST, 'profile-assign', 0)); if ($profile_id) { - if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) { + if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user(), 'deleted' => false])) { notice(L10n::t('Could not locate selected profile.') . EOL); return; } @@ -240,7 +236,7 @@ class Contact extends BaseModule notice(L10n::t('Failed to update contact record.') . EOL); } - $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]); if (DBA::isResult($contact)) { $a->data['contact'] = $contact; } @@ -252,7 +248,7 @@ class Contact extends BaseModule 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(), 'deleted' => false]); if (!DBA::isResult($contact)) { return; } @@ -273,7 +269,7 @@ class Contact extends BaseModule 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(), 'deleted' => false]); if (!DBA::isResult($contact)) { return; } @@ -374,7 +370,7 @@ class Contact extends BaseModule $cmd = $a->argv[2]; - $orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false]); + $orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]); if (!DBA::isResult($orig_record)) { notice(L10n::t('Could not access contact record.') . EOL); $a->internalRedirect('contact'); @@ -514,7 +510,7 @@ class Contact extends BaseModule $relation_text = ''; } - $relation_text = sprintf($relation_text, htmlentities($contact['name'])); + $relation_text = sprintf($relation_text, $contact['name']); $url = Model\Contact::magicLink($contact['url']); if (strpos($url, 'redir/') === 0) { @@ -570,12 +566,12 @@ class Contact extends BaseModule /// @todo Only show the following link with DFRN when the remote version supports it $follow = ''; $follow_text = ''; - if (in_array($contact['rel'], [Model\Contact::FRIEND, Model\Contact::SHARING])) { + if ($contact['uid'] && in_array($contact['rel'], [Model\Contact::FRIEND, Model\Contact::SHARING])) { if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { $follow = $a->getBaseURL(true) . '/unfollow?url=' . urlencode($contact['url']); $follow_text = L10n::t('Disconnect/Unfollow'); } - } else { + } elseif(!$contact['pending']) { $follow = $a->getBaseURL(true) . '/follow?url=' . urlencode($contact['url']); $follow_text = L10n::t('Connect/Follow'); } @@ -639,7 +635,7 @@ class Contact extends BaseModule '$ffi_keyword_blacklist' => $contact['ffi_keyword_blacklist'], '$ffi_keyword_blacklist' => ['ffi_keyword_blacklist', L10n::t('Blacklisted keywords'), $contact['ffi_keyword_blacklist'], L10n::t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')], '$photo' => $contact['photo'], - '$name' => htmlentities($contact['name']), + '$name' => $contact['name'], '$dir_icon' => $dir_icon, '$sparkle' => $sparkle, '$url' => $url, @@ -755,6 +751,14 @@ class Contact extends BaseModule 'id' => 'showhidden-tab', 'accesskey' => 'h', ], + [ + 'label' => L10n::t('Groups'), + 'url' => 'group', + 'sel' => ($hidden) ? 'active' : '', + 'title' => L10n::t('Organize your contact groups'), + 'id' => 'contactgroups-tab', + 'accesskey' => 'e', + ], ]; $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); @@ -774,6 +778,8 @@ class Contact extends BaseModule $sql_extra .= sprintf(" AND network = '%s' ", DBA::escape($nets)); } + $sql_extra .= " AND NOT `deleted` "; + $sql_extra2 = ((($sort_type > 0) && ($sort_type <= Model\Contact::FRIEND)) ? sprintf(" AND `rel` = %d ", intval($sort_type)) : ''); $r = q("SELECT COUNT(*) AS `total` FROM `contact` @@ -933,7 +939,7 @@ class Contact extends BaseModule } } - $contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id]); + $contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id, 'deleted' => false]); if (!$update) { $o .= self::getTabsHTML($a, $contact, 1); @@ -957,7 +963,7 @@ class Contact extends BaseModule 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, 'deleted' => false]); $o = self::getTabsHTML($a, $contact, 2); @@ -1025,14 +1031,14 @@ class Contact extends BaseModule 'alt_text' => $alt_text, 'dir_icon' => $dir_icon, 'thumb' => ProxyUtils::proxifyUrl($rr['thumb'], false, ProxyUtils::SIZE_THUMB), - 'name' => htmlentities($rr['name']), - 'username' => htmlentities($rr['name']), + 'name' => $rr['name'], + 'username' => $rr['name'], 'account_type' => Model\Contact::getAccountType($rr), 'sparkle' => $sparkle, 'itemurl' => defaults($rr, 'addr', $rr['url']), 'url' => $url, 'network' => ContactSelector::networkToName($rr['network'], $rr['url']), - 'nick' => htmlentities($rr['nick']), + 'nick' => $rr['nick'], ]; }