* $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, 2010 by Mailer Developer Team *
- * For more information visit: http://www.mxchange.org *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * 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 *
} // END - if
// Add description as navigation point
-addMenuDescription('admin', __FILE__);
+addYouAreHereLink('admin', __FILE__);
if (isFormSent('edit')) {
// Check if entires are checked
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// Add option for events
- $adminsList = generateOptionList('admins', 'id', 'login', '', 'email');
- $SW = 2; $rows = '';
- foreach (postRequestParameter('sel') as $template => $sel) {
+ $rows = '';
+ 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` ASC",
array($template), __FILE__, __LINE__);
$adminId2 = '0'; $id = '0';
while ($content = SQL_FETCHARRAY($result)) {
// @TODO Can this be rewritten to an API function?
- $OUT .= '<select name="admin_id[' . $content['id'] . ']" size="1" class="admin_select">
+ $OUT .= '<select name="admin_id[' . $content['id'] . ']" size="1" class="form_select">
<option value="0"';
- if ($content['admin_id'] == '0') $OUT .= ' selected="selected"';
- $OUT .= '>{--ADMINS_ALL_ADMINS--}</option>';
+ if (is_null($content['admin_id'])) {
+ $OUT .= ' selected="selected"';
+ } // END - if
+ $OUT .= '>{--ADMIN_TO_ALL_ADMINS--}</option>';
+
if (isExtensionActive('events')) {
$OUT .= '<option value="-1"';
- if ($content['admin_id'] == '-1') $OUT .= ' selected="selected"';
- $OUT .= '>{--ADMINS_TO_USER_EVENTS--}</option>';
- }
- $OUT .= generateOptionList('admins', 'id', 'login', $content['admin_id'], 'email');
+ if ($content['admin_id'] == '-1') {
+ $OUT .= ' selected="selected"';
+ } // END - if
+ $OUT .= '>{--ADMIN_ADMINS_TO_USER_EVENTS--}</option>';
+ } // END - if
+
+ $OUT .= generateOptions('admins', 'id', 'login', $content['admin_id'], 'email');
$OUT .= '</select>';
// Transfer ids
// Prepare content
$content['id'] = $id;
- $content['sw'] = $SW;
$content['mail_template'] = $template;
- $content['admins'] = $adminsList;
+ $content['admins'] = generateOptions('admins', 'id', 'login', '', 'email');;
- if ($adminId2 > 0) {
+ if (isValidUserId($adminId2)) {
// Add form for an additional admin
- $OUT .= loadTemplate('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
- $rows .= loadTemplate('admin_admins_mails_edit_row', true, $content);
- $SW = 3 - $SW;
- }
+ $rows .= loadTemplate('admin_admins_mails_edit_row', TRUE, $content);
+ } // END - foreach
// Edit checked entries
- loadTemplate('admin_admins_mails_edit', false, $rows);
+ loadTemplate('admin_admins_mails_edit', FALSE, $rows);
} else {
// Nothing selected
- loadTemplate('admin_settings_saved', false, '{--ADMINS_NO_MAIL_CHECKED--}');
+ displayMessage('{--ADMINS_NO_MAIL_CHECKED--}');
}
} else {
// Load all assigned mails
$result = SQL_QUERY("SELECT
- m.id, m.admin_id, a.login, m.mail_template
+ m.`id`,
+ m.`admin_id`,
+ a.`login`,
+ m.`mail_template`
FROM
- `{?_MYSQL_PREFIX?}_admins_mails` AS m
+ `{?_MYSQL_PREFIX?}_admins_mails` AS `m`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_admins` AS a
+ `{?_MYSQL_PREFIX?}_admins` AS `a`
ON
- m.admin_id=a.id
+ m.`admin_id`=a.`id`
WHERE
- (m.admin_id=a.id OR m.admin_id < 1) AND m.mail_template != ''
+ (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__);
+ m.`admin_id` ASC,
+ m.`mail_template` ASC", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0) {
+ if (!SQL_HASZERONUMS($result)) {
// Shall I change entries?
- if (isFormSent('change')) {
+ if (isFormSent('do_edit')) {
// Init SQLs
initSqls();
// Ok, update database
- foreach (postRequestParameter('admin_id') as $id => $content['admin_id']) {
+ foreach (postRequestElement('admin_id') as $id => $content['admin_id']) {
// Secure ids
$id = bigintval($id);
$content['admin_id'] = bigintval($content['admin_id']);
// Update entry
- 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));
+ 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 (($content['admin_id'] < 1) && (isPostRequestParameterSet('template', $id))) {
+ if ((!isValidUserId($content['admin_id'])) && (isPostRequestElementSet('template', $id))) {
// Remove any other admin entries
addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template='%s' AND id != '%s'",
- array(postRequestParameter('template', $id), $id), __FILE__, __LINE__, false));
+ array(postRequestElement('template', $id), $id), __FILE__, __LINE__, FALSE));
} // END - if
- if (postRequestParameter('admin_new', postRequestParameter('template', $id)) > 0) {
+ if (postRequestElement('admin_new', postRequestElement('template', $id)) > 0) {
// Add new admin
addSql(SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (admin_id, mail_template) VALUES ('%s','%s')",
- array($content['admin_id'], postRequestParameter('template', $id)), __FILE__, __LINE__, false));
+ array($content['admin_id'], postRequestElement('template', $id)), __FILE__, __LINE__, FALSE));
} // END - if
} // END - foreach
} // END - if
// List found entries
- $OUT = ''; $SW = 2;
+ $OUT = '';
while ($content = SQL_FETCHARRAY($result)) {
- // Prepare content
- $content['sw'] = $SW;
-
// Load row template
- $OUT .= loadTemplate('admin_admins_mails_list_row', true, $content);
- $SW = 3 - $SW;
+ $OUT .= loadTemplate('admin_admins_mails_list_row', TRUE, $content);
} // END - while
// Free result
SQL_FREERESULT($result);
// Load template
- loadTemplate('admin_admins_mails_list', false, $OUT);
+ loadTemplate('admin_admins_mails_list', FALSE, $OUT);
} else {
// No entries found
- loadTemplate('admin_settings_saved', false, '{--ADMINS_MAILS_NO_ENTRIES--}');
+ displayMessage('{--ADMIN_ADMINS_MAILS_NO_ENTRIES--}');
}
}