load->library('MessageLib', array('uid' => $this->_getUID())); } /** * @return void */ public function getMessagesByPersonID() { $person_id = $this->get('person_id'); $all = $this->get('all'); if (isset($person_id)) { $result = $this->messagelib->getMessagesByPerson($person_id, $all); $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } /** * @return void */ public function postMessage() { if ($this->_validate($this->post())) { $this->messagelib->addRecipient($this->post()['person_id']); $result = $this->messagelib->sendMessage( $this->post()['person_id'], $this->post()['subject'], $this->post()['body'], PRIORITY_NORMAL, NULL, $this->post()['oe_kurzbz'] ); $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } private function _validate($message = null) { if (!isset($message['person_id']) || !isset($message['subject']) || !isset($message['body']) || !isset($message['oe_kurzbz'])) { return false; } return true; } }