Replace string fields by array in Module\Contact
This commit is contained in:
parent
12ddb3bb54
commit
a883a99fe6
1 changed files with 12 additions and 23 deletions
|
@ -281,45 +281,34 @@ class Contact extends BaseModule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$updatefields = ["name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm",
|
$updatefields = ['name', 'nick', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'network', 'alias'];
|
||||||
"poco", "network", "alias"];
|
$fields = [];
|
||||||
$update = [];
|
|
||||||
|
|
||||||
if ($data["network"] == Protocol::OSTATUS) {
|
if ($data['network'] == Protocol::OSTATUS) {
|
||||||
$result = Model\Contact::createFromProbe($uid, $data["url"], false);
|
$result = Model\Contact::createFromProbe($uid, $data['url'], false);
|
||||||
|
|
||||||
if ($result['success']) {
|
if ($result['success']) {
|
||||||
$update["subhub"] = true;
|
$fields['subhub'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($updatefields AS $field) {
|
foreach ($updatefields AS $field) {
|
||||||
if (isset($data[$field]) && ($data[$field] != "")) {
|
if (!empty($data[$field])) {
|
||||||
$update[$field] = $data[$field];
|
$fields[$field] = $data[$field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$update["nurl"] = normalise_link($data["url"]);
|
$fields['nurl'] = normalise_link($data['url']);
|
||||||
|
|
||||||
$query = "";
|
if (!empty($data['priority'])) {
|
||||||
|
$fields['priority'] = intval($data['priority']);
|
||||||
if (isset($data["priority"]) && ($data["priority"] != 0)) {
|
|
||||||
$query = "'priority' => '" . intval($data["priority"]) . "'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($update AS $key => $value) {
|
if (empty($fields)) {
|
||||||
if ($query != "") {
|
|
||||||
$query .= ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$query .= "'" . $key . "' => '" . DBA::escape($value) . "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($query == "") {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = DBA::update('contact', $query, ['id' => $contact_id, 'uid' => local_user()]);
|
$r = DBA::update('contact', $fields, ['id' => $contact_id, 'uid' => local_user()]);
|
||||||
|
|
||||||
// Update the entry in the contact table
|
// Update the entry in the contact table
|
||||||
Model\Contact::updateAvatar($data['photo'], local_user(), $contact_id, true);
|
Model\Contact::updateAvatar($data['photo'], local_user(), $contact_id, true);
|
||||||
|
|
Loading…
Reference in a new issue