diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 7f8acc164..5493fcee0 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -747,56 +747,61 @@ class e_navigation */ function setIconArray() { - if(!defined('E_32_MAIN')) + if (!defined('E_32_MAIN')) + { + // e107::getCoreTemplate('admin_icons'); + e107::loadAdminIcons(); + } + + + $iconDefinitions = array( + 'main' => 'E_32_MAIN', + 'admin' => 'E_32_ADMIN', + 'admin_pass' => 'E_32_ADPASS', + 'banlist' => 'E_32_BANLIST', + 'cache' => 'E_32_CACHE', + 'comment' => 'E_32_COMMENT', + 'credits' => 'E_32_CREDITS', + 'cron' => 'E_32_CRON', + 'custom' => 'E_32_CUST', + // 'custom_field' => 'E_32_CUSTOMFIELD', + 'database' => 'E_32_DATAB', + 'docs' => 'E_32_DOCS', + // 'download' => 'E_32_DOWNL', + 'emoticon' => 'E_32_EMOTE', + 'filemanage' => 'E_32_FILE', + 'fileinspector' => 'E_32_INSPECT', + 'frontpage' => 'E_32_FRONT', + 'image' => 'E_32_IMAGES', + 'language' => 'E_32_LANGUAGE', + 'links' => 'E_32_LINKS', + 'mail' => 'E_32_MAIL', + 'maintain' => 'E_32_MAINTAIN', + 'menus' => 'E_32_MENUS', + 'meta' => 'E_32_META', + 'newsfeed' => 'E_32_NEWSFEED', + 'news' => 'E_32_NEWS', + 'notify' => 'E_32_NOTIFY', + 'phpinfo' => 'E_32_PHP', + 'plug_manage' => 'E_32_PLUGMANAGER', + 'poll' => 'E_32_POLLS', + 'prefs' => 'E_32_PREFS', + 'search' => 'E_32_SEARCH', + 'syslogs' => 'E_32_ADMINLOG', + 'theme_manage' => 'E_32_THEMEMANAGER', + 'upload' => 'E_32_UPLOADS', + 'eurl' => 'E_32_EURL', + 'userclass' => 'E_32_USERCLASS', + 'user_extended' => 'E_32_USER_EXTENDED', + 'users' => 'E_32_USER', + 'wmessage' => 'E_32_WELCOME' + ); + + $this->iconArray = array(); + foreach($iconDefinitions as $key => $constant) { - // e107::getCoreTemplate('admin_icons'); - e107::loadAdminIcons(); + $this->iconArray[$key] = defset($constant, '(missing)'); } - - - $this->iconArray = array( - 'main' => E_32_MAIN, - 'admin' => E_32_ADMIN, - 'admin_pass' => E_32_ADPASS, - 'banlist' => E_32_BANLIST, - 'cache' => E_32_CACHE, - 'comment' => E_32_COMMENT, - 'credits' => E_32_CREDITS, - 'cron' => E_32_CRON, - 'custom' => E_32_CUST, - // 'custom_field' => E_32_CUSTOMFIELD, - 'database' => E_32_DATAB, - 'docs' => E_32_DOCS, - //'download' => E_32_DOWNL, - 'emoticon' => E_32_EMOTE, - 'filemanage' => E_32_FILE, - 'fileinspector' => E_32_INSPECT, - 'frontpage' => E_32_FRONT, - 'image' => E_32_IMAGES, - 'language' => E_32_LANGUAGE, - 'links' => E_32_LINKS, - 'mail' => E_32_MAIL, - 'maintain' => E_32_MAINTAIN, - 'menus' => E_32_MENUS, - 'meta' => E_32_META, - 'newsfeed' => E_32_NEWSFEED, - 'news' => E_32_NEWS, - 'notify' => E_32_NOTIFY, - 'phpinfo' => E_32_PHP, - 'plug_manage' => E_32_PLUGMANAGER, - 'poll' => E_32_POLLS, - 'prefs' => E_32_PREFS, - 'search' => E_32_SEARCH, - 'syslogs' => E_32_ADMINLOG, - 'theme_manage' => E_32_THEMEMANAGER, - 'upload' => E_32_UPLOADS, - 'eurl' => E_32_EURL, - 'userclass' => E_32_USERCLASS, - 'user_extended' => E_32_USER_EXTENDED, - 'users' => E_32_USER, - 'wmessage' => E_32_WELCOME - ); - } @@ -894,6 +899,68 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } return $this->admin_cat; } + + private function adminLinksArray() // Assuming this is inside a class; adjust the name if needed + { + // Initial array with constant names as strings + $array_definitions = array( + 0 => array(e_ADMIN_ABS.'administrator.php', 'ADLAN_8', 'ADLAN_9', '3', 2, 'E_16_ADMIN', 'E_32_ADMIN'), + 1 => array(e_ADMIN_ABS.'updateadmin.php', 'ADLAN_10', 'ADLAN_11', false, 2, 'E_16_ADPASS', 'E_32_ADPASS'), + 2 => array(e_ADMIN_ABS.'banlist.php', 'ADLAN_34', 'ADLAN_35', '4', 2, 'E_16_BANLIST', 'E_32_BANLIST'), + 4 => array(e_ADMIN_ABS.'cache.php', 'ADLAN_74', 'ADLAN_75', 'C', 1, 'E_16_CACHE', 'E_32_CACHE'), + 5 => array(e_ADMIN_ABS.'cpage.php', 'ADLAN_42', 'ADLAN_43', '5|J', 3, 'E_16_CUST', 'E_32_CUST'), + 6 => array(e_ADMIN_ABS.'db.php', 'ADLAN_44', 'ADLAN_45', '0', 4, 'E_16_DATAB', 'E_32_DATAB'), + // 7 => array(e_ADMIN_ABS.'download.php', 'ADLAN_24', 'ADLAN_25', 'R', 3, 'E_16_DOWNL', 'E_32_DOWNL'), + 8 => array(e_ADMIN_ABS.'emoticon.php', 'ADLAN_58', 'ADLAN_59', 'F', 1, 'E_16_EMOTE', 'E_32_EMOTE'), + // 9 => array(e_ADMIN_ABS.'filemanager.php', 'ADLAN_30', 'ADLAN_31', '6', 5, 'E_16_FILE', 'E_32_FILE'), + 9 => array(e_ADMIN_ABS.'history.php', 'LAN_HISTORY', 'LAN_HISTORY', '7', 4, 'E_16_UNDO', 'E_32_UNDO'), + 10 => array(e_ADMIN_ABS.'frontpage.php', 'ADLAN_60', 'ADLAN_61', 'G', 1, 'E_16_FRONT', 'E_32_FRONT'), + 11 => array(e_ADMIN_ABS.'image.php', 'LAN_MEDIAMANAGER', 'LAN_MEDIAMANAGER', 'A', 5, 'E_16_IMAGES', 'E_32_IMAGES'), + 12 => array(e_ADMIN_ABS.'links.php', 'LAN_NAVIGATION', 'ADLAN_139', 'I', 1, 'E_16_LINKS', 'E_32_LINKS'), + 13 => array(e_ADMIN_ABS.'wmessage.php', 'ADLAN_28', 'ADLAN_29', 'M', 3, 'E_16_WELCOME', 'E_32_WELCOME'), + 14 => array(e_ADMIN_ABS.'ugflag.php', 'ADLAN_40', 'ADLAN_41', '9', 4, 'E_16_MAINTAIN', 'E_32_MAINTAIN'), + 15 => array(e_ADMIN_ABS.'menus.php', 'ADLAN_6', 'ADLAN_7', '2', 5, 'E_16_MENUS', 'E_32_MENUS'), + 16 => array(e_ADMIN_ABS.'meta.php', 'ADLAN_66', 'ADLAN_67', 'T', 1, 'E_16_META', 'E_32_META'), + 17 => array(e_ADMIN_ABS.'newspost.php', 'ADLAN_0', 'ADLAN_1', 'H|N|7|H0|H1|H2|H3|H4|H5', 3, 'E_16_NEWS', 'E_32_NEWS'), + 18 => array(e_ADMIN_ABS.'phpinfo.php', 'ADLAN_68', 'ADLAN_69', '0', 20, 'E_16_PHP', 'E_32_PHP'), + 19 => array(e_ADMIN_ABS.'prefs.php', 'LAN_PREFS', 'ADLAN_5', '1', 1, 'E_16_PREFS', 'E_32_PREFS'), + 20 => array(e_ADMIN_ABS.'search.php', 'LAN_SEARCH', 'ADLAN_143', 'X', 1, 'E_16_SEARCH', 'E_32_SEARCH'), + 21 => array(e_ADMIN_ABS.'admin_log.php', 'ADLAN_155', 'ADLAN_156', 'S', 4, 'E_16_ADMINLOG', 'E_32_ADMINLOG'), + 22 => array(e_ADMIN_ABS.'theme.php', 'ADLAN_140', 'ADLAN_141', '1|TMP', 5, 'E_16_THEMEMANAGER', 'E_32_THEMEMANAGER'), + 23 => array(e_ADMIN_ABS.'upload.php', 'ADLAN_72', 'ADLAN_73', 'V', 3, 'E_16_UPLOADS', 'E_32_UPLOADS'), + 24 => array(e_ADMIN_ABS.'users.php', 'ADLAN_36', 'ADLAN_37', '4|U0|U1|U2|U3', 2, 'E_16_USER', 'E_32_USER'), + 25 => array(e_ADMIN_ABS.'userclass2.php', 'ADLAN_38', 'ADLAN_39', '4', 2, 'E_16_USERCLASS', 'E_32_USERCLASS'), + 26 => array(e_ADMIN_ABS.'language.php', 'ADLAN_132', 'ADLAN_133', 'L', 1, 'E_16_LANGUAGE', 'E_32_LANGUAGE'), + 27 => array(e_ADMIN_ABS.'mailout.php', 'ADLAN_136', 'ADLAN_137', 'W', 2, 'E_16_MAIL', 'E_32_MAIL'), + 28 => array(e_ADMIN_ABS.'users_extended.php', 'ADLAN_78', 'ADLAN_79', '4', 2, 'E_16_USER_EXTENDED', 'E_32_USER_EXTENDED'), + 29 => array(e_ADMIN_ABS.'fileinspector.php', 'ADLAN_147', 'ADLAN_148', 'Y', 4, 'E_16_INSPECT', 'E_32_INSPECT'), + 30 => array(e_ADMIN_ABS.'notify.php', 'ADLAN_149', 'ADLAN_150', 'O', 4, 'E_16_NOTIFY', 'E_32_NOTIFY'), + 31 => array(e_ADMIN_ABS.'cron.php', 'ADLAN_157', 'ADLAN_158', 'U', 4, 'E_16_CRON', 'E_32_CRON'), + 32 => array(e_ADMIN_ABS.'eurl.php', 'ADLAN_159', 'ADLAN_160', 'K', 1, 'E_16_EURL', 'E_32_EURL'), + 33 => array(e_ADMIN_ABS.'plugin.php', 'ADLAN_98', 'ADLAN_99', 'Z', 5, 'E_16_PLUGMANAGER', 'E_32_PLUGMANAGER'), + 34 => array(e_ADMIN_ABS.'docs.php', 'ADLAN_12', 'ADLAN_13', false, 20, 'E_16_DOCS', 'E_32_DOCS'), + // 35 => array('#TODO', 'System Info', 'System Information', '', 20, '', ''), + 36 => array(e_ADMIN_ABS.'credits.php', 'LAN_CREDITS', 'LAN_CREDITS', false, 20, 'E_16_E107', 'E_32_E107'), + // 37 => array(e_ADMIN_ABS.'custom_field.php', 'ADLAN_161', 'ADLAN_162', 'U', 4, 'E_16_CUSTOMFIELD', 'E_32_CUSTOMFIELD), + 38 => array(e_ADMIN_ABS.'comment.php', 'LAN_COMMENTMAN', 'LAN_COMMENTMAN', 'B', 5, 'E_16_COMMENT', 'E_32_COMMENT'), + ); + + // Process the array, applying defset() to language and icon constants + $array_functions = array(); + foreach ($array_definitions as $key => $row) { + $array_functions[$key] = array( + 0 => $row[0], // File path (no constant) + 1 => defset($row[1], 'Untitled'), // Title (e.g., ADLAN_8) + 2 => defset($row[2], 'No description'), // Description (e.g., ADLAN_9) + 3 => $row[3], // Permission/flag (no constant) + 4 => $row[4], // Group/order (no constant) + 5 => defset($row[5], 'e-' . strtolower(str_replace('E_16_', '', $row[5])) . '-16'), // Small icon (e.g., E_16_ADMIN) + 6 => defset($row[6], 'e-' . strtolower(str_replace('E_32_', '', $row[6])) . '-32') // Large icon (e.g., E_32_ADMIN) + ); + } + + return $array_functions; // Or assign to a class property like $this->array_functions if needed + } // Previously $array_functions variable. @@ -903,15 +970,16 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } */ function adminLinks($mode=false) { - + $E_16_PLUGMANAGER = defset('E_16_PLUGMANAGER'); + if($mode === 'plugin') { - return $this->pluginLinks(E_16_PLUGMANAGER, "array") ; + return $this->pluginLinks($E_16_PLUGMANAGER, "array") ; } if($mode === 'plugin2') { - return $this->pluginLinks(E_16_PLUGMANAGER, "standard") ; + return $this->pluginLinks($E_16_PLUGMANAGER, "standard") ; } @@ -937,9 +1005,9 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } * */ $array_sub_functions = array(); - $array_sub_functions[17][] = array(e_ADMIN.'newspost.php', LAN_MANAGE, ADLAN_3, 'H', 3, E_16_MANAGE, E_32_MANAGE); - $array_sub_functions[17][] = array(e_ADMIN.'newspost.php?create', LAN_CREATE, ADLAN_2, 'H', 3, E_16_CREATE, E_32_CREATE); - $array_sub_functions[17][] = array(e_ADMIN.'newspost.php?pref', LAN_PREFS, LAN_PREFS, 'H', 3, E_16_SETTINGS, E_32_SETTINGS); + $array_sub_functions[17][] = array(e_ADMIN.'newspost.php', LAN_MANAGE, ADLAN_3, 'H', 3, defset('E_16_MANAGE'), defset('E_32_MANAGE')); + $array_sub_functions[17][] = array(e_ADMIN.'newspost.php?create', LAN_CREATE, ADLAN_2, 'H', 3, defset('E_16_CREATE'), defset('E_32_CREATE')); + $array_sub_functions[17][] = array(e_ADMIN.'newspost.php?pref', LAN_PREFS, LAN_PREFS, 'H', 3, defset('E_16_SETTINGS'), defset('E_32_SETTINGS')); return $array_sub_functions; } @@ -950,51 +1018,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } //XXX DO NOT EDIT without first checking perms in user_handler.php !!!! - $array_functions = array( - 0 => array(e_ADMIN_ABS.'administrator.php', ADLAN_8, ADLAN_9, '3', 2, E_16_ADMIN, E_32_ADMIN), - 1 => array(e_ADMIN_ABS.'updateadmin.php', ADLAN_10, ADLAN_11, false, 2, E_16_ADPASS, E_32_ADPASS), - 2 => array(e_ADMIN_ABS.'banlist.php', ADLAN_34, ADLAN_35, '4', 2, E_16_BANLIST, E_32_BANLIST), - 4 => array(e_ADMIN_ABS.'cache.php', ADLAN_74, ADLAN_75, 'C', 1, E_16_CACHE, E_32_CACHE), - 5 => array(e_ADMIN_ABS.'cpage.php', ADLAN_42, ADLAN_43, '5|J', 3, E_16_CUST, E_32_CUST), - 6 => array(e_ADMIN_ABS.'db.php', ADLAN_44, ADLAN_45, '0', 4, E_16_DATAB, E_32_DATAB), - // 7 => array(e_ADMIN.'download.php', ADLAN_24, ADLAN_25, 'R', 3, E_16_DOWNL, E_32_DOWNL), - 8 => array(e_ADMIN_ABS.'emoticon.php', ADLAN_58, ADLAN_59, 'F', 1, E_16_EMOTE, E_32_EMOTE), - // 9 => array(e_ADMIN.'filemanager.php', ADLAN_30, ADLAN_31, '6', 5, E_16_FILE, E_32_FILE), // replaced by media-manager - 9 => array(e_ADMIN.'history.php', LAN_HISTORY, LAN_HISTORY, '7', 4, E_16_UNDO, E_32_UNDO), - - 10 => array(e_ADMIN_ABS.'frontpage.php', ADLAN_60, ADLAN_61, 'G', 1, E_16_FRONT, E_32_FRONT), - 11 => array(e_ADMIN_ABS.'image.php', LAN_MEDIAMANAGER, LAN_MEDIAMANAGER, 'A', 5, E_16_IMAGES, E_32_IMAGES), - 12 => array(e_ADMIN_ABS.'links.php', LAN_NAVIGATION, ADLAN_139, 'I', 1, E_16_LINKS, E_32_LINKS), - 13 => array(e_ADMIN_ABS.'wmessage.php', ADLAN_28, ADLAN_29, 'M', 3, E_16_WELCOME, E_32_WELCOME), - 14 => array(e_ADMIN_ABS.'ugflag.php', ADLAN_40, ADLAN_41, '9', 4, E_16_MAINTAIN, E_32_MAINTAIN), - 15 => array(e_ADMIN_ABS.'menus.php', ADLAN_6, ADLAN_7, '2', 5, E_16_MENUS, E_32_MENUS), - 16 => array(e_ADMIN_ABS.'meta.php', ADLAN_66, ADLAN_67, 'T', 1, E_16_META, E_32_META), - 17 => array(e_ADMIN_ABS.'newspost.php', ADLAN_0, ADLAN_1, 'H|N|7|H0|H1|H2|H3|H4|H5', 3, E_16_NEWS, E_32_NEWS), - 18 => array(e_ADMIN_ABS.'phpinfo.php', ADLAN_68, ADLAN_69, '0', 20, E_16_PHP, E_32_PHP), - 19 => array(e_ADMIN_ABS.'prefs.php', LAN_PREFS, ADLAN_5, '1', 1, E_16_PREFS, E_32_PREFS), - 20 => array(e_ADMIN_ABS.'search.php', LAN_SEARCH, ADLAN_143, 'X', 1, E_16_SEARCH, E_32_SEARCH), - 21 => array(e_ADMIN_ABS.'admin_log.php', ADLAN_155, ADLAN_156, 'S', 4, E_16_ADMINLOG, E_32_ADMINLOG), - 22 => array(e_ADMIN_ABS.'theme.php', ADLAN_140, ADLAN_141, '1|TMP', 5, E_16_THEMEMANAGER, E_32_THEMEMANAGER), - 23 => array(e_ADMIN_ABS.'upload.php', ADLAN_72, ADLAN_73, 'V', 3, E_16_UPLOADS, E_32_UPLOADS), - 24 => array(e_ADMIN_ABS.'users.php', ADLAN_36, ADLAN_37, '4|U0|U1|U2|U3', 2, E_16_USER, E_32_USER), - 25 => array(e_ADMIN_ABS.'userclass2.php', ADLAN_38, ADLAN_39, '4', 2, E_16_USERCLASS, E_32_USERCLASS), - 26 => array(e_ADMIN_ABS.'language.php', ADLAN_132, ADLAN_133, 'L', 1, E_16_LANGUAGE, E_32_LANGUAGE), - 27 => array(e_ADMIN_ABS.'mailout.php', ADLAN_136, ADLAN_137, 'W', 2, E_16_MAIL, E_32_MAIL), - 28 => array(e_ADMIN_ABS.'users_extended.php', ADLAN_78, ADLAN_79, '4', 2, E_16_USER_EXTENDED, E_32_USER_EXTENDED), - 29 => array(e_ADMIN_ABS.'fileinspector.php', ADLAN_147, ADLAN_148, 'Y', 4, E_16_INSPECT, E_32_INSPECT), - 30 => array(e_ADMIN_ABS.'notify.php', ADLAN_149, ADLAN_150, 'O', 4, E_16_NOTIFY, E_32_NOTIFY), - 31 => array(e_ADMIN_ABS.'cron.php', ADLAN_157, ADLAN_158, 'U', 4, E_16_CRON, E_32_CRON), - - 32 => array(e_ADMIN_ABS.'eurl.php', ADLAN_159, ADLAN_160, 'K', 1, E_16_EURL, E_32_EURL), - 33 => array(e_ADMIN_ABS.'plugin.php', ADLAN_98, ADLAN_99, 'Z', 5 , E_16_PLUGMANAGER, E_32_PLUGMANAGER), - 34 => array(e_ADMIN_ABS.'docs.php', ADLAN_12, ADLAN_13, false, 20, E_16_DOCS, E_32_DOCS), - // TODO System Info. - // 35 => array('#TODO', 'System Info', 'System Information', '', 20, '', ''), - 36 => array(e_ADMIN_ABS.'credits.php', LAN_CREDITS, LAN_CREDITS, false, 20, E_16_E107, E_32_E107), - // 37 => array(e_ADMIN.'custom_field.php', ADLAN_161, ADLAN_162, 'U', 4, E_16_CUSTOMFIELD, E_32_CUSTOMFIELD), - 38 => array(e_ADMIN_ABS.'comment.php', LAN_COMMENTMAN, LAN_COMMENTMAN, 'B', 5, E_16_COMMENT, E_32_COMMENT), - ); - + $array_functions = $this->adminLinksArray(); if($mode === 'legacy') { @@ -1011,7 +1035,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } return $array_functions_assoc; } - $merged = array_merge($array_functions_assoc, $this->pluginLinks(E_16_PLUGMANAGER, "array")); + $merged = array_merge($array_functions_assoc, $this->pluginLinks($E_16_PLUGMANAGER, "array")); $sorted = multiarray_sort($merged,'title'); // this deleted the e-xxxx and p-xxxxx keys. return $this->restoreKeys($sorted); // we restore the keys with this. @@ -1140,8 +1164,13 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } * @param string $linkStyle standard = new in v2.1.5 | array | adminb * @return array|string */ - function pluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb') + function pluginLinks($iconSize = '', $linkStyle = 'adminb') { + if(empty($iconSize)) + { + $iconSize = defset('E_16_PLUGMANAGER'); + } + $plug = e107::getPlug(); $data = $plug->getInstalled(); @@ -1215,7 +1244,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } foreach ($arr as $plug_key => $plug_value) { - $the_icon = ($iconSize == E_16_PLUGMANAGER) ? $plug_value['icon'] : $plug_value['icon_32']; + $the_icon = ($iconSize == defset('E_16_PLUGMANAGER')) ? $plug_value['icon'] : $plug_value['icon_32']; $text .= $this->renderAdminButton($plug_value['link'], $plug_value['title'], $plug_value['caption'], $plug_value['perms'], $the_icon, $linkStyle); } @@ -1248,7 +1277,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } * @param array $tmpl * @param array $sub_link * @param bool $sortlist - * @return string parsed admin menu (or empty string if title is empty) + * @return string|null parsed admin menu (or empty string if title is empty) */ function admin($title, $active_page, $e107_vars, $tmpl = array(), $sub_link = false, $sortlist = false) { diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index b9e0e06bc..738d4c499 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -61,6 +61,8 @@ class UserHandler private $otherFields = array(); private $passwordAPI = false; + private $otherFieldTypes = array(); + // Constructor public function __construct() { @@ -261,7 +263,7 @@ class UserHandler * @param string $login_name - string used to log in (could actually be email address) * @param string $stored_hash - required value for password to match * - * @return string PASSWORD_INVALID|PASSWORD_VALID|string + * @return string|bool PASSWORD_INVALID|PASSWORD_VALID|string * PASSWORD_INVALID if no match * PASSWORD_VALID if valid password * Return a new hash to store if valid password but non-preferred encoding @@ -401,7 +403,7 @@ class UserHandler * @param $uid * @param string $loginName (optional) * @param array $options - * @return bool|string rawPassword + * @return bool|string|array rawPassword */ public function resetPassword($uid, $loginName='', $options=array()) { @@ -710,7 +712,7 @@ class UserHandler * @param array $lode - user information from DB - 'user_id' and 'user_password' required * @param bool $autologin - TRUE if the 'Remember Me' box ticked * - * @return void + * @return void|true */ public function makeUserCookie($lode,$autologin = false) { @@ -1918,84 +1920,7 @@ class e_userperms function __construct() { - $this->core_perms = array( - - // In the same order as admin navigation! Plus same labels. - - // Settings - "C" => array(ADLAN_74,E_16_CACHE, E_32_CACHE), // Clear the system cache - "F" => array(ADLAN_58,E_16_EMOTE, E_32_EMOTE), // Emoticons - "G" => array(ADLAN_60,E_16_FRONT, E_32_FRONT), // Front-Page Configuration - "L" => array(ADLAN_132,E_16_LANGUAGE, E_32_LANGUAGE), // Language Packs - "T" => array(ADLAN_66,E_16_META, E_32_META), // Meta tags - - "1" => array(LAN_PREFS,E_16_PREFS, E_32_PREFS), // Alter Site Preferences - "X" => array(LAN_SEARCH,E_16_SEARCH, E_32_SEARCH), // Search - "I" => array(LAN_NAVIGATION,E_16_LINKS, E_32_LINKS), // Post SiteLinks - "8" => array(ADMSLAN_27,E_16_LINKS, E_32_LINKS), // Oversee SiteLink Categories - "K" => array(ADLAN_159,E_16_EURL, E_32_EURL), // Configure URLs - - // Users - "3" => array(ADLAN_8,E_16_ADMIN, E_32_ADMIN), // Modify Admin perms - "4" => array(LAN_USER_MANAGEALL,E_16_USER, E_32_USER), // Manage all user access and settings etc - "U0" => array(ADLAN_34,E_16_USER, E_32_USER), // moderate users/bans but not userclasses or extended fields, - "U1" => array(LAN_USER_QUICKADD,E_16_USER, E_32_USER), // "User: Quick Add User", - "U2" => array(LAN_USER_OPTIONS,E_16_USER, E_32_USER), // Manage only user-options - "U3" => array(LAN_USER_RANKS,E_16_USER, E_32_USER), // Manage only user-ranks - "W" => array(ADLAN_136,E_16_MAIL, E_32_MAIL), // Configure mail settings and mailout - - - // Content - "5" => array(ADLAN_42,E_16_CUST, E_32_CUST), // create/edit custom PAGES - "J" => array(ADLAN_42,E_16_CUST, E_32_CUST), // create/edit custom MENUS - "J1" => array(ADLAN_42." (".LAN_DELETE.")",E_16_CUST, E_32_CUST), // Delete Pages/Menus. - - "H" => array(ADLAN_0,E_16_NEWS, E_32_NEWS), // Post News - All Areas except settings. - "H0" => array(ADLAN_0." (".LAN_CREATE.")",E_16_NEWS, E_32_NEWS), // Create News Items - "H1" => array(ADLAN_0." (".LAN_EDIT.")",E_16_NEWS, E_32_NEWS), // Edit News Items - "H2" => array(ADLAN_0." (".LAN_DELETE.")",E_16_NEWS, E_32_NEWS), // Delete News Items - "H3" => array(ADLAN_0." (".LAN_CATEGORY." - ".LAN_CREATE.")",E_16_NEWS, E_32_NEWS), // Create News Category - "H4" => array(ADLAN_0." (".LAN_CATEGORY." - ".LAN_EDIT.")",E_16_NEWS, E_32_NEWS), // Edit News Category - "H5" => array(ADLAN_0." (".LAN_CATEGORY." - ".LAN_DELETE.")",E_16_NEWS, E_32_NEWS), // Delete News Category - - "N" => array(ADLAN_0." (".LAN_SUBMITTED.")",E_16_NEWS, E_32_NEWS), // Moderate submitted news - "V" => array(ADLAN_31,E_16_UPLOADS, E_32_UPLOADS), // Configure public file uploads - "M" => array(ADLAN_28,E_16_WELCOME, E_32_WELCOME), // Welcome Messages - - // Tools - "Y" => array(ADLAN_147,E_16_INSPECT, E_32_INSPECT), // File inspector - "7" => array(defset('LAN_HISTORY', 'History'), E_16_UNDO, E_32_UNDO), // History/Undo - "9" => array(ADLAN_40, E_16_MAINTAIN, E_32_MAINTAIN), // Take Down site for Maintenance - "O" => array(ADLAN_149,E_16_NOTIFY, E_32_NOTIFY), // Notify - "U" => array(ADLAN_157,E_16_CRON, E_32_CRON), // Schedule Tasks - "S" => array(ADLAN_155,E_16_ADMINLOG, E_32_ADMINLOG), // System Logging - - - // Manage - "B" => array(LAN_COMMENTMAN,E_16_COMMENT, E_32_COMMENT), // Moderate Comments - "6" => array(LAN_MEDIAMANAGER,E_16_FILE, E_32_FILE), // File-Manager - Upload /manage files - - "A" => array(LAN_MEDIAMANAGER." (".LAN_ALL.")",E_16_IMAGES, E_32_IMAGES), // Media-Manager All Areas. - "A1"=> array(LAN_MEDIAMANAGER." (".LAN_UPLOAD."/".LAN_IMPORT.")",E_16_IMAGES, E_32_IMAGES), // Media-Manager (Media Upload/Add/Import) - "A2"=> array(LAN_MEDIAMANAGER." (".LAN_CATEGORIES.")",E_16_IMAGES, E_32_IMAGES), // Media-Manager (Media-Categories) - - "TMP"=> array(ADLAN_140." (".LAN_PREFS.")",E_16_THEMEMANAGER, E_32_THEMEMANAGER), - - "2" => array(ADLAN_6,E_16_MENUS, E_32_MENUS), // Alter Menus - - - // "D"=> ADMSLAN_29, // Manage Banners (deprecated - now a plugin) - // "E"=> ADMSLAN_30, // News feed headlines (deprecated - now a plugin) - // "K"=> - - // "P" // Reserved for Plugins - - // "Q"=> array(ADMSLAN_24), // Manage download categories (deprecated - now a plugin) - // "R"=> ADMSLAN_44, // Post Downloads (deprecated) - - - // "Z"=> ADMSLAN_62, // Plugin Manager.. included under Plugins category. - ); - + $this->setCorePerms(); // $sql = e107::getDb('sql2'); // $tp = e107::getParser(); @@ -2016,22 +1941,6 @@ class e_userperms $this->plugin_perms[$key] = $arr; } -/* - $plg = e107::getPlugin(); - $allPlugins = $plg->getall(1); // Needs all for 'reading' and 'installed' for writing. - - foreach($allPlugins as $k=>$row2) - { - if($plg->parse_plugin($row2['plugin_path'])) - { - $plug_vars = $plg->plug_vars; - $this->plugin_perms[("P".$row2['plugin_id'])] = array($tp->toHTML($row2['plugin_name'], false, 'RAWTEXT,defs')); - $this->plugin_perms[("P".$row2['plugin_id'])][1] = $plg->getIcon($row2['plugin_path'],16); - $this->plugin_perms[("P".$row2['plugin_id'])][2] = $plg->getIcon($row2['plugin_path'],32); - } - } -*/ - asort($this->plugin_perms); @@ -2057,6 +1966,304 @@ class e_userperms } + function setCorePerms() + { + + // Define permissions with associative keys and a separator + $perm_definitions = array( + // Settings + 'C' => [ + 'title' => 'ADLAN_74', // Clear the system cache + 'icon_16' => 'E_16_CACHE', + 'icon_32' => 'E_32_CACHE', + ], + 'F' => [ + 'title' => 'ADLAN_58', // Emoticons + 'icon_16' => 'E_16_EMOTE', + 'icon_32' => 'E_32_EMOTE', + ], + 'G' => [ + 'title' => 'ADLAN_60', // Front-Page Configuration + 'icon_16' => 'E_16_FRONT', + 'icon_32' => 'E_32_FRONT', + ], + 'L' => [ + 'title' => 'ADLAN_132', // Language Packs + 'icon_16' => 'E_16_LANGUAGE', + 'icon_32' => 'E_32_LANGUAGE', + ], + 'T' => [ + 'title' => 'ADLAN_66', // Meta tags + 'icon_16' => 'E_16_META', + 'icon_32' => 'E_32_META', + ], + '1' => [ + 'title' => 'LAN_PREFS', // Alter Site Preferences + 'icon_16' => 'E_16_PREFS', + 'icon_32' => 'E_32_PREFS', + ], + 'X' => [ + 'title' => 'LAN_SEARCH', // Search + 'icon_16' => 'E_16_SEARCH', + 'icon_32' => 'E_32_SEARCH', + ], + 'I' => [ + 'title' => 'LAN_NAVIGATION', // Post SiteLinks + 'icon_16' => 'E_16_LINKS', + 'icon_32' => 'E_32_LINKS', + ], + '8' => [ + 'title' => 'ADMSLAN_27', // Oversee SiteLink Categories + 'icon_16' => 'E_16_LINKS', + 'icon_32' => 'E_32_LINKS', + ], + 'K' => [ + 'title' => 'ADLAN_159', // Configure URLs + 'icon_16' => 'E_16_EURL', + 'icon_32' => 'E_32_EURL', + ], + + // Users + '3' => [ + 'title' => 'ADLAN_8', // Modify Admin perms + 'icon_16' => 'E_16_ADMIN', + 'icon_32' => 'E_32_ADMIN', + ], + '4' => [ + 'title' => 'LAN_USER_MANAGEALL', // Manage all user access and settings etc + 'icon_16' => 'E_16_USER', + 'icon_32' => 'E_32_USER', + ], + 'U0' => [ + 'title' => 'ADLAN_34', // moderate users/bans but not userclasses or extended fields + 'icon_16' => 'E_16_USER', + 'icon_32' => 'E_32_USER', + ], + 'U1' => [ + 'title' => 'LAN_USER_QUICKADD', // "User: Quick Add User" + 'icon_16' => 'E_16_USER', + 'icon_32' => 'E_32_USER', + ], + 'U2' => [ + 'title' => 'LAN_USER_OPTIONS', // Manage only user-options + 'icon_16' => 'E_16_USER', + 'icon_32' => 'E_32_USER', + ], + 'U3' => [ + 'title' => 'LAN_USER_RANKS', // Manage only user-ranks + 'icon_16' => 'E_16_USER', + 'icon_32' => 'E_32_USER', + ], + 'W' => [ + 'title' => 'ADLAN_136', // Configure mail settings and mailout + 'icon_16' => 'E_16_MAIL', + 'icon_32' => 'E_32_MAIL', + ], + + // Content + '5' => [ + 'title' => 'ADLAN_42', // create/edit custom PAGES + 'icon_16' => 'E_16_CUST', + 'icon_32' => 'E_32_CUST', + ], + 'J' => [ + 'title' => 'ADLAN_42', // create/edit custom MENUS + 'icon_16' => 'E_16_CUST', + 'icon_32' => 'E_32_CUST', + ], + 'J1' => [ + 'title' => ['ADLAN_42', 'LAN_DELETE'], + 'separator' => ' (', // Delete Pages/Menus + 'icon_16' => 'E_16_CUST', + 'icon_32' => 'E_32_CUST', + ], + 'H' => [ + 'title' => 'ADLAN_0', // Post News - All Areas except settings + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'H0' => [ + 'title' => ['ADLAN_0', 'LAN_CREATE'], + 'separator' => ' (', // Create News Items + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'H1' => [ + 'title' => ['ADLAN_0', 'LAN_EDIT'], + 'separator' => ' (', // Edit News Items + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'H2' => [ + 'title' => ['ADLAN_0', 'LAN_DELETE'], + 'separator' => ' (', // Delete News Items + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'H3' => [ + 'title' => ['ADLAN_0', 'LAN_CATEGORY', 'LAN_CREATE'], + 'separator' => ' (', // Create News Category + 'sub_separator' => ' - ', + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'H4' => [ + 'title' => ['ADLAN_0', 'LAN_CATEGORY', 'LAN_EDIT'], + 'separator' => ' (', // Edit News Category + 'sub_separator' => ' - ', + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'H5' => [ + 'title' => ['ADLAN_0', 'LAN_CATEGORY', 'LAN_DELETE'], + 'separator' => ' (', // Delete News Category + 'sub_separator' => ' - ', + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'N' => [ + 'title' => ['ADLAN_0', 'LAN_SUBMITTED'], + 'separator' => ' (', // Moderate submitted news + 'icon_16' => 'E_16_NEWS', + 'icon_32' => 'E_32_NEWS', + ], + 'V' => [ + 'title' => 'ADLAN_31', // Configure public file uploads + 'icon_16' => 'E_16_UPLOADS', + 'icon_32' => 'E_32_UPLOADS', + ], + 'M' => [ + 'title' => 'ADLAN_28', // Welcome Messages + 'icon_16' => 'E_16_WELCOME', + 'icon_32' => 'E_32_WELCOME', + ], + + // Tools + 'Y' => [ + 'title' => 'ADLAN_147', // File inspector + 'icon_16' => 'E_16_INSPECT', + 'icon_32' => 'E_32_INSPECT', + ], + '7' => [ + 'title' => 'LAN_HISTORY', // History/Undo + 'icon_16' => 'E_16_UNDO', + 'icon_32' => 'E_32_UNDO', + ], + '9' => [ + 'title' => 'ADLAN_40', // Take Down site for Maintenance + 'icon_16' => 'E_16_MAINTAIN', + 'icon_32' => 'E_32_MAINTAIN', + ], + 'O' => [ + 'title' => 'ADLAN_149', // Notify + 'icon_16' => 'E_16_NOTIFY', + 'icon_32' => 'E_32_NOTIFY', + ], + 'U' => [ + 'title' => 'ADLAN_157', // Schedule Tasks + 'icon_16' => 'E_16_CRON', + 'icon_32' => 'E_32_CRON', + ], + 'S' => [ + 'title' => 'ADLAN_155', // System Logging + 'icon_16' => 'E_16_ADMINLOG', + 'icon_32' => 'E_32_ADMINLOG', + ], + + // Manage + 'B' => [ + 'title' => 'LAN_COMMENTMAN', // Moderate Comments + 'icon_16' => 'E_16_COMMENT', + 'icon_32' => 'E_32_COMMENT', + ], + '6' => [ + 'title' => 'LAN_MEDIAMANAGER', // File-Manager - Upload /manage files + 'icon_16' => 'E_16_FILE', + 'icon_32' => 'E_32_FILE', + ], + 'A' => [ + 'title' => ['LAN_MEDIAMANAGER', 'LAN_ALL'], + 'separator' => ' (', // Media-Manager All Areas + 'icon_16' => 'E_16_IMAGES', + 'icon_32' => 'E_32_IMAGES', + ], + 'A1' => [ + 'title' => ['LAN_MEDIAMANAGER', 'LAN_UPLOAD', 'LAN_IMPORT'], + 'separator' => ' (', // Media-Manager (Media Upload/Add/Import) + 'sub_separator' => '/', + 'icon_16' => 'E_16_IMAGES', + 'icon_32' => 'E_32_IMAGES', + ], + 'A2' => [ + 'title' => ['LAN_MEDIAMANAGER', 'LAN_CATEGORIES'], + 'separator' => ' (', // Media-Manager (Media-Categories) + 'icon_16' => 'E_16_IMAGES', + 'icon_32' => 'E_32_IMAGES', + ], + 'TMP' => [ + 'title' => ['ADLAN_140', 'LAN_PREFS'], + 'separator' => ' (', // Theme preferences + 'icon_16' => 'E_16_THEMEMANAGER', + 'icon_32' => 'E_32_THEMEMANAGER', + ], + '2' => [ + 'title' => 'ADLAN_6', // Alter Menus + 'icon_16' => 'E_16_MENUS', + 'icon_32' => 'E_32_MENUS', + ], + + // Commented-out items + /*'D' => [ + 'title' => 'ADMSLAN_29', // Manage Banners (deprecated - now a plugin) + ], + 'E' => [ + 'title' => 'ADMSLAN_30', // News feed headlines (deprecated - now a plugin) + ], + 'Q' => [ + 'title' => 'ADMSLAN_24', // Manage download categories (deprecated - now a plugin) + ], + 'R' => [ + 'title' => 'ADMSLAN_44', // Post Downloads (deprecated) + ], + 'Z' => [ + 'title' => 'ADMSLAN_62', // Plugin Manager (included under Plugins category) + ],*/ + ); + + // Process the array with defset() + $this->core_perms = array(); + foreach($perm_definitions as $perm => $data) + { + if(is_array($data['title'])) + { + $title_parts = array_map(fn($const) => defset($const, 'Untitled'), $data['title']); + $separator = $data['separator'] ?? ''; + $sub_separator = $data['sub_separator'] ?? ''; + + if(count($title_parts) > 2 && $sub_separator) + { + // For cases like 'News (Category - Edit)' + $title = $title_parts[0] . $separator . $title_parts[1] . $sub_separator . $title_parts[2] . ')'; + } + else + { + // For cases like 'News (Create)' or 'Media Manager (Upload/Import)' + $title = implode($sub_separator ?: $separator, $title_parts) . ($separator ? ')' : ''); + } + } + else + { + $title = defset($data['title'], 'Untitled'); + } + + $this->core_perms[$perm] = array( + 0 => $title, + 1 => defset($data['icon_16'], 'e-' . strtolower(str_replace('E_16_', '', $data['icon_16'])) . '-16'), + 2 => defset($data['icon_32'], 'e-' . strtolower(str_replace('E_32_', '', $data['icon_32'])) . '-32') + ); + } + } + /** * @param $key * @return mixed diff --git a/e107_tests/tests/unit/e_navigationTest.php b/e107_tests/tests/unit/e_navigationTest.php index 1d9ef76b0..0eaaea530 100644 --- a/e107_tests/tests/unit/e_navigationTest.php +++ b/e107_tests/tests/unit/e_navigationTest.php @@ -99,7 +99,7 @@ 6 => ' ', ), 9 => array ( - 0 => './e107_admin/history.php', + 0 => '/e107_admin/history.php', 1 => 'History', 2 => 'History', 3 => '7', diff --git a/e107_tests/tests/unit/e_userpermsTest.php b/e107_tests/tests/unit/e_userpermsTest.php new file mode 100644 index 000000000..78957c88b --- /dev/null +++ b/e107_tests/tests/unit/e_userpermsTest.php @@ -0,0 +1,309 @@ +eup = $this->make('e_userperms'); + + } + catch(Exception $e) + { + $this::fail("Couldn't load e_userperms: {$e}"); + } + + + } + + function testGetPermList() + { + $this::assertSame(LAN_EDIT,'Edit'); + $this::assertSame(LAN_CATEGORY,'Category'); + $this::assertSame(ADLAN_0, 'News'); + $this::assertSame(LAN_MEDIAMANAGER, 'Media Manager'); + + $this->eup->__construct(); + + + $expected = array ( + 'C' => + array ( + 0 => 'Cache', + 1 => '', + 2 => ' ', + ), + 'F' => + array ( + 0 => 'Emoticons', + 1 => '', + 2 => ' ', + ), + 'G' => + array ( + 0 => 'Front Page', + 1 => '', + 2 => ' ', + ), + 'L' => + array ( + 0 => 'Language', + 1 => '', + 2 => ' ', + ), + 'T' => + array ( + 0 => 'Meta Tags', + 1 => '', + 2 => ' ', + ), + 1 => + array ( + 0 => 'Preferences', + 1 => '', + 2 => ' ', + ), + 'X' => + array ( + 0 => 'Search', + 1 => '', + 2 => ' ', + ), + 'I' => + array ( + 0 => 'Navigation', + 1 => '', + 2 => ' ', + ), + 8 => + array ( + 0 => 'Oversee link categories', + 1 => '', + 2 => ' ', + ), + 'K' => + array ( + 0 => 'URL Configuration', + 1 => '', + 2 => ' ', + ), + 3 => + array ( + 0 => 'Administrators', + 1 => '', + 2 => '', + ), + 4 => + array ( + 0 => 'Manage all User, Userclass and Extended User-Field settings', + 1 => '', + 2 => ' ', + ), + 'U0' => + array ( + 0 => 'Banlist', + 1 => '', + 2 => ' ', + ), + 'U1' => + array ( + 0 => 'Quick Add User', + 1 => '', + 2 => ' ', + ), + 'U2' => + array ( + 0 => 'User Options', + 1 => '', + 2 => ' ', + ), + 'U3' => + array ( + 0 => 'User Ranks', + 1 => '', + 2 => ' ', + ), + 'W' => + array ( + 0 => 'Mail', + 1 => '', + 2 => ' ', + ), + 5 => + array ( + 0 => 'Pages/Menus', + 1 => '', + 2 => ' ', + ), + 'J' => + array ( + 0 => 'Pages/Menus', + 1 => '', + 2 => ' ', + ), + 'J1' => + array ( + 0 => 'Pages/Menus (Delete)', + 1 => '', + 2 => ' ', + ), + 'H' => + array ( + 0 => 'News', + 1 => '', + 2 => ' ', + ), + 'H0' => + array ( + 0 => 'News (Create)', + 1 => '', + 2 => ' ', + ), + 'H1' => + array ( + 0 => 'News (Edit)', + 1 => '', + 2 => ' ', + ), + 'H2' => + array ( + 0 => 'News (Delete)', + 1 => '', + 2 => ' ', + ), + 'H3' => + array ( + 0 => 'News (Category - Create)', + 1 => '', + 2 => ' ', + ), + 'H4' => + array ( + 0 => 'News (Category - Edit)', + 1 => '', + 2 => ' ', + ), + 'H5' => + array ( + 0 => 'News (Category - Delete)', + 1 => '', + 2 => ' ', + ), + 'N' => + array ( + 0 => 'News (Submitted)', + 1 => '', + 2 => ' ', + ), + 'V' => + array ( + 0 => 'Manage/upload files', + 1 => '', + 2 => ' ', + ), + 'M' => + array ( + 0 => 'Welcome Message', + 1 => '', + 2 => ' ', + ), + 'Y' => + array ( + 0 => 'File Inspector', + 1 => '', + 2 => ' ', + ), + 7 => + array ( + 0 => 'History', + 1 => '\'\'', + 2 => '\'\'', + ), + 9 => + array ( + 0 => 'Maintenance', + 1 => '', + 2 => ' ', + ), + 'O' => + array ( + 0 => 'Notify', + 1 => '', + 2 => ' ', + ), + 'U' => + array ( + 0 => 'Schedule Tasks', + 1 => '', + 2 => ' ', + ), + 'S' => + array ( + 0 => 'System Logs', + 1 => '', + 2 => ' ', + ), + 'B' => + array ( + 0 => 'Comments Manager', + 1 => '', + 2 => ' ', + ), + 6 => + array ( + 0 => 'Media Manager', + 1 => '', + 2 => ' ', + ), + 'A' => + array ( + 0 => 'Media Manager (All)', + 1 => '', + 2 => ' ', + ), + 'A1' => + array ( + 0 => 'Media Manager (Upload/Import)', + 1 => '', + 2 => ' ', + ), + 'A2' => + array ( + 0 => 'Media Manager (Categories)', + 1 => '', + 2 => ' ', + ), + 'TMP' => + array ( + 0 => 'Theme Manager (Preferences)', + 1 => '', + 2 => ' ', + ), + 2 => + array ( + 0 => 'Menu Manager', + 1 => '', + 2 => ' ', + ), + ); + + + + $result = $this->eup->getPermList('core'); + $this::assertNotEmpty($result); + $this::assertSame($expected,$result); + + } +}