public function persistNotificationToAlerts(AJXP_Notification &$notification)
 {
     if ($this->eventStore) {
         AJXP_Controller::applyHook("msg.instant", array("<reload_user_feed/>", $notification->getNode()->getRepositoryId(), $notification->getTarget()));
         $this->eventStore->persistAlert($notification);
     }
 }
Exemplo n.º 2
0
 public function processNotification(AJXP_Notification &$notification)
 {
     $mailer = AJXP_PluginsService::getInstance()->getActivePluginsForType("mailer", true);
     if ($mailer !== false) {
         try {
             $mailer->sendMail(array($notification->getTarget()), $notification->getDescriptionShort(), $notification->getDescriptionLong(), $notification->getAuthor(), $notification->getMainLink());
         } catch (Exception $e) {
             $this->logError("Exception", $e->getMessage(), $e->getTrace());
         }
     }
 }
Exemplo n.º 3
0
 public function processNotification(AJXP_Notification &$notification)
 {
     $mailers = AJXP_PluginsService::getInstance()->getPluginsByType("mailer");
     if (count($mailers)) {
         $mailer = array_pop($mailers);
         try {
             $mailer->sendMail(array($notification->getTarget()), $notification->getDescriptionShort(), $notification->getDescriptionLong(), $notification->getAuthor(), $notification->getMainLink());
         } catch (Exception $e) {
             $this->logError("Exception", $e->getMessage(), $e->getTrace());
         }
     }
 }
Exemplo n.º 4
0
 /**
  * @abstract
  * @param AJXP_Notification $notif
  * @return mixed
  */
 public function persistAlert(AJXP_Notification $notif)
 {
     if (!$notif->getNode()) {
         return;
     }
     $repositoryId = $notif->getNode()->getRepositoryId();
     $userId = $notif->getTarget();
     if ($this->sqlDriver["password"] == "XXXX") {
         return;
     }
     require_once AJXP_BIN_FOLDER . "/dibi.compact.php";
     dibi::connect($this->sqlDriver);
     try {
         dibi::query("INSERT INTO [ajxp_feed] ([edate],[etype],[htype],[user_id],[repository_id],[content], [index_path]) VALUES (%i,%s,%s,%s,%s,%bin,%s)", time(), "alert", "notification", $userId, $repositoryId, serialize($notif), $notif->getNode() != null ? $notif->getNode()->getUrl() : '');
     } catch (DibiException $e) {
         $this->logError("DibiException", "trying to persist alert", $e->getMessage());
     }
 }
Exemplo n.º 5
0
 public function processNotification(AJXP_Notification &$notification)
 {
     // Inserting the node information.
     try {
         $notification->getNode()->loadNodeInfo();
     } catch (Exception $e) {
         // Do nothing
     }
     $userExist = AuthService::userExists($notification->getTarget());
     if ($userExist === true) {
         $userObject = ConfService::getConfStorageImpl()->createUserObject($notification->getTarget());
     } else {
         $messages = ConfService::getMessages();
         throw new AJXP_Exception($messages['core.mailer.2']);
     }
     if ($userObject->mergedRole->filterParameterValue("core.mailer", "NOTIFICATIONS_EMAIL_GET", AJXP_REPO_SCOPE_ALL, "true") !== "true") {
         // User does not want to receive any emails.
         return;
     }
     $notification_email = $userObject->mergedRole->filterParameterValue("core.mailer", "NOTIFICATIONS_EMAIL", AJXP_REPO_SCOPE_ALL, "");
     $arrayRecipients = array();
     $mainRecipient = $userObject->mergedRole->filterParameterValue("core.conf", "email", AJXP_REPO_SCOPE_ALL, "");
     $useHtml = $userObject->mergedRole->filterParameterValue("core.mailer", "NOTIFICATIONS_EMAIL_SEND_HTML", AJXP_REPO_SCOPE_ALL, "true") === "true" ? 1 : 0;
     if (!empty($mainRecipient)) {
         $arrayRecipients[] = $mainRecipient;
     }
     $additionalRecipients = array_map("trim", explode(',', $notification_email));
     foreach ($additionalRecipients as $addR) {
         if (!empty($addR)) {
             $arrayRecipients[] = $addR;
         }
     }
     if ($this->pluginConf["MAILER_ACTIVATE_QUEUE"] && count($arrayRecipients)) {
         $frequencyType = $userObject->mergedRole->filterParameterValue("core.mailer", "NOTIFICATIONS_EMAIL_FREQUENCY", AJXP_REPO_SCOPE_ALL, "M");
         $frequencyDetail = $userObject->mergedRole->filterParameterValue("core.mailer", "NOTIFICATIONS_EMAIL_FREQUENCY_USER", AJXP_REPO_SCOPE_ALL, "5");
         $nextFrequency = $this->computeEmailSendDate($frequencyType, $frequencyDetail);
         if (!empty($nextFrequency)) {
             if (!dibi::isConnected()) {
                 dibi::connect($this->getDibiDriver());
             }
             foreach ($arrayRecipients as $recipient) {
                 try {
                     dibi::query("INSERT INTO [ajxp_mail_queue] ([recipient],[url],[date_event],[notification_object],[html]) VALUES (%s,%s,%s,%bin,%i) ", $recipient, $notification->getNode()->getUrl(), $nextFrequency, serialize($notification), $useHtml);
                 } catch (Exception $e) {
                     $this->logError("[mailer]", $e->getMessage());
                 }
             }
         } else {
             $this->logError("[mailer]", "Could not determine email frequency from {$frequencyType} / {$frequencyDetail} for send email to user " . $userObject->getId());
         }
     } else {
         $mailer = AJXP_PluginsService::getInstance()->getActivePluginsForType("mailer", true);
         if ($mailer !== false) {
             try {
                 $mailer->sendMail(array($notification->getTarget()), $notification->getDescriptionShort(), $notification->getDescriptionLong(), $notification->getAuthor(), $notification->getMainLink(), $useHtml);
             } catch (Exception $e) {
                 throw new AJXP_Exception($e->getMessage());
             }
         }
     }
 }