public function findAction() { $notification = new Backoffice_Model_Notification(); $unread_number = $notification->findAll(array("is_read = ?" => 0))->count(); $unread_message = $unread_number > 1 ? $this->_("%d Unread Messages", $unread_number) : $this->_("%d Unread Message", $unread_number); $admin = new Admin_Model_Admin(); $admins = $admin->getStats(); $array_admin = array(); foreach ($admins as $admin) { $array_admin[$admin->getDay()] = $admin->getCount(); } $dateKey = new Siberian_Date(); $dateEnd = new Siberian_Date(); $dateKey = $dateKey->setDay(1); $dateEnd = $dateEnd->setDay(1); $dateEnd->addMonth(1); $dateEnd = $dateEnd->subDay(1); $stats = array(); $i = 0; while (strcmp($dateKey->toString("yyyy-MM-dd"), $dateEnd->toString("yyyy-MM-dd")) <= 0) { $admin = isset($array_admin[$dateKey->toString("yyyy-MM-dd")]) ? $array_admin[$dateKey->toString("yyyy-MM-dd")] : 0; $stats[] = array($dateKey->toString("EEE. MMM, dSS"), $admin); $dateKey->addDay(1); } $data = array("stats" => $stats, "notif" => array("unread_number" => $unread_number, "message" => $unread_message)); $this->_sendHtml($data); }
public function postAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { $this->getSession()->resetInstance(); try { if (empty($data['email']) or empty($data['password'])) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } $user = new Backoffice_Model_User(); $user->find($data['email'], 'email'); if ($user->authenticate($data['password'])) { $this->getSession()->setBackofficeUser($user); } $notification = new Backoffice_Model_Notification(); $notification->update(); if (!$this->getSession()->isLoggedIn()) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } $data = array("success" => 1, "user" => $user->getData()); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
public function markasAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($data["notif_id"])) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } $notification = new Backoffice_Model_Notification(); $notification->find($data["notif_id"]); if (!$notification->getId()) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } $is_read = (int) (!empty($data["is_read"])); $notification->setIsRead($is_read)->save(); $html = array('success' => 1, 'is_read' => $is_read); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
<?php $message = "Welcome! First of all, let's configure your platform. <a href=\"/system/backoffice_config_general\"><u>Click here</u></a> to fill in your information or <a href=\"/system/backoffice_config_email\"><u>here</u></a> to configure your email address"; $notif = new Backoffice_Model_Notification(); $notif->setTitle("Welcome!")->setDescription($message)->setOriginalNotificationId(0)->save();