* @}
*/
-/**
- * @name Contact_is
- *
- * Relationship types
- * @{
- */
-define('CONTACT_IS_FOLLOWER', 1);
-define('CONTACT_IS_SHARING', 2);
-define('CONTACT_IS_FRIEND', 3);
-/**
- * @}
- */
-
/**
* @name Update
*
* @name page/profile types
*
* PAGE_NORMAL is a typical personal profile account
- * PAGE_SOAPBOX automatically approves all friend requests as CONTACT_IS_SHARING, (readonly)
- * PAGE_COMMUNITY automatically approves all friend requests as CONTACT_IS_SHARING, but with
+ * PAGE_SOAPBOX automatically approves all friend requests as Contact::SHARING, (readonly)
+ * PAGE_COMMUNITY automatically approves all friend requests as Contact::SHARING, but with
* write access to wall and comments (no email and not included in page owner's ACL lists)
- * PAGE_FREELOVE automatically approves all friend requests as full friends (CONTACT_IS_FRIEND).
+ * PAGE_FREELOVE automatically approves all friend requests as full friends (Contact::FRIEND).
*
* @{
*/
'contributors_enabled' => false,
'is_translator' => false,
'is_translation_enabled' => false,
- 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) || ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)),
+ 'following' => (($uinfo[0]['rel'] == Contact::FOLLOWER) || ($uinfo[0]['rel'] == Contact::FRIEND)),
'follow_request_sent' => false,
'statusnet_blocking' => false,
'notifications' => false,
$sql_extra = '';
if ($qtype == 'friends') {
- $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
+ $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(Contact::SHARING), intval(Contact::FRIEND));
} elseif ($qtype == 'followers') {
- $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
+ $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(Contact::FOLLOWER), intval(Contact::FRIEND));
}
// friends and followers only for self
$menu[L10n::t("Poke")] = $poke_link;
}
- if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) &&
+ if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
in_array($item['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
$menu[L10n::t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
}
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Util\DateTimeFormat;
AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1",
intval($owner),
intval($cid),
- intval(CONTACT_IS_SHARING),
- intval(CONTACT_IS_FRIEND),
+ intval(Contact::SHARING),
+ intval(Contact::FRIEND),
intval(PAGE_COMMUNITY)
);
$dir_icon = '';
$relation_text = '';
switch ($contact['rel']) {
- case CONTACT_IS_FRIEND:
+ case Contact::FRIEND:
$dir_icon = 'images/lrarrow.gif';
$relation_text = L10n::t('You are mutual friends with %s');
break;
- case CONTACT_IS_FOLLOWER;
+
+ case Contact::FOLLOWER;
$dir_icon = 'images/larrow.gif';
$relation_text = L10n::t('You are sharing with %s');
break;
- case CONTACT_IS_SHARING;
+
+ case Contact::SHARING;
$dir_icon = 'images/rarrow.gif';
$relation_text = L10n::t('%s is sharing with you');
break;
+
default:
break;
}
$follow = '';
$follow_text = '';
if (in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_DFRN])) {
- if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
+ if ($contact['rel'] == Contact::FOLLOWER) {
$follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Connect/Follow");
- } elseif ($contact['rel'] == CONTACT_IS_FRIEND) {
+ } elseif ($contact['rel'] == Contact::FRIEND) {
$follow = System::baseUrl(true) . "/unfollow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Disconnect/Unfollow");
}
$sql_extra .= sprintf(" AND network = '%s' ", DBA::escape($nets));
}
- $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ", intval($sort_type)) : '');
+ $sql_extra2 = ((($sort_type > 0) && ($sort_type <= Contact::FRIEND)) ? sprintf(" AND `rel` = %d ", intval($sort_type)) : '');
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
return $tab_str;
}
-function contact_posts($a, $contact_id)
+function contact_posts(App $a, $contact_id)
{
$o = contacts_tab($a, $contact_id, 1);
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id]);
+
if (DBA::isResult($contact)) {
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
return $o;
}
-function _contact_detail_for_template($rr)
+function _contact_detail_for_template(array $rr)
{
$dir_icon = '';
$alt_text = '';
+
switch ($rr['rel']) {
- case CONTACT_IS_FRIEND:
+ case Contact::FRIEND:
$dir_icon = 'images/lrarrow.gif';
$alt_text = L10n::t('Mutual Friendship');
break;
- case CONTACT_IS_FOLLOWER;
+
+ case Contact::FOLLOWER;
$dir_icon = 'images/larrow.gif';
$alt_text = L10n::t('is a fan of yours');
break;
- case CONTACT_IS_SHARING;
+
+ case Contact::SHARING;
$dir_icon = 'images/rarrow.gif';
$alt_text = L10n::t('you are a fan of');
break;
+
default:
break;
}
$url = Contact::magicLink($rr['url']);
+
if (strpos($url, 'redir/') === 0) {
$sparkle = ' class="sparkle" ';
} else {
logger('dfrn_confirm: confirm - imported photos');
if ($network === NETWORK_DFRN) {
- $new_relation = CONTACT_IS_FOLLOWER;
- if (($relation == CONTACT_IS_SHARING) || ($duplex)) {
- $new_relation = CONTACT_IS_FRIEND;
+ $new_relation = Contact::FOLLOWER;
+ if (($relation == Contact::SHARING) || ($duplex)) {
+ $new_relation = Contact::FRIEND;
}
- if (($relation == CONTACT_IS_SHARING) && ($duplex)) {
+ if (($relation == Contact::SHARING) && ($duplex)) {
$duplex = 0;
}
if ($network === NETWORK_DIASPORA) {
if ($duplex) {
- $new_relation = CONTACT_IS_FRIEND;
+ $new_relation = Contact::FRIEND;
} else {
- $new_relation = CONTACT_IS_FOLLOWER;
+ $new_relation = Contact::FOLLOWER;
}
- if ($new_relation != CONTACT_IS_FOLLOWER) {
+ if ($new_relation != Contact::FOLLOWER) {
$writable = 1;
}
}
// reload contact info
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
- if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
+ if ((isset($new_relation) && $new_relation == Contact::FRIEND)) {
if (DBA::isResult($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
$ret = Diaspora::sendShare($user, $contact);
logger('share returns: ' . $ret);
logger('dfrn_confirm: request - photos imported');
- $new_relation = CONTACT_IS_SHARING;
- if (($relation == CONTACT_IS_FOLLOWER) || ($duplex)) {
- $new_relation = CONTACT_IS_FRIEND;
+ $new_relation = Contact::SHARING;
+ if (($relation == Contact::FOLLOWER) || ($duplex)) {
+ $new_relation = Contact::FRIEND;
}
- if (($relation == CONTACT_IS_FOLLOWER) && ($duplex)) {
+ if (($relation == Contact::FOLLOWER) && ($duplex)) {
$duplex = 0;
}
$combined = $r[0];
if ($combined['notify-flags'] & NOTIFY_CONFIRM) {
- $mutual = ($new_relation == CONTACT_IS_FRIEND);
+ $mutual = ($new_relation == Contact::FRIEND);
notification([
'type' => NOTIFY_CONFIRM,
'notify_flags' => $combined['notify-flags'],
$rino = $rino_remote;
}
- if (($r[0]['rel'] && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
+ if (($r[0]['rel'] && ($r[0]['rel'] != Contact::SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
$perm = 'rw';
} else {
$perm = 'r';
if (strlen($ret[0]['issued-id'])) {
notice(L10n::t('You have already introduced yourself here.') . EOL);
return;
- } elseif ($ret[0]['rel'] == CONTACT_IS_FRIEND) {
+ } elseif ($ret[0]['rel'] == Contact::FRIEND) {
notice(L10n::t('Apparently you are already friends with %s.', $a->profile['name']) . EOL);
return;
} else {
$r = q("SELECT `pending` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
(`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
`network` != '%s' LIMIT 1",
- intval(local_user()), DBA::escape(CONTACT_IS_FOLLOWER), DBA::escape(NETWORK_DFRN), DBA::escape(normalise_link($url)),
+ intval(local_user()), DBA::escape(Contact::FOLLOWER), DBA::escape(NETWORK_DFRN), DBA::escape(normalise_link($url)),
DBA::escape(normalise_link($url)), DBA::escape($url), DBA::escape(NETWORK_STATUSNET));
if ($r) {
AND NOT `item`.`moderated` AND $sql_extra4
$sql_extra3 $sql_extra $sql_range $sql_nets
ORDER BY `order_date` DESC LIMIT 100",
- intval(CONTACT_IS_SHARING),
- intval(CONTACT_IS_FRIEND),
+ intval(Contact::SHARING),
+ intval(Contact::FRIEND),
intval(local_user()),
intval(local_user())
);
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
$sql_extra2 $sql_extra3 $sql_range $sql_extra $sql_nets
ORDER BY `order_date` DESC $pager_sql",
- intval(CONTACT_IS_SHARING),
- intval(CONTACT_IS_FRIEND),
+ intval(Contact::SHARING),
+ intval(Contact::FRIEND),
intval(local_user()),
intval(local_user())
);
use Friendica\App;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Protocol\OStatus;
require_once('include/security.php');
}
}
- if (!in_array($contact['rel'], [CONTACT_IS_SHARING, CONTACT_IS_FRIEND]) && ($contact['network'] != NETWORK_FEED)) {
+ if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != NETWORK_FEED)) {
logger('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.');
hub_post_return();
}
`uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
intval($uid),
DBA::escape(NETWORK_OSTATUS),
- intval(CONTACT_IS_FRIEND),
- intval(CONTACT_IS_SHARING));
+ intval(Contact::FRIEND),
+ intval(Contact::SHARING));
if (!$r)
return($o.L10n::t("Error"));
LIMIT %d, 1",
intval($uid),
DBA::escape(NETWORK_OSTATUS),
- intval(CONTACT_IS_FRIEND),
- intval(CONTACT_IS_SHARING), $counter++);
+ intval(Contact::FRIEND),
+ intval(Contact::SHARING), $counter++);
if (!$r) {
$o .= L10n::t("Done");
// Have we ignored the person?
// If so we can not accept this post.
- //if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
+ //if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == Contact::FOLLOWER) || ($r[0]['blocked']))) {
if (DBA::isResult($r) && $r[0]['blocked']) {
logger('Ignoring this author.');
System::httpExit(202);
$return_url = $_SESSION['return_url'];
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
- $uid, CONTACT_IS_FRIEND, normalise_link($url),
+ $uid, Contact::FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
$contact = DBA::selectFirst('contact', [], $condition);
Contact::terminateFriendship($r[0], $contact);
}
}
- DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
+ DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
info(L10n::t('Contact unfollowed').EOL);
goaway(System::baseUrl().'/contacts/'.$contact['id']);
$submit = L10n::t('Submit Request');
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
- local_user(), CONTACT_IS_FRIEND, normalise_link($url),
+ local_user(), Contact::FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
$contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
$sql_extra = '';
if (!empty($x['mutual'])) {
- $sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
+ $sql_extra .= sprintf(" AND `rel` = %d ", intval(Contact::FRIEND));
}
if (!empty($x['exclude'])) {
// When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
// to one recipient. By default our selector allows multiple selects amongst all contacts.
- $sql_extra = sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
+ $sql_extra = sprintf(" AND `rel` = %d ", intval(Contact::FRIEND));
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", NETWORK_DFRN, NETWORK_DIASPORA);
$tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : '';
*/
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
*
'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"],
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', [
}
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?
DBA::escape($nick),
DBA::escape($photo),
DBA::escape(NETWORK_OSTATUS),
- intval(CONTACT_IS_FOLLOWER)
+ intval(self::FOLLOWER)
);
$contact_record = [
}
}
- 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']);
}
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = $master_table.`author-id` AND NOT `author`.`blocked`
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = $master_table.`owner-id` AND NOT `owner`.`blocked`
LEFT JOIN `user-item` ON `user-item`.`iid` = $master_table_key AND `user-item`.`uid` = %d",
- CONTACT_IS_SHARING, CONTACT_IS_FRIEND, GRAVITY_PARENT, intval($uid));
+ Contact::SHARING, Contact::FRIEND, GRAVITY_PARENT, intval($uid));
} else {
if (strpos($sql_commands, "`contact`.") !== false) {
$joins .= "LEFT JOIN `contact` ON `contact`.`id` = $master_table.`contact-id`";
$users = [];
$condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)",
- $parent['owner-id'], CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
+ $parent['owner-id'], Contact::SHARING, Contact::FRIEND];
+
$contacts = DBA::select('contact', ['uid'], $condition);
+
while ($contact = DBA::fetch($contacts)) {
$users[$contact['uid']] = $contact['uid'];
}
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
"SELECT `url` FROM `contact` WHERE `uid` = %d AND `id` = '%s' AND `rel` = %d",
intval($profile['uid']),
intval(remote_user()),
- intval(CONTACT_IS_FRIEND)
+ intval(Contact::FRIEND)
);
} else {
$r = q(
"SELECT `url` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `rel` = %d",
intval($profile['uid']),
DBA::escape(normalise_link(self::getMyURL())),
- intval(CONTACT_IS_FRIEND)
+ intval(Contact::FRIEND)
);
}
if ($r) {
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Protocol\Email;
use Friendica\Protocol\Feed;
'pubkey' => $data['pubkey'],
'priority' => $data['priority'],
'writable' => true,
- 'rel' => CONTACT_IS_SHARING];
+ 'rel' => Contact::SHARING];
$fieldnames = [];
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
- || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))
+ || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']);
$postvars['dissolve'] = '1';
}
- if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
+ if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
$postvars['data'] = $atom;
$postvars['perm'] = 'rw';
} else {
if ($dfrn_version >= 2.1) {
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
- || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))
+ || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
} else {
$item["owner-id"] = Contact::getIdForURL($importer["url"], 0);
}
- if (($importer["rel"] == CONTACT_IS_FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) {
+ if (($importer["rel"] == Contact::FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) {
logger("Contact ".$importer["id"]." is only follower and tgroup check was negative.", LOGGER_DEBUG);
return;
}
'name' => 'relay', 'nick' => 'relay',
'url' => $server_url, 'network' => NETWORK_DIASPORA,
'batch' => $server_url . '/receive/public',
- 'rel' => CONTACT_IS_FOLLOWER, 'blocked' => false,
+ 'rel' => Contact::FOLLOWER, 'blocked' => false,
'pending' => false, 'writable' => true];
$fields = array_merge($fields, $network_fields);
*/
// It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
// It is not removed by now. Possibly the code is needed?
- //if (!$is_comment && $contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
+ //if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
// dba::update(
// 'contact',
- // array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
+ // array('rel' => Contact::FRIEND, 'writable' => true),
// array('id' => $contact["id"], 'uid' => $contact["uid"])
// );
//
- // $contact["rel"] = CONTACT_IS_FRIEND;
+ // $contact["rel"] = Contact::FRIEND;
// logger("defining user ".$contact["nick"]." as friend");
//}
// Maybe blocked, don't accept.
return false;
// We are following this person?
- } elseif (($contact["rel"] == CONTACT_IS_SHARING) || ($contact["rel"] == CONTACT_IS_FRIEND)) {
+ } elseif (($contact["rel"] == Contact::SHARING) || ($contact["rel"] == Contact::FRIEND)) {
// Yes, then it is fine.
return true;
// Is it a post to a community?
- } elseif (($contact["rel"] == CONTACT_IS_FOLLOWER) && in_array($importer["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
+ } elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
// That's good
return true;
// Is the message a global user or a comment?
{
$a = get_app();
- if ($contact["rel"] == CONTACT_IS_SHARING) {
+ if ($contact["rel"] == Contact::SHARING) {
DBA::update(
'contact',
- ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
+ ['rel' => Contact::FRIEND, 'writable' => true],
['id' => $contact["id"], 'uid' => $importer["uid"]]
);
}
// If we are now friends, we are sending a share message.
// Normally we needn't to do so, but the first message could have been vanished.
- if (in_array($contact["rel"], [CONTACT_IS_FRIEND])) {
+ if (in_array($contact["rel"], [Contact::FRIEND])) {
$u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
if ($u) {
logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
Contact::updateAvatar($contact_record["photo"], $importer["uid"], $contact_record["id"]);
- // technically they are sharing with us (CONTACT_IS_SHARING),
+ // technically they are sharing with us (Contact::SHARING),
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
// we are going to change the relationship and make them a follower.
if (($importer["page-flags"] == PAGE_FREELOVE) && $sharing && $following) {
- $new_relation = CONTACT_IS_FRIEND;
+ $new_relation = Contact::FRIEND;
} elseif (($importer["page-flags"] == PAGE_FREELOVE) && $sharing) {
- $new_relation = CONTACT_IS_SHARING;
+ $new_relation = Contact::SHARING;
} else {
- $new_relation = CONTACT_IS_FOLLOWER;
+ $new_relation = Contact::FOLLOWER;
}
$r = q(
/*
switch ($contact["rel"]) {
- case CONTACT_IS_FRIEND:
+ case Contact::FRIEND:
$following = true;
$sharing = true;
- case CONTACT_IS_SHARING:
+
+ case Contact::SHARING:
$following = false;
$sharing = true;
- case CONTACT_IS_FOLLOWER:
+
+ case Contact::FOLLOWER:
$following = true;
$sharing = false;
}
AND `uid` = %d AND `rel` != %d",
DBA::escape(NETWORK_DIASPORA),
intval($uid),
- intval(CONTACT_IS_SHARING)
+ intval(Contact::SHARING)
);
}
if ($aliaslink != '') {
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $aliaslink, NETWORK_STATUSNET,
- CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
+ Contact::SHARING, Contact::FRIEND];
$contact = DBA::selectFirst('contact', [], $condition);
}
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], normalise_link($author["author-link"]), normalise_link($aliaslink),
- NETWORK_STATUSNET, CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
+ NETWORK_STATUSNET, Contact::SHARING, Contact::FRIEND];
$contact = DBA::selectFirst('contact', [], $condition);
}
if (!DBA::isResult($contact) && ($addr != '')) {
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $addr, NETWORK_STATUSNET,
- CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
+ Contact::SHARING, Contact::FRIEND];
$contact = DBA::selectFirst('contact', [], $condition);
}
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Util\DateTimeFormat;
require_once 'include/dba.php';
}
// Check Diaspora contacts or followers once a week
- if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
+ if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
$contact['priority'] = 4;
}
// only expose our real email address to true friends
- if (($contact['rel'] == CONTACT_IS_FRIEND) && !$contact['blocked']) {
+ if (($contact['rel'] == Contact::FRIEND) && !$contact['blocked']) {
if ($reply_to) {
$headers = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $reply_to.'>' . "\n";
$headers .= 'Sender: ' . $local_user['email'] . "\n";
AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch`",
DBA::escape(NETWORK_DIASPORA),
intval($owner['uid']),
- intval(CONTACT_IS_SHARING)
+ intval(Contact::SHARING)
);
// Fetch the participation list
}
$condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
- 'pending' => false, 'archive' => false, 'rel' => [CONTACT_IS_FOLLOWER, CONTACT_IS_FRIEND]];
+ 'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
+
$r2 = DBA::toArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
$r = array_merge($r2, $r1);
}
// Diaspora users, archived users and followers are only checked if they still exist.
- if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
+ if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
$last_updated = PortableContact::lastUpdated($contact["url"], true);
$updated = DateTimeFormat::utcNow();
+
if ($last_updated) {
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
Contact::markForArchival($contact);
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
}
+
return;
}
logger('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
-
if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) {
logger("$url appears to be dead - marking for death ");
// Will only do this once per notify-enabled OStatus contact
// or if relationship changes
- $stat_writeable = ((($contact['notify']) && ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['rel'] == CONTACT_IS_FRIEND)) ? 1 : 0);
+ $stat_writeable = ((($contact['notify']) && ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND)) ? 1 : 0);
// Contacts from OStatus are always writable
if ($contact['network'] === NETWORK_OSTATUS) {
// Are we allowed to import from this person?
- if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked']) {
+ if ($contact['rel'] == Contact::FOLLOWER || $contact['blocked']) {
// set the last-update so we don't keep polling
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return;
$xml = $ret['body'];
} elseif ($contact['network'] === NETWORK_MAIL) {
-
logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
logger("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG);
$metas = Email::messageMeta($mbox, implode(',', $msgs));
+
if (count($metas) != count($msgs)) {
logger("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG);
} else {
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
- if (strlen($hub) && $hub_update && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
+ if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
$hubs = explode(',', $hub);
if (count($hubs)) {