]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-config_admins.php
Total eval() commands slightly reduced, still there are some left
[mailer.git] / inc / modules / admin / what-config_admins.php
index f53b8c206a06a4eb96d9b5808112b0a4358a0eab..f964eedb105b207db0780ce4bce4f7a765f36421 100644 (file)
@@ -45,22 +45,24 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 // Add description as navigation point
 addMenuDescription('admin', __FILE__);
 
-if ((isFormSent('edit')) && (countPostSelection() > 0)) {
+if ((isFormSent('edit')) && (ifPostContainsSelections())) {
        // Edit ACLs
        $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($adminId, $action, $what, $mode) = SQL_FETCHROW($result);
+               $content = SQL_FETCHARRAY($result);
+
+               // Free result
                SQL_FREERESULT($result);
 
                // Prepare data for the row template
                $content = array(
-                       'id'               => $id,
-                       'admins_selection' => generateOptionList('admins', 'id', 'login', $adminId, 'default_acl'),
-                       'action_selection' => adminMenuSelectionBox_DEPRECATED('action', $action, $id),
-                       'what_selection'   => adminMenuSelectionBox_DEPRECATED('what', $what, $id),
+                       'id'               => $content['id'],
+                       'admins_selection' => generateOptionList('admins', 'id', 'login', $content['admin_id'], 'default_acl'),
+                       'action_selection' => adminMenuSelectionBox_DEPRECATED('action', $content['action_menu'], $content['id']),
+                       'what_selection'   => adminMenuSelectionBox_DEPRECATED('what', $content['what_menu'], $content['id']),
                        'mode_options'     => generateOptionList(
                                '/ARRAY/',
                                array('allow', 'deny'),
@@ -68,7 +70,7 @@ if ((isFormSent('edit')) && (countPostSelection() > 0)) {
                                        '{--ADMINS_ALLOW_MODE--}',
                                        '{--ADMINS_DENY_MODE--}'
                                ),
-                               $mode
+                               $content['access_mode']
                        ),
                );
 
@@ -78,7 +80,7 @@ if ((isFormSent('edit')) && (countPostSelection() > 0)) {
 
        // Load main template
        loadTemplate('admin_config_admins_edit', false, $OUT);
-} elseif ((isFormSent('change')) && (countPostSelection() > 0)) {
+} elseif ((isFormSent('change')) && (ifPostContainsSelections())) {
        // Change entries
        foreach (postRequestParameter('sel') as $id => $selected) {
                // Secure id
@@ -102,7 +104,7 @@ if ((isFormSent('edit')) && (countPostSelection() > 0)) {
 
        // Entries changed
        loadTemplate('admin_settings_saved', false, '{--ADMIN_ADMINS_ENTRIES_CHANGED--}');
-} elseif ((isFormSent('del')) && (countPostSelection() > 0)) {
+} elseif ((isFormSent('del')) && (ifPostContainsSelections())) {
        // Delete ACLs
        $OUT = '';
        foreach (postRequestParameter('sel') as $id => $selected) {
@@ -121,7 +123,7 @@ if ((isFormSent('edit')) && (countPostSelection() > 0)) {
 
        // Load main template
        loadTemplate('admin_config_admins_del', false, $OUT);
-} elseif ((isFormSent('remove')) && (countPostSelection() > 0)) {
+} elseif ((isFormSent('remove')) && (ifPostContainsSelections())) {
        // Remove entries
        // @TODO Rewrite this to filter 'run_sqls'
        foreach (postRequestParameter('sel') as $id => $selected) {
@@ -152,11 +154,11 @@ if ((isFormSent('edit')) && (countPostSelection() > 0)) {
                $BOTH = ((isPostRequestParameterSet('action_menu')) && (isPostRequestParameterSet('what_menu')));
                if (((isPostRequestParameterSet('action_menu')) || (isPostRequestParameterSet('what_menu'))) && ($BOTH === false)) {
                        // Main or sub menu selected
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE admin_id=%s AND action_menu='%s' AND what_menu='%s' LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `action_menu`='%s' AND `what_menu`='%s' LIMIT 1",
                                array(bigintval(postRequestParameter('admin_id')), postRequestParameter('action_menu'), postRequestParameter('what_menu')), __FILE__, __LINE__);
                        if (SQL_HASZERONUMS($result)) {
                                // Finally add the new ACL
-                               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (admin_id, action_menu, what_menu, access_mode)
+                               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (`admin_id`, `action_menu`, `what_menu`, `access_mode`)
 VALUES ('%s','%s','%s','%s')",
                                array(
                                        bigintval(postRequestParameter('admin_id')),
@@ -193,7 +195,7 @@ 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 = '';
                while ($content = SQL_FETCHARRAY($result_acls)) {
@@ -219,13 +221,13 @@ VALUES ('%s','%s','%s','%s')",
                '/ARRAY/',
                array('allow', 'deny'),
                array(
-                       'ADMINS_ALLOW_MODE--}',
-                       'ADMINS_DENY_MODE--}'
+                       '{--ADMINS_ALLOW_MODE--}',
+                       '{--ADMINS_DENY_MODE--}'
                )
        );
 
        // Load template for adding new ACL
-       loadTemplate('admin_admins_add_acl', false, $content);
+       loadTemplate('admin_add_admins_acl', false, $content);
 }
 
 // [EOF]