コード例 #1
0
 /**
  * Creates and returns an notification object from a row
  * @param $row array
  * @return Notification object
  */
 function &_returnNotificationFromRow($row)
 {
     $notification = new Notification();
     $notification->setId($row['notification_id']);
     $notification->setUserId($row['user_id']);
     $notification->setDateCreated($row['date_created']);
     $notification->setDateRead($row['date_read']);
     $notification->setContents($row['contents']);
     $notification->setParam($row['param']);
     $notification->setLocation($row['location']);
     $notification->setIsLocalized($row['is_localized']);
     $notification->setContext($row['context']);
     $notification->setAssocType($row['assoc_type']);
     HookRegistry::call('NotificationDAO::_returnNotificationFromRow', array(&$notification, &$row));
     return $notification;
 }
コード例 #2
0
 /**
  * Create a new notification with the specified arguments and insert into DB
  * This is a static method
  * @param $userId int
  * @param $contents string
  * @param $param string
  * @param $location string
  * @param $isLocalized bool
  * @param $assocType int
  * @param $assocId int
  * @return Notification object
  */
 function createNotification($userId, $contents, $param, $location, $isLocalized, $assocType)
 {
     $notification = new Notification();
     $context =& Request::getContext();
     $contextId = $context->getId();
     $notification->setUserId($userId);
     $notification->setContents($contents);
     $notification->setParam($param);
     $notification->setLocation($location);
     $notification->setIsLocalized($isLocalized);
     $notification->setAssocType($assocType);
     $notification->setContext($contextId);
     $notificationDao =& DAORegistry::getDAO('NotificationDAO');
     $notificationDao->insertNotification($notification);
     return $notification;
 }
コード例 #3
0
 /**
  * Create a new notification with the specified arguments and insert into DB
  * This is a static method
  * @param $title string
  * @param $contents string
  * @param $param string
  * @param $isLocalized boolean
  * @return Notification object
  */
 function createTrivialNotification($title, $contents, $assocType = NOTIFICATION_TYPE_SUCCESS, $param = null, $isLocalized = 1)
 {
     $notification = new Notification();
     $context =& Request::getContext();
     $contextId = $context ? $context->getId() : 0;
     $user =& Request::getUser();
     $notification->setUserId($user->getId());
     $notification->setTitle($title);
     $notification->setContents($contents);
     $notification->setParam($param);
     $notification->setIsLocalized($isLocalized);
     $notification->setContext($contextId);
     $notification->setAssocType($assocType);
     $notification->setLevel(NOTIFICATION_LEVEL_TRIVIAL);
     $notificationDao =& DAORegistry::getDAO('NotificationDAO');
     $notificationDao->insertNotification($notification);
     return $notification;
 }
コード例 #4
0
 /**
  * Slap a notice onto a user.
  * 
  * @param string $message The message.
  * @param string $url URL fragment (slug/args/) to link to.
  * @return bool
  **/
 public function notify($message, $url)
 {
     $notice = new Notification($this->db);
     $notice->setUserId($this->getUserId());
     $notice->setNotificationDatetime($notice->sysdate());
     $notice->setNotificationText($message);
     $notice->setNotificationUrl($url);
     return $notice->save();
 }