X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=fb70b05816708e712cf0e756b55367677d6e2d7f;hp=e34b0cf014f0a22421e43f54ca3c6bae1c479fdc;hb=e3934352dffa6eb9da59a137ae1a9414e5b4d80b;hpb=6a0c39a390c28999679d84a7ae5264363b0054dc diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index e34b0cf014..fb70b05816 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -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 * @@ -52,7 +52,7 @@ function addAdminAccount ($adminLogin, $passHash, $adminEmail) { // Is the entry there? if (SQL_HASZERONUMS($result)) { // Ok, let's create the admin login - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`,`password`,`email`) VALUES ('%s', '%s', '%s')", array( $adminLogin, $passHash, @@ -74,7 +74,7 @@ function addAdminAccount ($adminLogin, $passHash, $adminEmail) { function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) { // First of all, no admin login is found, so the admin hash is null $ret = '404'; - $adminHash = null; + $adminHash = NULL; // Get admin id from login $adminId = getAdminId($adminLogin); @@ -97,7 +97,7 @@ function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) { // All fine $ret = 'done'; } else { - // Set status + // Did not match! $ret = 'password'; } } // END - if @@ -216,14 +216,14 @@ LIMIT 1", loadInclude($inc); } elseif ($GLOBALS['acl_allow'] === false) { // Access denied - loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACCESS_DENIED', $what)); + loadTemplate('admin_menu_failed', false, '{%message,ADMIN_ACCESS_DENIED=' . $what . '%}'); } else { // Include file not found :-( - loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_404', $action)); + loadTemplate('admin_menu_failed', false, '{%message,ADMIN_ACTION_404=' . $action . '%}'); } } else { // Invalid action/what pair found - loadTemplate('admin_menu_failed', false, getMaskedMessage('ADMIN_ACTION_INVALID', $action . '/' . $what)); + loadTemplate('admin_menu_failed', false, '{%message,ADMIN_ACTION_INVALID=' . $action . '/' . $what . '%}'); } // Free memory @@ -235,12 +235,12 @@ LIMIT 1", // Checks wether current admin is allowed to access given action/what combination // (only one is allowed to be null!) -function isAdminAllowedAccessMenu ($action, $what = null) { +function isAdminAllowedAccessMenu ($action, $what = NULL) { // Do we have cache? if (!isset($GLOBALS[__FUNCTION__][$action][$what])) { // ACL is always 'allow' when no ext-admins is installed // @TODO This can be rewritten into a filter - $GLOBALS[__FUNCTION__][$action][$what] = ((!isExtensionInstalledAndNewer('admins', '0.2.0')) || (adminsCheckAdminAcl($action, $what))); + $GLOBALS[__FUNCTION__][$action][$what] = ((!isExtensionInstalledAndNewer('admins', '0.2.0')) || (isAdminsAllowedByAcl($action, $what))); } // END - if // Return the cached value @@ -259,7 +259,7 @@ function addAdminMenu ($action, $what, $return = false) { // Build main menu $result_main = SQL_QUERY("SELECT - `action`, `title`, `descr` + `action`,`title`,`descr` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE @@ -296,7 +296,7 @@ ORDER BY $OUT .= '['; } } else { - $OUT .= ''; + $OUT .= ''; } $OUT .= $title; @@ -316,7 +316,7 @@ ORDER BY // Check for menu entries $result_what = SQL_QUERY_ESC("SELECT - `what`, `title`, `descr` + `what`,`title`,`descr` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE @@ -359,7 +359,7 @@ ORDER BY $OUT .= '['; } } else { - $OUT .= ''; + $OUT .= ''; } $OUT .= $title_what; @@ -389,7 +389,7 @@ ORDER BY // Free memory SQL_FREERESULT($result_main); $OUT .= ''; - } + } // END - if // Is there a cache instance again? // Return or output content? @@ -400,21 +400,68 @@ ORDER BY } } -// Create member selection box -function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') { +// Create an admin selection box form +function addAdminSelectionBox ($adminId = NULL, $special = '') { + // Default is email as "special column" + $ADD = ',`email` AS `special`'; + + // Is a special column given? + if (!empty($special)) { + // Additional column for SQL query + $ADD = ',`' . $special . '` AS `special`'; + } // END - if + + // Query all entries + $result = SQL_QUERY('SELECT + `id`,`login`' . $ADD . ' +FROM + `{?_MYSQL_PREFIX?}_admins` +ORDER BY + `login` ASC', __FUNCTION__, __LINE__); + + // Init output + $OUT = ''; + + // Load all entries + while ($content = SQL_FETCHARRAY($result)) { + // Add the entry + $OUT .= loadTemplate('select_admins_option', true, $content); + } // END - if + + // Free memory + SQL_FREERESULT($result); + + // Add form to content + $content['form_selection'] = $OUT; + + // Output form + loadTemplate('select_admins_box', false, $content); +} + +// Create a member selection box +function addMemberSelectionBox ($userid = NULL, $add_all = false, $return = false, $none = false, $field = 'userid') { // Output selection form with all confirmed user accounts listed - $result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SELECT + `userid`,`surname`,`family` +FROM + `{?_MYSQL_PREFIX?}_user_data` +ORDER BY + `userid` ASC', __FUNCTION__, __LINE__); // Default output $OUT = ''; // USe this only for adding points (e.g. adding refs really makes no sence ;-) ) - if ($add_all === true) $OUT = ' '; - elseif ($none === true) $OUT = ' '; + if ($add_all === true) { + $OUT = ' '; + } elseif ($none === true) { + $OUT = ' '; + } + // Load all entries while ($content = SQL_FETCHARRAY($result)) { $OUT .= '' . $login . ''; } else { // Extension not found - $adminLink = getMaskedMessage('ADMIN_TASK_ROW_EXTENSION_NOT_INSTALLED', 'admins'); + $adminLink = '{%message,ADMIN_TASK_ROW_EXTENSION_NOT_INSTALLED=admins%}'; } } else { // Maybe deleted? - $adminLink = '
' . getMaskedMessage('ADMIN_ID_404', $adminId) . '
'; + $adminLink = '
{%message,ADMIN_ID_404=' . $adminId . '%}
'; } } // END - if @@ -1320,7 +1662,7 @@ function doVerifyExpertSettings () { // Ask for them if (isFormSent()) { // Is the element set, then we need to change the admin - if (isPostRequestParameterSet('expert_settings')) { + if (isPostRequestElementSet('expert_settings')) { // Get it and prepare final post data array $postData['login'][getCurrentAdminId()] = getCurrentAdminLogin(); $postData['expert_warning'][getCurrentAdminId()] = 'N'; @@ -1329,7 +1671,7 @@ function doVerifyExpertSettings () { adminsChangeAdminAccount($postData, 'expert_warning'); // Clear form - unsetPostRequestParameter('ok'); + unsetPostRequestElement('ok'); } // END - if // All fine! @@ -1395,7 +1737,7 @@ function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=f $NAV = ''; for ($page = 1; $page <= $numPages; $page++) { // Is the page currently selected or shall we generate a link to it? - if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) { + if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) { // Is currently selected, so only highlight it $NAV .= '-'; } else { @@ -1403,13 +1745,13 @@ function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=f $NAV .= ''; } $NAV .= $page; - if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) { + if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) { // Is currently selected, so only highlight it $NAV .= '-'; } else { @@ -1417,7 +1759,7 @@ function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=f $NAV .= ''; } - // Add seperator if we have not yet reached total pages + // Add separator if we have not yet reached total pages if ($page < $numPages) { // Add it $NAV .= '|'; @@ -1444,7 +1786,7 @@ function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=f // Process menu editing form function adminProcessMenuEditForm ($type, $subMenu) { // An action is done... - foreach (postRequestParameter('sel') as $sel => $menu) { + foreach (postRequestElement('sel') as $sel => $menu) { $AND = "(`what` = '' OR `what` IS NULL)"; $sel = bigintval($sel); @@ -1453,25 +1795,25 @@ function adminProcessMenuEditForm ($type, $subMenu) { $AND = "`action`='" . $subMenu . "'"; } // END - if - switch (postRequestParameter('ok')) { + switch (postRequestElement('ok')) { case 'edit': // Edit menu - if (postRequestParameter('sel_what', $sel) == '') { + if (postRequestElement('sel_what', $sel) == '') { // Update with 'what'=null - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s',`action`='%s',`what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1", array( $type, $menu, - postRequestParameter('sel_action', $sel), + postRequestElement('sel_action', $sel), $sel ), __FILE__, __LINE__); } else { // Update with selected 'what' - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s',`action`='%s',`what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1", array( $type, $menu, - postRequestParameter('sel_action', $sel), - postRequestParameter('sel_what', $sel), + postRequestElement('sel_action', $sel), + postRequestElement('sel_what', $sel), $sel ), __FILE__, __LINE__); } @@ -1483,13 +1825,13 @@ function adminProcessMenuEditForm ($type, $subMenu) { break; case 'status': // Change status of menus - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1", - array($type, postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s',`locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1", + array($type, postRequestElement('visible', $sel), postRequestElement('locked', $sel), $sel), __FILE__, __LINE__); break; default: // Unexpected action - logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok'))); - displayMessage(getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok'))); + logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestElement('ok'))); + displayMessage('{%message,ADMIN_UNKNOWN_OKAY=' . postRequestElement('ok') . '%}'); break; } // END - switch } // END - foreach @@ -1501,26 +1843,26 @@ function adminProcessMenuEditForm ($type, $subMenu) { // Handle weightning function doAdminProcessMenuWeightning ($type, $AND) { // Are there all required (generalized) GET parameter? - if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) { + if ((isGetRequestElementSet('act')) && (isGetRequestElementSet('tid')) && (isGetRequestElementSet('fid'))) { // Init variables $tid = ''; $fid = ''; // Get ids - if (isGetRequestParameterSet('w')) { + if (isGetRequestElementSet('w')) { // Sub menus selected $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1", array( $type, - getRequestParameter('act'), - bigintval(getRequestParameter('tid')) + getRequestElement('act'), + bigintval(getRequestElement('tid')) ), __FILE__, __LINE__); list($tid) = SQL_FETCHROW($result); SQL_FREERESULT($result); $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1", array( $type, - getRequestParameter('act'), - bigintval(getRequestParameter('fid')) + getRequestElement('act'), + bigintval(getRequestElement('fid')) ), __FILE__, __LINE__); list($fid) = SQL_FETCHROW($result); SQL_FREERESULT($result); @@ -1529,14 +1871,14 @@ function doAdminProcessMenuWeightning ($type, $AND) { $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1", array( $type, - bigintval(getRequestParameter('tid')) + bigintval(getRequestElement('tid')) ), __FILE__, __LINE__); list($tid) = SQL_FETCHROW($result); SQL_FREERESULT($result); $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1", array( $type, - bigintval(getRequestParameter('fid')) + bigintval(getRequestElement('fid')) ), __FILE__, __LINE__); list($fid) = SQL_FETCHROW($result); SQL_FREERESULT($result); @@ -1547,13 +1889,13 @@ function doAdminProcessMenuWeightning ($type, $AND) { SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1", array( $type, - bigintval(getRequestParameter('tid')), + bigintval(getRequestElement('tid')), bigintval($fid) ), __FILE__, __LINE__); SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1", array( $type, - bigintval(getRequestParameter('fid')), + bigintval(getRequestElement('fid')), bigintval($tid) ), __FILE__, __LINE__); } // END - if