/** * fetchNotifications AJAX * * @author Jaco Ruit */ require '../startOrongo.php'; startOrongo(); define("NOT_LOGGED_IN", 1); function errorDie($paramError, $paramErrorCode) { $arrayToJs = array(); $arrayToJs["response"] = $paramError; $arrayToJs["response_code"] = $paramErrorCode; die(json_encode($arrayToJs)); } if (getUser() == null) { errorDie("Not logged in!", NOT_LOGGED_IN); } $arrayToJs = array(); $arrayToJs["notifications"] = array(); $count = 0; foreach (getUser()->getNotifications() as $notification) { if ($notification["notification"] instanceof OrongoNotification == false) { continue; } $arrayToJs["notifications"][$count] = array("title" => $notification["notification"]->getTitle(), "text" => $notification["notification"]->getText(), "time" => $notification["notification"]->getTime(), "image" => $notification["notification"]->getImage()); OrongoNotifier::deleteNotification($notification["id"]); $count++; } $arrayToJs["newNotifications"] = $count > 0 ? true : false; die(json_encode($arrayToJs));
/** * Deletes the notifications for user */ public function deleteNotifications() { OrongoNotifier::deleteNotificationsByUser($this); }
/** * Dispatches the Notification * @param User User to notify */ public function dispatch($paramUser) { OrongoNotifier::dispatchNotification($this, $paramUser); }
/** * Renders the Display */ public function render() { if ($this->rendered) { return; } $this->setTemplateVariable("website_name", Settings::getWebsiteName()); $this->setTemplateVariable("website_url", Settings::getWebsiteURL()); $this->setTemplateVariable("version", "r" . REVISION); $this->setTemplateVariable("menu", getMenu()->toHTML()); if (getUser() != null) { $this->setTemplateVariable("user", getUser()); $on = new OrongoNotifier(); $on->start(); } if (!$this->isImported(orongoURL('orongo-admin/theme/smoothness/jquery-ui-1.8.16.custom.css'))) { $this->import(orongoURL('orongo-admin/theme/smoothness/jquery-ui-1.8.16.custom.css')); } if (!$this->isImported('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js')) { $this->import('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js'); } foreach ($this->objects as $object) { if ($object == null) { continue; } if ($object instanceof OrongoDisplayableObject == false) { continue; } $this->addToTemplateVariable("body", $object->toHTML()); } foreach ($this->imports as $import) { $type = strrev($import); $type = explode(".", $type); $type = strrev($type[0]); if (stristr($type, "?")) { $type = explode("?", $type); $type = $type[0]; } switch ($type) { case "css": $this->addHTML('<link rel="stylesheet" href="' . $import . '" type="text/css" media="screen" />', "head"); break; case "js": $this->addHTML('<script type="text/javascript" src="' . $import . '"></script>', "head"); break; default: break; } } $this->addToTemplateVariable("head", $this->head); $this->addToTemplateVariable("body", $this->generalhtml); foreach ($this->pluginhtml as $field => $html) { $this->setTemplateVariable($field, $html); } $this->addToTemplateVariable("body", '<script type="text/javascript">' . $this->js . '</script>'); foreach ($this->tpls as $tpl) { if (empty($tpl)) { continue; } if (function_exists("getCurrentPage") && !stristr(getCurrentPage(), "admin") && !file_exists(raintpl::$tpl_dir . $tpl . ".html")) { $msgbox = new MessageBox("Style was missing a file: " . $tpl . ".html"); die($msgbox->getImports() . $msgbox->toHTML()); } $this->raintpl->draw($tpl); } $this->rendered = true; }