Exemplo n.º 1
0
 public function renderAjaxErrorResponse()
 {
     $errors = $this->parse($this->form->getErrors());
     if (!empty($errors)) {
         \PH7\Framework\Http\Http::setContentType('application/json');
         echo json_encode(array('errors' => $errors));
     }
 }
Exemplo n.º 2
0
 protected function send()
 {
     $sFrom = $_SESSION['messenger_username'];
     $sTo = $this->_oHttpRequest->post('to');
     $sMsg = $this->_oHttpRequest->post('message');
     $_SESSION['messenger_openBoxes'][$this->_oHttpRequest->post('to')] = date('Y-m-d H:i:s', time());
     $sMsgTransform = $this->sanitize($sMsg);
     $sMsgTransform = Emoticon::init($sMsgTransform, false);
     if (!isset($_SESSION['messenger_history'][$this->_oHttpRequest->post('to')])) {
         $_SESSION['messenger_history'][$this->_oHttpRequest->post('to')] = '';
     }
     if (!$this->isOnline($sFrom)) {
         $sMsgTransform = t('You must have the ONLINE status in order to chat with other members.');
     } elseif (!$this->isOnline($sTo)) {
         $sMsgTransform = '<small><em>' . t('%0% is offline. Send a Private Message instead.', $sTo) . '</em></small>';
     } else {
         $this->_oMessengerModel->insert($sFrom, $sTo, $sMsg, (new \PH7\Framework\Date\CDateTime())->get()->dateTime('Y-m-d H:i:s'));
     }
     $_SESSION['messenger_history'][$this->_oHttpRequest->post('to')] .= $this->setJsonContent(['status' => '1', 'user' => $sTo, 'msg' => $sMsgTransform]);
     unset($_SESSION['messenger_boxes'][$this->_oHttpRequest->post('to')]);
     Http::setContentType('application/json');
     echo $this->setJsonContent(['user' => $sFrom, 'msg' => $sMsgTransform], false);
     exit(0);
 }
 public static function output()
 {
     static::_gets();
     Http::setContentType('application/json');
     echo static::$_sData;
 }