public function detailsAction() { $userId = null; $auth = Zend_Auth::getInstance(); $authAccount = $auth->getStorage()->read(); if (null != $authAccount) { if (null != $authAccount->getId()) { $userId = $authAccount->getId(); } } $id = $this->getRequest()->getParam('id'); if ($id) { $model = new Default_Model_NotificationMessages(); /*if($model->find($id)){ $vizualizare = $model->setVizualizare(); }*/ $select = $model->getMapper()->getDbTable()->select()->where('NOT deleted')->where('id=?', $id); $result = $model->fetchRow($select); if ($result) { $modelto = new Default_Model_NotificationTo(); $select = $modelto->getMapper()->getDbTable()->select()->where('NOT deleted')->where('idNotification=?', $id)->where('idUserTo=?', $userId); $result2 = $modelto->fetchRow($select); if ($modelto->find($result2->id)) { } if ($modelto->getStatus() == 1) { $this->view->notificationBg = "necitit"; } $modelto->setStatus('0'); $modelto->save(); $this->view->result = $result; } } }
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; }