Beispiel #1
0
 public function indexAction()
 {
     $userId = null;
     $auth = Zend_Auth::getInstance();
     $authAccount = $auth->getStorage()->read();
     if (null != $authAccount) {
         if (null != $authAccount->getId()) {
             $userId = $authAccount->getId();
         }
     }
     $model = new Default_Model_NotificationMessages();
     $notification = new Default_Model_NotificationTo();
     $params = array();
     $subject = $this->getRequest()->getParam('subject');
     $message = $this->getRequest()->getParam('message');
     $select = $notification->getMapper()->getDbTable()->select()->from(array('n' => 'notification_to'), array('n.*'))->where("NOT n.deleted")->where("n.status=?", '1')->where("n.idUserTo=?", $userId);
     $result = $notification->fetchAll($select);
     $notifications = count($result) != 0 ? count($result) : 0;
     $select2 = $model->getMapper()->getDbTable()->select()->from(array('nm' => 'notification_messages'), array('nm.*'))->joinLeft(array('n' => 'notification_to'), 'nm.`id` = n.`idNotification`', array('nid' => 'n.id', 'status' => 'n.status'))->where("NOT n.deleted")->where("n.idUserTo=?", $userId);
     if (!empty($subject)) {
         $params['subject'] = $subject;
         $select2->where('subject LIKE ?', '%' . $subject . '%');
     }
     if (!empty($message)) {
         $params['message'] = $message;
         $select2->where('message LIKE ?', '%' . $message . '%');
     }
     $select2->order(array('n.status desc', 'n.created desc'))->setIntegrityCheck(false);
     $form = new Default_Form_NotificationsSearch();
     $form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/notifications/notifications-search.phtml'))));
     $this->view->form = $form;
     $this->view->search = $params;
     $result2 = $model->fetchAll($select2);
     if (NULL != $result2) {
         $paginator = Zend_Paginator::factory($result2);
         $paginator->setItemCountPerPage(25);
         $paginator->setCurrentPageNumber($this->_getParam('page'));
         $paginator->setPageRange(5);
         $this->view->result = $paginator;
         $this->view->itemCountPerPage = $paginator->getItemCountPerPage();
         $this->view->totalItemCount = $notifications;
         Zend_Paginator::setDefaultScrollingStyle('Sliding');
         Zend_View_Helper_PaginationControl::setDefaultViewPartial('_pagination.phtml');
     }
 }
Beispiel #2
0
 public static function notifications($id)
 {
     $notification = new Default_Model_NotificationTo();
     $select = $notification->getMapper()->getDbTable()->select()->from(array('n' => 'notification_to'), array('n.*'))->where("NOT n.deleted")->where("n.status=?", '1')->where("n.idUserTo=?", $id);
     $result = $notification->fetchAll($select);
     $notifications = count($result) != 0 ? count($result) : 0;
     $notification = new Default_Model_NotificationMessages();
     $select = $notification->getMapper()->getDbTable()->select()->from(array('n' => 'notification_to'), array('n.*'))->joinLeft(array('nm' => 'notification_messages'), 'n.`idNotification` = nm.`id`', array('nm.*'))->where("NOT n.deleted")->where("n.status=?", '1')->where("n.idUserTo=?", $id)->limit(3)->setIntegrityCheck(false);
     $result = $notification->fetchAll($select);
     $res_notificari = '<ul>';
     foreach ($result as $rez) {
         $res_notificari .= "<li><a href='" . WEBROOT . "notifications/details/id/" . $rez->getId() . "'>" . $rez->getSubject() . "</a></li>";
     }
     if ($notifications > 0) {
         $res_notificari .= "<a href=\"" . WEBROOT . "notifications\" class=\"notificari\">Toate Notificarile</a>";
     } else {
         $res_notificari .= "<li>Nu aveti notificari</li>";
     }
     $res_notificari .= "</ul>";
     $result_array = array($res_notificari, $notifications);
     return $result_array;
 }