From: Roland Häder Date: Wed, 10 Aug 2011 18:44:11 +0000 (+0000) Subject: Extension ext-admins updated: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7c6a5b9e1e07dd360286130fe7e39000bfc68d4a;p=mailer.git Extension ext-admins updated: - We don't shortcut names of any columns, array elements et cetera. This may lead to misunderstandings of the code. - More EL code used in ext-admins - Function getAdminMenuMode() introduced - Internal TODO closed (SQL_FETCHARRAY() shall be more used) - TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 68ce899955..738b121c41 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -52,7 +52,7 @@ ./inc/functions.php:156:// @TODO Rewrite this to an extension 'smtp' ./inc/functions.php:1940: // @TODO Find a way to cache this ./inc/functions.php:2041: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2233: // @TODO Rename column data_type to e.g. mail_status +./inc/functions.php:2236: // @TODO Rename column data_type to e.g. mail_status ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0); ./inc/language/de.php:1071: // @TODO Rewrite these two constants @@ -64,7 +64,7 @@ ./inc/language/rallye_de.php:13: * @TODO Naming convention not applied for language strings * ./inc/language/refback_de.php:53: // @TODO Rewrite these constants to one ./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf() -./inc/libs/admins_functions.php:474: // @TODO This can be, somehow, rewritten +./inc/libs/admins_functions.php:505: // @TODO This can be, somehow, rewritten ./inc/libs/bonus_functions.php:194: // @TODO Move this HTML to a template ./inc/libs/doubler_functions.php:44:// @TODO Lame description ./inc/libs/doubler_functions.php:93: // @TODO Can't this be moved into EL? @@ -90,12 +90,12 @@ ./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter? ./inc/module-functions.php:267: // @TODO Nothing helped??? ./inc/module-functions.php:308: // @TODO Rewrite this to a filter -./inc/modules/admin/admin-inc.php:1373: // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided +./inc/modules/admin/admin-inc.php:1379: // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided ./inc/modules/admin/admin-inc.php:171: // @TODO This and the next getCurrentAdminId() call might be moved into the templates? ./inc/modules/admin/admin-inc.php:242: // @TODO This can be rewritten into a filter ./inc/modules/admin/admin-inc.php:274: // @TODO Rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/admin/admin-inc.php:340: // @TODO Rewrite this to $content = SQL_FETCHARRAY() -./inc/modules/admin/admin-inc.php:438:// @TODO Try to rewrite this to adminAddMenuSelectionBox() +./inc/modules/admin/admin-inc.php:444:// @TODO Try to rewrite this to adminAddMenuSelectionBox() ./inc/modules/admin/overview-inc.php:162: // @TODO Rewrite this to a filter ./inc/modules/admin/overview-inc.php:275: // @TODO Rewrite this to something with include files and/or filter ./inc/modules/admin/overview-inc.php:309: // @TODO This may also be rewritten to include files @@ -108,7 +108,7 @@ ./inc/modules/admin/what-admin_add.php:59: // @TODO Cant this be rewritten? ./inc/modules/admin/what-admin_add.php:75: // @TODO This can be somehow rewritten to a function ./inc/modules/admin/what-adminedit.php:56: // @TODO Kill all constants in this file -./inc/modules/admin/what-admins_mails.php:59: // @TODO Can this be rewritten to an API function? +./inc/modules/admin/what-admins_mails.php:58: // @TODO Can this be rewritten to an API function? ./inc/modules/admin/what-bonus.php:46:// @TODO Unused at the moment ./inc/modules/admin/what-config_mods.php:55: // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function ./inc/modules/admin/what-config_points.php:110: // @TODO Rewrite this to a filter @@ -123,8 +123,8 @@ ./inc/modules/admin/what-guest_add.php:67: // @TODO Cant this be rewritten? ./inc/modules/admin/what-guest_add.php:80: // @TODO This can be somehow rewritten to a function ./inc/modules/admin/what-holiday_list.php:46:// @TODO Unused at the moment -./inc/modules/admin/what-list_admins_acls.php:108: // @TODO Rewrite this to a filter -./inc/modules/admin/what-list_admins_acls.php:136: // @TODO Rewrite this to filter 'run_sqls' +./inc/modules/admin/what-list_admins_acls.php:101: // @TODO Rewrite this to a filter +./inc/modules/admin/what-list_admins_acls.php:129: // @TODO Rewrite this to filter 'run_sqls' ./inc/modules/admin/what-list_autopurge.php:47:// @TODO Rewrite those lines to filter ./inc/modules/admin/what-list_bonus.php:136: // @TODO Can't this be moved into our expression language? ./inc/modules/admin/what-list_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , 'admins und (kommender) contact. Beseitigung eines Fehlers HTTP_POSR_VARS beim Ändern von Administratoren."); @@ -349,6 +349,11 @@ INDEX (`admin_id`)", // Update notes (these will be set as task text!) setExtensionUpdateNotes("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern NULL."); break; + + case '0.7.8': // SQL queries for v0.7.8 + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Abgekürzte Bezeichnungen können für Missverständnisse am Code sorgen. Daher wurde der Spaltenalias def_acl entfernt."); + break; } // END - switch break; diff --git a/inc/filter/admins_filter.php b/inc/filter/admins_filter.php index f7fab4603e..7e5faa5557 100644 --- a/inc/filter/admins_filter.php +++ b/inc/filter/admins_filter.php @@ -44,10 +44,10 @@ if (!defined('__SECURITY')) { function FILTER_ADD_EXTRA_SQL_DATA ($add = '') { // Is the admins extension updated? (should be!) //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); - if (isExtensionInstalledAndNewer('admins', '0.3.0')) $add .= ', `default_acl` AS def_acl'; - if (isExtensionInstalledAndNewer('admins', '0.6.7')) $add .= ', `la_mode`'; - if (isExtensionInstalledAndNewer('admins', '0.7.2')) $add .= ', `login_failures`, UNIX_TIMESTAMP(`last_failure`) AS last_failure'; - if (isExtensionInstalledAndNewer('admins', '0.7.3')) $add .= ', `expert_settings`,`expert_warning`'; + if (isExtensionInstalledAndNewer('admins', '0.3.0')) $add .= ',`default_acl`'; + if (isExtensionInstalledAndNewer('admins', '0.6.7')) $add .= ',`la_mode`'; + if (isExtensionInstalledAndNewer('admins', '0.7.2')) $add .= ',`login_failures`,UNIX_TIMESTAMP(`last_failure`) AS `last_failure`'; + if (isExtensionInstalledAndNewer('admins', '0.7.3')) $add .= ',`expert_settings`,`expert_warning`'; // Return it //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); diff --git a/inc/functions.php b/inc/functions.php index 7885108fd2..becc231d6b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2185,13 +2185,16 @@ function makeZeroToNull ($number) { return $number; } -// Converts NULL into number zero +// Converts a NULL to zero function makeNullToZero ($number) { - // Is this a NULL? - if ((is_null($number)) || (empty($number))) { - // Simply set it + // Is it a valid username? + if ((!is_null($number)) && (!empty($number)) && ($number > 0)) { + // Always secure it + $number = bigintval($number); + } else { + // Is not valid or zero $number = '0'; - } // END - if + } // Return it return $number; diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index 31d1a4d444..27c0a10491 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -337,35 +337,66 @@ function adminsEditAdminAccount ($postData) { $id = bigintval($id); // Get the admin's data - $result = SQL_QUERY_ESC("SELECT `login`,`email`,`default_acl` AS mode, `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `login`,`email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1", array($id), __FUNCTION__, __LINE__); if ((SQL_NUMROWS($result) == 1) && ($selected == 1)) { // Entry found $content = SQL_FETCHARRAY($result); - SQL_FREERESULT($result); // Prepare some more data for the template $content['id'] = $id; // Shall we allow changing default ACL? if ($currMode == 'allow') { - // Allow chaning it - $content['mode'] = generateOptionList('/ARRAY/', array('allow', 'deny'), array('{--ADMIN_ADMINS_ACCESS_MODE_ALLOW--}', '{--ADMIN_ADMINS_ACCESS_MODE_DENY--}'), $content['mode']); + // Allow changing it + $content['mode'] = '{%pipe,generateAdminAccessModeSelectionBox=' . $id . '%}'; } else { // Don't allow it $content['mode'] = ' '; } - $content['la_mode'] = generateOptionList('/ARRAY/', array('global', 'OLD', 'NEW'), array('{--ADMIN_ADMINS_LA_MODE_GLOBAL--}', '{--ADMIN_ADMINS_LA_MODE_OLD--}', '{--ADMIN_ADMINS_LA_MODE_NEW--}'), $content['la_mode']); // Load row template and switch color $OUT .= loadTemplate('admin_edit_admins_row', true, $content); } // END - if + + // Free result + SQL_FREERESULT($result); } // END - foreach // Load template loadTemplate('admin_edit_admins', false, $OUT); } +// Generate access mode selection box for given admin id +function generateAdminAccessModeSelectionBox ($adminId = NULL) { + // Start the selection box + $OUT = ''; + + // Return content + return $OUT; +} + +// Generate menu mode selection box for given admin it +function generateAdminMenuModeSelectionBox ($adminId = NULL) { + // Start the selection box + $OUT = ''; + + // Return content + return $OUT; +} + // Delete given admin accounts function adminsDeleteAdminAccount ($postData) { // Check if this account is the last one which cannot be deleted... diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 546aebe01e..14d65d059e 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -400,10 +400,16 @@ ORDER BY } } -// Create member selection box -function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') { +// Create an admin selection box +function generateAdminSelectionBox ($adminId = NULL) { + // Return content + return $OUT; +} + +// Create a member selection box +function addMemberSelectionBox ($userid = NULL, $add_all = false, $return = false, $none = false, $field = 'userid') { // Output selection form with all confirmed user accounts listed - $result = SQL_QUERY("SELECT `userid`,`surname`,`family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SELECT `userid`,`surname`,`family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC', __FUNCTION__, __LINE__); // Default output $OUT = ''; @@ -414,7 +420,7 @@ function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $no while ($content = SQL_FETCHARRAY($result)) { $OUT .= '