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"]); } }
/** * @param AJXP_Node $oldNode * @param AJXP_Node $newNode * @param bool $copy * @param string $targetNotif * @return AJXP_Notification */ public function generateNotificationFromChangeHook(AJXP_Node $oldNode = null, AJXP_Node $newNode = null, $copy = false, $targetNotif = "new") { $type = ""; $primaryNode = null; $secondNode = null; $notif = new AJXP_Notification(); if ($oldNode == null) { if ($targetNotif == "old") { return false; } $type = AJXP_NOTIF_NODE_ADD; $primaryNode = $newNode; } else { if ($newNode == null) { if ($targetNotif == "new") { return false; } $type = AJXP_NOTIF_NODE_DEL; $primaryNode = $oldNode; } else { if ($oldNode->getUrl() == $newNode->getUrl()) { $type = AJXP_NOTIF_NODE_CHANGE; $primaryNode = $newNode; } else { if (dirname($oldNode->getPath()) == dirname($newNode->getPath())) { $type = AJXP_NOTIF_NODE_RENAME; $primaryNode = $newNode; $secondNode = $oldNode; } else { if ($targetNotif == "new") { $type = $copy ? AJXP_NOTIF_NODE_COPY_FROM : AJXP_NOTIF_NODE_MOVE_FROM; $primaryNode = $newNode; $secondNode = $oldNode; } else { if ($targetNotif == "old") { $type = $copy ? AJXP_NOTIF_NODE_COPY_TO : AJXP_NOTIF_NODE_MOVE_TO; $primaryNode = $oldNode; $secondNode = $newNode; } else { if ($targetNotif == "unify") { $type = $copy ? AJXP_NOTIF_NODE_COPY : AJXP_NOTIF_NODE_MOVE; $primaryNode = $newNode; $secondNode = $oldNode; } } } } } } } $notif->setNode($primaryNode); $notif->setAction($type); if ($secondNode != null) { $notif->setSecondaryNode($secondNode); } return $notif; }
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"]); } }
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); } } } }