X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/7bcd30edb23fcc1872f0a6772ab91b3c9d8b4779..cd26522ba6ff68c18e1504b022ca92f4d01827be:/Classes/class-notes.php diff --git a/Classes/class-notes.php b/Classes/class-notes.php index ca9f604..d6686e9 100644 --- a/Classes/class-notes.php +++ b/Classes/class-notes.php @@ -6,32 +6,33 @@ class Notes { // OKAY CLASS GET YOUR NOTEPAD OUT /** * Find function for Notes * @param array $query The query to search for -- ["ip" => "127.0.0.1", "nick" => "bob", "account" => "bob", "id" => "lol] - * @return array|NULL Returns an array of objects (notes) + * @return array Returns an array of objects (notes) */ - public static function find(array $query) : array|NULL + public static function find(array $query) : array { global $config; read_config_db(); if (!isset($config['notes'])) - return NULL; + return []; $notes = []; foreach ($query as $key => $value) - { - foreach (get_config("notes") as $nkey => $nvalue) + { + foreach ($config['notes'] as $nkey => $nvalue) // $nkey = "ip" "nick" "account", $nvalue = array { - if ($value != $nvalue) - continue; - - $note = (object)[]; - $note->id = $nkey; - $note->type = $key; - $note->data - $value; - $note->note = $nvalue; - $notes[] = $note; + foreach ($nvalue as $k => $n) // $k = "127.0.0.1", "bob", "bobsaccount", $n = array of notes [id => note] + { + if ($value != $k) + continue; + $note = []; + $note["type"] = $nkey; + $note["data"] = $k; + $note["notes"] = $n; + $notes[$key] = $note; + } } } - return !empty($notes) ? $notes : NULL; + return !empty($notes) ? $notes : []; } /**