X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FContact.php;h=b18159d40cf0cf823bba43b082e6d897af214b9c;hb=b6cb83ed4c670c3ea9dde080cb7d9a3bb292d6b2;hp=095bad37cda5703b9269577892a771e268ebebce;hpb=f82580c2efc910c05653e5240ee73e39ca76fdc1;p=friendica.git diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 095bad37cd..b18159d40c 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -9,6 +9,7 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -146,7 +147,7 @@ class Contact extends BaseObject AND `contact`.`notify` != ""', $gid, local_user(), - NETWORK_OSTATUS + Protocol::OSTATUS ); $return = $contacts['count']; } @@ -313,15 +314,10 @@ class Contact extends BaseObject return; } - $archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts'); - if ($archive) { - DBA::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]); - return; - } - - DBA::delete('contact', ['id' => $id]); + // Archive the contact + DBA::update('contact', ['archive' => true, 'network' => Protocol::PHANTOM], ['id' => $id]); - // Delete the rest in the background + // Delete it in the background Worker::add(PRIORITY_LOW, 'RemoveContact', $id); } @@ -334,7 +330,7 @@ class Contact extends BaseObject */ public static function terminateFriendship(array $user, array $contact) { - if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) { + if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) { // create an unfollow slap $item = []; $item['verb'] = NAMESPACE_OSTATUS . "/unfollow"; @@ -349,7 +345,7 @@ class Contact extends BaseObject if (!empty($contact['notify'])) { Salmon::slapper($user, $contact['notify'], $slap); } - } elseif ($contact['network'] == NETWORK_DIASPORA) { + } elseif ($contact['network'] == Protocol::DIASPORA) { Diaspora::sendUnshare($user, $contact); } } @@ -508,7 +504,7 @@ class Contact extends BaseObject // If there is more than one entry we filter out the connector networks if (count($r) > 1) { foreach ($r as $id => $result) { - if ($result["network"] == NETWORK_STATUSNET) { + if ($result["network"] == Protocol::STATUSNET) { unset($r[$id]); } } @@ -562,13 +558,13 @@ class Contact extends BaseObject } if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0) - && in_array($profile["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) + && in_array($profile["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) ) { Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]); } // Show contact details of Diaspora contacts only if connected - if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == NETWORK_DIASPORA)) { + if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == Protocol::DIASPORA)) { $profile["location"] = ""; $profile["about"] = ""; $profile["gender"] = ""; @@ -687,7 +683,7 @@ class Contact extends BaseObject } $sparkle = false; - if (($contact['network'] === NETWORK_DFRN) && !$contact['self']) { + if (($contact['network'] === Protocol::DFRN) && !$contact['self']) { $sparkle = true; $profile_link = System::baseUrl() . '/redir/' . $contact['id']; } else { @@ -704,11 +700,11 @@ class Contact extends BaseObject $profile_link = $profile_link . '?url=profile'; } - if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA]) && !$contact['self']) { + if (in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA]) && !$contact['self']) { $pm_url = System::baseUrl() . '/message/new/' . $contact['id']; } - if (($contact['network'] == NETWORK_DFRN) && !$contact['self']) { + if (($contact['network'] == Protocol::DFRN) && !$contact['self']) { $poke_link = System::baseUrl() . '/poke/?f=&c=' . $contact['id']; } @@ -869,7 +865,7 @@ class Contact extends BaseObject } // Last try in gcontact for unsupported networks - if (!in_array($data["network"], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO, NETWORK_MAIL, NETWORK_FEED])) { + if (!in_array($data["network"], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::PUMPIO, Protocol::MAIL, Protocol::FEED])) { if ($uid != 0) { return 0; } @@ -1108,7 +1104,7 @@ class Contact extends BaseObject return ''; } - if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) { + if (in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) { $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))"; } else { $sql = "`item`.`uid` = ?"; @@ -1400,7 +1396,7 @@ class Contact extends BaseObject ); } - if (($ret['network'] === NETWORK_DFRN) && !DBA::isResult($r)) { + if (($ret['network'] === Protocol::DFRN) && !DBA::isResult($r)) { if ($interactive) { if (strlen($a->urlpath)) { $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']); @@ -1412,14 +1408,14 @@ class Contact extends BaseObject // NOTREACHED } - } elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != NETWORK_DFRN)) { + } elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != Protocol::DFRN)) { $result['message'] = L10n::t('This site is not configured to allow communications with other networks.') . EOL; $result['message'] != L10n::t('No compatible communication protocols or feeds were discovered.') . EOL; return $result; } // This extra param just confuses things, remove it - if ($ret['network'] === NETWORK_DIASPORA) { + if ($ret['network'] === Protocol::DIASPORA) { $ret['url'] = str_replace('?absolute=true', '', $ret['url']); } @@ -1443,7 +1439,7 @@ class Contact extends BaseObject return $result; } - if ($ret['network'] === NETWORK_OSTATUS && Config::get('system', 'ostatus_disabled')) { + if ($ret['network'] === Protocol::OSTATUS && Config::get('system', 'ostatus_disabled')) { $result['message'] .= L10n::t('The profile address specified belongs to a network which has been disabled on this site.') . EOL; $ret['notify'] = ''; } @@ -1452,13 +1448,13 @@ class Contact extends BaseObject $result['message'] .= L10n::t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL; } - $writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0); + $writeable = ((($ret['network'] === Protocol::OSTATUS) && ($ret['notify'])) ? 1 : 0); - $subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false); + $subhub = (($ret['network'] === Protocol::OSTATUS) ? true : false); - $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0); + $hidden = (($ret['network'] === Protocol::MAIL) ? 1 : 0); - if (in_array($ret['network'], [NETWORK_MAIL, NETWORK_DIASPORA])) { + if (in_array($ret['network'], [Protocol::MAIL, Protocol::DIASPORA])) { $writeable = 1; } @@ -1469,7 +1465,7 @@ class Contact extends BaseObject $fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false]; DBA::update('contact', $fields, ['id' => $r[0]['id']]); } else { - $new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? self::FRIEND : self::SHARING); + $new_relation = ((in_array($ret['network'], [Protocol::MAIL])) ? self::FRIEND : self::SHARING); // create contact record DBA::insert('contact', [ @@ -1522,7 +1518,7 @@ class Contact extends BaseObject ); if (DBA::isResult($r)) { - if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) { + if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) { // create a follow slap $item = []; $item['verb'] = ACTIVITY_FOLLOW; @@ -1536,7 +1532,7 @@ class Contact extends BaseObject if (!empty($contact['notify'])) { Salmon::slapper($r[0], $contact['notify'], $slap); } - } elseif ($contact['network'] == NETWORK_DIASPORA) { + } elseif ($contact['network'] == Protocol::DIASPORA) { $ret = Diaspora::sendShare($a->user, $contact); logger('share returns: ' . $ret); } @@ -1817,7 +1813,7 @@ class Contact extends BaseObject */ public static function magicLinkbyContact($contact, $url = '') { - if ($contact['network'] != NETWORK_DFRN) { + if ($contact['network'] != Protocol::DFRN) { return $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url']; }