diff options
-rw-r--r-- | admin/include/functions.php | 6 | ||||
-rw-r--r-- | admin/include/functions_notification_by_mail.inc.php | 168 | ||||
-rw-r--r-- | admin/notification_by_mail.php | 485 | ||||
-rw-r--r-- | include/functions_mail.inc.php | 3 | ||||
-rw-r--r-- | install/config.sql | 4 | ||||
-rw-r--r-- | install/db/17-database.php | 64 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/admin.lang.php | 37 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/help/notification_by_mail.html | 13 | ||||
-rw-r--r-- | language/fr_FR.iso-8859-1/admin.lang.php | 37 | ||||
-rw-r--r-- | language/fr_FR.iso-8859-1/help/notification_by_mail.html | 15 | ||||
-rw-r--r-- | template/yoga/admin/notification_by_mail.tpl | 88 |
11 files changed, 719 insertions, 201 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 076c69fb4..4dd2869ef 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -743,7 +743,7 @@ UPDATE '.$tablename.' { // creation of the temporary table $query = ' -DESCRIBE '.$tablename.' +SHOW FULL COLUMNS FROM '.$tablename.' ;'; $result = pwg_query($query); $columns = array(); @@ -762,6 +762,10 @@ DESCRIBE '.$tablename.' { $column.= " default '".$row['Default']."'"; } + if (isset($row['Collation'])) + { + $column.= " collate '".$row['Collation']."'"; + } array_push($columns, $column); } } diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php new file mode 100644 index 000000000..31753c7de --- /dev/null +++ b/admin/include/functions_notification_by_mail.inc.php @@ -0,0 +1,168 @@ +<?php +// +-----------------------------------------------------------------------+ +// | PhpWebGallery - a PHP based picture gallery | +// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | +// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net | +// +-----------------------------------------------------------------------+ +// | branch : BSF (Best So Far) +// | file : $RCSfile$ +// | last update : $Date: 2006-03-23 02:49:04 +0100 (jeu., 23 mars 2006) $ +// | last modifier : $Author: rvelices $ +// | revision : $Revision: 1094 $ +// +-----------------------------------------------------------------------+ +// | 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 | +// | the Free Software Foundation | +// | | +// | This program is distributed in the hope that it will be useful, but | +// | WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | +// | General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | +// | USA. | +// +-----------------------------------------------------------------------+ + +/* + * Search an available check_key + * + * It's a copy of function find_available_feed_id + * + * @return string nbm identifier + */ +function find_available_check_key() +{ + while (true) + { + $key = generate_key(128); + $query = ' +select + count(*) +from + '.USER_MAIL_NOTIFICATION_TABLE.' +where + check_key = \''.$key.'\';'; + + list($count) = mysql_fetch_row(pwg_query($query)); + if ($count == 0) + { + return $key; + } + } +} + + +/* + * Add quote to all elements of check_key_list + * + * @return quoted check key list + */ +function quote_check_key_list($check_key_list = array()) +{ + return array_map(create_function('$s', 'return \'\\\'\'.$s.\'\\\'\';'), $check_key_list); +} + +/* + * Subscribe or unsubscribe notification by mail + * + * is_subscribe define if action=subscribe or unsubscribe + * check_key list where action will be done + * + * @return updated data count + */ +function do_subscribe_unsubcribe_notification_by_mail($is_subscribe = false, $check_key_list = array()) +{ + global $page; + + $updated_data_count = 0; + if ($is_subscribe) + { + $msg_info = l10n('nbm_user_change_enabled_true'); + } + else + { + $msg_info = l10n('nbm_user_change_enabled_false'); + } + + if (count($check_key_list) != 0) + { + $quoted_check_key_list = quote_check_key_list($check_key_list); + + $query = ' +select + N.check_key, U.username, U.mail_address +from + '.USER_MAIL_NOTIFICATION_TABLE.' as N, + '.USERS_TABLE.' as U +where + N.user_id = U.id and + N.enabled = \''.boolean_to_string(!$is_subscribe).'\' and + check_key in ('.implode(",", $quoted_check_key_list).') +order by + username;'; + + $result = pwg_query($query); + if (!empty($result)) + { + $updates = array(); + $enabled_value = boolean_to_string($is_subscribe); + + while ($row = mysql_fetch_array($result)) + { + array_push + ( + $updates, + array + ( + 'check_key' => $row['check_key'], + 'enabled' => $enabled_value + ) + ); + $updated_data_count += 1; + array_push($page['infos'], sprintf($msg_info, $row['username'], $row['mail_address'])); + } + + mass_updates( + USER_MAIL_NOTIFICATION_TABLE, + array( + 'primary' => array('check_key'), + 'update' => array('enabled') + ), + $updates + ); + } + } + + array_push($page['infos'], sprintf(l10n('nbm_user_change_enabled_updated_data_count'), $updated_data_count)); + + return $updated_data_count; +} + +/* + * Unsubscribe notification by mail + * + * check_key list where action will be done + * + * @return updated data count + */ +function unsubcribe_notification_by_mail($check_key_list = array()) +{ + return do_subscribe_unsubcribe_notification_by_mail(false, $check_key_list); +} + +/* + * Subscribe notification by mail + * + * check_key list where action will be done + * + * @return updated data count + */ +function subcribe_notification_by_mail($check_key_list = array()) +{ + return do_subscribe_unsubcribe_notification_by_mail(true, $check_key_list); +} + +?>
\ No newline at end of file diff --git a/admin/notification_by_mail.php b/admin/notification_by_mail.php index db92b8e72..c6212299a 100644 --- a/admin/notification_by_mail.php +++ b/admin/notification_by_mail.php @@ -36,7 +36,7 @@ if (!defined('PHPWG_ROOT_PATH')) } include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); -include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); +include_once(PHPWG_ROOT_PATH.'admin/include/functions_notification_by_mail.inc.php'); include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); include_once(PHPWG_ROOT_PATH.'include/functions_notification.inc.php'); include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); @@ -49,38 +49,34 @@ check_status(ACCESS_ADMINISTRATOR); // +-----------------------------------------------------------------------+ // | functions | // +-----------------------------------------------------------------------+ + /* - * Search an available check_key - * - * It's a copy of function find_available_feed_id - * - * @return string feed identifier - */ -function find_available_check_key() + * Get the authorized_status for each tab + * return corresponding status +*/ +function get_tab_status($mode) { - while (true) + $result = ACCESS_WEBMASTER; + switch ($mode) { - $key = generate_key(128); - $query = ' -select - count(*) -from - '.USER_MAIL_NOTIFICATION_TABLE.' -where - check_key = \''.$key.'\';'; - - list($count) = mysql_fetch_row(pwg_query($query)); - if ($count == 0) - { - return $key; - } + case 'param': + case 'subscribe' : + $result = ACCESS_WEBMASTER; + break; + case 'send' : + $result = ACCESS_ADMINISTRATOR; + break; + default: + $result = ACCESS_WEBMASTER; + break; } + return $result; } /* - * Updating News users + * Inserting News users */ -function update_data_user_mail_notification() +function insert_new_data_user_mail_notification() { global $conf, $page; @@ -94,6 +90,7 @@ where trim(mail_address) = \'\';'; pwg_query($query); + // null mail_address are not selected in the list $query = ' select u.id user_id, u.username, u.mail_address @@ -110,57 +107,108 @@ order by if (mysql_num_rows($result) > 0) { $inserts = array(); + $check_key_list = array(); while ($row = mysql_fetch_array($result)) { - array_push($inserts, array('user_id' => $row['user_id'], - 'check_key' => find_available_check_key(), - 'enabled' => ($conf['default_value_user_mail_notification_enabled'] == true ? 'true' : 'false'))); + // Calculate key + $row['check_key'] = find_available_check_key(); + + // Save key + array_push($check_key_list, $row['check_key']); + + // Insert new rows + array_push + ( + $inserts, + array + ( + 'user_id' => $row['user_id'], + 'check_key' => $row['check_key'], + 'enabled' => 'false' // By default if false, set to true with specific functions + ) + ); + array_push($page['infos'], sprintf(l10n('nbm_User %s [%s] added.'), $row['username'], $row['mail_address'])); } + // Insert new rows mass_inserts(USER_MAIL_NOTIFICATION_TABLE, array('user_id', 'check_key', 'enabled'), $inserts); + // Update field enabled with specific function + do_subscribe_unsubcribe_notification_by_mail + ( + ($conf['default_value_user_mail_notification_enabled'] == true ? true : false), + $check_key_list + ); } } /* - * Updating News users + * Send mail for notification to all users + * Return list of "treated/selected" users */ -function send_all_user_mail_notification() +function do_action_send_mail_notification($action = 'prepare', $check_key_list = array(), $customize_mail_content = '') { - global $conf, $conf_mail, $page, $user, $lang_info, $lang; + global $conf, $page, $user, $lang_info, $lang; list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); + $return_list = array(); + $is_action_send = ($action == 'send'); + + $quoted_check_key_list = quote_check_key_list($check_key_list); + if (count($quoted_check_key_list) != 0 ) + { + $query_and_check_key = ' and + check_key in ('.implode(",", $quoted_check_key_list).') '; + } + else + { + $query_and_check_key = ''; + } + if (isset($customize_mail_content)) + { + $customize_mail_content = $conf['nbm_complementary_mail_content']; + } + + // disabled and null mail_address are not selected in the list $query = ' select - N.user_id, U.username, U.mail_address, N.last_send + N.user_id, N.check_key, U.username, U.mail_address, N.last_send from '.USER_MAIL_NOTIFICATION_TABLE.' as N, '.USERS_TABLE.' as U where N.user_id = U.id and N.enabled = \'true\' and - U.mail_address is not null + U.mail_address is not null'.$query_and_check_key.' order by - user_id;'; + username;'; $result = pwg_query($query); if (mysql_num_rows($result) > 0) { $error_on_mail_count = 0; - $sended_mail_count = 0; + $sent_mail_count = 0; $datas = array(); // Save $user, $lang_info and $lang arrays (include/user.inc.php has been executed) $sav_mailtousers_user = $user; $sav_mailtousers_lang_info = $lang_info; $sav_mailtousers_lang = $lang; // Save message info and error in the original language - $msg_info = l10n('nbm_Mail sended to %s [%s].'); + $msg_info = l10n('nbm_Mail sent to %s [%s].'); $msg_error = l10n('nbm_Error when sending email to %s [%s].'); // Last Language $last_mailtousers_language = $user['language']; + if ($is_action_send) + { + // Init mail configuration + $send_as_name = ((isset($conf['nbm_send_mail_as']) and !empty($conf['nbm_send_mail_as'])) ? $conf['nbm_send_mail_as'] : $conf['gallery_title']); + $send_as_mail_address = get_webmaster_mail_address(); + $send_as_mail_formated = format_email($send_as_name, $send_as_mail_address); + } + while ($row = mysql_fetch_array($result)) { $user = array(); @@ -186,35 +234,51 @@ order by $news = news($row['last_send'], $dbnow); if (count($news) > 0) { - $subject = '['.$conf['gallery_title'].']: '.l10n('nbm_New elements added'); - $message .= sprintf(l10n('nbm_Hello %s'), $row['username']).",\n\n"; - - if (!is_null($row['last_send'])) - $message .= sprintf(l10n('nbm_New elements were added between %s and %s:'), $row['last_send'], $dbnow); - else - $message .= sprintf(l10n('nbm_New elements were added on %s:'), $dbnow); - $message .= "\n"; + array_push($return_list, $row); - foreach ($news as $line) + if ($is_action_send) { - $message .= ' o '.$line."\n"; - } - - $message .= "\n".sprintf(l10n('nbm_Go to %s %s.'), $conf['gallery_title'], $conf['gallery_url'])."\n\n"; - $message .= "\n".sprintf(l10n('nbm_To unsubscribe send a message to %s.'), $conf_mail['email_webmaster'])."\n\n"; - - if (pwg_mail(format_email($row['username'], $row['mail_address']), '', $subject, $message)) - { - $sended_mail_count += 1; - array_push($page['infos'], sprintf($msg_info, $row['username'], $row['mail_address'])); - $data = array('user_id' => $row['user_id'], - 'last_send' => $dbnow); - array_push($datas, $data); - } - else - { - $error_on_mail_count += 1; - array_push($page['errors'], sprintf($msg_error, $row['username'], $row['mail_address'])); + $subject = '['.$conf['gallery_title'].']: '.l10n('nbm_ContentObject'); + $message .= sprintf(l10n('nbm_ContentHello'), $row['username']).",\n\n"; + + if (!is_null($row['last_send'])) + $message .= sprintf(l10n('nbm_ContentNewElementsBetween'), $row['last_send'], $dbnow); + else + $message .= sprintf(l10n('nbm_ContentNewElements'), $dbnow); + + if ($conf['nbm_send_detailed_content']) + { + $message .= ":\n"; + + foreach ($news as $line) + { + $message .= ' o '.$line."\n"; + } + $message .= "\n"; + } + else + { + $message .= ".\n"; + } + + $message .= sprintf(l10n('nbm_ContentGoTo'), $conf['gallery_title'], $conf['gallery_url'])."\n\n"; + $message .= $customize_mail_content."\n\n"; + $message .= l10n('nbm_ContentByeBye')."\n ".$send_as_name."\n\n"; + $message .= "\n".sprintf(l10n('nbm_ContentUnsubscribe'), $send_as_mail_address)."\n\n"; + + if (pwg_mail(format_email($row['username'], $row['mail_address']), $send_as_mail_formated, $subject, $message)) + { + $sent_mail_count += 1; + array_push($page['infos'], sprintf($msg_info, $row['username'], $row['mail_address'])); + $data = array('user_id' => $row['user_id'], + 'last_send' => $dbnow); + array_push($datas, $data); + } + else + { + $error_on_mail_count += 1; + array_push($page['errors'], sprintf($msg_error, $row['username'], $row['mail_address'])); + } } } } @@ -224,39 +288,43 @@ order by $lang_info = $sav_mailtousers_lang_info; $lang = $sav_mailtousers_lang; - mass_updates( - USER_MAIL_NOTIFICATION_TABLE, - array( - 'primary' => array('user_id'), - 'update' => array('last_send') - ), - $datas - ); - - if ($error_on_mail_count != 0) + if ($is_action_send) { - array_push($page['errors'], sprintf(l10n('nbm_%d mails were not sended.'), $error_on_mail_count)); - } - else - { - if ($sended_mail_count == 0) - array_push($page['infos'], l10n('nbm_No mail to send.')); + mass_updates( + USER_MAIL_NOTIFICATION_TABLE, + array( + 'primary' => array('user_id'), + 'update' => array('last_send') + ), + $datas + ); + + if ($error_on_mail_count != 0) + { + array_push($page['errors'], sprintf(l10n('nbm_%d mails were not sent.'), $error_on_mail_count)); + } else - array_push($page['infos'], sprintf(l10n('nbm_%d mails were sended.'), $sended_mail_count)); + { + if ($sent_mail_count == 0) + array_push($page['infos'], l10n('nbm_No mail to send.')); + else + array_push($page['infos'], sprintf(l10n('nbm_%d mails were sent.'), $sent_mail_count)); + } } } else { - array_push($page['errors'], l10n('nbm_No user to send notifications by mail.')); + if ($is_action_send) + { + array_push($page['errors'], l10n('nbm_No user to send notifications by mail.')); + } } + return $return_list; } // +-----------------------------------------------------------------------+ // | Main | // +-----------------------------------------------------------------------+ -update_data_user_mail_notification(); -//send_all_user_mail_notification(); - if (!isset($_GET['mode'])) { $page['mode'] = 'send'; @@ -267,26 +335,131 @@ else } // +-----------------------------------------------------------------------+ +// | Check Access and exit when user status is not ok | +// +-----------------------------------------------------------------------+ +check_status(get_tab_status($page['mode'])); + +// +-----------------------------------------------------------------------+ +// | Insert new users with mails | +// +-----------------------------------------------------------------------+ +if (!isset($_POST) or (count($_POST) ==0)) +{ + // No insert data in post mode + insert_new_data_user_mail_notification(); +} + +// +-----------------------------------------------------------------------+ +// | Treatment of tab post | +// +-----------------------------------------------------------------------+ +switch ($page['mode']) +{ + case 'param' : + { + $updated_param_count = 0; + // Update param + $result = pwg_query('select param, value from '.CONFIG_TABLE.' where param like \'nbm\\_%\''); + while ($row = mysql_fetch_array($result)) + { + if (isset($_POST['param_submit'])) + { + if (isset($_POST[$row['param']])) + { + $value = $_POST[$row['param']]; + + $query = ' +update + '.CONFIG_TABLE.' +set + value = \''. str_replace("\'", "''", $value).'\' +where + param = \''.$row['param'].'\';'; + pwg_query($query); + $updated_param_count += 1; + } + } + + $conf[$row['param']] = $row['value']; + + // if the parameter is present in $_POST array (if a form is submited), we + // override it with the submited value + if (isset($_POST[$row['param']])) + { + $conf[$row['param']] = stripslashes($_POST[$row['param']]); + } + + // If the field is true or false, the variable is transformed into a + // boolean value. + if ($conf[$row['param']] == 'true' or $conf[$row['param']] == 'false') + { + $conf[$row['param']] = get_boolean($conf[$row['param']]); + } + } + + if ($updated_param_count != 0) + { + array_push($page['infos'], sprintf(l10n('nbm_updated_param_count'), $updated_param_count)); + } + } + case 'subscribe' : + { + if (isset($_POST['falsify']) and isset($_POST['cat_true'])) + { + unsubcribe_notification_by_mail($_POST['cat_true']); + } + else + if (isset($_POST['trueify']) and isset($_POST['cat_false'])) + { + subcribe_notification_by_mail($_POST['cat_false']); + } + break; + } + + case 'send' : + { + if (isset($_POST['send_submit']) and isset($_POST['send_selection']) and isset($_POST['send_customize_mail_content'])) + { + do_action_send_mail_notification('send', $_POST['send_selection'], $_POST['send_customize_mail_content']); + } + } +} + +// +-----------------------------------------------------------------------+ // | template initialization | // +-----------------------------------------------------------------------+ -$template->set_filenames( - array( +$template->set_filenames +( + array + ( 'double_select' => 'admin/double_select.tpl', 'notification_by_mail'=>'admin/notification_by_mail.tpl' - ) - ); + ) +); $base_url = get_root_url().'admin.php'; -$template->assign_vars( - array( +$template->assign_vars +( + array + ( 'U_TABSHEET_TITLE' => l10n('nbm_'.$page['mode'].'_mode'), - 'U_HELP' => add_url_params(get_root_url().'/popuphelp.php', array('page'=>'notification_by_mail') ), - 'U_PARAM_MODE' => add_url_params($base_url.get_query_string_diff(array('mode')), array('mode'=>'param') ), - 'U_SUBSCRIBE_MODE' => add_url_params($base_url.get_query_string_diff(array('mode')), array('mode'=>'subscribe') ), - 'U_SEND_MODE' => add_url_params($base_url.get_query_string_diff(array('mode')), array('mode'=>'send') ), + 'U_HELP' => add_url_params(get_root_url().'/popuphelp.php', array('page' => 'notification_by_mail')), 'F_ACTION'=> $base_url.get_query_string_diff(array()) - )); + ) +); + +if (is_autorize_status(ACCESS_WEBMASTER)) +{ + $template->assign_block_vars + ( + 'header_link', + array + ( + 'PARAM_MODE' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'param')), + 'SUBSCRIBE_MODE' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'subscribe')), + 'SEND_MODE' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'send')) + ) + ); +} switch ($page['mode']) { @@ -295,16 +468,19 @@ switch ($page['mode']) $template->assign_block_vars( $page['mode'], array( - //'HISTORY_YES'=>$history_yes + 'SEND_MAIL_AS' => $conf['nbm_send_mail_as'], + 'SEND_DETAILED_CONTENT_YES' => ($conf['nbm_send_detailed_content'] ? 'checked="checked"' : ''), + 'SEND_DETAILED_CONTENT_NO' => (!$conf['nbm_send_detailed_content'] ? 'checked="checked"' : ''), + 'COMPLEMENTARY_MAIL_CONTENT' => $conf['nbm_complementary_mail_content'] )); break; } + case 'subscribe' : { $template->assign_block_vars( $page['mode'], array( - //'HISTORY_YES'=>$history_yes )); $template->assign_vars( @@ -314,83 +490,72 @@ switch ($page['mode']) ) ); + $query = ' +select + N.check_key, N.enabled, U.username, U.mail_address +from + '.USER_MAIL_NOTIFICATION_TABLE.' as N, + '.USERS_TABLE.' as U +where + N.user_id = U.id +order by + username;'; -/* $template->assign_block_vars( - $blockname, - array('SELECTED'=>$selected, - 'VALUE'=>$category['id'], - 'OPTION'=>$option - ));*/ - $template->assign_block_vars( - 'category_option_true', - array('SELECTED'=>'', - 'VALUE'=>'rub', - 'OPTION'=>'rub [rub@phpwebgallery.net]' - )); + $result = pwg_query($query); + if (!empty($result)) + { + while ($row = mysql_fetch_array($result)) + { + $template->assign_block_vars( + (get_boolean($row['enabled']) ? 'category_option_true' : 'category_option_false'), + array('SELECTED' => '', + 'VALUE' => $row['check_key'], + 'OPTION' => $row['username'].'['.$row['mail_address'].']' + )); + } + } break; } + case 'send' : { - $template->assign_block_vars( - $page['mode'], - array( - //'HISTORY_YES'=>$history_yes - )); - - $template->assign_vars( - array( - 'L_CAT_OPTIONS_TRUE' => l10n('nbm_send_col'), - 'L_CAT_OPTIONS_FALSE' => l10n('nbm_nosend_col') - ) - ); + $template->assign_block_vars($page['mode'], array()); + $data_rows = do_action_send_mail_notification('prepare'); -/* $template->assign_block_vars( - $blockname, - array('SELECTED'=>$selected, - 'VALUE'=>$category['id'], - 'OPTION'=>$option - ));*/ - $template->assign_block_vars( - 'category_option_true', - array('SELECTED'=>' selected="selected"', - 'VALUE'=>'rub', - 'OPTION'=>'rub [2006-03-20 23:35:23]' - )); + if (count($data_rows) == 0) + { + $template->assign_block_vars($page['mode'].'.send_empty', array()); + } + else + { + $template->assign_block_vars( + $page['mode'].'.send_data', + array( + // 'URL_CHECK_ALL' => add_url_params($base_url.get_query_string_diff(array('select')), array('select' => 'all')), + // 'URL_UNCHECK_ALL' => add_url_params($base_url.get_query_string_diff(array('select')), array('select' => 'none')), + 'CUSTOMIZE_MAIL_CONTENT' => isset($_POST['send_customize_mail_content']) ? $_POST['send_customize_mail_content'] : $conf['nbm_complementary_mail_content'] + )); + + foreach ($data_rows as $num => $local_user) + $template->assign_block_vars( + $page['mode'].'.send_data.user_send_mail', + array( + 'CLASS' => ($num % 2 == 1) ? 'row2' : 'row1', + 'ID' => $local_user['check_key'], + 'CHECKED' => isset($_POST['send_uncheck_all']) ? '' : 'checked="checked"', + 'USERNAME'=> $local_user['username'], + 'EMAIL' => $local_user['mail_address'], + 'LAST_SEND'=> $local_user['last_send'] + )); + } break; } } // +-----------------------------------------------------------------------+ -// | infos & errors display | -// +-----------------------------------------------------------------------+ - -/*echo '<pre>'; - -if (count($page['errors']) != 0) -{ - echo "\n\nErrors:\n"; - foreach ($page['errors'] as $error) - { - echo $error."\n"; - } -} - -if (count($page['infos']) != 0) -{ - echo "\n\nInformations:\n"; - foreach ($page['infos'] as $info) - { - echo $info."\n"; - } -} - -echo '</pre>'; -*/ - -// +-----------------------------------------------------------------------+ // | Sending html code | // +-----------------------------------------------------------------------+ $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php index edd08c6ce..9c5b8aaa8 100644 --- a/include/functions_mail.inc.php +++ b/include/functions_mail.inc.php @@ -29,7 +29,7 @@ /** * - Extract mail fonctions of password.php * - Modify pwg_mail (add pararameters + news fonctionnalities) - * - Var conf_mail, function init_conf_mail, function format_email + * - Var conf_mail, function get_mail_configuration, format_email, pwg_mail */ // +-----------------------------------------------------------------------+ @@ -133,4 +133,5 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '') return mail($to, $subject, $content, $headers); } } + ?>
\ No newline at end of file diff --git a/install/config.sql b/install/config.sql index 80c572903..6bd677fa6 100644 --- a/install/config.sql +++ b/install/config.sql @@ -20,3 +20,7 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate','true','Ra INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate_anonymous','true','Rating pictures feature is also enabled for visitors'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('page_banner','<div id=\"theHeader\"><h1>PhpWebGallery demonstration site</h1><p>My photos web site</p></div>','html displayed on the top each page of your gallery'); +-- Notification by mail +INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail'); +INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail'); +INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_complementary_mail_content','','Complementary mail content for notification by mail'); diff --git a/install/db/17-database.php b/install/db/17-database.php new file mode 100644 index 000000000..820ca6194 --- /dev/null +++ b/install/db/17-database.php @@ -0,0 +1,64 @@ +<?php +// +-----------------------------------------------------------------------+ +// | PhpWebGallery - a PHP based picture gallery | +// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | +// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | +// +-----------------------------------------------------------------------+ +// | branch : BSF (Best So Far) +// | file : $RCSfile$ +// | last update : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $ +// | last modifier : $Author: plg $ +// | revision : $Revision: 870 $ +// +-----------------------------------------------------------------------+ +// | 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 | +// | the Free Software Foundation | +// | | +// | This program is distributed in the hope that it will be useful, but | +// | WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | +// | General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | +// | USA. | +// +-----------------------------------------------------------------------+ + +if (!defined('PHPWG_ROOT_PATH')) +{ + die('Hacking attempt!'); +} + +$upgrade_description = 'Add notification by mail param'; + +include_once(PHPWG_ROOT_PATH.'include/constants.php'); + +// +-----------------------------------------------------------------------+ +// | Upgrade content | +// +-----------------------------------------------------------------------+ + +echo "Add param on ".CONFIG_TABLE; +$query = " +INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail'); +"; +pwg_query($query); + + +$query = " +INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail'); +"; +pwg_query($query); + +$query = " +INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('nbm_complementary_mail_content','','Complementary mail content for notification by mail'); +"; +pwg_query($query); + +echo +"\n" +.'"'.$upgrade_description.'"'.' ended' +."\n" +; + +?> diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php index 1596d3d24..fe0d5cd64 100644 --- a/language/en_UK.iso-8859-1/admin.lang.php +++ b/language/en_UK.iso-8859-1/admin.lang.php @@ -238,35 +238,50 @@ $lang['metadata_basic'] = 'basic'; $lang['metadata_exif'] = 'EXIF'; $lang['metadata_iptc'] = 'IPTC'; $lang['name'] = 'name'; -$lang['nbm_%d mails were not sended.'] = '%d mails were not sended.'; -$lang['nbm_%d mails were sended.'] = '%d mails were sended.'; +$lang['nbm_%d mails were not sent.'] = '%d mails were not sent.'; +$lang['nbm_%d mails were sent.'] = '%d mails were sent.'; $lang['nbm_Error when sending email to %s [%s].'] = 'Error when sending email to %s [%s].'; -$lang['nbm_Go to %s %s.'] = 'Go to %s %s.'; -$lang['nbm_Hello %s'] = 'Hello %s'; -$lang['nbm_Mail sended to %s [%s].'] = 'Mail sended to %s [%s].'; -$lang['nbm_New elements added'] = 'New elements added'; -$lang['nbm_New elements were added between %s and %s:'] = 'New elements were added between %s and %s:'; -$lang['nbm_New elements were added on %s:'] = 'New elements were added on %s:'; +$lang['nbm_Mail sent to %s [%s].'] = 'Mail sent to %s [%s].'; +$lang['nbm_ContentObject'] = 'New elements added'; +$lang['nbm_ContentHello'] = 'Hello %s'; +$lang['nbm_ContentNewElementsBetween'] = 'New elements were added between %s and %s'; +$lang['nbm_ContentNewElements'] = 'New elements were added on %s'; +$lang['nbm_ContentGoTo'] = 'Go to %s %s.'; +$lang['nbm_ContentByeBye'] = 'See you soon'; +$lang['nbm_ContentUnsubscribe'] = 'To unsubscribe send a message to %s.'; $lang['nbm_No mail to send.'] = 'No mail to send.'; $lang['nbm_No user to send notifications by mail.'] = 'No user to send notifications by mail.'; $lang['nbm_Send mail to users'] = 'Send mail to users'; -$lang['nbm_To unsubscribe send a message to %s.'] = 'To unsubscribe send a message to %s.'; $lang['nbm_User %s [%s] added.'] = 'User %s [%s] added.'; $lang['nbm_item_notification'] = 'Notification'; $lang['nbm_param_mode'] = 'Parameter'; $lang['nbm_subscribe_mode'] = 'Subscribe'; $lang['nbm_send_mode'] = 'Send'; $lang['nbm_title_param'] = 'Parameters'; +$lang['nbm_updated_param_count'] = '%d parameters are updated.'; +$lang['nbm_send_mail_as'] = 'Send mail as'; +$lang['nbm_info_send_mail_as'] = 'With blank value, gallery title will be used'; $lang['nbm_send_detailed_content'] = 'Send detailed content'; $lang['nbm_complementary_mail_content'] = 'Complementary mail content'; $lang['nbm_title_subscribe'] = 'Subscribe/unscribe users'; $lang['nbm_warning_subscribe_unsubcribe'] = 'Warning, subscribe or unscribe send mails to users [Not Implemented]'; $lang['nbm_subscribe_col'] = 'Subscribed'; $lang['nbm_unsubscribe_col'] = 'Unsubcribed'; +$lang['nbm_no_user_available_to_send_L1'] = 'No user are available in order to send mail.'; +$lang['nbm_no_user_available_to_send_L2'] = 'A user is available, if the are news elements to notify'; $lang['nbm_title_send'] = 'Select sendings'; +$lang['nbm_col_user'] = 'User'; +$lang['nbm_col_mail'] = 'email'; +$lang['nbm_col_last_send'] = 'Last send'; +$lang['nbm_col_check_user_send_mail'] = 'To send ?'; +$lang['nbm_send_options'] = 'Options'; +$lang['nbm_send_complementary_mail_content'] = 'Complementary mail content'; $lang['nbm_send_submit'] = 'Send'; -$lang['nbm_send_col'] = 'To send'; -$lang['nbm_nosend_col'] = 'No to send'; +$lang['nbm_send_check_all'] = 'Check All'; +$lang['nbm_send_uncheck_all'] = 'Uncheck All'; +$lang['nbm_user_change_enabled_true'] = 'User %s [%s] added to subscribe list.'; +$lang['nbm_user_change_enabled_false'] = 'User %s [%s] removed of subscribe list.'; +$lang['nbm_user_change_enabled_updated_data_count'] = '%d user(s) are updated.'; $lang['no_write_access'] = 'no write access'; $lang['order_by'] = 'order by'; $lang['path'] = 'path'; diff --git a/language/en_UK.iso-8859-1/help/notification_by_mail.html b/language/en_UK.iso-8859-1/help/notification_by_mail.html index aa977a816..106c5a736 100644 --- a/language/en_UK.iso-8859-1/help/notification_by_mail.html +++ b/language/en_UK.iso-8859-1/help/notification_by_mail.html @@ -1,2 +1,15 @@ <h2>Notification by mail</h2> +<p>This screen allows to configure, to manage the notification to users of news sendinf mail.</p> + +<p>This screen is composed of 3 tabs:</p> + +<h3>Parameters</h3> +<p>Available only for webmasters, this tab sets parameters of the notification by mail.</p> + +<h3>Subscribe</h3> +<p>Available only for webmasters, this tab manages subscribe/unsubscribe of notification by mail.</p> + +<h3>Envoi</h3> +<p>Available only for webmasters and administrators, this tab allows to send mails to notify news.</p> + diff --git a/language/fr_FR.iso-8859-1/admin.lang.php b/language/fr_FR.iso-8859-1/admin.lang.php index 0ad69bced..810716154 100644 --- a/language/fr_FR.iso-8859-1/admin.lang.php +++ b/language/fr_FR.iso-8859-1/admin.lang.php @@ -238,35 +238,50 @@ $lang['metadata_basic'] = 'basique'; $lang['metadata_exif'] = 'EXIF'; $lang['metadata_iptc'] = 'IPTC'; $lang['name'] = 'nom'; -$lang['nbm_%d mails were not sended.'] = '%s mails n\'ont pas été envoyés.'; -$lang['nbm_%d mails were sended.'] = '%s mails ont été envoyés.'; +$lang['nbm_%d mails were not sent.'] = '%s mails n\'ont pas été envoyés.'; +$lang['nbm_%d mails were sent.'] = '%s mails ont été envoyés.'; $lang['nbm_Error when sending email to %s [%s].'] = 'Erreur lors de l\'envoi du mail à %s [%s].'; -$lang['nbm_Go to %s %s.'] = 'Allez sur %s %s.'; -$lang['nbm_Hello %s'] = 'Bonjour %s'; -$lang['nbm_Mail sended to %s [%s].'] = 'Mail envoyé à %s [%s].'; -$lang['nbm_New elements added'] = 'Nouveaux éléments ajoutés'; -$lang['nbm_New elements were added between %s and %s:'] = 'Des nouveaux éléments ont été ajoutés entre le %s et le %s:'; -$lang['nbm_New elements were added on %s:'] = 'Des nouveaux éléments ont été ajoutés le %s:'; +$lang['nbm_Mail sent to %s [%s].'] = 'Mail envoyé à %s [%s].'; +$lang['nbm_ContentObject'] = 'Nouveaux éléments ajoutés'; +$lang['nbm_ContentHello'] = 'Bonjour %s'; +$lang['nbm_ContentNewElementsBetween'] = 'Des nouveaux éléments ont été ajoutés entre le %s et le %s'; +$lang['nbm_ContentNewElements'] = 'Des nouveaux éléments ont été ajoutés le %s'; +$lang['nbm_ContentGoTo'] = 'Rendez-vous sur %s %s.'; +$lang['nbm_ContentByeBye'] = 'A bientôt'; +$lang['nbm_ContentUnsubscribe'] = 'Pour vous désinscrire, envoyer un mail à %s.'; $lang['nbm_No mail to send.'] = 'Pas de mail à envoyer.'; $lang['nbm_No user to send notifications by mail.'] = 'Pas d\'utilisateur pour envoyer des notifications par mails.'; $lang['nbm_Send mail to users'] = 'Envoi de mail aux utilisateurs'; -$lang['nbm_To unsubscribe send a message to %s.'] = 'Pour vous désinscrire, envoyer un mail à %s.'; $lang['nbm_User %s [%s] added.'] = 'Utilisateur %s [%s] ajouté.'; $lang['nbm_item_notification'] = 'Notification'; $lang['nbm_param_mode'] = 'Paramètrage'; $lang['nbm_subscribe_mode'] = 'Inscription'; $lang['nbm_send_mode'] = 'Envoi'; $lang['nbm_title_param'] = 'Paramètres'; +$lang['nbm_updated_param_count'] = '%d paramètres ont été mis à jour.'; +$lang['nbm_send_mail_as'] = 'Envoyer le mail en tant que'; +$lang['nbm_info_send_mail_as'] = 'Sans valeur, le titre de la galerie sera utilisé'; $lang['nbm_send_detailed_content'] = 'Envoi d\'un contenu détaillé'; $lang['nbm_complementary_mail_content'] = 'Contenu complémentaire au mail'; $lang['nbm_title_subscribe'] = 'Inscrire/desinscrire les utilisateurs'; $lang['nbm_warning_subscribe_unsubcribe'] = 'Attention, l\'inscription ou la desincription entraine l\'envoi de mails aux utilisateurs concernés [Fonction non implementée]'; $lang['nbm_subscribe_col'] = 'Inscrits'; $lang['nbm_unsubscribe_col'] = 'Non Inscrits'; +$lang['nbm_no_user_available_to_send_L1'] = 'Il n\'y a pas d\'utilisateur à notifier par mail.'; +$lang['nbm_no_user_available_to_send_L2'] = 'Un utilisateur est à notifier si de nouveaux éléments sont disponibles pour cet utilisateur.'; $lang['nbm_title_send'] = 'Sélection des envois'; +$lang['nbm_col_user'] = 'Utilisateur'; +$lang['nbm_col_mail'] = 'email'; +$lang['nbm_col_last_send'] = 'Dernier envoi'; +$lang['nbm_col_check_user_send_mail'] = 'A envoyer ?'; +$lang['nbm_send_options'] = 'Options'; +$lang['nbm_send_complementary_mail_content'] = 'Contenu complémentaire du mail'; $lang['nbm_send_submit'] = 'Envoyer'; -$lang['nbm_send_col'] = 'A envoyer'; -$lang['nbm_nosend_col'] = 'A ne pas envoyer'; +$lang['nbm_send_check_all'] = 'Tout cocher'; +$lang['nbm_send_uncheck_all'] = 'Tout décocher'; +$lang['nbm_user_change_enabled_true'] = 'L\'utilisateur %s [%s] a été ajouté à la liste des inscrits.'; +$lang['nbm_user_change_enabled_false'] = 'L\'utilisateur %s [%s] a été supprimé de la liste des inscrits.'; +$lang['nbm_user_change_enabled_updated_data_count'] = '%d utilisateur(s) a(ont) été mis à jour.'; $lang['no_write_access'] = 'pas d\'accès en écriture'; $lang['order_by'] = 'trier selon'; $lang['path'] = 'chemin'; diff --git a/language/fr_FR.iso-8859-1/help/notification_by_mail.html b/language/fr_FR.iso-8859-1/help/notification_by_mail.html index 1426d3671..3178aa0ec 100644 --- a/language/fr_FR.iso-8859-1/help/notification_by_mail.html +++ b/language/fr_FR.iso-8859-1/help/notification_by_mail.html @@ -1,2 +1,15 @@ -<h2>Avertissement par mail</h2> +<h2>Notification par mail</h2> + +<p>Cet écran permet de configurer, de gérer la notification aux utilisateurs de changements par l'envoi d'un mail.</p> + +<p>Cet écran est composé de 3 onglets:</p> + +<h3>Paramètrage</h3> +<p>Accésible uniquement aux webmestres, cet onglet permet de positionner les paramètres de la notification par mail.</p> + +<h3>Inscription</h3> +<p>Accésible uniquement aux webmestres, cet onglet permet de gérer les inscriptions/désinscriptions à la notification par mail.</p> + +<h3>Envoi</h3> +<p>Accésible aux webmestres et aux administrateurs, cet onglet permet d'effectuer les envois des mails pour notifier les changements.</p> diff --git a/template/yoga/admin/notification_by_mail.tpl b/template/yoga/admin/notification_by_mail.tpl index 36bff3cf3..07ddda54e 100644 --- a/template/yoga/admin/notification_by_mail.tpl +++ b/template/yoga/admin/notification_by_mail.tpl @@ -4,13 +4,15 @@ <li><a href="{U_HELP}" onclick="popuphelp(this.href); return false;" title="{lang:Help}"><img src="{themeconf:icon_dir}/help.png" class="button" alt="(?)"></a></li> </ul> <h2>{lang:nbm_Send mail to users} [{U_TABSHEET_TITLE}]</h2> + <!-- BEGIN header_link --> <h3> <p style="text-align:center;"> - <a href="{U_PARAM_MODE}">{lang:nbm_param_mode}</a> | - <a href="{U_SUBSCRIBE_MODE}">{lang:nbm_subscribe_mode}</a> | - <a href="{U_SEND_MODE}">{lang:nbm_send_mode}</a> + <a href="{header_link.PARAM_MODE}">{lang:nbm_param_mode}</a> | + <a href="{header_link.SUBSCRIBE_MODE}">{lang:nbm_subscribe_mode}</a> | + <a href="{header_link.SEND_MODE}">{lang:nbm_send_mode}</a> </p> </h3> + <!-- END header_link --> </div> <form method="post" name="notification_by_mail" action="{F_ACTION}"> @@ -21,40 +23,94 @@ <table> <tr> + <tr> + <td> + <label for="send_mail_as">{lang:nbm_send_mail_as}</label> + <br><i><small>{lang:nbm_info_send_mail_as}</small></i> + </td> + <td><input type="text" maxlength="35" size="35" name="nbm_send_mail_as" id="send_mail_as" value="{param.SEND_MAIL_AS}"/></td> + </tr> <td><label for="send_detailed_content">{lang:nbm_send_detailed_content} </label></td> - <td><input type="checkbox" name="send_detailed_content" id="send_detailed_content" value="true" {param.SEND_DETAILED_CONTENT}/></td> + <td> + <label><input type="radio" name="nbm_send_detailed_content" value="true" {param.SEND_DETAILED_CONTENT_YES}/>{lang:yes}</label> + <label><input type="radio" name="nbm_send_detailed_content" value="false" {param.SEND_DETAILED_CONTENT_NO}/>{lang:no}</label> + </td> </tr> <tr> <td><label for="complementary_mail_content">{lang:nbm_complementary_mail_content} </label></td> - <td><textarea cols="50" rows="5" name="complementary_mail_content" id="complementary_mail_content">{param.COMPLEMENTARY_MAIL_CONTENT}</textarea></td> + <td><textarea cols="50" rows="5" name="nbm_complementary_mail_content" id="complementary_mail_content">{param.COMPLEMENTARY_MAIL_CONTENT}</textarea></td> </tr> </table> </fieldset> <p> - <input type="submit" value="{lang:Submit}" name="param_submit" {TAG_INPUT_ENABLED} /> - <input type="reset" value="{lang:Reset}" name="param_reset" /> + <input type="submit" value="{lang:Submit}" name="param_submit" {TAG_INPUT_ENABLED}/> + <input type="reset" value="{lang:Reset}" name="param_reset"/> </p> <!-- END param --> <!-- BEGIN subscribe --> <fieldset> <legend><strong>{lang:nbm_title_subscribe}</strong></legend> - <legend><center><i>{lang:nbm_warning_subscribe_unsubcribe}</i></center></legend> + <br><center><i>{lang:nbm_warning_subscribe_unsubcribe}</i></center><br> {DOUBLE_SELECT} </fieldset> <!-- END subscribe --> <!-- BEGIN send --> - <fieldset> - <legend><strong>{lang:nbm_title_send}</strong></legend> - {DOUBLE_SELECT} - </fieldset> + <!-- BEGIN send_empty --> + <center> + {lang:nbm_no_user_available_to_send_L1}<br> + {lang:nbm_no_user_available_to_send_L2} + </center> + <!-- END send_empty --> + <!-- BEGIN send_data --> + <fieldset> + <legend><strong>{lang:nbm_title_send}</strong></legend> + <table class="table2"> + <tr class="throw"> + <th>{lang:nbm_col_user}</th> + <th>{lang:nbm_col_mail}</th> + <th>{lang:nbm_col_last_send}</th> + <th>{lang:nbm_col_check_user_send_mail}</th> + </tr> + <!-- BEGIN user_send_mail --> + <tr class="{send.send_data.user_send_mail.CLASS}"> + <td><label for="send_selection-{send.send_data.user_send_mail.ID}">{send.send_data.user_send_mail.USERNAME}</label></td> + <td><label for="send_selection-{send.send_data.user_send_mail.ID}">{send.send_data.user_send_mail.EMAIL}</label></td> + <td><label for="send_selection-{send.send_data.user_send_mail.ID}">{send.send_data.user_send_mail.LAST_SEND}</label></td> + <td><input type="checkbox" name="send_selection[]" value="{send.send_data.user_send_mail.ID}" {send.send_data.user_send_mail.CHECKED} id="send_selection-{send.send_data.user_send_mail.ID}"/></td> + </tr> + <!-- END user_send_mail --> + </table> + <!-- + <p> + <a href="{send.send_data.URL_CHECK_ALL}">{lang:nbm_send_check_all}</a> + / <a href="{send.send_data.URL_UNCHECK_ALL}">{lang:nbm_send_uncheck_all}</a> + </p> + --> + <p> + <input type="submit" value="{lang:nbm_send_check_all}" name="send_check_all"/> + / + <input type="submit" value="{lang:nbm_send_uncheck_all}" name="send_uncheck_all"/> + </p> + </fieldset> - <p> - <input type="submit" value="{lang:nbm_send_submit}" name="sene_submit" {TAG_INPUT_ENABLED} /> - <input type="reset" value="{lang:Reset}" name="send_reset" /> - </p> + <fieldset> + <legend><strong>{lang:nbm_send_options}</strong></legend> + + <table> + <tr> + <td><label for="send_customize_mail_content">{lang:nbm_send_complementary_mail_content} </label></td> + <td><textarea cols="50" rows="5" name="send_customize_mail_content" id="send_customize_mail_content">{send.send_data.CUSTOMIZE_MAIL_CONTENT}</textarea></td> + </tr> + </table> + </fieldset> + + <p> + <input type="submit" value="{lang:nbm_send_submit}" name="send_submit" {TAG_INPUT_ENABLED}/> + </p> + <!-- END send_data --> <!-- END send --> </form> |