From: Hypolite Petovan Date: Sun, 14 Oct 2018 22:27:24 +0000 (-0400) Subject: Replace string fields by array in Module\Contact X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a883a99fe6533c4378091c37fac1c8e335c1bdeb;p=friendica.git Replace string fields by array in Module\Contact --- diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 74dac524a0..6c0d876050 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -281,45 +281,34 @@ class Contact extends BaseModule return; } - $updatefields = ["name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", - "poco", "network", "alias"]; - $update = []; + $updatefields = ['name', 'nick', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'network', 'alias']; + $fields = []; - if ($data["network"] == Protocol::OSTATUS) { - $result = Model\Contact::createFromProbe($uid, $data["url"], false); + if ($data['network'] == Protocol::OSTATUS) { + $result = Model\Contact::createFromProbe($uid, $data['url'], false); if ($result['success']) { - $update["subhub"] = true; + $fields['subhub'] = true; } } foreach ($updatefields AS $field) { - if (isset($data[$field]) && ($data[$field] != "")) { - $update[$field] = $data[$field]; + if (!empty($data[$field])) { + $fields[$field] = $data[$field]; } } - $update["nurl"] = normalise_link($data["url"]); + $fields['nurl'] = normalise_link($data['url']); - $query = ""; - - if (isset($data["priority"]) && ($data["priority"] != 0)) { - $query = "'priority' => '" . intval($data["priority"]) . "'"; - } - - foreach ($update AS $key => $value) { - if ($query != "") { - $query .= ", "; - } - - $query .= "'" . $key . "' => '" . DBA::escape($value) . "'"; + if (!empty($data['priority'])) { + $fields['priority'] = intval($data['priority']); } - if ($query == "") { + if (empty($fields)) { 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 Model\Contact::updateAvatar($data['photo'], local_user(), $contact_id, true);