]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - Classes/class-paneluser.php
Merge branch 'main' of https://github.com/unrealircd/unrealircd-webpanel
[irc/unrealircd/unrealircd-webpanel.git] / Classes / class-paneluser.php
index e9abb9b31ae4cd8c86213da22e9e70ae47e844c8..0a3cf8a9548e10a8a2e476ff15ad4614699b25c9 100644 (file)
@@ -27,6 +27,8 @@ define('PERMISSION_SPAMFILTER_ADD', 'sf_add');
 define('PERMISSION_SPAMFILTER_DEL', 'sf_del'); 
 /** Can rehash servers */
 define('PERMISSION_REHASH', 'rhs');
+/** Can install and uninstall plugins */
+define('PERMISSION_MANAGE_PLUGINS', 'mng_plg');
 /**
  * PanelUser
  * This is the User class for the SQL_Auth plugin
@@ -101,23 +103,25 @@ class PanelUser
 
        /**
         * Add user meta data
-        * You may use arrays or strings but both parameter types must match
+        * If using an array for the first param then you
+        * must also use an array for the second param
         * @param array|string $key
-        * @param array|string $value
+        * @param array|string|int|bool|null $value
         */
-       function add_meta(array|string $key, array|string $value)
+       function add_meta(array|string $key, array|string|int|bool|null $value)
        {
                
-               if (!$key || !$value)
+               if (!$key)
                        return false;
 
-               if (is_string($key) && is_string($value))
-                       $arr[$key] = $value;
-
-               else
+               if (is_array($key))
+               {
                        foreach ($key as $i => $k)
                                $arr[$k] = $value[$i];
-               
+               } else {
+                       $arr[$key] = $value;
+               }
+
                foreach($arr as $k => $v)
                {
                        $meta = [
@@ -338,6 +342,7 @@ function get_panel_user_permission_list()
 {
        $list = [
                "Can add/delete/edit Admin Panel users" => PERMISSION_MANAGE_USERS,
+               "Can add/delete/manage plugins" => PERMISSION_MANAGE_PLUGINS,
                "Can ban/kill IRC users" => PERMISSION_BAN_USERS,
                "Can change properties of a user, i.e. vhost, modes and more" => PERMISSION_EDIT_USER,
                "Can change properties of a channel, i.e. topic, modes and more" => PERMISSION_EDIT_CHANNEL,
@@ -350,6 +355,7 @@ function get_panel_user_permission_list()
                "Can remove server ban exceptions" => PERMISSION_BAN_EXCEPTION_DEL,
                "Can add Spamfilter entries" => PERMISSION_SPAMFILTER_ADD,
                "Can remove Spamfilter entries" => PERMISSION_SPAMFILTER_DEL
+
        ];
        Hook::run(HOOKTYPE_USER_PERMISSION_LIST, $list); // so plugin writers can add their own permissions
        return $list;