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


PHP Notifications::task_notifications方法代码示例

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


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

示例1: send_later

 /**
  * Sends notifications *later*, so stores them in the database
  * @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_later($to, $to_type, $type, $data = array())
 {
     global $db, $user;
     // we only "send later" to registered users
     if ($to_type == ADDRESS_EMAIL) {
         return false;
     }
     if ($to_type == ADDRESS_TASK) {
         $data['task_id'] = $to;
         list(, , $to) = Notifications::task_notifications($to, $type, ADDRESS_USER);
     }
     // otherwise we already have a list of users
     $to = (array) $to;
     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);
     }
     list($data['subject'], $data['body']) = Notifications::generate_message($type, $data);
     $time = time();
     // on a sidenote: never do strange things like $date = time() or $time = date('U');
     // just in case
     $res = $db->x->autoExecute('{notification_messages}', array('message_data' => serialize($data), 'time_created' => $time));
     if (PEAR::isError($res)) {
         return false;
     }
     $message_id = $db->lastInsertID();
     if (count($to)) {
         $stmt = $db->x->autoPrepare('{notification_recipients}', array('message_id', 'user_id'));
         foreach ($to as $user_id) {
             if ($user_id == $user->id && !$user->infos['notify_own']) {
                 continue;
             }
             $stmt->execute(array($message_id, $user_id));
         }
         $stmt->free();
     }
     return true;
 }
开发者ID:negram,项目名称:flyspray,代码行数:49,代码来源:class.notify.php


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