/**
  * Removes a notifcation and triggers a follow up notification to remove
  * the notification from the browser view of the original recipient
  * 
  * @global ilDB $ilDB
  * @param integer $notification_osd_id 
  */
 public static function removeNotification($notification_osd_id)
 {
     global $ilDB;
     $query = 'SELECT usr_id FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
     $types = array('integer');
     $values = array($notification_osd_id);
     $rset = $ilDB->queryF($query, $types, $values);
     if ($row = $ilDB->fetchAssoc($rset)) {
         $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
         $types = array('integer');
         $values = array($notification_osd_id);
         $ilDB->manipulateF($query, $types, $values);
         // sends a "delete the given notification" notification using the
         // osd_maint channel
         $deletedNotification = new ilNotificationConfig('osd_maint');
         $deletedNotification->setValidForSeconds(120);
         $deletedNotification->setTitleVar('deleted');
         $deletedNotification->setShortDescriptionVar($notification_osd_id);
         $deletedNotification->setLongDescriptionVar('dummy');
         require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
         ilNotificationSystem::sendNotificationToUsers($deletedNotification, array($row['usr_id']));
     }
 }
Beispiel #2
0
 /**
  * @param        $gui
  * @param mixed $sender (can be an instance of ilChatroomUser or an user id of an ilObjUser instance
  * @param int $recipient_id
  * @param int    $subScope
  * @param string $invitationLink
  * @throws InvalidArgumentException
  */
 public function sendInvitationNotification($gui, $sender, $recipient_id, $subScope = 0, $invitationLink = '')
 {
     /**
      * @var $lng ilLanguage
      */
     global $lng;
     if ($gui && !$invitationLink) {
         $invitationLink = $this->getChatURL($gui, $subScope);
     }
     if ($recipient_id > 0 && !in_array(ANONYMOUS_USER_ID, array($recipient_id))) {
         if (is_numeric($sender) && $sender > 0) {
             $sender_id = $sender;
             /**
              * @var $usr ilObjUser
              */
             $usr = ilObjectFactory::getInstanceByObjId($sender);
             $public_name = $usr->getPublicName();
         } else {
             if ($sender instanceof ilChatroomUser) {
                 if ($sender->getUserId() > 0) {
                     $sender_id = $sender->getUserId();
                 } else {
                     $sender_id = ANONYMOUS_USER_ID;
                 }
                 $public_name = $sender->getUsername();
             } else {
                 throw new InvalidArgumentException('$sender must be an instance of ilChatroomUser or an id of an ilObjUser instance');
             }
         }
         $lng->loadLanguageModule('mail');
         $recipient = ilObjectFactory::getInstanceByObjId($recipient_id);
         $bodyParams = array('link' => $invitationLink, 'inviter_name' => $public_name, 'room_name' => $this->getTitle(), 'salutation' => $lng->txt('mail_salutation_' . $recipient->getGender()) . ' ' . $recipient->getFullname());
         if ($subScope) {
             $bodyParams['room_name'] .= ' - ' . self::lookupPrivateRoomTitle($subScope);
         }
         require_once 'Services/Notifications/classes/class.ilNotificationConfig.php';
         $notification = new ilNotificationConfig('chat_invitation');
         $notification->setTitleVar('chat_invitation', $bodyParams, 'chatroom');
         $notification->setShortDescriptionVar('chat_invitation_short', $bodyParams, 'chatroom');
         $notification->setLongDescriptionVar('chat_invitation_long', $bodyParams, 'chatroom');
         $notification->setAutoDisable(false);
         $notification->setLink($invitationLink);
         $notification->setIconPath('templates/default/images/icon_chtr.svg');
         $notification->setValidForSeconds(0);
         $notification->setHandlerParam('mail.sender', $sender_id);
         $notification->notifyByUsers(array($recipient_id));
     }
 }
 /**
  * Sends the notification to all listener which are subscribed to the given
  * ref_id
  * 
  * @param ilNotificationConfig $notification
  * @param type $ref_id
  * @param type $processAsync 
  */
 private function toListeners(ilNotificationConfig $notification, $ref_id, $processAsync = false)
 {
     require_once 'Services/Notifications/classes/class.ilNotificationUserIterator.php';
     require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
     if ($processAsync == false) {
         $users = ilNotificationDatabaseHandler::getUsersByListener($notification->getType(), $ref_id);
         self::toUsers($notification, $users, false);
         if ($notification->hasDisableAfterDeliverySet()) {
             ilNotificationDatabaseHandler::disableListeners($notification->getType(), $ref_id);
         }
     } else {
         ilNotificationDatabaseHandler::enqueueByListener($notification, $ref_id);
     }
 }