aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2006-04-12 22:56:55 +0000
committerrub <rub@piwigo.org>2006-04-12 22:56:55 +0000
commit53e48e76751d5e1cc821ce3a59b8ade4cf5da08d (patch)
tree051db5297bf8d628213ee44eefcb4f36f73077c4 /admin/include
parentbcc40eb10dd50d26a7d66c4ff59cdb474415aeb6 (diff)
Issue ID 330:
o Change NBM configuration in order to avoid lose treatment action when occurred timeout o Add news redirect/repost functions Reports of svn:1156 git-svn-id: http://piwigo.org/svn/branches/branch-1_6@1157 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include')
-rw-r--r--admin/include/functions_notification_by_mail.inc.php41
1 files changed, 34 insertions, 7 deletions
diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php
index d19085685..bfaaf8cb0 100644
--- a/admin/include/functions_notification_by_mail.inc.php
+++ b/admin/include/functions_notification_by_mail.inc.php
@@ -27,7 +27,13 @@
// +-----------------------------------------------------------------------+
/* nbm_global_var */
-$env_nbm = array();
+$env_nbm = array
+ (
+ 'start_time' => get_moment(),
+ 'sendmail_timeout' => (intval(ini_get('max_execution_time')) * $conf['nbm_max_treatment_timeout_percent']),
+ 'is_sendmail_timeout' => false
+ );
+
/*
* Search an available check_key
@@ -57,6 +63,20 @@ where
}
}
+/*
+ * Check sendmail timeout state
+ *
+ * @return true, if it's timeout
+ */
+function check_sendmail_timeout()
+{
+ global $env_nbm;
+
+ $env_nbm['is_sendmail_timeout'] = ((get_moment() - $env_nbm['start_time']) > $env_nbm['sendmail_timeout']);
+
+ return $env_nbm['is_sendmail_timeout'];
+}
+
/*
* Add quote to all elements of check_key_list
@@ -318,12 +338,13 @@ function get_mail_content_subscribe_unsubcribe($nbm_user)
* is_subscribe define if action=subscribe or unsubscribe
* check_key list where action will be done
*
- * @return updated data count
+ * @return check_key lisr treated
*/
function do_subscribe_unsubcribe_notification_by_mail($is_admin_request, $is_subscribe = false, $check_key_list = array())
{
global $conf, $page, $env_nbm, $conf;
+ $check_key_treated = array();
$updated_data_count = 0;
$error_on_updated_data_count = 0;
@@ -344,18 +365,24 @@ function do_subscribe_unsubcribe_notification_by_mail($is_admin_request, $is_sub
$enabled_value = boolean_to_string($is_subscribe);
$data_users = get_user_notifications('subscribe', $check_key_list, !$is_subscribe);
+ // Prepare message after change language
+ $msg_break_timeout = l10n('nbm_nbm_break_timeout_send_mail');
+
// Begin nbm users environment
begin_users_env_nbm(true);
foreach ($data_users as $nbm_user)
{
- if (($env_nbm['error_on_mail_count'] + $env_nbm['sent_mail_count']) >= $conf['nbm_max_mails_send'])
+ if (check_sendmail_timeout())
{
// Stop fill list on 'send', if the quota is override
- array_push($page['errors'], sprintf(l10n('nbm_nbm_break_send_mail'), $conf['nbm_max_mails_send']));
+ array_push($page['errors'], $msg_break_timeout);
break;
}
+ // Fill return list
+ array_push($check_key_treated, $nbm_user['check_key']);
+
$do_update = true;
if ($nbm_user['mail_address'] != '')
{
@@ -436,7 +463,7 @@ function do_subscribe_unsubcribe_notification_by_mail($is_admin_request, $is_sub
array_push($page['errors'], sprintf(l10n('nbm_user_change_enabled_error_on_updated_data_count'), $error_on_updated_data_count));
}
- return $updated_data_count;
+ return $check_key_treated;
}
/*
@@ -444,7 +471,7 @@ function do_subscribe_unsubcribe_notification_by_mail($is_admin_request, $is_sub
*
* check_key list where action will be done
*
- * @return updated data count
+ * @return check_key lisr treated
*/
function unsubcribe_notification_by_mail($is_admin_request, $check_key_list = array())
{
@@ -456,7 +483,7 @@ function unsubcribe_notification_by_mail($is_admin_request, $check_key_list = ar
*
* check_key list where action will be done
*
- * @return updated data count
+ * @return check_key lisr treated
*/
function subcribe_notification_by_mail($is_admin_request, $check_key_list = array())
{