Skip to content

Commit

Permalink
Updated Mail Users and now requires site admin email to be used to send
Browse files Browse the repository at this point in the history
Fix for #1086 (part 2). Also updated mail form and removed hard coded html.
  • Loading branch information
eSilverStrike committed Jan 21, 2022
1 parent 54322ee commit 94545e3
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 30 deletions.
6 changes: 3 additions & 3 deletions language/english.php
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@
# admin/mail.php

$LANG31 = array(
1 => "{$_CONF['site_name']} Mail Utility",
1 => "Mail Users",
2 => 'From Name',
3 => 'From Email Address',
4 => 'Subject',
Expand All @@ -1353,8 +1353,8 @@
16 => 'Successfully sent messages to: ',
17 => "<a href=\"{$_CONF['site_admin_url']}/mail.php\">Send another message</a>",
18 => 'To',
19 => 'NOTE: if you wish to send a message to all site members, select the Logged-in Users group from the drop down.',
20 => "Successfully sent <successcount> messages and unsuccessfully sent <failcount> messages. If you need them, the details of each message attempts is below. Otherwise you can <a href=\"{$_CONF['site_admin_url']}/mail.php\">Send another message</a> or you can <a href=\"{$_CONF['site_admin_url']}/moderation.php\">go back to the administration page</a>.",
19 => 'If you wish to send a message to all site members, select the Logged-in Users group from the drop down. Please note that some email hosts may limit the number of emails you can send in a certain time period.',
20 => "<p><successcount> messages was sent successfully and <failcount> messages failed to send.</p><p>The details of the message attempts are below:</p>",
21 => 'Failures',
22 => 'Successes',
23 => 'No failures',
Expand Down
6 changes: 3 additions & 3 deletions language/english_utf-8.php
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@
# admin/mail.php

$LANG31 = array(
1 => "{$_CONF['site_name']} Mail Utility",
1 => "Mail Users",
2 => 'From Name',
3 => 'From Email Address',
4 => 'Subject',
Expand All @@ -1352,8 +1352,8 @@
16 => 'Successfully sent messages to: ',
17 => "<a href=\"{$_CONF['site_admin_url']}/mail.php\">Send another message</a>",
18 => 'To',
19 => 'NOTE: if you wish to send a message to all site members, select the Logged-in Users group from the drop down.',
20 => "Successfully sent <successcount> messages and unsuccessfully sent <failcount> messages. If you need them, the details of each message attempts is below. Otherwise you can <a href=\"{$_CONF['site_admin_url']}/mail.php\">Send another message</a> or you can <a href=\"{$_CONF['site_admin_url']}/moderation.php\">go back to the administration page</a>.",
19 => 'If you wish to send a message to all site members, select the Logged-in Users group from the drop down. Please note that some email hosts may limit the number of emails you can send in a certain time period.',
20 => "<p><successcount> messages was sent successfully and <failcount> messages failed to send.</p><p>The details of the message attempts are below:</p>",
21 => 'Failures',
22 => 'Successes',
23 => 'No failures',
Expand Down
2 changes: 1 addition & 1 deletion language/japanese_utf-8.php
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@
17 => "<a href={$_CONF['site_admin_url']}/mail.php>別のメッセージを送る</a>",
18 => '送信先',
19 => '補足: 登録者全員に送信するには、送信先のドロップダウンメニューから「Logged-in Users」を選択してください。',
20 => "<successcount> 件のメッセージの送信に成功し、<failcount> 件のメッセージの送信には失敗しました。個別のメッセージの送信状態は次のとおりです。<a href=\"{$_CONF['site_admin_url']}/mail.php\">別のメッセージを送信</a>するか、<a href=\"{$_CONF['site_admin_url']}/moderation.php\">管理画面に戻る</a>ことができます",
20 => "<p><successcount> messages was sent successfully and <failcount> messages failed to send.</p><p>The details of the message attempts are below:</p>",
21 => '送信に失敗',
22 => '送信に成功',
23 => '失敗した送信先はありません',
Expand Down
65 changes: 45 additions & 20 deletions public_html/admin/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
exit;
}

require_once $_CONF['path_system'] . 'lib-admin.php';

/**
* Shows the form the admin uses to send Geeklog members a message. Right now
* you can only email an entire group.
Expand All @@ -70,8 +72,6 @@ function display_mailform($vars = array())
{
global $_CONF, $LANG31, $LANG_ADMIN, $_IMAGE_TYPE;

require_once $_CONF['path_system'] . 'lib-admin.php';

$retval = COM_startBlock($LANG31[1], '',
COM_getBlockTemplate('_admin_block', 'header'));

Expand All @@ -80,7 +80,7 @@ function display_mailform($vars = array())
'text' => $LANG_ADMIN['admin_home'])
);

$desc = '<p>' . $LANG31[19] . '</p>';
$desc = $LANG31[19];
$icon = $_CONF['layout_url'] . '/images/icons/mail.' . $_IMAGE_TYPE;
$retval .= ADMIN_createMenu($menu_arr, $desc, $icon);

Expand Down Expand Up @@ -182,7 +182,7 @@ function display_mailform($vars = array())
*/
function send_messages(array $vars)
{
global $_CONF, $_TABLES, $LANG31;
global $_CONF, $_TABLES, $LANG31, $LANG_ADMIN, $_IMAGE_TYPE;

require_once $_CONF['path_system'] . 'lib-user.php';

Expand All @@ -198,9 +198,8 @@ function send_messages(array $vars)

$to_group = COM_applyFilter($vars['to_group'], true);
if ($to_group > 0) {
$group_name = DB_getItem($_TABLES['groups'], 'grp_name',
"grp_id = $to_group");
if (! SEC_inGroup($group_name)) {
$group_name = DB_getItem($_TABLES['groups'], 'grp_name', "grp_id = $to_group");
if (!SEC_inGroup($group_name)) {
COM_redirect($_CONF['site_admin_url'] . '/mail.php');
}
} else {
Expand Down Expand Up @@ -229,7 +228,8 @@ function send_messages(array $vars)
$result = DB_query($sql);
$numRows = DB_numRows($result);

$from = array($vars['fraepost'] => $vars['fra']);
//$from = array($vars['fraepost'] => $vars['fra']);
$from = array($vars['fraepost'] => $_CONF['site_mail']);
$subject = $vars['subject'];
$subject = GLText::stripTags($subject);
$message = $vars['message'];
Expand Down Expand Up @@ -264,39 +264,64 @@ function send_messages(array $vars)

$tempTo = is_array($to) ? implode('', array_keys($to)) : $to;

if (! COM_mail($to, $subject, $message, $from, $html, $priority)) {
if (!COM_mail($to, $subject, $message, $from, $html, $priority)) {
$failures[] = htmlspecialchars($tempTo);
} else {
$successes[] = htmlspecialchars($tempTo);
}
}

$retval .= COM_startBlock($LANG31[1]);
$mail_templates = COM_newTemplate(CTL_core_templatePath($_CONF['path_layout'] . 'admin/mail'));
$mail_templates->set_file(array('form' => 'mailsent.thtml'));
$mail_templates->set_block('form', 'display_email');

$mail_templates->set_var('start_block_mailusers', COM_startBlock($LANG31[1], '', COM_getBlockTemplate('_admin_block', 'header')));
$mail_templates->set_var('end_block_mailusers', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')),);

$mail_templates->set_var('start_block_failures', COM_startBlock($LANG31[21], '', 'blockheader-child.thtml'));
$mail_templates->set_var('end_block_failures', COM_endBlock(COM_getBlockTemplate('-child', 'footer')));

$mail_templates->set_var('start_block_successes', COM_startBlock($LANG31[22], '', 'blockheader-child.thtml'));
$mail_templates->set_var('end_block_successes', COM_endBlock(COM_getBlockTemplate('-child', 'footer')));

$menu_arr = array(
array('url' => $_CONF['site_admin_url'] . '/mail.php',
'text' => $LANG31[1]),
array('url' => $_CONF['site_admin_url'],
'text' => $LANG_ADMIN['admin_home'])
);

$desc = $LANG31[19];
$icon = $_CONF['layout_url'] . '/images/icons/mail.' . $_IMAGE_TYPE;
$mail_templates->set_var('admin_menu', ADMIN_createMenu($menu_arr, $desc, $icon));

$failCount = count($failures);
$successCount = count($successes);
$mailResult = str_replace('<successcount>', $successCount, $LANG31[20]);
$retval .= str_replace('<failcount>', $failCount, $mailResult);
$retval .= '<h2>' . $LANG31[21] . '</h2>';

$mailResult = str_replace('<failcount>', $failCount, $mailResult);
$mail_templates->set_var('lang_mail_results', $mailResult);
for ($i = 0; $i < count($failures); $i++) {
$retval .= current($failures) . '<br' . XHTML . '>';
$mail_templates->set_var('email_address', current($failures));
$mail_templates->parse('display_failures', 'display_email', true);
next($failures);
}
if (count($failures) === 0) {
$retval .= $LANG31[23];
$mail_templates->set_var('lang_no_failure_message', $LANG31[23]);
}

$retval .= '<h2>' . $LANG31[22] . '</h2>';
for ($i = 0; $i < count($successes); $i++) {
$retval .= current($successes) . '<br' . XHTML . '>';
$mail_templates->set_var('email_address', current($successes));
$mail_templates->parse('display_successes', 'display_email', true);

next($successes);
}
if (count($successes) === 0) {
$retval .= $LANG31[24];
$mail_templates->set_var('lang_no_success_message', $LANG31[24]);
}

$retval .= COM_endBlock();

$mail_templates->parse('output', 'form');
$retval .= $mail_templates->finish($mail_templates->get_var('output'));

return $retval;
}
Expand Down
2 changes: 1 addition & 1 deletion public_html/layout/denim/admin/mail/mailform.thtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dd><input type="text" value="{site_name}" name="fra" class="size4" id="admin-mailform-fra"{xhtml}></dd>

<dt><label for="admin-mailform-fraepost">{lang_replyto}</label></dt>
<dd><input type="text" value="{site_mail}" name="fraepost" class="size4" id="admin-mailform-fraepost"{xhtml}></dd>
<dd><input type="text" value="{site_mail}" name="fraepost" class="size4" id="admin-mailform-fraepost" readonly="readonly"{xhtml}></dd>

<dt><label for="admin-mailform-subject">{lang_subject}</label></dt>
<dd><input type="text" value="{subject}" name="subject" class="size4" id="admin-mailform-subject"{xhtml}></dd>
Expand Down
34 changes: 34 additions & 0 deletions public_html/layout/denim/admin/mail/mailsent.thtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{# start {templatelocation} #}

{start_block_mailusers}
{admin_menu}

{lang_mail_results}

{start_block_failures}
{!if lang_no_failure_message}
<p>{lang_no_failure_message}</p>
{!else}
<ul>
{display_failures}
</ul>
{!endif}
{end_block_failures}

{start_block_successes}
{!if lang_no_success_message}
<p>{lang_no_success_message}</p>
{!else}
<ul>
{display_successes}
</ul>
{!endif}
{end_block_successes}

{end_block_mailusers}

<!-- BEGIN display_email -->
<li>{email_address}</li>
<!-- END display_email -->

{# end {templatelocation} #}
2 changes: 1 addition & 1 deletion public_html/layout/denim_three/admin/mail/mailform.thtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dd><input type="text" value="{site_name}" name="fra" class="uk-input size5" id="admin-mailform-fra"{xhtml}></dd>

<dt><label for="admin-mailform-fraepost">{lang_replyto}</label></dt>
<dd><input type="text" value="{site_mail}" name="fraepost" class="uk-input size5" id="admin-mailform-fraepost"{xhtml}></dd>
<dd><input type="text" value="{site_mail}" name="fraepost" class="uk-input size5" id="admin-mailform-fraepost" readonly="readonly"{xhtml}></dd>

<dt><label for="admin-mailform-subject">{lang_subject}</label></dt>
<dd><input type="text" value="{subject}" name="subject" class="uk-input size5" id="admin-mailform-subject"{xhtml}></dd>
Expand Down
34 changes: 34 additions & 0 deletions public_html/layout/denim_three/admin/mail/mailsent.thtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{# start {templatelocation} #}

{start_block_mailusers}
{admin_menu}

{lang_mail_results}

{start_block_failures}
{!if lang_no_failure_message}
<p>{lang_no_failure_message}</p>
{!else}
<ul>
{display_failures}
</ul>
{!endif}
{end_block_failures}

{start_block_successes}
{!if lang_no_success_message}
<p>{lang_no_success_message}</p>
{!else}
<ul>
{display_successes}
</ul>
{!endif}
{end_block_successes}

{end_block_mailusers}

<!-- BEGIN display_email -->
<li>{email_address}</li>
<!-- END display_email -->

{# end {templatelocation} #}
2 changes: 1 addition & 1 deletion public_html/layout/modern_curve/admin/mail/mailform.thtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dd><input type="text" value="{site_name}" size="40" name="fra" class="text" id="admin-mailform-fra"{xhtml}></dd>

<dt><label for="admin-mailform-fraepost">{lang_replyto}</label></dt>
<dd><input type="text" value="{site_mail}" size="40" name="fraepost" class="text" id="admin-mailform-fraepost"{xhtml}></dd>
<dd><input type="text" value="{site_mail}" size="40" name="fraepost" class="text" id="admin-mailform-fraepost" readonly="readonly"{xhtml}></dd>

<dt><label for="admin-mailform-subject">{lang_subject}</label></dt>
<dd><input type="text" value="{subject}" size="40" name="subject" class="text" id="admin-mailform-subject"{xhtml}></dd>
Expand Down
34 changes: 34 additions & 0 deletions public_html/layout/modern_curve/admin/mail/mailsent.thtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{# start {templatelocation} #}

{start_block_mailusers}
{admin_menu}

{lang_mail_results}

{start_block_failures}
{!if lang_no_failure_message}
<p>{lang_no_failure_message}</p>
{!else}
<ul>
{display_failures}
</ul>
{!endif}
{end_block_failures}

{start_block_successes}
{!if lang_no_success_message}
<p>{lang_no_success_message}</p>
{!else}
<ul>
{display_successes}
</ul>
{!endif}
{end_block_successes}

{end_block_mailusers}

<!-- BEGIN display_email -->
<li>{email_address}</li>
<!-- END display_email -->

{# end {templatelocation} #}

0 comments on commit 94545e3

Please sign in to comment.