X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-config_admins.php;h=f98b503e9ee917c5bd6c1999337234943a257961;hb=0176313718a3887a7d833d578142ae41d3a06a15;hp=b5c0af248dfd7aa7425fd98d225872fb782d85e2;hpb=fe8e4c180ec67e320be98e1e8dc1f9ea612c3636;p=mailer.git diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php index b5c0af248d..f98b503e9e 100644 --- a/inc/modules/admin/what-config_admins.php +++ b/inc/modules/admin/what-config_admins.php @@ -14,10 +14,9 @@ * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * * $Author:: $ * - * Needs to be in all Files and every File needs "svn propset * - * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * + * Copyright (c) 2009 - 2011 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -39,111 +38,103 @@ // Some security stuff... if ((!defined('__SECURITY')) || (!isAdmin())) { die(); -} +} // END - if // Add description as navigation point -addMenuDescription('admin', __FILE__); +addYouAreHereLink('admin', __FILE__); -if ((isPostRequestElementSet('edit')) && (countPostSelection() > 0)) { +if ((isFormSent('edit')) && (ifPostContainsSelections())) { // Edit ACLs - $OUT = ''; $SW = 2; - foreach (postRequestElement('sel') as $id => $selected) { + $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( - 'sw' => $SW, - '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'), array( - getMessage('ADMINS_ALLOW_MODE'), - getMessage('ADMINS_DENY_MODE') + '{--ADMIN_ADMINS_MODE_ALLOW--}', + '{--ADMIN_ADMINS_MODE_DENY--}' ), - $mode + $content['access_mode'] ), ); // 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 ((isPostRequestElementSet('change')) && (countPostSelection() > 0)) { +} elseif ((isFormSent('change')) && (ifPostContainsSelections())) { // Change entries - foreach (postRequestElement('sel') as $id => $selected) { + 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( - postRequestElement('admin', $id), - postRequestElement('action_menu', $id), - postRequestElement('what_menu', $id), - postRequestElement('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 + // @TODO Rewrite this to a filter if (isExtensionActive('cache')) { if ($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) $GLOBALS['cache_instance']->removeCacheFile(); } // END - if // Entries changed - loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ADMINS_ENTRIES_CHANGED')); -} elseif ((isPostRequestElementSet('del')) && (countPostSelection() > 0)) { + displayMessage('{--ADMIN_ADMINS_ENTRIES_CHANGED--}'); +} elseif ((isFormSent('delete')) && (ifPostContainsSelections())) { // Delete ACLs - $OUT = ''; $SW = 2; - foreach (postRequestElement('sel') as $id => $selected) { + $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'] = '{--ADMIN_ADMINS_MODE_' . strtoupper($content['access_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 ((isPostRequestElementSet('remove')) && (countPostSelection() > 0)) { +} elseif ((isFormSent('remove')) && (ifPostContainsSelections())) { // Remove entries // @TODO Rewrite this to filter 'run_sqls' - foreach (postRequestElement('sel') as $id => $selected) { + 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 @@ -154,36 +145,40 @@ if ((isPostRequestElementSet('edit')) && (countPostSelection() > 0)) { } // END - if // Entries deleted - loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ADMINS_ENTRIES_DELETED')); -} elseif (isPostRequestElementSet('add')) { + displayMessage('{--ADMIN_ADMINS_ENTRIES_DELETED--}'); +} elseif (isFormSent('add')) { // Check if everything is fine... - $mode = getAdminDefaultAcl(bigintval(postRequestElement('admin_id'))); + $mode = getAdminDefaultAcl(bigintval(postRequestParameter('admin_id'))); // Default ACL is false $ACL = false; - if (isPostRequestElementSet('what_menu')) { + if (isPostRequestParameterSet('what_menu')) { // Check parent ACL - $ACL = adminsCheckAdminAcl(getModeAction('admin', postRequestElement('what_menu')), ''); + $ACL = adminsCheckAdminAcl(getActionFromModuleWhat('admin', postRequestParameter('what_menu')), ''); } // END - if - if (($mode != postRequestElement('mode')) || ($ACL)) { + if (($mode != postRequestParameter('mode')) || ($ACL)) { // Mode is fine - $BOTH = ((isPostRequestElementSet('action_menu')) && (isPostRequestElementSet('what_menu'))); - if (((isPostRequestElementSet('action_menu')) || (isPostRequestElementSet('what_menu'))) && ($BOTH === false)) { + $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(postRequestElement('admin_id')), postRequestElement('action_menu'), postRequestElement('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(postRequestElement('admin_id')), - postRequestElement('action_menu'), - postRequestElement('what_menu'), - postRequestElement('mode') + bigintval(postRequestParameter('admin_id')), + postRequestParameter('action_menu'), + 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')) { @@ -191,51 +186,36 @@ 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 - loadTemplate('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` 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 @@ -253,14 +233,14 @@ VALUES ('%s','%s','%s','%s')", '/ARRAY/', array('allow', 'deny'), array( - getMessage('ADMINS_ALLOW_MODE'), - getMessage('ADMINS_DENY_MODE') + '{--ADMIN_ADMINS_MODE_ALLOW--}', + '{--ADMIN_ADMINS_MODE_DENY--}' ) ); // Load template for adding new ACL - loadTemplate('admin_admins_add_acl', false, $content); + loadTemplate('admin_add_admins_acl', false, $content); } -// +// [EOF] ?>