public function dismissUserAlert($actionName, $httpVars, $fileVars) { if (!$this->eventStore) { return; } $alertId = $httpVars["alert_id"]; $oc = 1; if (isset($httpVars["occurrences"])) { $oc = intval($httpVars["occurrences"]); } $this->eventStore->dismissAlertById($alertId, $oc); }
public function loadUserAlerts($actionName, $httpVars, $fileVars) { if (!$this->eventStore) { return; } $u = AuthService::getLoggedUser(); $userId = $u->getId(); $repositoryFilter = null; if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) { $repositoryFilter = $httpVars["repository_id"]; } if ($repositoryFilter == null) { $repositoryFilter = ConfService::getRepository()->getId(); } $res = $this->eventStore->loadAlerts($userId, $repositoryFilter); if (!count($res)) { return; } // Recompute children notifs $format = $httpVars["format"]; $skipContainingTags = isset($httpVars["skip_container_tags"]); $mess = ConfService::getMessages(); if (!$skipContainingTags) { if ($format == "html") { echo "<h2>" . $mess["notification_center.3"] . "</h2>"; echo "<ul class='notification_list'>"; } else { AJXP_XMLWriter::header(); } } $parentRepository = ConfService::getRepositoryById($repositoryFilter); $parentRoot = $parentRepository->getOption("PATH"); $cumulated = array(); foreach ($res as $notification) { if ($format == "html") { echo "<li>"; echo $notification->getDescriptionLong(true); echo "</li>"; } else { $node = $notification->getNode(); $path = $node->getPath(); $nodeRepo = $node->getRepository(); if ($nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter) { $currentRoot = $nodeRepo->getOption("PATH"); $contentFilter = $nodeRepo->getContentFilter(); if (isset($contentFilter)) { $nodePath = $contentFilter->filterExternalPath($node->getPath()); if ($nodePath == "/") { $k = array_keys($contentFilter->filters); $nodePath = $k[0]; } } else { $nodePath = $node->getPath(); } $relative = rtrim(substr($currentRoot, strlen($parentRoot)), "/") . rtrim($nodePath, "/"); $parentNodeURL = $node->getScheme() . "://" . $repositoryFilter . $relative; $this->logDebug("action.share", "Recompute alert to " . $parentNodeURL); $node = new AJXP_Node($parentNodeURL); } if (isset($cumulated[$path])) { $cumulated[$path]->event_occurence++; continue; } try { $node->loadNodeInfo(); } catch (Exception $e) { if ($notification->alert_id) { $this->eventStore->dismissAlertById($notification->alert_id); } continue; } $node->event_is_alert = true; $node->event_description = ucfirst($notification->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notification->getAuthorLabel(); $node->event_description_long = $notification->getDescriptionLong(true); $node->event_date = SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($notification->getDate(), $mess)); $node->event_type = "alert"; $node->alert_id = $notification->alert_id; if ($node->getRepository() != null) { $node->repository_id = '' . $node->getRepository()->getId(); if ($node->repository_id != $repositoryFilter && $node->getRepository()->getDisplay() != null) { $node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]"; } } else { $node->event_repository_label = "[N/A]"; } $node->event_author = $notification->getAuthor(); $node->event_occurence = 1; $cumulated[$path] = $node; } } $index = 1; foreach ($cumulated as $nodeToSend) { $nodeOcc = $nodeToSend->event_occurence > 1 ? "(" . $nodeToSend->event_occurence . ")" : ""; if (isset($httpVars["merge_description"]) && $httpVars["merge_description"] == "true") { if (isset($httpVars["description_as_label"]) && $httpVars["description_as_label"] == "true") { $nodeToSend->setLabel($nodeToSend->event_description . " " . $nodeOcc . " " . $nodeToSend->event_date); } else { $nodeToSend->setLabel(basename($nodeToSend->getPath()) . " " . $nodeOcc . " " . " <small class='notif_desc'>" . $nodeToSend->event_description . " " . $nodeToSend->event_date . "</small>"); } } else { $nodeToSend->setLabel(basename($nodeToSend->getPath()) . $nodeOcc); } // Replace PATH $nodeToSend->real_path = $path; //$url = parse_url($nodeToSend->getUrl()); //$nodeToSend->setUrl($url["scheme"]."://".$url["host"]."/alert_".$index); $index++; AJXP_XMLWriter::renderAjxpNode($nodeToSend); } if (!$skipContainingTags) { if ($format == "html") { echo "</ul>"; } else { AJXP_XMLWriter::close(); } } }