public function sendToQueue(AJXP_Notification $notification) { if (!$this->useQueue) { $this->logDebug("SHOULD DISPATCH NOTIFICATION ON " . $notification->getNode()->getUrl() . " ACTION " . $notification->getAction()); AJXP_Controller::applyHook("msg.notification", array(&$notification)); } else { if ($this->msgExchanger) { $this->msgExchanger->publishWorkerMessage("user_notifications", $notification); } } }
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()); } } }
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()); } } }
private function processActiveHook(AJXP_Notification $notification, $namespace, $parentActionType = null) { $node = $notification->getNode(); $all = $this->collectWatches($node, $namespace); foreach ($all["node"] as $id) { $this->notificationCenter->postNotification($notification, $id); } foreach ($all["ancestors"] as $pair) { $parentNotification = new AJXP_Notification(); $parentNotification->setNode($pair["node"]); $parentNotification->getNode()->setLeaf(false); if ($parentActionType == null) { $parentNotification->setAction($notification->getAction()); } else { $parentNotification->setAction($parentActionType); } $this->notificationCenter->prepareNotification($notification); $parentNotification->addRelatedNotification($notification); $this->notificationCenter->postNotification($parentNotification, $pair["id"]); } }
private function processActiveHook(AJXP_Notification $notification, $namespace, $parentActionType = null) { $origNode = $notification->getNode(); $node = new AJXP_Node($origNode->getUrl()); $all = $this->collectWatches($node, $namespace); if ($node->isRoot() && $node->getRepository() !== null && $node->getRepository()->hasContentFilter()) { $node->setLeaf(true); } else { $node->setLeaf(false); } foreach ($all["node"] as $id) { $this->notificationCenter->postNotification($notification, $id); } foreach ($all["ancestors"] as $pair) { $parentNotification = new AJXP_Notification(); /** * @var AJXP_Node $parentNode */ $parentNode = $pair["node"]; if ($parentNode->isRoot() && $parentNode->getRepository() !== null && $parentNode->getRepository()->hasContentFilter()) { $parentNode->setLeaf(true); } else { $parentNode->setLeaf(false); } $parentNotification->setNode($parentNode); if ($parentActionType == null) { $parentNotification->setAction($notification->getAction()); } else { $parentNotification->setAction($parentActionType); } $this->notificationCenter->prepareNotification($notification); $parentNotification->addRelatedNotification($notification); $this->notificationCenter->postNotification($parentNotification, $pair["id"]); } }
/** * @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()); } }
public function prepareNotification(AJXP_Notification &$notif) { $notif->setAuthor($this->userId); $notif->setDate(time()); }
public function processReadHook(AJXP_Node $node) { $ids = $this->getWatchesOnNode($node, self::$META_WATCH_READ); $notif = new AJXP_Notification(); $notif->setAction(AJXP_NOTIF_NODE_VIEW); $notif->setNode($node); if (count($ids)) { foreach ($ids as $id) { $this->notificationCenter->postNotification($notif, $id); } } if (!$node->isRoot()) { $parentNode = new AJXP_Node(dirname($node->getUrl())); $parentNode->setLeaf(false); $ids = $this->getWatchesOnNode($parentNode, self::$META_WATCH_READ); if (count($ids)) { // POST NOW : PARENT FOLDER IS AFFECTED $parentNotif = new AJXP_Notification(); $parentNotif->setNode($parentNode); $parentNotif->setAction(AJXP_NOTIF_NODE_VIEW); $this->notificationCenter->prepareNotification($notif); $parentNotif->addRelatedNotification($notif); foreach ($ids as $id) { $this->notificationCenter->postNotification($parentNotif, $id); } } } }
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()); } } } }