예제 #1
0
 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);
     }
 }
예제 #2
0
 public function findallAction()
 {
     $notif = new Backoffice_Model_Notification();
     $notif->update();
     $notifs = $notif->findAll();
     $data = array("notifs" => array());
     foreach ($notifs as $notif) {
         $notif->setIsRead((bool) $notif->getIsRead());
         $notif->setIsHighPriority((bool) $notif->getIsHighPriority());
         $data["notifs"][] = $notif->getData();
     }
     $this->_sendHtml($data);
 }