X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-admins_mails.php;h=16e4a6a3950e0777b4432b4825de5d5399a3f9d7;hb=eb301334eb0960dd060cc0d59e6021260a41f835;hp=98098a7631aef516b9d6d8887c6028441a7cc21b;hpb=ac04130f9ccbaba51d7d7992d8a10c38db776eee;p=mailer.git
diff --git a/inc/modules/admin/what-admins_mails.php b/inc/modules/admin/what-admins_mails.php
index 98098a7631..16e4a6a395 100644
--- a/inc/modules/admin/what-admins_mails.php
+++ b/inc/modules/admin/what-admins_mails.php
@@ -10,9 +10,14 @@
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Stellen Sie ein, welcher Admin welche Mail erh. *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $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 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -32,167 +37,150 @@
************************************************************************/
// Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+ die();
}
// Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+addMenuDescription('admin', __FILE__);
-if (isset($_POST['edit']))
-{
+if (isPostRequestElementSet('edit')) {
// Check if entires are checked
- $SEL = SELECTION_COUNT($_POST['sel']);
- if ($SEL > 0)
- {
- // Add option for userlog
- $cacheArray['admins'] = ADD_OPTION_LINES("admins", "id", "login", "", "email");
- $SW = 2; $rowNameS = "";
- foreach ($_POST['sel'] as $template => $sel)
- {
+ $SEL = countPostSelection();
+ if ($SEL > 0) {
+ // Add option for events
+ $adminsList = generateOptionList('admins', 'id', 'login', '', 'email');
+ $SW = 2; $rowNameS = '';
+ foreach (postRequestElement('sel') as $template => $sel) {
// First of all load data from DB
- $result = SQL_QUERY_ESC("SELECT admin_id, id FROM "._MYSQL_PREFIX."_admins_mails WHERE mail_template='%s' ORDER BY id",
- array($template), __FILE__, __LINE__);
- $OUT = ""; $aid = 0; $aid2 = 0;
- while (list($aid, $id) = SQL_FETCHROW($result))
- {
- $OUT .= "\n
\n";
+ $adminId2 = $content['admin_id']; $id2 = $content['id'];
}
// Free memory
SQL_FREERESULT($result);
+ // Prepare content
$content = array(
'sw' => $SW,
'id' => $id,
'id2' => $id2,
'tpl' => $template,
- 'admins' => $cacheArray['admins']
+ 'admins' => $adminsList
);
- if ($aid2 > 0)
- {
+ if ($adminId2 > 0) {
// Add form for an additional admin
- $OUT .= LOAD_TEMPLATE("admin_admins_mails_edit_form", true, $content);
- }
+ $OUT .= loadTemplate('admin_admins_mails_edit_form', true, $content);
+ } // END - if
+
// Save full rendered content
$content['content'] = $OUT;
// Start outputing line
- $rowNameS .= LOAD_TEMPLATE("admin_admins_mails_edit_row", true, $content);
+ $rowNameS .= loadTemplate('admin_admins_mails_edit_row', true, $content);
$SW = 3 - $SW;
}
- define('__ADMINS_ROWS', $rowNameS);
// Edit checked entries
- LOAD_TEMPLATE("admin_admins_mails_edit");
- }
- else
- {
+ loadTemplate('admin_admins_mails_edit', false, $rowNameS);
+ } else {
// Nothing selected
- LOAD_TEMPLATE("admin_settings_saved", false, ADMINS_NO_MAIL_CHECKED);
+ loadTemplate('admin_settings_saved', false, getMessage('ADMINS_NO_MAIL_CHECKED'));
}
-}
- else
-{
+} else {
// Load all assigned mails
- $result = SQL_QUERY("SELECT DISTINCT m.id, m.admin_id, a.login, m.mail_template
-FROM "._MYSQL_PREFIX."_admins_mails AS m
-LEFT JOIN "._MYSQL_PREFIX."_admins AS a
-ON m.admin_id=a.id
-WHERE (m.admin_id=a.id OR m.admin_id < 1) AND m.mail_template != ''
-ORDER BY m.admin_id, m.mail_template", __FILE__, __LINE__);
-
- if (SQL_NUMROWS($result) > 0)
- {
+ $result = SQL_QUERY("SELECT
+ m.id, m.admin_id, a.login, m.mail_template
+FROM
+ `{?_MYSQL_PREFIX?}_admins_mails` AS m
+LEFT JOIN
+ `{?_MYSQL_PREFIX?}_admins` AS a
+ON
+ m.admin_id=a.id
+WHERE
+ (m.admin_id=a.id OR m.admin_id < 1) AND m.mail_template != ''
+ORDER BY
+ m.admin_id ASC,
+ m.mail_template ASC", __FILE__, __LINE__);
+
+ if (SQL_NUMROWS($result) > 0) {
// Shall I change entries?
- if (isset($_POST['change']))
- {
+ if (isPostRequestElementSet('change')) {
+ // Init SQLs
+ initSqls();
+
// Ok, update database
- foreach ($_POST['admin_id'] as $id => $aid)
- {
+ foreach (postRequestElement('admin_id') as $id => $content['admin_id']) {
// Secure IDs
$id = bigintval($id);
- $aid = bigintval($aid);
+ $content['admin_id'] = bigintval($content['admin_id']);
// Update entry
- SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_admins_mails SET admin_id=%s WHERE id=%s ORDER BY id LIMIT 1",
- array($aid, $id), __FILE__, __LINE__);
+ addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins_mails` SET admin_id=%s WHERE `id`=%s ORDER BY `id` LIMIT 1",
+ array($content['admin_id'], $id), __FILE__, __LINE__, false));
- if (($aid < 1) && (!empty($_POST['template'][$id])))
- {
+ if (($content['admin_id'] < 1) && (isPostRequestElementSet('template', $id))) {
// Remove any other admin entries
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admins_mails WHERE mail_template='%s' AND id != '%s'",
- array($_POST['template'][$id], $id), __FILE__, __LINE__);
- }
- if ($_POST['admin_new'][$_POST['template'][$id]] > 0)
- {
+ addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template='%s' AND id != '%s'",
+ array(postRequestElement('template', $id), $id), __FILE__, __LINE__, false));
+ } // END - if
+
+ if (postRequestElement('admin_new', postRequestElement('template', $id)) > 0) {
// Add new admin
- SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admins_mails (admin_id, mail_template) VALUES ('%s','%s')",
- array($aid, $_POST['template'][$id]), __FILE__, __LINE__);
- }
- }
+ addSql(SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (admin_id, mail_template) VALUES ('%s','%s')",
+ array($content['admin_id'], postRequestElement('template', $id)), __FILE__, __LINE__, false));
+ } // END - if
+ } // END - foreach
+
+ // Run all queries
+ runFilterChain('run_sqls');
// Query again...
- $result = SQL_QUERY("SELECT DISTINCT m.id, m.admin_id, a.login, m.mail_template FROM "._MYSQL_PREFIX."_admins_mails AS m, "._MYSQL_PREFIX."_admins AS a WHERE m.admin_id=a.id OR m.admin_id < 1 ORDER BY m.admin_id", __FILE__, __LINE__);
- }
+ $result = SQL_QUERY("SELECT m.id, m.admin_id, a.login, m.mail_template FROM `{?_MYSQL_PREFIX?}_admins_mails` AS m, `{?_MYSQL_PREFIX?}_admins` AS a WHERE m.admin_id=a.id OR m.admin_id < 1 ORDER BY m.admin_id", __FILE__, __LINE__);
+ } // END - if
// List found entries
- $SW = 2; $OUT = "";
- while(list($id, $aid, $admin, $templ) = SQL_FETCHROW($result))
- {
- if ($aid > 0)
- {
- // Admin assigned
- $admin_link = "".$admin."";
- }
- elseif ($aid == 0)
- {
- // All admins
- $admin_link = "".ADMINS_ALL_ADMINS."";
- }
- elseif (($aid == -1) && (EXT_IS_ACTIVE("usrlog")))
- {
- // To userlog
- $admin_link = "".ADMINS_TO_USERLOG."";
- }
+ $OUT = ''; $SW = 2;
+ while ($data = SQL_FETCHARRAY($result)) {
+ // Prepare content
$content = array(
'sw' => $SW,
- 'id' => $id,
- 'tpl' => $templ,
- 'alnk' => $admin_link
+ 'id' => $data['id'],
+ 'tpl' => $data['mail_template'],
+ 'alnk' => generateAdminLink($data['admin_id'])
);
// Load row template
- $OUT .= LOAD_TEMPLATE("admin_admins_mails_list_row", true, $content);
+ $OUT .= loadTemplate('admin_admins_mails_list_row', true, $content);
$SW = 3 - $SW;
- }
+ } // END - while
// Free result
SQL_FREERESULT($result);
- define('__MAILS_ROWS', $OUT);
// Load template
- LOAD_TEMPLATE("admin_admins_mails_list");
- }
- else
- {
+ loadTemplate('admin_admins_mails_list', false, $OUT);
+ } else {
// No entries found
- LOAD_TEMPLATE("admin_settings_saved", false, ADMINS_MAILS_NO_ENTRIES);
+ loadTemplate('admin_settings_saved', false, getMessage('ADMINS_MAILS_NO_ENTRIES'));
}
}
-//
+
+// [EOF]
?>