aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/functions_mail.inc.php127
-rw-r--r--include/functions_notification.inc.php95
2 files changed, 162 insertions, 60 deletions
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index 523bbd6fd..07be28b50 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -64,10 +64,6 @@ function get_mail_configuration()
$conf_mail['formated_email_webmaster'] =
format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
- // what to display at the bottom of each mail ?
- $conf_mail['text_footer'] =
- "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : '');
-
return $conf_mail;
}
@@ -105,23 +101,34 @@ function format_email($name, $email)
*
* @param none
*/
-function get_mail_template()
+function get_mail_template($email_format)
{
global $conf;
// for mail, default template are used
list($tmpl, $thm) = explode('/', $conf['default_template']);
- $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
+ $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
+ $mail_template->set_rootdir(PHPWG_ROOT_PATH.'template/'.$tmpl.'/mail/'.$email_format);
return $mail_template;
}
+
+/**
+ * Return string email format (html or not)
+ *
+ * @param string format
+ */
+function get_str_email_format($is_html)
+{
+ return ($is_html ? 'text/html' : 'text/plain');
+}
/**
* sends an email, using PhpWebGallery specific informations
*/
function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $format_infos = 'text/plain', $email_format = null)
{
- global $conf, $conf_mail, $lang_info, $user, $page;
+ global $conf, $conf_mail, $lang_info, $page;
$cvt7b_subject = str_translate_to_ascii7bits($subject);
@@ -170,32 +177,48 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $for
$content = '';
- if (!isset($conf_mail[$email_format][$lang_info['charset']]['header']))
+ if (!isset($conf_mail[$email_format][$lang_info['charset']]))
{
- if ($email_format == 'text/html')
+ if (!isset($mail_template))
{
- $mail_template = get_mail_template();
+ $mail_template = get_mail_template($email_format);
+ }
- $mail_template->set_filenames(array('mail_header'=>'mail/header.tpl'));
+ $mail_template->set_filename('mail_header', 'header.tpl');
+ $mail_template->set_filename('mail_footer', 'footer.tpl');
- $mail_template->assign_vars(
- array(
- 'BODY_ID' =>
- isset($page['body_id']) ?
- $page['body_id'] : '',
+ $mail_template->assign_vars(
+ array(
+ //Header
+ 'BODY_ID' =>
+ isset($page['body_id']) ?
+ $page['body_id'] : '',
- 'CONTENT_ENCODING' => $lang_info['charset'],
- 'LANG' => $lang_info['code'],
- 'DIR' => $lang_info['direction']
- ));
+ 'CONTENT_ENCODING' => $lang_info['charset'],
+ 'LANG' => $lang_info['code'],
+ 'DIR' => $lang_info['direction'],
+
+ // Footer
+ 'GALLERY_URL' =>
+ isset($page['gallery_url']) ?
+ $page['gallery_url'] : $conf['gallery_url'],
+ 'GALLERY_TITLE' =>
+ isset($page['gallery_title']) ?
+ $page['gallery_title'] : $conf['gallery_title'],
+ 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
+ 'PHPWG_URL' => PHPWG_URL,
- $conf_mail[$email_format][$lang_info['charset']]['header'] =
- $mail_template->parse('mail_header', true);
- }
- else
- {
- $conf_mail[$email_format][$lang_info['charset']]['header'] = '';
- }
+ 'TITLE_MAIL' => urlencode(l10n('title_send_mail')),
+ 'MAIL' => get_webmaster_mail_address()
+ ));
+
+ // what are displayed on the header of each mail ?
+ $conf_mail[$email_format][$lang_info['charset']]['header'] =
+ $mail_template->parse('mail_header', true);
+
+ // what are displayed on the footer of each mail ?
+ $conf_mail[$email_format][$lang_info['charset']]['footer'] =
+ $mail_template->parse('mail_footer', true);
}
$content.= $conf_mail[$email_format][$lang_info['charset']]['header'];
@@ -209,36 +232,6 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $for
$content.= $infos;
}
- if (!isset($conf_mail[$email_format][$lang_info['charset']]['footer']))
- {
- if ($email_format == 'text/html')
- {
- $mail_template->set_filenames(array('mail_footer'=>'mail/footer.tpl'));
-
- $mail_template->assign_vars(
- array(
- 'GALLERY_URL' =>
- isset($page['gallery_url']) ?
- $page['gallery_url'] : $conf['gallery_url'],
- 'GALLERY_TITLE' =>
- isset($page['gallery_title']) ?
- $page['gallery_title'] : $conf['gallery_title'],
- 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
- 'PHPWG_URL' => PHPWG_URL,
-
- 'TITLE_MAIL' => urlencode(l10n('title_send_mail')),
- 'MAIL' => get_webmaster_mail_address()
- ));
-
- $conf_mail[$email_format][$lang_info['charset']]['footer'] =
- $mail_template->parse('mail_footer', true);
- }
- else
- {
- $conf_mail[$email_format][$lang_info['charset']]['footer'] = $conf_mail['text_footer'];
- }
- }
-
$content.= $conf_mail[$email_format][$lang_info['charset']]['footer'];
// Undo Compute root_path in order have complete path
@@ -247,6 +240,26 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $for
unset_make_full_url();
}
+ /*Testing block
+ {
+ global $user;
+ @mkdir(PHPWG_ROOT_PATH.'testmail');
+ $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'];
+ if ($format_infos == 'text/plain')
+ {
+ $filename .= '.txt';
+ }
+ else
+ {
+ $filename .= '.html';
+ }
+ $file = fopen($filename, 'w+');
+ fwrite($file, $content);
+ fclose($file);
+ return true;
+ }
+ */
+
if ($conf_mail['mail_options'])
{
$options = '-f '.$conf_mail['email_webmaster'];
diff --git a/include/functions_notification.inc.php b/include/functions_notification.inc.php
index 631922303..78c561475 100644
--- a/include/functions_notification.inc.php
+++ b/include/functions_notification.inc.php
@@ -407,13 +407,15 @@ function news($start, $end, $exclude_img_cats=false, $add_url=false)
if (!$exclude_img_cats)
{
add_news_line( $news,
- nb_new_elements($start, $end), '%d new element', '%d new elements');
+ nb_new_elements($start, $end), '%d new element', '%d new elements',
+ get_root_url().'index.php?/recent_pics', $add_url );
}
if (!$exclude_img_cats)
{
add_news_line( $news,
- nb_updated_categories($start, $end), '%d category updated', '%d categories updated');
+ nb_updated_categories($start, $end), '%d category updated', '%d categories updated',
+ get_root_url().'/index.php?/recent_cats', $add_url );
}
add_news_line( $news,
@@ -508,5 +510,92 @@ SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
}
}
return $dates;
-}
+}
+
+/**
+ * returns html description about recently published elements grouped by post date
+ * @param $date_detail: selected date computed by get_recent_post_dates function
+ */
+function get_html_description_recent_post_date($date_detail)
+{
+ global $conf;
+
+ $description = '';
+
+ $description .=
+ '<li>'
+ .l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements'])
+ .' ('
+ .'<a href="'.make_index_url(array('section'=>'recent_pics')).'">'
+ .l10n('recent_pics_cat').'</a>'
+ .')'
+ .'</li><br/>';
+
+ foreach($date_detail['elements'] as $element)
+ {
+ $tn_src = get_thumbnail_url($element);
+ $description .= '<img src="'.$tn_src.'"/>';
+ }
+ $description .= '...<br/>';
+
+ $description .=
+ '<li>'
+ .l10n_dec('%d category updated', '%d categories updated',
+ $date_detail['nb_cats'])
+ .'</li>';
+
+ $description .= '<ul>';
+ foreach($date_detail['categories'] as $cat)
+ {
+ $description .=
+ '<li>'
+ .get_cat_display_name_cache($cat['uppercats'])
+ .' ('.
+ l10n_dec('%d new element',
+ '%d new elements', $cat['img_count']).')'
+ .'</li>';
+ }
+ $description .= '</ul>';
+
+ return $description;
+}
+
+/**
+ * explodes a MySQL datetime format (2005-07-14 23:01:37) in fields "year",
+ * "month", "day", "hour", "minute", "second".
+ *
+ * @param string mysql datetime format
+ * @return array
+ */
+function explode_mysqldt($mysqldt)
+{
+ $date = array();
+ list($date['year'],
+ $date['month'],
+ $date['day'],
+ $date['hour'],
+ $date['minute'],
+ $date['second'])
+ = preg_split('/[-: ]/', $mysqldt);
+
+ return $date;
+}
+
+/**
+ * returns title about recently published elements grouped by post date
+ * @param $date_detail: selected date computed by get_recent_post_dates function
+ */
+function get_title_recent_post_date($date_detail)
+{
+ global $lang;
+
+ $date = $date_detail['date_available'];
+ $exploded_date = explode_mysqldt($date);
+
+ $title = l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements']);
+ $title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')';
+
+ return $title;
+}
+
?> \ No newline at end of file