<?php
use Friendica\App;
+use Friendica\Core\System;
require_once 'include/probe.php';
require_once 'include/socgraph.php';
// make sure to not overwrite existing values with blank entries
foreach ($ret AS $key => $val) {
- if (isset($r[0][$key]) AND ($r[0][$key] != "") AND ($val == ""))
+ if (isset($r[0][$key]) && ($r[0][$key] != "") && ($val == ""))
$ret[$key] = $r[0][$key];
- if (isset($r[0][$key]) AND ($ret[$key] != $r[0][$key]))
+ if (isset($r[0][$key]) && ($ret[$key] != $r[0][$key]))
$update = true;
}
if ($ret['network'] === NETWORK_DFRN) {
if ($interactive) {
if (strlen($a->path)) {
- $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']);
+ $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
} else {
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
}
if (dbm::is_result($r)) {
// update contact
- if ($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
- q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d",
- intval(CONTACT_IS_FRIEND),
- intval($subhub),
- intval($r[0]['id']),
- intval($uid)
- );
- }
+ $new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+
+ $fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false);
+ dba::update('contact', $fields, array('id' => $r[0]['id']));
} else {
// check service class limits
return $result;
}
- $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+ $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
// create contact record
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`,