]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-list_admins_acls.php
Admin menu prepared for AJAX requests:
[mailer.git] / inc / modules / admin / what-list_admins_acls.php
index e8159b074c4d8f31666889d61138f2ef1b0676a5..65c605e1b348cd2a28fda0806b2cd288ad2c3dbf 100644 (file)
@@ -17,7 +17,7 @@
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -46,10 +46,12 @@ addYouAreHereLink('admin', __FILE__);
 if ((isFormSent('edit')) && (ifPostContainsSelections())) {
        // Edit ACLs
        $OUT = '';
-       foreach (postRequestParameter('sel') as $id => $selected) {
+       foreach (postRequestElement('sel') as $id => $selected) {
                // Load data for the id
-               $result = SQL_QUERY_ESC("SELECT `id`, `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__);
+
+               // Load all data
                $content = SQL_FETCHARRAY($result);
 
                // Free result
@@ -61,15 +63,6 @@ if ((isFormSent('edit')) && (ifPostContainsSelections())) {
                        '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'),
-                               array(
-                                       '{--ADMIN_ADMINS_ACCESS_MODE_ALLOW--}',
-                                       '{--ADMIN_ADMINS_ACCESS_MODE_DENY--}'
-                               ),
-                               $content['access_mode']
-                       ),
                );
 
                // Load row template
@@ -78,9 +71,9 @@ if ((isFormSent('edit')) && (ifPostContainsSelections())) {
 
        // Load main template
        loadTemplate('admin_edit_admins_acls', false, $OUT);
-} elseif ((isFormSent('change')) && (ifPostContainsSelections())) {
+} elseif ((isFormSent('do_edit')) && (ifPostContainsSelections())) {
        // Change entries
-       foreach (postRequestParameter('sel') as $id => $selected) {
+       foreach (postRequestElement('sel') as $id => $selected) {
                // Secure id
                $id = bigintval($id);
 
@@ -96,10 +89,10 @@ WHERE
        `id`=%s
 LIMIT 1",
                        array(
-                               postRequestParameter('admin', $id),
-                               postRequestParameter('action_menu', $id),
-                               postRequestParameter('what_menu', $id),
-                               postRequestParameter('mode', $id),
+                               postRequestElement('admin', $id),
+                               postRequestElement('action_menu', $id),
+                               postRequestElement('what_menu', $id),
+                               postRequestElement('mode', $id),
                                $id
                        ),__FILE__, __LINE__);
        } // END - foreach
@@ -115,9 +108,9 @@ LIMIT 1",
 } elseif ((isFormSent('delete')) && (ifPostContainsSelections())) {
        // Delete ACLs
        $OUT = '';
-       foreach (postRequestParameter('sel') as $id => $selected) {
+       foreach (postRequestElement('sel') as $id => $selected) {
                // Load data for the id
-               $result = SQL_QUERY_ESC("SELECT `id`, `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__);
                $content = SQL_FETCHARRAY($result);
                SQL_FREERESULT($result);
@@ -131,10 +124,10 @@ LIMIT 1",
 
        // Load main template
        loadTemplate('admin_delete_admins_acls', false, $OUT);
-} elseif ((isFormSent('remove')) && (ifPostContainsSelections())) {
+} elseif ((isFormSent('do_delete')) && (ifPostContainsSelections())) {
        // Remove entries
        // @TODO Rewrite this to filter 'run_sqls'
-       foreach (postRequestParameter('sel') as $id => $selected) {
+       foreach (postRequestElement('sel') as $id => $selected) {
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
                        array(bigintval($id)),__FILE__, __LINE__);
        } // END - foreach
@@ -148,37 +141,37 @@ LIMIT 1",
        displayMessage('{--ADMIN_ADMINS_ENTRIES_DELETED--}');
 } elseif (isFormSent('add')) {
        // Check if everything is fine...
-       $mode = getAdminDefaultAcl(bigintval(postRequestParameter('admin_id')));
+       $mode = getAdminDefaultAcl(bigintval(postRequestElement('admin_id')));
 
        // Default ACL is false
        $ACL = false;
-       if (isPostRequestParameterSet('what_menu')) {
+       if (isPostRequestElementSet('what_menu')) {
                // Check parent ACL
-               $ACL = adminsCheckAdminAcl(getActionFromModuleWhat('admin', postRequestParameter('what_menu')), '');
+               $ACL = isAdminsAllowedByAcl(getActionFromModuleWhat('admin', postRequestElement('what_menu')), '');
        } // END - if
 
-       if (($mode != postRequestParameter('mode')) || (($ACL === true) && (postRequestParameter('mode') == 'deny'))) {
+       if (($mode != postRequestElement('mode')) || (($ACL === true) && (postRequestElement('mode') == 'deny'))) {
                // Mode is fine
-               $BOTH = ((isPostRequestParameterSet('action_menu')) && (isPostRequestParameterSet('what_menu')) && (postRequestParameter('action_menu') != '') && (postRequestParameter('what_menu') != ''));
+               $BOTH = ((isPostRequestElementSet('action_menu')) && (isPostRequestElementSet('what_menu')) && (postRequestElement('action_menu') != '') && (postRequestElement('what_menu') != ''));
 
                // Check if one has been selected
-               if ((((isPostRequestParameterSet('action_menu')) && (postRequestParameter('action_menu') != '')) || ((isPostRequestParameterSet('what_menu')) && (postRequestParameter('what_menu') != ''))) && ($BOTH === false)) {
+               if ((((isPostRequestElementSet('action_menu')) && (postRequestElement('action_menu') != '')) || ((isPostRequestElementSet('what_menu')) && (postRequestElement('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",
                                array(
-                                       bigintval(postRequestParameter('admin_id')),
-                                       postRequestParameter('action_menu'),
-                                       postRequestParameter('what_menu')
+                                       bigintval(postRequestElement('admin_id')),
+                                       postRequestElement('action_menu'),
+                                       postRequestElement('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`)
-VALUES ('%s','%s','%s','%s')",
+                               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')),
-                                       postRequestParameter('action_menu'),
-                                       postRequestParameter('what_menu'),
-                                       postRequestParameter('mode')
+                                       bigintval(postRequestElement('admin_id')),
+                                       postRequestElement('action_menu'),
+                                       postRequestElement('what_menu'),
+                                       postRequestElement('mode')
                                ), __FILE__, __LINE__);
                                $content = '{--ADMIN_ADMINS_ACL_SAVED--}';
 
@@ -206,7 +199,7 @@ VALUES ('%s','%s','%s','%s')",
        displayMessage($content);
 } else {
        // List all ACLs
-       $result = 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__);
+       $result = 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_HASZERONUMS($result)) {
@@ -231,14 +224,6 @@ VALUES ('%s','%s','%s','%s')",
        $content['admins_selection'] = generateOptionList('admins', 'id', 'login', '', 'default_acl');
        $content['action_selection'] = adminMenuSelectionBox_DEPRECATED('action');
        $content['what_selection']   = adminMenuSelectionBox_DEPRECATED('what');
-       $content['mode_options']     = generateOptionList(
-               '/ARRAY/',
-               array('allow', 'deny'),
-               array(
-                       '{--ADMIN_ADMINS_ACCESS_MODE_ALLOW--}',
-                       '{--ADMIN_ADMINS_ACCESS_MODE_DENY--}'
-               )
-       );
 
        // Load template for adding new ACL
        loadTemplate('admin_add_admins_acl', false, $content);