]> git.mxchange.org Git - friendica.git/commitdiff
Replace string fields by array in Module\Contact
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 14 Oct 2018 22:27:24 +0000 (18:27 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 14 Oct 2018 22:27:24 +0000 (18:27 -0400)
src/Module/Contact.php

index 74dac524a0bbb91d1c241805349d60cfd039de0b..6c0d876050869684cd60cd0daebd581de9161383 100644 (file)
@@ -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);