X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-config_admins.php;h=f98b503e9ee917c5bd6c1999337234943a257961;hb=0176313718a3887a7d833d578142ae41d3a06a15;hp=feb20a53ec26e7ecab8b4f8ae1176016b3a120db;hpb=1e6e1b8fbc79df082c8463f3e7eb72ae4761287c;p=mailer.git
diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php
index feb20a53ec..f98b503e9e 100644
--- a/inc/modules/admin/what-config_admins.php
+++ b/inc/modules/admin/what-config_admins.php
@@ -1,7 +1,7 @@
0)) {
+if ((isFormSent('edit')) && (ifPostContainsSelections())) {
// Edit ACLs
- $SW = 2; $OUT = "";
- foreach ($_POST['sel'] as $id => $sel) {
- // 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",
- array(bigintval($id)), __FILE__, __LINE__);
- list($aid, $act, $wht, $mode) = SQL_FETCHROW($result);
+ $OUT = '';
+ foreach (postRequestParameter('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",
+ array(bigintval($id)), __FILE__, __LINE__);
+ $content = SQL_FETCHARRAY($result);
+
+ // Free result
SQL_FREERESULT($result);
// Prepare data for the row template
$content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'admins_selection' => ADD_OPTION_LINES("admins", "id", "login", $aid, "default_acl"),
- 'action_selection' => ADMIN_MENU_SELECTION("action", $act, $id),
- 'what_selection' => ADMIN_MENU_SELECTION("what", $wht, $id),
- 'mode_options' => ADD_OPTION_LINES(
- "/ARRAY/",
- array("allow", "deny"),
- array(ADMINS_ALLOW_MODE, ADMINS_DENY_MODE),
- $mode
+ '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'),
+ array(
+ '{--ADMIN_ADMINS_MODE_ALLOW--}',
+ '{--ADMIN_ADMINS_MODE_DENY--}'
+ ),
+ $content['access_mode']
),
);
// Load row template
- $OUT .= LOAD_TEMPLATE("admin_config_admins_edit_row", true, $content);
- $SW = 3 - $SW;
- }
- define('__ACL_ROWS', $OUT);
+ $OUT .= loadTemplate('admin_config_admins_edit_row', true, $content);
+ } // END - foreach
// Load main template
- LOAD_TEMPLATE("admin_config_admins_edit");
-} elseif ((isset($_POST['change'])) && ($SEL > 0)) {
+ loadTemplate('admin_config_admins_edit', false, $OUT);
+} elseif ((isFormSent('change')) && (ifPostContainsSelections())) {
// Change entries
- foreach ($_POST['sel'] as $id => $sel) {
- // Secure ID
+ foreach (postRequestParameter('sel') as $id => $selected) {
+ // Secure id
$id = bigintval($id);
// Update entries
- SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_admins_acls SET admin_id=%s, action_menu='%s', what_menu='%s', access_mode='%s' WHERE id=%s LIMIT 1",
- array($_POST['admin'][$id], $_POST['action_menu'][$id], $_POST['what_menu'][$id], $_POST['mode'][$id], $id),__FILE__, __LINE__);
- }
+ SQL_QUERY_ESC("UPDATE
+ `{?_MYSQL_PREFIX?}_admins_acls`
+SET
+ `admin_id`=%s,
+ `action_menu`='%s',
+ `what_menu`='%s',
+ `access_mode`='%s'
+WHERE
+ `id`=%s
+LIMIT 1",
+ array(
+ postRequestParameter('admin', $id),
+ postRequestParameter('action_menu', $id),
+ postRequestParameter('what_menu', $id),
+ postRequestParameter('mode', $id),
+ $id
+ ),__FILE__, __LINE__);
+ } // END - foreach
// Update cache when installed
- if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("admins_acls")) $cacheInstance->destroyCacheFile();
-
- // Purge menu cache
- CACHE_PURGE_ADMIN_MENU($_POST['admin'][$id]);
- }
+ // @TODO Rewrite this to a filter
+ if (isExtensionActive('cache')) {
+ if ($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) $GLOBALS['cache_instance']->removeCacheFile();
+ } // END - if
// Entries changed
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ADMINS_ENTRIES_CHANGED);
-} elseif ((isset($_POST['del'])) && ($SEL > 0)) {
+ displayMessage('{--ADMIN_ADMINS_ENTRIES_CHANGED--}');
+} elseif ((isFormSent('delete')) && (ifPostContainsSelections())) {
// Delete ACLs
- $SW = 2; $OUT = "";
- foreach ($_POST['sel'] as $id => $sel) {
- // 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",
+ $OUT = '';
+ foreach (postRequestParameter('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",
array(bigintval($id)), __FILE__, __LINE__);
- list($admin, $act, $wht, $mode) = SQL_FETCHROW($result);
+ $content = SQL_FETCHARRAY($result);
SQL_FREERESULT($result);
- // Prepare variables
- if (empty($act)) $act = "---";
- if (empty($wht)) $wht = "---";
-
// Get admin mode
- $mode = constant('ADMINS_'.strtoupper($mode).'_MODE');
-
- // Load admin's data
- $login = GET_ADMIN_LOGIN($admin);
- if ($login != "***") {
- // Admin found
- $admin = "".$login."";
- } else {
- // Maybe deleted?
- $admin = "".ADMIN_ID_404_1.$admin.ADMIN_ID_404_2."";
- }
-
- // Prepare data for the row template
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'admin' => $admin,
- 'action' => $act,
- 'what' => $wht,
- 'mode' => $mode,
- );
+ $content['access_mode'] = '{--ADMIN_ADMINS_MODE_' . strtoupper($content['access_mode']) . '--}';
// Load row template and switch colors
- $OUT .= LOAD_TEMPLATE("admin_config_admins_del_row", true, $content);
- $SW = 3 - $SW;
- }
- define('__ACL_ROWS', $OUT);
+ $OUT .= loadTemplate('admin_config_admins_del_row', true, $content);
+ } // END - foreach
// Load main template
- LOAD_TEMPLATE("admin_config_admins_del");
-} elseif ((isset($_POST['remove'])) && ($SEL > 0)) {
+ loadTemplate('admin_config_admins_del', false, $OUT);
+} elseif ((isFormSent('remove')) && (ifPostContainsSelections())) {
// Remove entries
- foreach ($_POST['sel'] as $id => $sel) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admins_acls WHERE id=%s LIMIT 1",
+ // @TODO Rewrite this to filter 'run_sqls'
+ foreach (postRequestParameter('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
// Update cache when installed
- if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("admins_acls")) $cacheInstance->destroyCacheFile();
-
- // @TODO This causes the whole (!) menu cache being rebuild
- CACHE_PURGE_ADMIN_MENU();
- }
+ if (isExtensionActive('cache')) {
+ if ($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) $GLOBALS['cache_instance']->removeCacheFile();
+ } // END - if
// Entries deleted
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ADMINS_ENTRIES_DELETED);
-} elseif (isset($_POST['add'])) {
+ displayMessage('{--ADMIN_ADMINS_ENTRIES_DELETED--}');
+} elseif (isFormSent('add')) {
// Check if everything is fine...
- $mode = GET_ADMIN_DEFAULT_ACL(bigintval($_POST['admin_id']));
+ $mode = getAdminDefaultAcl(bigintval(postRequestParameter('admin_id')));
// Default ACL is false
$ACL = false;
- if (!empty($_POST['what_menu'])) {
+ if (isPostRequestParameterSet('what_menu')) {
// Check parent ACL
- $ACL = ADMINS_CHECK_ACL(GET_ACTION("admin", $_POST['what_menu']), "");
- }
+ $ACL = adminsCheckAdminAcl(getActionFromModuleWhat('admin', postRequestParameter('what_menu')), '');
+ } // END - if
- if ($mode != $_POST['mode'] || ($ACL)) {
+ if (($mode != postRequestParameter('mode')) || ($ACL)) {
// Mode is fine
- $BOTH = ((!empty($_POST['action_menu'])) && (!empty($_POST['what_menu'])));
- if (((!empty($_POST['action_menu'])) || (!empty($_POST['what_menu']))) && (!$BOTH)) {
+ $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",
- array(bigintval($_POST['admin_id']), $_POST['action_menu'], $_POST['what_menu']), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0) {
+ $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($_POST['admin_id']),
- $_POST['action_menu'],
- $_POST['what_menu'],
- $_POST['mode']
-), __FILE__, __LINE__);
- $content = ADMIN_ADMINS_ACL_SAVED;
+ array(
+ bigintval(postRequestParameter('admin_id')),
+ postRequestParameter('action_menu'),
+ postRequestParameter('what_menu'),
+ postRequestParameter('mode')
+ ), __FILE__, __LINE__);
+ $content = '{--ADMIN_ADMINS_ACL_SAVED--}';
// Update cache when installed
- if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("admins_acls")) $cacheInstance->destroyCacheFile();
-
- // Purge cache
- CACHE_PURGE_ADMIN_MENU($_POST['admin_id'], $_POST['action_menu'], $_POST['what_menu']);
+ if (isExtensionActive('cache')) {
+ if ($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) $GLOBALS['cache_instance']->removeCacheFile();
} // END - if
} else {
// ACL does already exist!
- $content = 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 = ADMIN_ADMINS_SELECT_ACTION_WHAT;
+ $content = '{--ADMIN_ADMINS_SELECT_ACTION_WHAT--}';
}
} else {
// Same mode makes no sence...
- $content = ADMIN_ADMINS_SAME_MODE_SELECTED;
+ $content = '{--ADMIN_ADMINS_SAME_MODE_SELECTED--}';
}
// Display message
- LOAD_TEMPLATE("admin_settings_saved", false, $content);
+ displayMessage($content);
} else {
// List all ACLs
- $result_acls = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, id", __FILE__, __LINE__);
- if (SQL_NUMROWS($result_acls) > 0)
- {
- // List ACLs
- $SW = 2; $OUT = "";
- while(list($id, $admin, $act, $wht, $mode) = SQL_FETCHROW($result_acls))
- {
- // Prepare variables
- if (empty($act)) $act = "---";
- if (empty($wht)) $wht = "---";
+ $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__);
- // Get mode
- $mode = constant('ADMINS_'.strtoupper($mode).'_MODE');
-
- // Load admin's data
- $login = GET_ADMIN_LOGIN($admin);
- if ($login != "***")
- {
- // Admin found
- $admin = "".$login."";
- }
- else
- {
- // Maybe deleted?
- $admin = "".ADMIN_ID_404_1.$admin.ADMIN_ID_404_2."";
- }
-
- // Prepare data for the row template
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'admin' => $admin,
- 'action' => $act,
- 'what' => $wht,
- 'mode' => $mode,
- );
+ // Entries found?
+ if (!SQL_HASZERONUMS($result_acls)) {
+ // List ACLs
+ $OUT = '';
+ while ($content = SQL_FETCHARRAY($result_acls)) {
+ // Generate mode string
+ $content['access_mode'] = '{--ADMINS_' . strtoupper($content['access_mode']) . '_MODE--}';
// Load row template and switch colors
- $OUT .= LOAD_TEMPLATE("admin_config_admins_row", true, $content);
- $SW = 3 - $SW;
- }
+ $OUT .= loadTemplate('admin_config_admins_row', true, $content);
+ } // END - while
// Free memory
SQL_FREERESULT($result);
- define('__ACL_ROWS', $OUT);
// Load main template
- LOAD_TEMPLATE("admin_config_admins");
- }
+ loadTemplate('admin_config_admins', false, $OUT);
+ } // END - if
// Prepare some constants for the template
- define('_ADMINS_SELECTION', ADD_OPTION_LINES("admins", "id", "login", "", "default_acl"));
- define('_ACTION_SELECTION', ADMIN_MENU_SELECTION("action"));
- define('_WHAT_SELECTION' , ADMIN_MENU_SELECTION("what"));
- define('_MODE_OPTIONS' , ADD_OPTION_LINES("/ARRAY/", array("allow", "deny"), array(ADMINS_ALLOW_MODE, ADMINS_DENY_MODE)));
+ $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_MODE_ALLOW--}',
+ '{--ADMIN_ADMINS_MODE_DENY--}'
+ )
+ );
// Load template for adding new ACL
- LOAD_TEMPLATE("admin_admins_add_acl");
+ loadTemplate('admin_add_admins_acl', false, $content);
}
-//
+// [EOF]
?>