当前位置: 首页>>代码示例>>PHP>>正文


PHP Notifications::user_to_address方法代码示例

本文整理汇总了PHP中Notifications::user_to_address方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::user_to_address方法的具体用法?PHP Notifications::user_to_address怎么用?PHP Notifications::user_to_address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notifications的用法示例。


在下文中一共展示了Notifications::user_to_address方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send_now

 /**
  * Sends notifications *now*
  * @param mixed $to string or array...the type of address (email, task ID, user ID) is specified below
  * @param integer $to_type type of $to address
  * @param integer $type type of notification
  * @param array $data additional info needed for notification
  * @access public
  * @return bool
  */
 function send_now($to, $to_type, $type, $data = array())
 {
     global $db, $fs, $proj;
     $emails = array();
     $jids = array();
     $result = true;
     if (defined('FS_NO_MAIL')) {
         return true;
     }
     switch ($to_type) {
         case ADDRESS_DONE:
             // from send_stored()
             list($emails, $jids) = $to;
             $data = unserialize($data['message_data']);
             $subject = $data['subject'];
             $body = $data['body'];
             break;
         case ADDRESS_EMAIL:
             // this happens on email confirmation, when no user exists
             $emails = is_array($to) ? $to : array($to);
             break;
         case ADDRESS_USER:
             // list of user IDs
             list($emails, $jids) = Notifications::user_to_address($to, $type);
             break;
         case ADDRESS_TASK:
             // now we need everyone on the notification list and the assignees
             list($emails, $jids) = Notifications::task_notifications($to, $type, ADDRESS_EMAIL);
             $data['task_id'] = $to;
             break;
     }
     if (isset($data['task_id'])) {
         $data['task'] = Flyspray::getTaskDetails($data['task_id']);
         // we have project specific options
         $pid = $db->x->GetOne('SELECT project_id FROM {tasks} WHERE task_id = ?', null, $data['task_id']);
         $data['project'] = new Project($pid);
     }
     if ($to_type != ADDRESS_DONE) {
         list($subject, $body) = Notifications::generate_message($type, $data);
     }
     if (isset($data['task_id'])) {
         // Now, we add the project contact addresses,
         // but only if the task is public
         $data['task'] = Flyspray::getTaskDetails($data['task_id']);
         if ($data['task']['mark_private'] != '1' && in_array($type, explode(' ', $data['project']->prefs['notify_types']))) {
             $proj_emails = preg_split('/[\\s,;]+/', $proj->prefs['notify_email'], -1, PREG_SPLIT_NO_EMPTY);
             $proj_jids = preg_split('/[\\s,;]+/', $proj->prefs['notify_jabber'], -1, PREG_SPLIT_NO_EMPTY);
             $emails = array_merge($proj_emails, $emails);
             if ($fs->prefs['global_email']) {
                 $emails[] = $fs->prefs['global_email'];
             }
             if ($fs->prefs['global_jabber']) {
                 $jids[] = $fs->prefs['global_jabber'];
             }
             $jids = array_merge($proj_jids, $emails);
         }
     }
     // Now we start sending
     if (count($emails)) {
         Swift_ClassLoader::load('Swift_Connection_Multi');
         Swift_ClassLoader::load('Swift_Connection_SMTP');
         $pool = new Swift_Connection_Multi();
         // first choose method
         if ($fs->prefs['smtp_server']) {
             $split = explode(':', $fs->prefs['smtp_server']);
             $port = null;
             if (count($split) == 2) {
                 $fs->prefs['smtp_server'] = $split[0];
                 $port = $split[1];
             }
             // connection... SSL, TLS or none
             if ($fs->prefs['email_ssl']) {
                 $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port ? $port : SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_SSL);
             } else {
                 if ($fs->prefs['email_tls']) {
                     $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port ? $port : SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
                 } else {
                     $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port);
                 }
             }
             if ($fs->prefs['smtp_user']) {
                 $smtp->setUsername($fs->prefs['smtp_user']);
                 $smtp->setPassword($fs->prefs['smtp_pass']);
             }
             if (defined('FS_SMTP_TIMEOUT')) {
                 $smtp->setTimeout(FS_SMTP_TIMEOUT);
             }
             $pool->addConnection($smtp);
         } else {
             Swift_ClassLoader::load('Swift_Connection_NativeMail');
             // a connection to localhost smtp server as fallback, discarded if there is no such thing available.
//.........这里部分代码省略.........
开发者ID:negram,项目名称:flyspray,代码行数:101,代码来源:class.notify.php


注:本文中的Notifications::user_to_address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。