mirror of
https://github.com/friendica/friendica
synced 2025-04-27 17:10:10 +00:00
Moved CONTACT_* constants to Friendica\Model\Contact class, lesser in global namespace (#5490)
* Rewrite: - moved all CONTACT_* constants from boot.php to Contact class * CR request: - renamed Contact::CONTACT_IS_* -> Contact::* ;-)
This commit is contained in:
parent
cff90e20f2
commit
37253656e3
26 changed files with 139 additions and 118 deletions
|
@ -30,6 +30,19 @@ require_once 'include/text.php';
|
|||
*/
|
||||
class Contact extends BaseObject
|
||||
{
|
||||
/**
|
||||
* @name Contact_is
|
||||
*
|
||||
* Relationship types
|
||||
* @{
|
||||
*/
|
||||
const FOLLOWER = 1;
|
||||
const SHARING = 2;
|
||||
const FRIEND = 3;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Returns a list of contacts belonging in a group
|
||||
*
|
||||
|
@ -849,7 +862,7 @@ class Contact extends BaseObject
|
|||
'about' => $data["about"],
|
||||
'network' => $data["network"],
|
||||
'pubkey' => $data["pubkey"],
|
||||
'rel' => CONTACT_IS_SHARING,
|
||||
'rel' => self::SHARING,
|
||||
'priority' => $data["priority"],
|
||||
'batch' => $data["batch"],
|
||||
'request' => $data["request"],
|
||||
|
@ -1374,12 +1387,12 @@ class Contact extends BaseObject
|
|||
|
||||
if (DBA::isResult($r)) {
|
||||
// update contact
|
||||
$new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
|
||||
$new_relation = (($r[0]['rel'] == self::FOLLOWER) ? self::FRIEND : self::SHARING);
|
||||
|
||||
$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])) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
|
||||
$new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? self::FRIEND : self::SHARING);
|
||||
|
||||
// create contact record
|
||||
DBA::insert('contact', [
|
||||
|
@ -1500,9 +1513,9 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
if (is_array($contact)) {
|
||||
if (($contact['rel'] == CONTACT_IS_SHARING)
|
||||
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
DBA::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
|
||||
if (($contact['rel'] == self::SHARING)
|
||||
|| ($sharing && $contact['rel'] == self::FOLLOWER)) {
|
||||
DBA::update('contact', ['rel' => self::FRIEND, 'writable' => true],
|
||||
['id' => $contact['id'], 'uid' => $importer['uid']]);
|
||||
}
|
||||
// send email notification to owner?
|
||||
|
@ -1524,7 +1537,7 @@ class Contact extends BaseObject
|
|||
DBA::escape($nick),
|
||||
DBA::escape($photo),
|
||||
DBA::escape(NETWORK_OSTATUS),
|
||||
intval(CONTACT_IS_FOLLOWER)
|
||||
intval(self::FOLLOWER)
|
||||
);
|
||||
|
||||
$contact_record = [
|
||||
|
@ -1580,19 +1593,19 @@ class Contact extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
public static function removeFollower($importer, $contact, array $datarray = [], $item = "") {
|
||||
|
||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
|
||||
DBA::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
|
||||
public static function removeFollower($importer, $contact, array $datarray = [], $item = "")
|
||||
{
|
||||
if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) {
|
||||
DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
|
||||
} else {
|
||||
Contact::remove($contact['id']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeSharer($importer, $contact, array $datarray = [], $item = "") {
|
||||
|
||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
|
||||
public static function removeSharer($importer, $contact, array $datarray = [], $item = "")
|
||||
{
|
||||
if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::FOLLOWER)) {
|
||||
DBA::update('contact', ['rel' => self::FOLLOWER], ['id' => $contact['id']]);
|
||||
} else {
|
||||
Contact::remove($contact['id']);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue