X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-admins_mails.php;h=8afbb9aef92509d1ba40428cfd38ca77187bcfd8;hp=b4f752c93986e2618dd5037c3cba9a372958d404;hb=18e32f1a8971b18bace4f051094acf27800bd7d9;hpb=d0d885e08aba45b77818d49bcf40396bf788c386 diff --git a/inc/modules/admin/what-admins_mails.php b/inc/modules/admin/what-admins_mails.php index b4f752c939..8afbb9aef9 100644 --- a/inc/modules/admin/what-admins_mails.php +++ b/inc/modules/admin/what-admins_mails.php @@ -1,7 +1,7 @@ 0) { // Add option for events $adminsList = generateOptionList('admins', 'id', 'login', '', 'email'); - $SW = 2; $rowNameS = ''; - foreach (postRequestElement('sel') as $template => $sel) { + $SW = 2; $rows = ''; + foreach (postRequestParameter('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__); - $OUT = ''; $adminId2 = '0'; + $OUT = ''; + $adminId2 = '0'; $id = '0'; while ($content = SQL_FETCHARRAY($result)) { // @TODO Can this be rewritten??? $OUT .= "\n
\n"; - $adminId2 = $content['admin_id']; $id2 = $content['id']; - } + + // Transfer ids + $adminId2 = $content['admin_id']; + $id = $content['id']; + } // END - while // Free memory SQL_FREERESULT($result); // Prepare content - $content = array( - 'sw' => $SW, - 'id' => $id, - 'id2' => $id2, - 'tpl' => $template, - 'admins' => $adminsList - ); + $content['id'] = $id; + $content['sw'] = $SW; + $content['mail_template'] = $template; + $content['admins'] = $adminsList; if ($adminId2 > 0) { // Add form for an additional admin @@ -92,12 +94,12 @@ if (isPostRequestElementSet('edit')) { $content['content'] = $OUT; // Start outputing line - $rowNameS .= loadTemplate('admin_admins_mails_edit_row', true, $content); + $rows .= loadTemplate('admin_admins_mails_edit_row', true, $content); $SW = 3 - $SW; } // Edit checked entries - loadTemplate('admin_admins_mails_edit', false, $rowNameS); + loadTemplate('admin_admins_mails_edit', false, $rows); } else { // Nothing selected loadTemplate('admin_settings_saved', false, getMessage('ADMINS_NO_MAIL_CHECKED')); @@ -120,30 +122,30 @@ ORDER BY if (SQL_NUMROWS($result) > 0) { // Shall I change entries? - if (isPostRequestElementSet('change')) { + if (isFormSent('change')) { // Init SQLs initSqls(); // Ok, update database - foreach (postRequestElement('admin_id') as $id => $content['admin_id']) { + foreach (postRequestParameter('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)); + array($content['admin_id'], $id), __FILE__, __LINE__, false)); - if (($content['admin_id'] < 1) && (isPostRequestElementSet('template', $id))) { + if (($content['admin_id'] < 1) && (isPostRequestParameterSet('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(postRequestElement('template', $id), $id), __FILE__, __LINE__, false)); + array(postRequestParameter('template', $id), $id), __FILE__, __LINE__, false)); } // END - if - if (postRequestElement('admin_new', postRequestElement('template', $id)) > 0) { + if (postRequestParameter('admin_new', postRequestParameter('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'], postRequestElement('template', $id)), __FILE__, __LINE__, false)); + array($content['admin_id'], postRequestParameter('template', $id)), __FILE__, __LINE__, false)); } // END - if } // END - foreach @@ -151,19 +153,27 @@ ORDER BY runFilterChain('run_sqls'); // Query again... - $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__); + $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__); } // END - if // List found entries $OUT = ''; $SW = 2; - while ($data = SQL_FETCHARRAY($result)) { + while ($content = SQL_FETCHARRAY($result)) { // Prepare content - $content = array( - 'sw' => $SW, - 'id' => $data['id'], - 'tpl' => $data['mail_template'], - 'alnk' => generateAdminLink($data['admin_id']) - ); + $content['sw'] = $SW; + $content['alnk'] = generateAdminLink($content['admin_id']); // Load row template $OUT .= loadTemplate('admin_admins_mails_list_row', true, $content);