protected function error($msg) { $this->setNoRender(); $this->_request->setDispatched(true); if ($this->_request->isXmlHttpRequest()) { $arp = new AjaxResponse(); $arp->setStatus(AjaxResponse::STATUS_FAILED); $arp->setMessage($msg); $this->json($arp); } else { $this->view->msg = $msg; $this->renderScript('common/error.phtml'); } }
protected function sendResult($result = '') { $arp = new AjaxResponse(); $arp->setStatus(AjaxResponse::STATUS_OK); $arp->setMessage($result); $this->json($arp); }
public function signInAction() { if (!$this->_request->isXmlHttpRequest()) { return; } $arp = new AjaxResponse(); $arp->setStatus(AjaxResponse::STATUS_FAILED); $email = trim($this->_getParam('email')); $password = trim($this->_getParam('password')); if (empty($email) || empty($password)) { $arp->setMessage('E-mail and password can not be empty.'); $this->json($arp); return; } $hashedPassword = hash('sha256', $password); $user = new Model_User($email); if (!$user->exists() || $user->get('password') != $hashedPassword) { $arp->setMessage('Authentication failed, You entered an incorrect username, or password.'); $this->json($arp); return; } $this->setLoginCookie($email, $hashedPassword); $arp->setStatus(AjaxResponse::STATUS_OK); $this->json($arp); }
public function addOrderConversationAction() { $sn = trim($this->_getParam('sn')); $message = trim($this->_getParam('message')); $imageUrl = $this->_getParam('imageUrl'); $oc = new Model_OrderConversation(); $oc->set('sn', $sn); $oc->set('sender', Model_OrderConversation::SENDER_CS); $oc->set('message', $message); $oc->set('image_url', $imageUrl); $oc->set('created_time', time()); $oc->save(); $arp = new AjaxResponse(); $arp->setStatus(AjaxResponse::STATUS_OK); $this->json($arp); $c = new ApiControllerAbstract(); $c->sendPush(Model_OrderConversation::SENDER_CS, $sn, $message); }