public function index_get() { //checkIsLoggedIn($this); $status = 404; $return["result"] = "NOOK"; $return["data"] = ""; $id = $this->get("id"); $userNoOwner = $this->get("userNoOwner"); $userOwner = $this->get("userOwner"); $userInConversations = $this->get("userInConversations"); $conversationId = $this->get("conversationId"); if ($id) { $messages = CI_Message::getById($id); } elseif ($userNoOwner) { $messages = CI_Message::getConversationFromOthersPublications($userNoOwner); } elseif ($userOwner) { $messages = CI_Message::getConversationFromMyPublications($userOwner); } elseif ($userInConversations) { $messages = CI_Message::getConversationFromAllPublications($userInConversations); } elseif ($conversationId) { $messages = CI_Message::getConversation($conversationId); if ($messages) { $reads = CI_Message::setMessagesRead($conversationId); } } if ($messages) { $status = 200; $return["result"] = "OK"; $return["data"] = ""; foreach ($messages as $key => $message) { $myMessage = new stdClass(); $myMessage->userTo = $message->getUserTo(); $myMessage->userFrom = $message->getUserFrom(); $myMessage->id = $message->getId(); $myMessage->publication = $message->getPublication(); $myMessage->conversationId = $message->getConversationId(); $myMessage->FAQ = $message->getFAQ(); $myMessage->commonState = $message->getCommonState(); $myMessage->subject = $message->getSubject(); $myMessage->text = $message->getText(); $myMessage->createDate = $message->getCreateDate(); $myMessage->updateDate = $message->getUpdateDate(); $return["data"][$key] = $myMessage; } } $this->response($return, $status); }