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
|
@ -514,18 +514,21 @@ function contacts_content(App $a)
|
|||
$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;
|
||||
}
|
||||
|
@ -590,10 +593,10 @@ function contacts_content(App $a)
|
|||
$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");
|
||||
}
|
||||
|
@ -781,7 +784,7 @@ function contacts_content(App $a)
|
|||
$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 ",
|
||||
|
@ -905,11 +908,12 @@ function contacts_tab($a, $contact_id, $active_tab)
|
|||
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"]));
|
||||
|
@ -919,28 +923,33 @@ function contact_posts($a, $contact_id)
|
|||
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 {
|
||||
|
|
|
@ -305,12 +305,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -347,12 +347,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
|
||||
// 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);
|
||||
|
@ -547,12 +547,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -598,7 +598,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
$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'],
|
||||
|
|
|
@ -375,7 +375,7 @@ function dfrn_notify_content(App $a) {
|
|||
$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';
|
||||
|
|
|
@ -309,7 +309,7 @@ function dfrn_request_post(App $a)
|
|||
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 {
|
||||
|
|
|
@ -65,7 +65,7 @@ function follow_content(App $a)
|
|||
$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) {
|
||||
|
|
|
@ -776,8 +776,8 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
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())
|
||||
);
|
||||
|
@ -796,8 +796,8 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
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())
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Protocol\OStatus;
|
||||
|
||||
require_once('include/security.php');
|
||||
|
@ -113,7 +114,7 @@ function pubsub_post(App $a)
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ function repair_ostatus_content(App $a) {
|
|||
`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"));
|
||||
|
@ -43,8 +43,8 @@ function repair_ostatus_content(App $a) {
|
|||
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");
|
||||
|
|
|
@ -171,7 +171,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
// 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);
|
||||
|
|
|
@ -27,7 +27,7 @@ function unfollow_post(App $a)
|
|||
$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);
|
||||
|
||||
|
@ -43,7 +43,7 @@ function unfollow_post(App $a)
|
|||
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']);
|
||||
|
@ -66,7 +66,7 @@ function unfollow_content(App $a)
|
|||
$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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue