]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-config_admins.php
More rewrites to make use of (cached) wrapper functions
[mailer.git] / inc / modules / admin / what-config_admins.php
index 97834713aeed8cd0b2dca186ad2742f7a9e843ba..25b0fb39801dc74137698902a1698d3bd37c89ba 100644 (file)
@@ -45,9 +45,9 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 // Add description as navigation point
 addMenuDescription('admin', __FILE__);
 
-if ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
+if ((isFormSent('edit')) && (ifPostContainsSelections())) {
        // Edit ACLs
-       $OUT = ''; $SW = 2;
+       $OUT = '';
        foreach (postRequestParameter('sel') as $id => $selected) {
                // Load data for the id
                $result = SQL_QUERY_ESC("SELECT admin_id, action_menu, what_menu, access_mode FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
@@ -57,7 +57,6 @@ if ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
 
                // Prepare data for the row template
                $content = array(
-                       'sw'               => $SW,
                        'id'               => $id,
                        'admins_selection' => generateOptionList('admins', 'id', 'login', $adminId, 'default_acl'),
                        'action_selection' => adminMenuSelectionBox_DEPRECATED('action', $action, $id),
@@ -66,8 +65,8 @@ if ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
                                '/ARRAY/',
                                array('allow', 'deny'),
                                array(
-                                       getMessage('ADMINS_ALLOW_MODE'),
-                                       getMessage('ADMINS_DENY_MODE')
+                                       '{--ADMINS_ALLOW_MODE--}',
+                                       '{--ADMINS_DENY_MODE--}'
                                ),
                                $mode
                        ),
@@ -75,12 +74,11 @@ if ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
 
                // Load row template
                $OUT .= loadTemplate('admin_config_admins_edit_row', true, $content);
-               $SW = 3 - $SW;
-       }
+       } // END - foreach
 
        // Load main template
        loadTemplate('admin_config_admins_edit', false, $OUT);
-} elseif ((isPostRequestParameterSet('change')) && (countPostSelection() > 0)) {
+} elseif ((isFormSent('change')) && (ifPostContainsSelections())) {
        // Change entries
        foreach (postRequestParameter('sel') as $id => $selected) {
                // Secure id
@@ -103,45 +101,27 @@ if ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
        } // END - if
 
        // Entries changed
-       loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ADMINS_ENTRIES_CHANGED'));
-} elseif ((isPostRequestParameterSet('del')) && (countPostSelection() > 0)) {
+       loadTemplate('admin_settings_saved', false, '{--ADMIN_ADMINS_ENTRIES_CHANGED--}');
+} elseif ((isFormSent('del')) && (ifPostContainsSelections())) {
        // Delete ACLs
-       $OUT = ''; $SW = 2;
+       $OUT = '';
        foreach (postRequestParameter('sel') as $id => $selected) {
                // Load data for the id
-               $result = SQL_QUERY_ESC("SELECT admin_id, action_menu, what_menu, access_mode FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT `id`, `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
                        array(bigintval($id)), __FILE__, __LINE__);
-               list($admin, $action, $what, $mode) = SQL_FETCHROW($result);
+               $content = SQL_FETCHARRAY($result);
                SQL_FREERESULT($result);
 
-               // Prepare variables
-               if (empty($action)) $action = '---';
-               if (empty($what)) $what = '---';
-
                // Get admin mode
-               $mode = getMessage('ADMINS_'.strtoupper($mode).'_MODE');
-
-               // Generate link
-               $admin = generateAdminLink($admin);
-
-               // Prepare data for the row template
-               $content = array(
-                       'sw'     => $SW,
-                       'id'     => $id,
-                       'admin'  => $admin,
-                       'action' => $action,
-                       'what'   => $what,
-                       'mode'   => $mode,
-               );
+               $content['access_mode'] = '{--ADMINS_' . strtoupper($content['access_mode']) . '_MODE--}';
 
                // Load row template and switch colors
                $OUT .= loadTemplate('admin_config_admins_del_row', true, $content);
-               $SW = 3 - $SW;
        } // END - foreach
 
        // Load main template
        loadTemplate('admin_config_admins_del', false, $OUT);
-} elseif ((isPostRequestParameterSet('remove')) && (countPostSelection() > 0)) {
+} elseif ((isFormSent('remove')) && (ifPostContainsSelections())) {
        // Remove entries
        // @TODO Rewrite this to filter 'run_sqls'
        foreach (postRequestParameter('sel') as $id => $selected) {
@@ -155,8 +135,8 @@ if ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
        } // END - if
 
        // Entries deleted
-       loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ADMINS_ENTRIES_DELETED'));
-} elseif (isPostRequestParameterSet('add')) {
+       loadTemplate('admin_settings_saved', false, '{--ADMIN_ADMINS_ENTRIES_DELETED--}');
+} elseif (isFormSent('add')) {
        // Check if everything is fine...
        $mode = getAdminDefaultAcl(bigintval(postRequestParameter('admin_id')));
 
@@ -184,7 +164,7 @@ VALUES ('%s','%s','%s','%s')",
                                        postRequestParameter('what_menu'),
                                        postRequestParameter('mode')
                                ), __FILE__, __LINE__);
-                               $content = getMessage('ADMIN_ADMINS_ACL_SAVED');
+                               $content = '{--ADMIN_ADMINS_ACL_SAVED--}';
 
                                // Update cache when installed
                                if (isExtensionActive('cache')) {
@@ -192,18 +172,18 @@ VALUES ('%s','%s','%s','%s')",
                                } // END - if
                        } else {
                                // ACL does already exist!
-                               $content = getMessage('ADMIN_ADMINS_ACL_ALREADY_ADDED');
+                               $content = '{--ADMIN_ADMINS_ACL_ALREADY_ADDED--}';
                        }
 
                        // Free memory
                        SQL_FREERESULT($result);
                } else {
                        // No menu selected makes also no sence...
-                       $content = getMessage('ADMIN_ADMINS_SELECT_ACTION_WHAT');
+                       $content = '{--ADMIN_ADMINS_SELECT_ACTION_WHAT--}';
                }
        } else {
                // Same mode makes no sence...
-               $content = getMessage('ADMIN_ADMINS_SAME_MODE_SELECTED');
+               $content = '{--ADMIN_ADMINS_SAME_MODE_SELECTED--}';
        }
 
        // Display message
@@ -213,30 +193,15 @@ VALUES ('%s','%s','%s','%s')",
        $result_acls = SQL_QUERY('SELECT `id`, `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC, `id` ASC', __FILE__, __LINE__);
 
        // Entries found?
-       if (SQL_NUMROWS($result_acls) > 0) {
+       if (!SQL_HASZERONUMS($result_acls)) {
                // List ACLs
-               $OUT = ''; $SW = 2;
+               $OUT = '';
                while ($content = SQL_FETCHARRAY($result_acls)) {
-                       // Prepare variables
-                       if (empty($content['action_menu'])) $content['action_menu'] = '---';
-                       if (empty($content['what_menu']))   $content['what_menu']   = '---';
-
-                       // Get mode
-                       $content['access_mode'] = getMessage('ADMINS_'.strtoupper($content['access_mode']).'_MODE');
-
-                       // Prepare data for the row template
-                       $content = array(
-                               'sw'     => $SW,
-                               'id'     => $content['id'],
-                               'admin'  => generateAdminLink($content['admin_id']),
-                               'action' => $content['action_menu'],
-                               'what'   => $content['what_menu'],
-                               'mode'   => $content['access_mode'],
-                       );
+                       // Generate mode string
+                       $content['access_mode'] = '{--ADMINS_' . strtoupper($content['access_mode']) . '_MODE--}';
 
                        // Load row template and switch colors
                        $OUT .= loadTemplate('admin_config_admins_row', true, $content);
-                       $SW = 3 - $SW;
                } // END - while
 
                // Free memory
@@ -254,8 +219,8 @@ VALUES ('%s','%s','%s','%s')",
                '/ARRAY/',
                array('allow', 'deny'),
                array(
-                       getMessage('ADMINS_ALLOW_MODE'),
-                       getMessage('ADMINS_DENY_MODE')
+                       'ADMINS_ALLOW_MODE--}',
+                       'ADMINS_DENY_MODE--}'
                )
        );
 
@@ -263,5 +228,5 @@ VALUES ('%s','%s','%s','%s')",
        loadTemplate('admin_admins_add_acl', false, $content);
 }
 
-//
+// [EOF]
 ?>