mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
Added method postChangeStatus to controller Message
This commit is contained in:
@@ -119,6 +119,28 @@ class Message extends APIv1_Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postChangeStatus()
|
||||
{
|
||||
$person_id = $this->post()['person_id'];
|
||||
$message_id = $this->post()['message_id'];
|
||||
$status = $this->post()['status'];
|
||||
|
||||
if (isset($person_id) && isset($message_id) && isset($status) &&
|
||||
in_array($status, array(MSG_STATUS_UNREAD, MSG_STATUS_READ, MSG_STATUS_ARCHIVED, MSG_STATUS_DELETED)))
|
||||
{
|
||||
$result = $this->messagelib->updateMessageStatus($message_id, $person_id, $status);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
private function _validatePostMessage($message = null)
|
||||
{
|
||||
if (!isset($message))
|
||||
|
||||
@@ -118,31 +118,30 @@ class MessageLib
|
||||
* @param integer $status_id REQUIRED - should come from config/message.php list of constants
|
||||
* @return array
|
||||
*/
|
||||
function updateMessageStatus($msg_id, $user_id, $status_id )
|
||||
function updateMessageStatus($message_id, $person_id, $status)
|
||||
{
|
||||
if (empty($msg_id))
|
||||
if (empty($message_id))
|
||||
{
|
||||
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
|
||||
}
|
||||
|
||||
if (empty($user_id))
|
||||
if (empty($person_id))
|
||||
{
|
||||
return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
|
||||
}
|
||||
|
||||
if (empty($status_id))
|
||||
// Not use empty otherwise if status is 0 it returns an error
|
||||
if (!isset($status))
|
||||
{
|
||||
return $this->_invalid_id(MSG_ERR_INVALID_STATUS_ID);
|
||||
}
|
||||
|
||||
if ($this->ci->message_model->update_message_status($msg_id, $user_id, $status_id))
|
||||
{
|
||||
return $this->_success(NULL, MSG_STATUS_UPDATE);
|
||||
}
|
||||
|
||||
// General Error Occurred
|
||||
return $this->_general_error();
|
||||
|
||||
$result = $this->ci->MsgStatusModel->update(
|
||||
array('message_id' => $message_id, 'person_id' => $person_id),
|
||||
array('status' => $status)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -343,4 +342,4 @@ class MessageLib
|
||||
'msg' => lang('message_'.$error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user