Changeset 2139


Ignore:
Timestamp:
Oct 16, 2007, 10:45:00 PM (17 years ago)
Author:
rub
Message:

Resolved issue 0000763: mail triggers:
Add triggers on mail part:

o NBM
o Group mail
o process send mail

+ check groud_id null on group mail

Location:
branches/branch-1_7
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_7/admin/cat_modify.php

    r1916 r2139  
    530530
    531531// info by email to an access granted group of category informations
    532 if (isset($_POST['submitEmail']))
     532if (isset($_POST['submitEmail']) and !empty($_POST['group']))
    533533{
    534534  set_make_full_url();
     
    641641  {
    642642    $template->assign_block_vars(
    643       'group_option',
     643      'group_mail.group_option',
    644644      array(
    645645        'VALUE' => $row['id'],
  • branches/branch-1_7/admin/notification_by_mail.php

    r2088 r2139  
    211211
    212212/*
     213 * Apply global functions to mail content
     214 * return customize mail content rendered
     215 */
     216function render_global_customize_mail_content($customize_mail_content)
     217{
     218  global $conf;
     219
     220  if ($conf['nbm_send_html_mail'] and !(strpos($customize_mail_content, '<') === 0))
     221  {
     222    // On HTML mail, detects if the content are HTML format.
     223    // If it's plain text format, convert content to readable HTML
     224    return nl2br(htmlspecialchars($customize_mail_content));
     225  }
     226  else
     227  {
     228    return $customize_mail_content;
     229  }
     230}
     231
     232/*
    213233 * Send mail for notification to all users
    214234 * Return list of "selected" users for 'list_to_send'
     
    244264        }
    245265
    246         if ($conf['nbm_send_html_mail'] and !(strpos($customize_mail_content, '<') === 0))
    247         {
    248           // On HTML mail, detects if the content are HTML format.
    249           // If it's plain text format, convert content to readable HTML
    250           $customize_mail_content = nl2br(htmlentities($customize_mail_content));
    251         }
     266        $customize_mail_content =
     267          trigger_event('nbm_render_global_customize_mail_content', $customize_mail_content);
     268
    252269
    253270        // Prepare message after change language
     
    344361              }
    345362
    346               if (!empty($customize_mail_content))
     363              $nbm_user_customize_mail_content =
     364                trigger_event('nbm_render_user_customize_mail_content',
     365                  $customize_mail_content, $nbm_user);
     366              if (!empty($nbm_user_customize_mail_content))
    347367              {
    348368                $env_nbm['mail_template']->assign_block_vars
    349369                (
    350                   'custom', array('CUSTOMIZE_MAIL_CONTENT' => $customize_mail_content)
     370                  'custom',
     371                  array('CUSTOMIZE_MAIL_CONTENT' =>
     372                    $nbm_user_customize_mail_content)
    351373                );
    352374              }
     
    481503// +-----------------------------------------------------------------------+
    482504check_status(get_tab_status($page['mode']));
     505
     506
     507// +-----------------------------------------------------------------------+
     508// | Add event handler                                                     |
     509// +-----------------------------------------------------------------------+
     510add_event_handler('nbm_render_global_customize_mail_content', 'render_global_customize_mail_content');
     511trigger_action('nbm_event_handler_added');
     512
    483513
    484514// +-----------------------------------------------------------------------+
  • branches/branch-1_7/include/functions_mail.inc.php

    r2133 r2139  
    242242      $lang = $switch_lang[$language]['lang'];
    243243    }
     244
     245    $user['language'] = $language;
    244246  }
    245247}
     
    272274      $lang = $switch_lang[$language]['lang'];
    273275    }
     276    $user['language'] = $language;
    274277  }
    275278}
     
    293296function pwg_mail_notification_admins($keyargs_subject, $keyargs_content)
    294297{
     298  // Check arguments
     299  if
     300    (
     301      empty($keyargs_subject) or
     302      empty($keyargs_content)
     303    )
     304  {
     305    return false;
     306  }
     307
    295308  global $conf, $user;
    296309  $return = true;
     
    377390  $assign_vars = array(), $language_selected = '')
    378391{
     392  // Check arguments
     393  if
     394    (
     395      empty($group_id) or
     396      empty($email_format) or
     397      empty($keyargs_subject) or
     398      empty($tpl_shortname)
     399    )
     400  {
     401    return false;
     402  }
     403
    379404  global $conf;
    380405  $return = true;
     
    449474          $mail_template->set_filename($tpl_shortname,
    450475            (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
    451           $mail_template->assign_vars($assign_vars);
     476
     477          $mail_template->assign_vars(
     478            trigger_event('mail_group_assign_vars', $assign_vars));
    452479
    453480          $return = pwg_mail
     
    479506 *
    480507 * @param:
    481  *   - to: Receiver, or receivers of the mail.
     508 *   - to: receiver(s) of the mail.
    482509 *   - args: function params of mail function:
    483510 *       o from: sender [default value webmaster email]
     
    696723  }
    697724
    698   /*Testing block
    699   {
    700     global $user;
     725  return
     726    trigger_event('send_mail',
     727      false, /* Result */
     728      trigger_event('send_mail_to', $to),
     729      trigger_event('send_mail_subject', $cvt_subject),
     730      trigger_event('send_mail_content', $content),
     731      trigger_event('send_mail_headers', $headers),
     732      $args
     733    );
     734}
     735
     736/*
     737 * pwg sendmail
     738 *
     739 * @param:
     740 *   - result of other sendmail
     741 *   - to: Receiver or receiver(s) of the mail.
     742 *   - subject  [default value 'PhpWebGallery']
     743 *   - content: content of mail
     744 *   - headers: headers of mail
     745 *
     746 * @return boolean (Ok or not)
     747 */
     748function pwg_send_mail($result, $to, $subject, $content, $headers)
     749{
     750 if (!$result)
     751 {
     752    global $conf_mail;
     753
     754    if ($conf_mail['use_smtp'])
     755    {
     756      include_once( PHPWG_ROOT_PATH.'include/class_smtp_mail.inc.php' );
     757      $smtp_mail = new smtp_mail(
     758        $conf_mail['smtp_host'], $conf_mail['smtp_user'], $conf_mail['smtp_password'],
     759        $conf_mail['email_webmaster']);
     760      return $smtp_mail->mail($to, $subject, $content, $headers);
     761    }
     762    else
     763    {
     764      if ($conf_mail['mail_options'])
     765      {
     766        $options = '-f '.$conf_mail['email_webmaster'];
     767        return mail($to, $subject, $content, $headers, $options);
     768      }
     769      else
     770      {
     771        return mail($to, $subject, $content, $headers);
     772      }
     773    }
     774 }
     775}
     776
     777/*Testing block
     778function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
     779{
     780    global $user, $lang_info;
    701781    @mkdir(PHPWG_ROOT_PATH.'testmail');
    702     $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'];
     782    $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
    703783    if ($args['content_format'] == 'text/plain')
    704784    {
     
    710790    }
    711791    $file = fopen($filename, 'w+');
     792    fwrite($file, $to);
     793    fwrite($file, $subject);
     794    fwrite($file, $headers);
    712795    fwrite($file, $content);
    713796    fclose($file);
    714797    return true;
    715   }*/
    716 
    717   if ($conf_mail['use_smtp'])
    718   {
    719     include_once( PHPWG_ROOT_PATH.'include/class_smtp_mail.inc.php' );
    720     $smtp_mail = new smtp_mail(
    721       $conf_mail['smtp_host'], $conf_mail['smtp_user'], $conf_mail['smtp_password'],
    722       $conf_mail['email_webmaster']);
    723     return $smtp_mail->mail($to, $cvt_subject, $content, $headers);
    724   }
    725   else
    726   {
    727     if ($conf_mail['mail_options'])
    728     {
    729       $options = '-f '.$conf_mail['email_webmaster'];
    730       return mail($to, $cvt_subject, $content, $headers, $options);
    731     }
    732     else
    733     {
    734       return mail($to, $cvt_subject, $content, $headers);
    735     }
    736   }
    737 }
     798}
     799add_event_handler('send_mail', 'pwg_send_mail_test', 0, 6);*/
     800
     801
     802add_event_handler('send_mail', 'pwg_send_mail', EVENT_HANDLER_PRIORITY_NEUTRAL, 5);
     803trigger_action('functions_mail_included');
    738804
    739805?>
  • branches/branch-1_7/template/yoga/admin/cat_modify.tpl

    r1916 r2139  
    213213</fieldset>
    214214
     215<!-- BEGIN group_mail -->
    215216<fieldset id="emailCatInfo">
    216217  <legend>{lang:Send an information email to group members}</legend>
     
    222223        <select name="group">
    223224          <!-- BEGIN group_option -->
    224           <option value="{group_option.VALUE}">{group_option.OPTION}</option>
     225          <option value="{group_mail.group_option.VALUE}">{group_mail.group_option.OPTION}</option>
    225226          <!-- END group_option -->
    226227        </select>
     
    242243
    243244</fieldset>
     245<!-- END group_mail -->
    244246
    245247</form>
Note: See TracChangeset for help on using the changeset viewer.