aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/cat_modify.php4
-rw-r--r--admin/notification_by_mail.php46
-rw-r--r--include/functions_mail.inc.php119
-rw-r--r--template/yoga/admin/cat_modify.tpl4
4 files changed, 134 insertions, 39 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index fd6588c97..63da625c5 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -529,7 +529,7 @@ display_select_cat_wrapper(
);
// info by email to an access granted group of category informations
-if (isset($_POST['submitEmail']))
+if (isset($_POST['submitEmail']) and !empty($_POST['group']))
{
set_make_full_url();
@@ -640,7 +640,7 @@ SELECT
while ($row = mysql_fetch_array($result))
{
$template->assign_block_vars(
- 'group_option',
+ 'group_mail.group_option',
array(
'VALUE' => $row['id'],
'OPTION' => $row['name'],
diff --git a/admin/notification_by_mail.php b/admin/notification_by_mail.php
index ca59b3158..10c65214e 100644
--- a/admin/notification_by_mail.php
+++ b/admin/notification_by_mail.php
@@ -210,6 +210,26 @@ order by
}
/*
+ * Apply global functions to mail content
+ * return customize mail content rendered
+ */
+function render_global_customize_mail_content($customize_mail_content)
+{
+ global $conf;
+
+ if ($conf['nbm_send_html_mail'] and !(strpos($customize_mail_content, '<') === 0))
+ {
+ // On HTML mail, detects if the content are HTML format.
+ // If it's plain text format, convert content to readable HTML
+ return nl2br(htmlspecialchars($customize_mail_content));
+ }
+ else
+ {
+ return $customize_mail_content;
+ }
+}
+
+/*
* Send mail for notification to all users
* Return list of "selected" users for 'list_to_send'
* Return list of "treated" check_key for 'send'
@@ -243,12 +263,9 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
$customize_mail_content = $conf['nbm_complementary_mail_content'];
}
- if ($conf['nbm_send_html_mail'] and !(strpos($customize_mail_content, '<') === 0))
- {
- // On HTML mail, detects if the content are HTML format.
- // If it's plain text format, convert content to readable HTML
- $customize_mail_content = nl2br(htmlspecialchars($customize_mail_content));
- }
+ $customize_mail_content =
+ trigger_event('nbm_render_global_customize_mail_content', $customize_mail_content);
+
// Prepare message after change language
if ($is_action_send)
@@ -343,11 +360,16 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
}
}
- if (!empty($customize_mail_content))
+ $nbm_user_customize_mail_content =
+ trigger_event('nbm_render_user_customize_mail_content',
+ $customize_mail_content, $nbm_user);
+ if (!empty($nbm_user_customize_mail_content))
{
$env_nbm['mail_template']->assign_block_vars
(
- 'custom', array('CUSTOMIZE_MAIL_CONTENT' => $customize_mail_content)
+ 'custom',
+ array('CUSTOMIZE_MAIL_CONTENT' =>
+ $nbm_user_customize_mail_content)
);
}
@@ -481,6 +503,14 @@ else
// +-----------------------------------------------------------------------+
check_status(get_tab_status($page['mode']));
+
+// +-----------------------------------------------------------------------+
+// | Add event handler |
+// +-----------------------------------------------------------------------+
+add_event_handler('nbm_render_global_customize_mail_content', 'render_global_customize_mail_content');
+trigger_action('nbm_event_handler_added');
+
+
// +-----------------------------------------------------------------------+
// | Insert new users with mails |
// +-----------------------------------------------------------------------+
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index b4ad2c4e3..785d000f8 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -241,6 +241,8 @@ function switch_lang_to($language)
$lang_info = $switch_lang[$language]['lang_info'];
$lang = $switch_lang[$language]['lang'];
}
+
+ $user['language'] = $language;
}
}
@@ -271,6 +273,7 @@ function switch_lang_back()
$lang_info = $switch_lang[$language]['lang_info'];
$lang = $switch_lang[$language]['lang'];
}
+ $user['language'] = $language;
}
}
@@ -292,6 +295,16 @@ function switch_lang_back()
*/
function pwg_mail_notification_admins($keyargs_subject, $keyargs_content)
{
+ // Check arguments
+ if
+ (
+ empty($keyargs_subject) or
+ empty($keyargs_content)
+ )
+ {
+ return false;
+ }
+
global $conf, $user;
$return = true;
@@ -376,6 +389,18 @@ function pwg_mail_group(
$dirname, $tpl_shortname,
$assign_vars = array(), $language_selected = '')
{
+ // Check arguments
+ if
+ (
+ empty($group_id) or
+ empty($email_format) or
+ empty($keyargs_subject) or
+ empty($tpl_shortname)
+ )
+ {
+ return false;
+ }
+
global $conf;
$return = true;
@@ -448,7 +473,9 @@ WHERE
$mail_template = get_mail_template($email_format, $elem);
$mail_template->set_filename($tpl_shortname,
(empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
- $mail_template->assign_vars($assign_vars);
+
+ $mail_template->assign_vars(
+ trigger_event('mail_group_assign_vars', $assign_vars));
$return = pwg_mail
(
@@ -478,7 +505,7 @@ WHERE
* sends an email, using PhpWebGallery specific informations
*
* @param:
- * - to: Receiver, or receivers of the mail.
+ * - to: receiver(s) of the mail.
* - args: function params of mail function:
* o from: sender [default value webmaster email]
* o Cc: array of carbon copy receivers of the mail. [default value empty]
@@ -690,9 +717,62 @@ function pwg_mail($to, $args = array())
unset_make_full_url();
}
- /*Testing block
- {
- global $user;
+ return
+ trigger_event('send_mail',
+ false, /* Result */
+ trigger_event('send_mail_to', $to),
+ trigger_event('send_mail_subject', $cvt_subject),
+ trigger_event('send_mail_content', $content),
+ trigger_event('send_mail_headers', $headers),
+ $args
+ );
+}
+
+/*
+ * pwg sendmail
+ *
+ * @param:
+ * - result of other sendmail
+ * - to: Receiver or receiver(s) of the mail.
+ * - subject [default value 'PhpWebGallery']
+ * - content: content of mail
+ * - headers: headers of mail
+ *
+ * @return boolean (Ok or not)
+ */
+function pwg_send_mail($result, $to, $subject, $content, $headers)
+{
+ if (!$result)
+ {
+ global $conf_mail;
+
+ if ($conf_mail['use_smtp'])
+ {
+ include_once( PHPWG_ROOT_PATH.'include/class_smtp_mail.inc.php' );
+ $smtp_mail = new smtp_mail(
+ $conf_mail['smtp_host'], $conf_mail['smtp_user'], $conf_mail['smtp_password'],
+ $conf_mail['email_webmaster']);
+ return $smtp_mail->mail($to, $subject, $content, $headers);
+ }
+ else
+ {
+ if ($conf_mail['mail_options'])
+ {
+ $options = '-f '.$conf_mail['email_webmaster'];
+ return mail($to, $subject, $content, $headers, $options);
+ }
+ else
+ {
+ return mail($to, $subject, $content, $headers);
+ }
+ }
+ }
+}
+
+/*Testing block
+function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
+{
+ global $user, $lang_info;
@mkdir(PHPWG_ROOT_PATH.'testmail');
$filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
if ($args['content_format'] == 'text/plain')
@@ -705,33 +785,16 @@ function pwg_mail($to, $args = array())
}
$file = fopen($filename, 'w+');
fwrite($file, $to);
- fwrite($file, $cvt_subject);
+ fwrite($file, $subject);
fwrite($file, $headers);
fwrite($file, $content);
fclose($file);
return true;
- }*/
-
- if ($conf_mail['use_smtp'])
- {
- include_once( PHPWG_ROOT_PATH.'include/class_smtp_mail.inc.php' );
- $smtp_mail = new smtp_mail(
- $conf_mail['smtp_host'], $conf_mail['smtp_user'], $conf_mail['smtp_password'],
- $conf_mail['email_webmaster']);
- return $smtp_mail->mail($to, $cvt_subject, $content, $headers);
- }
- else
- {
- if ($conf_mail['mail_options'])
- {
- $options = '-f '.$conf_mail['email_webmaster'];
- return mail($to, $cvt_subject, $content, $headers, $options);
- }
- else
- {
- return mail($to, $cvt_subject, $content, $headers);
- }
- }
}
+add_event_handler('send_mail', 'pwg_send_mail_test', 0, 6);*/
+
+
+add_event_handler('send_mail', 'pwg_send_mail', EVENT_HANDLER_PRIORITY_NEUTRAL, 5);
+trigger_action('functions_mail_included');
?>
diff --git a/template/yoga/admin/cat_modify.tpl b/template/yoga/admin/cat_modify.tpl
index 8db494991..1e135f42d 100644
--- a/template/yoga/admin/cat_modify.tpl
+++ b/template/yoga/admin/cat_modify.tpl
@@ -212,6 +212,7 @@
</fieldset>
+<!-- BEGIN group_mail -->
<fieldset id="emailCatInfo">
<legend>{lang:Send an information email to group members}</legend>
@@ -221,7 +222,7 @@
<td>
<select name="group">
<!-- BEGIN group_option -->
- <option value="{group_option.VALUE}">{group_option.OPTION}</option>
+ <option value="{group_mail.group_option.VALUE}">{group_mail.group_option.OPTION}</option>
<!-- END group_option -->
</select>
</td>
@@ -241,5 +242,6 @@
</p>
</fieldset>
+<!-- END group_mail -->
</form>