X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=ae6191a043e05021fe8b47ddbc5d7d0f1266c32a;hb=c9b2e406d8e94ffcff8bac9d453e671f337552e4;hp=82cb196abecc01361e90e739d807cffacc204b56;hpb=f4d7dc336fde4cebc47701026a94d193f77854a1;p=mailer.git
diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php
index 82cb196abe..ae6191a043 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
@@ -177,10 +177,10 @@ function doAdminAction () {
// Load header, footer, render menu
$content['header'] = loadTemplate('admin_header' , true, $content);
$content['footer'] = loadTemplate('admin_footer' , true, $content);
- $content['menu'] = addAdminMenu($action, $what, true);
+ $content['menu'] = addAdminMenu($action, $what);
- // Tableset header
- loadTemplate('admin_main_header', false, $content);
+ // Load main template
+ loadTemplate('admin_main', false, $content);
// Check if action/what pair is valid
$result_action = SQL_QUERY_ESC("SELECT
@@ -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,7 +235,7 @@ 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
@@ -248,18 +248,20 @@ function isAdminAllowedAccessMenu ($action, $what = null) {
}
// Adds an admin menu
-function addAdminMenu ($action, $what, $return = false) {
+function addAdminMenu ($action, $what) {
// Init variables
$SUB = false;
$OUT = '';
// Menu descriptions
$GLOBALS['menu']['description'] = array();
- $GLOBALS['menu']['title'] = array();
+ $GLOBALS['menu']['title'] = array();
// Build main menu
$result_main = SQL_QUERY("SELECT
- `action`, `title`, `descr`
+ `action` AS `main_action`,
+ `title` AS `main_title`,
+ `descr` AS `main_descr`
FROM
`{?_MYSQL_PREFIX?}_admin_menu`
WHERE
@@ -271,52 +273,76 @@ ORDER BY
// Do we have entries?
if (!SQL_HASZERONUMS($result_main)) {
$OUT .= '
';
- // @TODO Rewrite this to $content = SQL_FETCHARRAY()
- while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
+
+ // Load all 'action' menus
+ while ($mainContent = SQL_FETCHARRAY($result_main)) {
// Filename
- $inc = sprintf("inc/modules/admin/action-%s.php", $menu);
+ $inc = sprintf("inc/modules/admin/action-%s.php", $mainContent['main_action']);
// Is the file readable?
$readable = isIncludeReadable($inc);
// Is the current admin allowed to access this 'action' menu?
- if (isAdminAllowedAccessMenu($menu)) {
+ if (isAdminAllowedAccessMenu($mainContent['main_action'])) {
if ($SUB === false) {
// Insert compiled menu title and description
- $GLOBALS['menu']['title'][$menu] = $title;
- $GLOBALS['menu']['description'][$menu] = $descr;
+ $GLOBALS['menu']['title'][$mainContent['main_action']] = $mainContent['main_title'];
+ $GLOBALS['menu']['description'][$mainContent['main_action']] = $mainContent['main_descr'];
} // END - if
- $OUT .= '';
- // Check for menu entries
- $result_what = SQL_QUERY_ESC("SELECT
- `what`, `title`, `descr`
+ // Add sub menu
+ $OUT .= addAdminSubMenu($mainContent, $action, $what);
+ } // END - if
+ } // END - while
+
+ // Close ul-tag
+ $OUT .= '
';
+
+ // Free memory
+ SQL_FREERESULT($result_main);
+ } // END - if
+
+ // Return content
+ return $OUT;
+}
+
+// Add admin sub menu
+function addAdminSubMenu ($mainContent, $action, $what) {
+ // Init content
+ $OUT = '';
+
+ // Check for menu entries
+ $result_what = SQL_QUERY_ESC("SELECT
+ `what` AS `sub_what`,
+ `title` AS `sub_title`,
+ `descr` AS `sub_descr`
FROM
`{?_MYSQL_PREFIX?}_admin_menu`
WHERE
@@ -326,95 +352,137 @@ WHERE
ORDER BY
`sort` ASC,
`id` DESC",
- array($menu), __FUNCTION__, __LINE__);
-
- // Remember the count for later checks
- setAdminMenuHasEntries($menu, ((!SQL_HASZERONUMS($result_what)) && ($action == $menu)));
-
- // Do we have entries?
- if ((ifAdminMenuHasEntries($menu)) && (!SQL_HASZERONUMS($result_what))) {
- $GLOBALS['menu']['description'] = array();
- $GLOBALS['menu']['title'] = array();
- $SUB = true;
- $OUT .= '';
+
+ // Return content
+ return $OUT;
+}
+
+// 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 member selection box
-function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
+// 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 .= '