Changeset 1178


Ignore:
Timestamp:
Apr 15, 2006, 1:25:48 AM (18 years ago)
Author:
rub
Message:

Issue ID 330:

o Remove "background treatment"
o Add button "Continue treatment"

Report of svn:1177 (BSF Branch)

Warning: functions.inc.php is not the same of BSF/trunk branch (die_on_sql_error)

Location:
branches/branch-1_6
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_6/admin/include/functions_notification_by_mail.inc.php

    r1157 r1178  
    339339 * check_key list where action will be done
    340340 *
    341  * @return check_key lisr treated
     341 * @return check_key list treated
    342342 */
    343343function do_subscribe_unsubcribe_notification_by_mail($is_admin_request, $is_subscribe = false, $check_key_list = array())
     
    367367
    368368    // Prepare message after change language
    369     $msg_break_timeout = l10n('nbm_nbm_break_timeout_send_mail');
     369    $msg_break_timeout = l10n('nbm_break_timeout_send_mail');
    370370
    371371    // Begin nbm users environment
     
    472472 * check_key list where action will be done
    473473 *
    474  * @return check_key lisr treated
     474 * @return check_key list treated
    475475 */
    476476function unsubcribe_notification_by_mail($is_admin_request, $check_key_list = array())
     
    484484 * check_key list where action will be done
    485485 *
    486  * @return check_key lisr treated
     486 * @return check_key list treated
    487487 */
    488488function subcribe_notification_by_mail($is_admin_request, $check_key_list = array())
  • branches/branch-1_6/admin/notification_by_mail.php

    r1161 r1178  
    5151// +-----------------------------------------------------------------------+
    5252$base_url = get_root_url().'admin.php';
     53$must_repost = false;
    5354
    5455// +-----------------------------------------------------------------------+
     
    5758
    5859/*
    59  * Do background treatmetn in order to finish to send mails
     60 * Do timeout treatment in order to finish to send mails
    6061 *
    6162 * @param $post_keyname: key of check_key post array
    62  * @param check_key_treated:array of check_key treated
     63 * @param check_key_treated: array of check_key treated
    6364 * @return none
    6465 */
    65 function do_background_treatment($post_keyname, $check_key_treated = array())
    66 {
    67   global $env_nbm, $base_url;
     66function do_timeout_treatment($post_keyname, $check_key_treated = array())
     67{
     68  global $env_nbm, $base_url, $page, $must_repost;
    6869
    6970  if ($env_nbm['is_sendmail_timeout'])
     
    7980      else
    8081      {
    81         $time_refresh = 10;
     82        $time_refresh = 0;
    8283      }
    8384      $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated);
    84       re_post_http($base_url.get_query_string_diff(array()), sprintf(l10n('nbm_background_treatment_redirect'), $time_refresh) , $time_refresh);
     85     
     86      $must_repost = true;
     87      array_push($page['errors'], sprintf(l10n('nbm_background_treatment_redirect'), $time_refresh));
    8588    }
    8689  }
     
    117120{
    118121  global $conf, $page, $env_nbm;
    119 
    120   // Treatment of simulate post
    121   if (isset($_POST['insert_new_user_nbm']))
    122   {
    123      $check_key_treated = do_subscribe_unsubcribe_notification_by_mail
    124     (
    125       true,
    126       $conf['nbm_default_value_user_enabled'],
    127       $_POST['insert_new_user_nbm']
    128     );
    129     do_background_treatment('insert_new_user_nbm', $check_key_treated);
    130   }
    131122
    132123  // Set null mail_address empty
     
    197188    if ($env_nbm['is_sendmail_timeout'])
    198189    {
    199       if ($conf['nbm_default_value_user_enabled'])
    200       {
    201         // Simulate Post
    202         $_POST['insert_new_user_nbm'] = $check_key_list;
    203         do_background_treatment('insert_new_user_nbm', $check_key_treated);
     190      $quoted_check_key_list = quote_check_key_list(array_diff($check_key_list, $check_key_treated));
     191      if (count($quoted_check_key_list) != 0 )
     192      {
     193        $query = 'delete from '.USER_MAIL_NOTIFICATION_TABLE.' where check_key in ('.implode(",", $quoted_check_key_list).');';
     194        $result = pwg_query($query);
     195
     196        redirect($base_url.get_query_string_diff(array()));
    204197      }
    205198    }
     
    231224    $data_users = get_user_notifications('send', $check_key_list);
    232225
     226    // List all if it's define on options or on timeout
     227    $is_list_all_without_test = ($env_nbm['is_sendmail_timeout'] or $conf['nbm_list_all_enabled_users_to_send']);
     228
    233229    // Check if exist news to list user or send mails
    234     if (($conf['nbm_list_all_enabled_users_to_send'] == false) or ($is_action_send))
     230    if ((!$is_list_all_without_test == false) or ($is_action_send))
    235231    {
    236232      if (count($data_users) > 0)
     
    241237        if ($is_action_send)
    242238        {
    243           $msg_break_timeout = l10n('nbm_nbm_break_timeout_send_mail');
     239          $msg_break_timeout = l10n('nbm_break_timeout_send_mail');
    244240        }
    245241        else
     
    461457    {
    462458      $check_key_treated = unsubcribe_notification_by_mail(true, $_POST['cat_true']);
    463       do_background_treatment('cat_true', $check_key_treated);
     459      do_timeout_treatment('cat_true', $check_key_treated);
    464460    }
    465461    else
     
    467463    {
    468464      $check_key_treated = subcribe_notification_by_mail(true, $_POST['cat_false']);
    469       do_background_treatment('cat_false', $check_key_treated);
     465      do_timeout_treatment('cat_false', $check_key_treated);
    470466    }
    471467    break;
     
    477473    {
    478474      $check_key_treated = do_action_send_mail_notification('send', $_POST['send_selection'], $_POST['send_customize_mail_content']);
    479       do_background_treatment('send_selection', $check_key_treated);
     475      do_timeout_treatment('send_selection', $check_key_treated);
    480476    }
    481477  }
     
    518514}
    519515
     516if ($must_repost)
     517{
     518  // Get name of submit button
     519  $repost_submit_name = '';
     520  if (isset($_POST['falsify']))
     521  {
     522    $repost_submit_name = 'falsify';
     523  }
     524  elseif (isset($_POST['trueify']))
     525  {
     526    $repost_submit_name = 'trueify';
     527  }
     528  elseif (isset($_POST['send_submit']))
     529  {
     530    $repost_submit_name = 'send_submit';
     531  }
     532
     533  $template->assign_block_vars
     534  (
     535    'repost',
     536      array
     537      (
     538        'REPOST_SUBMIT_NAME' => $repost_submit_name
     539      )
     540    );
     541}
     542
    520543switch ($page['mode'])
    521544{
     
    590613              'CHECKED' =>  ( // not check if not selected,  on init select<all
    591614                              isset($_POST['send_selection']) and // not init
    592                               !in_array($nbm_user['check_key'],  $_POST['send_selection']) // not selected
     615                              !in_array($nbm_user['check_key'], $_POST['send_selection']) // not selected
    593616                            )   ? '' : 'checked="checked"',
    594617              'USERNAME'=> $nbm_user['username'],
  • branches/branch-1_6/include/functions.inc.php

    r1174 r1178  
    882882}
    883883
    884 /**
    885  * Adaptation of _HTTPRequestToString (http://fr.php.net/urlencode)
    886  *
    887  *
    888  * @return array request to string
    889  */
    890 function http_request_to_string($arr_request, $var_name, $separator='&') {
    891    $ret = "";
    892    if (is_array($arr_request)) {
    893        foreach ($arr_request as $key => $value) {
    894            if (is_array($value)) {
    895                if ($var_name) {
    896                    $ret .= http_request_to_string($value, "{$var_name}[{$key}]", $separator);
    897                } else {
    898                    $ret .= http_request_to_string($value, "{$key}", $separator);
    899                }
    900            } else {
    901                if ($var_name) {
    902                    $ret .= "{$var_name}[{$key}]=".urlencode($value)."&";
    903                } else {
    904                    $ret .= "{$key}=".urlencode($value)."&";
    905                }
    906            }
    907        }
    908    }
    909    if (!$var_name) {
    910        $ret = substr($ret,0,-1);
    911    }
    912    return $ret;
    913 }
    914 
    915 /**
    916  * Post request HTTP on backgroung and redirec to selected url
    917  *
    918  * Note : once this function called, the execution doesn't go further
    919  * (presence of an exit() instruction.
    920  *
    921  * @param string $url_redirect
    922  * @param string $redirect_message
    923  * @param integer $redirect_refreh_time
    924  * @return void
    925  */
    926 function re_post_http($url_redirect, $redirect_message, $redirect_refreh_time)
    927 {
    928   global $conf;
    929 
    930   $data_post = http_request_to_string($_POST, '');
    931 
    932   $message_post  = "POST ".$_SERVER['PHP_SELF'].html_entity_decode(get_query_string_diff(array()))." HTTP/1.1\r\n";
    933 
    934 /*  foreach (array_flip(array_diff(array_flip(apache_request_headers()), array('Content-Type', 'Content-Length'))) as $header_name => $header_value)
    935   {
    936     $message_post .= $header_name.": ".$header_value."\r\n";
    937   }*/
    938   $message_post .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
    939   $message_post .= "Cookie: ".$conf['session_name']."=".$_COOKIE[$conf['session_name']]."\r\n";
    940 
    941 
    942   $message_post .= "Content-Type: application/x-www-form-urlencoded\r\n";
    943   $message_post .= "Content-Length: ".strlen($data_post)."\r\n";
    944   $message_post .= "\r\n";
    945   $message_post .= $data_post."\r\n";
    946 
    947   $fd = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT']);
    948   fputs($fd, $message_post);
    949   fclose($fd);
    950 
    951   redirect($url_redirect, $redirect_message, $redirect_refreh_time);
    952   //exit(); done by redirect
    953 }
    954 
    955884?>
  • branches/branch-1_6/language/en_UK.iso-8859-1/admin.lang.php

    r1173 r1178  
    254254$lang['metadata_iptc'] = 'IPTC';
    255255$lang['name'] = 'name';
    256 $lang['nbm_background_treatment_redirect'] = 'Execution time is out, treatment continue on background.'."\n".'Re-display on %d secondes...';
     256$lang['nbm_background_treatment_redirect'] = 'Execution time is out, treatment must be continue [Estmated time: %d secondes].';
     257$lang['nbm_repost_submit'] = 'Continue processing treatment';
    257258$lang['nbm_break_timeout_list_user'] = 'Prepared time for list of users to send mail is limited. Others users are not listed.';
    258259$lang['nbm_col_check_user_send_mail'] = 'To send ?';
     
    279280$lang['nbm_msg_n_mails_sent'] = '%d mails were sent.';
    280281$lang['nbm_msg_no_mail_to_send'] = '%d mails were not sent.';
    281 $lang['nbm_nbm_break_timeout_send_mail'] = 'Time to send mail is limited. Others mails are skipped or sent on background.';
     282$lang['nbm_break_timeout_send_mail'] = 'Time to send mail is limited. Others mails are skipped.';
    282283$lang['nbm_no_mail_to_send'] = 'No mail to send.';
    283284$lang['nbm_no_user_available_to_send_L1'] = 'No user are available in order to send mail.';
  • branches/branch-1_6/language/fr_FR.iso-8859-1/admin.lang.php

    r1173 r1178  
    257257$lang['metadata_iptc'] = 'IPTC';
    258258$lang['name'] = 'nom';
    259 $lang['nbm_background_treatment_redirect'] = 'Le temps d\'éxécution étant dépassé, le traitement continue en arrière plan.'."\n".'Ré-affichage dans %d secondes...';
     259$lang['nbm_background_treatment_redirect'] = 'Le temps d\'éxécution étant dépassé, le traitement doit continuer [Temps estimé: %d secondes].';
     260$lang['nbm_repost_submit'] = 'Continuer le traitement en cours...';
    260261$lang['nbm_break_timeout_list_user'] = 'Le temps de préparation de la liste des utilisateurs pour l\'envoi est limité. Les autres utilisateurs ne sont pas listés.';
    261262$lang['nbm_col_check_user_send_mail'] = 'A envoyer ?';
     
    282283$lang['nbm_msg_n_mails_sent'] = '%s mails ont été envoyés.';
    283284$lang['nbm_msg_no_mail_to_send'] = '%s mails n\'ont pas été envoyés.';
    284 $lang['nbm_nbm_break_timeout_send_mail'] = 'Le temps d\'envoi des mails est limité. Les autres envois de mail ont été ignorés ou vont être envoyés en arrière plan.';
     285$lang['nbm_break_timeout_send_mail'] = 'Le temps d\'envoi des mails est limité. Les autres envois de mail ont été ignorés.';
    285286$lang['nbm_no_mail_to_send'] = 'Pas de mail à envoyer.';
    286287$lang['nbm_no_user_available_to_send_L1'] = 'Il n\'y a pas d\'utilisateur à notifier par mail.';
  • branches/branch-1_6/template/yoga/admin/notification_by_mail.tpl

    r1116 r1178  
    1717
    1818<form method="post" name="notification_by_mail" id="notification_by_mail" action="{F_ACTION}">
     19  <!-- BEGIN repost -->
     20  <fieldset>
     21    <div class="errors">
     22      <p>
     23        <input type="submit" value="{lang:nbm_repost_submit}" name="{REPOST_SUBMIT_NAME}" {TAG_INPUT_ENABLED}/>
     24      </p>
     25    </div>
     26  </fieldset>
     27  <!-- END repost -->
    1928
    2029  <!-- BEGIN param -->
     
    6372      {lang:nbm_no_user_available_to_send_L1}<br>
    6473      {lang:nbm_no_user_available_to_send_L2}<br>
     74      <br>
    6575    </center>
    6676    <!-- END send_empty -->
Note: See TracChangeset for help on using the changeset viewer.