Update new function

update function name and statements
This commit is contained in:
Adam Magness 2018-01-09 09:48:31 -05:00
parent fd1515eff4
commit edfb08a779
1 changed files with 30 additions and 30 deletions

View File

@ -1088,7 +1088,7 @@ class Contact extends BaseObject
* @param string $network * @param string $network
* @return boolean|string * @return boolean|string
*/ */
function new_contact($uid, $url, $interactive = false, $network = '') public static function add($uid, $url, $interactive = false, $network = '')
{ {
$result = array('cid' => -1, 'success' => false, 'message' => ''); $result = array('cid' => -1, 'success' => false, 'message' => '');
@ -1216,44 +1216,44 @@ class Contact extends BaseObject
$new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING); $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
// create contact record // create contact record
q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`, dba::insert(
`writable`, `hidden`, `blocked`, `readonly`, `pending`, `subhub` ) 'contact',
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0, %d ) ", [
intval($uid), 'uid' => $uid,
dbesc(datetime_convert()), 'created' => datetime_convert(),
dbesc($ret['url']), 'url' => $ret['url'],
dbesc(normalise_link($ret['url'])), 'nurl' => normalise_link($ret['url']),
dbesc($ret['addr']), 'addr' => $ret['addr'],
dbesc($ret['alias']), 'alias' => $ret['alias'],
dbesc($ret['batch']), 'batch' => $ret['batch'],
dbesc($ret['notify']), `notify` => $ret['notify'],
dbesc($ret['poll']), `poll` => $ret['poll'],
dbesc($ret['poco']), `poco` => $ret['poco'],
dbesc($ret['name']), `name` => $ret['name'],
dbesc($ret['nick']), `nick` => $ret['nick'],
dbesc($ret['network']), `network` => $ret['network'],
dbesc($ret['pubkey']), `pubkey` => $ret['pubkey'],
intval($new_relation), `rel` => $new_relation,
intval($ret['priority']), `priority` => $ret['priority'],
intval($writeable), `writable` => $writeable,
intval($hidden), `hidden` => $hidden,
intval($subhub) `blocked` => 0,
`readonly` => 0,
`pending` => 0,
`subhub` => $subhub
]
); );
} }
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1", $r = dba::select('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid], ['limit' => 1]);
dbesc($ret['url']),
dbesc($ret['network']),
intval($uid)
);
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
$result['message'] .= t('Unable to retrieve contact information.') . EOL; $result['message'] .= t('Unable to retrieve contact information.') . EOL;
return $result; return $result;
} }
$contact = $r[0]; $contact = $r;
$contact_id = $r[0]['id']; $contact_id = $r['id'];
$result['cid'] = $contact_id; $result['cid'] = $contact_id;
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact_id); Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact_id);