From 3609c224c74f50a9049524ebedc996ddd1187108 Mon Sep 17 00:00:00 2001 From: rub Date: Tue, 21 Mar 2006 22:58:59 +0000 Subject: [NBM] Step 3: Layout Model o Rename mailtousers.php on notification_by_mail.php o Deactivate temporary function on notification_by_mail.php o First design layout, no function activated, it's only a model git-svn-id: http://piwigo.org/svn/trunk@1091 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/mailtousers.php | 293 -------------------------------------------------- 1 file changed, 293 deletions(-) delete mode 100644 admin/mailtousers.php (limited to 'admin/mailtousers.php') diff --git a/admin/mailtousers.php b/admin/mailtousers.php deleted file mode 100644 index c2539a398..000000000 --- a/admin/mailtousers.php +++ /dev/null @@ -1,293 +0,0 @@ - 0) - { - $inserts = 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'))); - array_push($page['infos'], sprintf(l10n('nbm_User %s [%s] added.'), $row['username'], $row['mail_address'])); - } - - mass_inserts(USER_MAIL_NOTIFICATION_TABLE, array('user_id', 'check_key', 'enabled'), $inserts); - } -} - -/* - * Updating News users - */ -function send_all_user_mail_notification() -{ - global $conf, $conf_mail, $page, $user, $lang_info, $lang; - list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); - - $query = ' -select - N.user_id, 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 -order by - user_id;'; - - $result = pwg_query($query); - - if (mysql_num_rows($result) > 0) - { - $error_on_mail_count = 0; - $sended_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_error = l10n('nbm_Error when sending email to %s [%s].'); - // Last Language - $last_mailtousers_language = $user['language']; - - while ($row = mysql_fetch_array($result)) - { - $user = array(); - $user['id'] = $row['user_id']; - $user = array_merge($user, getuserdata($user['id'], true)); - - if ($last_mailtousers_language != $user['language']) - { - $last_mailtousers_language = $user['language']; - - // Re-Init language arrays - $lang_info = array(); - $lang = array(); - - // language files - include(get_language_filepath('common.lang.php')); - // No test admin because script is checked admin (user selected no) - // Translations are in admin file too - include(get_language_filepath('admin.lang.php')); - } - - $message = ''; - $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"; - - foreach ($news as $line) - { - $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'])); - } - } - } - - // Restore $user, $lang_info and $lang arrays (include/user.inc.php has been executed) - $user = $sav_mailtousers_user; - $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) - { - 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.')); - else - array_push($page['infos'], sprintf(l10n('nbm_%d mails were sended.'), $sended_mail_count)); - } - } - else - { - array_push($page['errors'], l10n('nbm_No user to send notifications by mail.')); - } -} - -// +-----------------------------------------------------------------------+ -// | Main -// +-----------------------------------------------------------------------+ -update_data_user_mail_notification(); -send_all_user_mail_notification(); - - -// +-----------------------------------------------------------------------+ -// | template initialization | -// +-----------------------------------------------------------------------+ - -$title = l10n('nbm_Send mail to users'); - -// +-----------------------------------------------------------------------+ -// | infos & errors display | -// +-----------------------------------------------------------------------+ - -/*echo '
';
-
-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 '
'; -*/ -?> \ No newline at end of file -- cgit v1.2.3