예제 #1
0
 /**
  * добавить пользователя в чат
  * 
  * @uses ApiController::_userId
  * @uses Controller::request
  * @return void
  */
 public function chat_add_member()
 {
     if (!isset($this->_controller->request->data['room_id']) or !isset($this->_controller->request->data['user_id'])) {
         throw new ApiIncorrectRequestException();
     }
     if ($this->_controller->request->data['user_id'] == $this->_userId) {
         throw new ApiIncorrectRequestException();
     }
     if (!$this->_controller->ApiChatRoom->canAddMember($this->_controller->request->data['room_id'], $this->_userId)) {
         throw ApiAccessDeniedException();
     }
     if (!$this->_controller->ApiUser->isActive($this->_controller->request->data['user_id'])) {
         throw ApiAccessDeniedException();
     }
     if ($this->_controller->ApiChatMember->inRoom($this->_controller->request->data['user_id'], $this->_controller->request->data['room_id'])) {
         throw new ApiAccessDeniedException();
     }
     $roomId = $this->_controller->ApiChatMember->addChatMember($this->_userId, $this->_controller->request->data['room_id'], $this->_controller->request->data['user_id']);
     $result = $this->_controller->ApiChatContact->openRoom($this->_userId, 0, null, $roomId);
     $this->_controller->setResponse($result);
 }
 /**
  * Список документов пользователя
  * 
  * @uses ApiController::_userId
  * @uses Controller::request
  * @return void
  */
 public function get_document_body()
 {
     if (!isset($this->_controller->request->data['document_id']) or !$this->_controller->request->data['document_id']) {
         throw new ApiIncorrectRequestException();
     }
     if (!$this->_controller->ApiNote->checkAccessToDoc($this->_userId, $this->_controller->request->data['document_id'])) {
         throw ApiAccessDeniedException();
     }
     $result = $this->_controller->ApiNote->getDocumentBody($this->_controller->request->data['document_id']);
     $this->_controller->setResponse($result);
 }