Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from tonydew/master

I love the idea of the code, but there is so much duplication!
  • Loading branch information...
commit b5581ee786f9d925a78db5bd6433d8c9db59e13d 2 parents 1b34c90 + 4fd3803
@jrmadsen67 authored
Showing with 746 additions and 391 deletions.
  1. +343 −159 application/libraries/Mahana_messaging.php
  2. +403 −232 application/models/mahana_model.php
View
502 application/libraries/Mahana_messaging.php
@@ -1,277 +1,461 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
-* Name: Mahana Messaging Library for CodeIgniter
+* Name: Mahana Messaging Library for CodeIgniter
*
-* Author: Jeff Madsen
-* jrmadsen67@gmail.com
- http://www.codebyjeff.com
+* Author: Jeff Madsen
+* jrmadsen67@gmail.com
+* http://www.codebyjeff.com
*
-* Location: - will be on github shortly
+* Location: will be on github shortly
*
-* Description: CI library for linking to application's existing user table and creating basis of an internal messaging system
-* No views or controllers included - DO CHECK the README.txt for setup instructions and notes
+* Description: CI library for linking to application's existing user table and
+* creating basis of an internal messaging system. No views or controllers
+* included.
+*
+* DO CHECK the README.txt for setup instructions and notes!
*
*/
class Mahana_messaging
{
-
-
- public function __construct()
- {
-
- $this->ci =& get_instance();
- require_once(APPPATH.'config/mahana.php');
+ public function __construct()
+ {
+ $this->ci =& get_instance();
+ // ------------------------------------------------------------------------
+ // @TODO: There must be a better way than this to specify a file
+ // path that works in both standard CodeIgniter and HMVC modules.
+ // ------------------------------------------------------------------------
+ require_once dirname(__FILE__).'/../config/mahana.php';
$this->ci->load->model('mahana_model');
$this->ci->load->helper('language');
$this->ci->lang->load('mahana');
-
-
}
- /*
- function get_message() - will return a single message, including the status for specified user.
- @parameters - $msg_id REQUIRED, $user_id REQUIRED
- */
+ // ------------------------------------------------------------------------
+ /**
+ * get_message() - will return a single message, including the status for specified user.
+ *
+ * @param integer $msg_id EQUIRED
+ * @param integer $user_id REQUIRED
+ * @return array
+ */
function get_message($msg_id, $user_id)
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ if (empty($msg_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
+ }
- if (empty($msg_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_MSG_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_MSG_ID));return $status;}
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
+ if (empty($user_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
+ }
if ($message = $this->ci->mahana_model->get_message($msg_id, $user_id))
{
- return $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_SUCCESS), 'retval'=>$message);
+ return $this->_success($message);
}
- return $status;
- }
+ // General Error Occurred
+ return $this->_general_error();
+ }
- /*
- function get_full_thread() - will return a entire thread, including the status for specified user.
-
- @parameters - $thread_id REQUIRED, $user_id REQUIRED, $order_by OPTIONAL
- - $full_thread - if true, user will also see messages from thread posted BEFORE user became participant
- */
-
- function get_full_thread($thread_id, $user_id, $full_thread=false, $order_by='asc')
+ // ------------------------------------------------------------------------
+
+ /**
+ * get_full_thread() - will return a entire thread, including the status for specified user.
+ *
+ * @param integer $thread_id REQUIRED
+ * @param integer $user_id REQUIRED
+ * @param boolean $full_thread OPTIONAL - If true, user will also see messages from thread posted BEFORE user became participant
+ * @param string $order_by OPTIONAL
+ * @return array
+ */
+ function get_full_thread($thread_id, $user_id, $full_thread = FALSE, $order_by = 'ASC')
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ if (empty($thread_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
+ }
- if (empty($thread_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_THREAD_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_THREAD_ID));return $status;}
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
+ if (empty($user_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
+ }
if ($message = $this->ci->mahana_model->get_full_thread($thread_id, $user_id, $full_thread, $order_by))
{
- return $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_SUCCESS), 'retval'=>$message);
+ return $this->_success($message);
}
- return $status;
- }
-
- /*
- function get_all_threads() - will return all threads for user, including the status for specified user.
- @parameters - $user_id REQUIRED, $order_by OPTIONAL
- - $full_thread - if true, user will also see messages from thread posted BEFORE user became participant
- */
+ // General Error Occurred
+ return $this->_general_error();
+ }
- function get_all_threads($user_id, $full_thread=false, $order_by='asc')
+ // ------------------------------------------------------------------------
+
+ /**
+ * get_all_threads() - will return all threads for user, including the status for specified user.
+ *
+ * @param integer $user_id REQUIRED
+ * @param boolean $full_thread OPTIONAL - If true, user will also see messages from thread posted BEFORE user became participant
+ * @param string $order_by OPTIONAL
+ * @return array
+ */
+ function get_all_threads($user_id, $full_thread = FALSE, $order_by = 'ASC')
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
-
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
-
- if ($message = $this->ci->mahana_model->get_all_threads($user_id, $full_thread, $order_by))
+ if (empty($user_id))
{
- return $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_SUCCESS), 'retval'=>$message);
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
}
- return $status;
- }
-
- /*
- function get_all_threads_grouped() - will return all threads for user, including the status for specified user.
- - messages are grouped in threads.
- @parameters - $user_id REQUIRED, $order_by OPTIONAL
- - $full_thread - if true, user will also see messages from thread posted BEFORE user became participant
+ if ($message = $this->ci->mahana_model->get_all_threads($user_id, $full_thread, $order_by))
+ {
+ return $this->_success($message);
+ }
- // Thanks to mirzadelic for this great addition
- */
+ // General Error Occurred
+ return $this->_general_error();
+ }
- function get_all_threads_grouped($user_id, $full_thread=false, $order_by='asc')
+ // ------------------------------------------------------------------------
+
+ /**
+ * get_all_threads_grouped() - will return all threads for user, including the status for specified user.
+ * - messages are grouped in threads.
+ *
+ * @param integer $user_id REQUIRED
+ * @param boolean $full_thread OPTIONAL - If true, user will also see messages from thread posted BEFORE user became participant
+ * @param string $order_by OPTIONAL
+ * @return array
+ */
+ function get_all_threads_grouped($user_id, $full_thread = FALSE, $order_by = 'ASC')
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
-
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
+ if (empty($user_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
+ }
- if ($message = $this->ci->mahana_model->get_all_threads($user_id, $full_thread, $order_by))
+ if ($message = $this->ci->mahana_model->get_all_threads($user_id, $full_thread, $order_by))
{
$threads = array();
- foreach ($message as $msg) {
- if (!isset($threads[$msg['thread_id']]))
+ foreach ($message as $msg)
+ {
+ if ( ! isset($threads[$msg['thread_id']]))
{
$threads[$msg['thread_id']]['thread_id'] = $msg['thread_id'];
- $threads[$msg['thread_id']]['messages'] = array($msg);
+ $threads[$msg['thread_id']]['messages'] = array($msg);
}
else
{
$threads[$msg['thread_id']]['messages'][] = $msg;
}
}
- return $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_SUCCESS), 'retval'=>$threads);
- }
- return $status;
- }
+ return $this->_success($threads);
+ }
- /*
- function update_message_status() - will change status on message for particular user
+ // General Error Occurred
+ return $this->_general_error();
+ }
- @parameters - $msg_id REQUIRED, $user_id REQUIRED, $status_id REQUIRED
- - $status_id should come from config/mahana.php list of constants
- */
- function update_message_status($msg_id, $user_id, $status_id )
+ // ------------------------------------------------------------------------
+
+ /**
+ * update_message_status() - will change status on message for particular user
+ *
+ * @param integer $msg_id REQUIRED
+ * @param integer $user_id REQUIRED
+ * @param integer $status_id REQUIRED - should come from config/mahana.php list of constants
+ * @return array
+ */
+ function update_message_status($msg_id, $user_id, $status_id )
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ if (empty($msg_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
+ }
- if (empty($msg_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_MSG_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_MSG_ID));return $status;}
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
- if (empty($status_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_STATUS_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_STATUS_ID));return $status;}
+ if (empty($user_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
+ }
- if ($this->ci->mahana_model->update_message_status($msg_id, $user_id, $status_id ))
+ if (empty($status_id))
{
- $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_STATUS_UPDATE));
+ return $this->_invalid_id(MSG_ERR_INVALID_STATUS_ID);
}
- return $status;
+
+ if ($this->ci->mahana_model->update_message_status($msg_id, $user_id, $status_id))
+ {
+ return $this->_success(NULL, MSG_STATUS_UPDATE);
+ }
+
+ // General Error Occurred
+ return $this->_general_error();
+
}
- /*
- function add_participant() - adds user to existing thread
+ // ------------------------------------------------------------------------
- @parameters - $thread_id REQUIRED, $user_id REQUIRED
- */
+ /**
+ * add_participant() - adds user to existing thread
+ *
+ * @param integer $thread_id REQUIRED
+ * @param integer $user_id REQUIRED
+ * @return array
+ */
function add_participant($thread_id, $user_id)
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ if (empty($thread_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
+ }
- if (empty($thread_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_THREAD_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_THREAD_ID));return $status;}
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
+ if (empty($user_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
+ }
- if (!$this->ci->mahana_model->valid_new_participant($thread_id, $user_id))
+ if ( ! $this->ci->mahana_model->valid_new_participant($thread_id, $user_id))
{
- $status = array('err'=>1, 'code'=>1, 'msg'=>lang('mahana_'.MSG_ERR_PARTICIPANT_EXISTS));
- return $status;
+ $this->_particpant_error(MSG_ERR_PARTICIPANT_EXISTS);
}
- if (!$this->ci->mahana_model->application_user($user_id))
+ if ( ! $this->ci->mahana_model->application_user($user_id))
{
- $status = array('err'=>1, 'code'=>1, 'msg'=>lang('mahana_'.MSG_ERR_PARTICIPANT_NONSYSTEM));
- return $status;
+ $this->_particpant_error(MSG_ERR_PARTICIPANT_NONSYSTEM);
}
if ($this->ci->mahana_model->add_participant($thread_id, $user_id ))
{
- $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_PARTICIPANT_ADDED));
+ return $this->_success(NULL, MSG_PARTICIPANT_ADDED);
}
- return $status;
+
+ // General Error Occurred
+ return $this->_general_error();
}
- /*
- function remove_participant() - removes user from existing thread
+ // ------------------------------------------------------------------------
- @parameters - $thread_id REQUIRED, $user_id REQUIRED
- */
+ /**
+ * remove_participant() - removes user from existing thread
+ *
+ * @param integer $thread_id REQUIRED
+ * @param integer $user_id REQUIRED
+ * @return array
+ */
function remove_participant($thread_id, $user_id)
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ if (empty($thread_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
+ }
- if (empty($thread_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_THREAD_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_THREAD_ID));return $status;}
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
-
- if ($this->ci->mahana_model->remove_participant($thread_id, $user_id ))
+ if (empty($user_id))
{
- $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_PARTICIPANT_REMOVED));
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
}
- return $status;
- }
- /*
- function send_new_message() - sends new internal message. This function will create a new thread
+ if ($this->ci->mahana_model->remove_participant($thread_id, $user_id))
+ {
+ return $this->_success(NULL, MSG_PARTICIPANT_REMOVED);
+ }
- @parameters - $sender_id REQUIRED, $recipients REQUIRED
- - $recipients may be either a single integer or an array of integers, representing user_ids
- */
- function send_new_message($sender_id, $recipients, $subject='', $body='', $priority=PRIORITY_NORMAL){
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ // General Error Occurred
+ return $this->_general_error();
+ }
- if (empty($sender_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_SENDER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_SENDER_ID));return $status;}
- if (empty($recipients)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_RECIPIENTS, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_RECIPIENTS));return $status;}
+ // ------------------------------------------------------------------------
+
+ /**
+ * send_new_message() - sends new internal message. This function will create a new thread
+ *
+ * @param integer $sender_id REQUIRED
+ * @param mixed $recipients REQUIRED - a single integer or an array of integers, representing user_ids
+ * @param string $subject
+ * @param string $body
+ * @param integer $priority
+ * @return array
+ */
+ function send_new_message($sender_id, $recipients, $subject = '', $body = '', $priority = PRIORITY_NORMAL)
+ {
+ if (empty($sender_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_SENDER_ID);
+ }
- if ($this->ci->mahana_model->send_new_message($sender_id, $recipients, $subject, $body, $priority))
+ if (empty($recipients))
{
- $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_MESSAGE_SENT));
+ return array(
+ 'err' => 1,
+ 'code' => MSG_ERR_INVALID_RECIPIENTS,
+ 'msg' => lang('mahana_'.MSG_ERR_INVALID_RECIPIENTS)
+ );
+ }
+
+ if ($thread_id = $this->ci->mahana_model->send_new_message($sender_id, $recipients, $subject, $body, $priority))
+ {
+ return $this->_success($thread_id);
}
- return $status;
- }
- /*
- function reply_to_message() - replies to internal message. This function will NOT create a new thread or participant list
+ // General Error Occurred
+ return $this->_general_error();
+ }
- @parameters - $sender_id REQUIRED, $msg_id REQUIRED
- */
- function reply_to_message($msg_id, $sender_id, $subject='', $body='', $priority=PRIORITY_NORMAL)
+ // ------------------------------------------------------------------------
+
+ /**
+ * reply_to_message() - replies to internal message. This function will NOT create a new thread or participant list
+ *
+ * @param integer $msg_id REQUIRED
+ * @param integer $sender_id REQUIRED
+ * @param string $subject
+ * @param string $body
+ * @param integer $priority
+ * @return array
+ */
+ function reply_to_message($msg_id, $sender_id, $subject = '', $body = '', $priority = PRIORITY_NORMAL)
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ if (empty($sender_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_SENDER_ID);
+ }
- if (empty($sender_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_SENDER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_SENDER_ID));return $status;}
- if (empty($msg_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_MSG_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_MSG_ID));return $status;}
+ if (empty($msg_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
+ }
- if ($this->ci->mahana_model->reply_to_message($msg_id, $sender_id, $body, $priority))
+ if ($this->ci->mahana_model->reply_to_message($msg_id, $sender_id, $body, $priority))
{
- $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_MESSAGE_SENT));
+ return $this->_success(NULL, MSG_MESSAGE_SENT);
}
- return $status;
+
+ // General Error Occurred
+ return $this->_general_error();
}
- /*
- function get_participant_list() - returns list of participants on given thread. If sender_id set, sender_id will be left off list
+ // ------------------------------------------------------------------------
- @parameters - $sender_id REQUIRED, $thread_id REQUIRED
- */
- function get_participant_list($thread_id, $sender_id=0)
+ /**
+ * get_participant_list() - returns list of participants on given thread. If sender_id set, sender_id will be left off list
+ *
+ * @param integer $thread_id REQUIRED
+ * @param integer $sender_id REQUIRED
+ * @return array
+ */
+ function get_participant_list($thread_id, $sender_id = 0)
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
+ if (empty($thread_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_THREAD_ID);
+ }
- if (empty($thread_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_THREAD_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_THREAD_ID));return $status;}
-
if ($participants = $this->ci->mahana_model-> get_participant_list($thread_id, $sender_id))
{
- $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_SUCCESS) ,'retval'=>$participants);
+ return $this->_success($participants);
}
- return $status;
- }
- /*
- function get_msg_count() - returns integer with count of message for user, by status. defaults to new messages
+ // General Error Occurred
+ return $this->_general_error();
+ }
- @parameters - $user_id REQUIRED, $status_id OPTIONAL (defaults to "Unread")
- */
+ // ------------------------------------------------------------------------
+ /**
+ * get_msg_count() - returns integer with count of message for user, by status. defaults to new messages
+ *
+ * @param integer $user_id REQUIRED
+ * @param integer $status_id OPTIONAL - defaults to "Unread"
+ * @return array
+ */
function get_msg_count($user_id, $status_id = MSG_STATUS_UNREAD)
{
- $status = array('err'=>1, 'code'=>MSG_ERR_GENERAL, 'msg'=>lang('mahana_'.MSG_ERR_GENERAL));
-
- if (empty($user_id)){$status = array('err'=>1, 'code'=>MSG_ERR_INVALID_USER_ID, 'msg'=>lang('mahana_'.MSG_ERR_INVALID_USER_ID));return $status;}
+ if (empty($user_id))
+ {
+ return $this->_invalid_id(MSG_ERR_INVALID_USER_ID);
+ }
if ($message = $this->ci->mahana_model->get_msg_count($user_id, $status_id))
{
- return $status = array('err'=>0, 'code'=>MSG_SUCCESS, 'msg'=>lang('mahana_'.MSG_SUCCESS), 'retval'=>$message);
+ return $this->_success($message);
}
- return $status;
+
+ // General Error Occurred
+ return $this->_general_error();
+ }
+
+ // ------------------------------------------------------------------------
+ // Private Functions from here out!
+ // ------------------------------------------------------------------------
+
+ /**
+ * Success
+ *
+ * @param mixed $retval
+ * @return array
+ */
+ private function _success($retval = '', $message = MSG_SUCCESS)
+ {
+ return array(
+ 'err' => 0,
+ 'code' => MSG_SUCCESS,
+ 'msg' => lang('mahana_' . $message),
+ 'retval' => $retval
+ );
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Invalid ID
+ *
+ * @param integer config.php error code numbers
+ * @return array
+ */
+ private function _invalid_id($error = '')
+ {
+ return array(
+ 'err' => 1,
+ 'code' => $error,
+ 'msg' => lang('mahana_'.$error)
+ );
}
+ // ------------------------------------------------------------------------
+
+ /**
+ * Error Particpant Exists
+ *
+ * @return array
+ */
+ private function _participant_error($error = '')
+ {
+ return array(
+ 'err' => 1,
+ 'code' => 1,
+ 'msg' => lang('mahana_' . $error)
+ );
+ }
+
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * General Error
+ *
+ * @return array
+ */
+ private function _general_error()
+ {
+ return array(
+ 'err' => 1,
+ 'code' => MSG_ERR_GENERAL,
+ 'msg' => lang('mahana_'.MSG_ERR_GENERAL)
+ );
+ }
}
View
635 application/models/mahana_model.php
@@ -1,339 +1,510 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mahana_model extends CI_Model
{
+ /**
+ * Send a New Message
+ *
+ * @param integer $sender_id
+ * @param mixed $recipients A single integer or an array of integers
+ * @param string $subject
+ * @param string $body
+ * @param integer $priority
+ * @return boolean
+ */
+ function send_new_message($sender_id, $recipients, $subject, $body, $priority)
+ {
+ $this->db->trans_start();
- function send_new_message($sender_id, $recipients, $subject, $body, $priority){
-
- $this->db->trans_start();
+ $thread_id = $this->_insert_thread($subject);
+ $msg_id = $this->_insert_message($thread_id, $sender_id, $body, $priority);
- $thread_id = $this->_insert_thread($subject);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ // Create batch inserts
+ $participants[] = array('thread_id' => $thread_id,'user_id' => $sender_id);
+ $statuses[] = array('message_id' => $msg_id, 'user_id' => $sender_id,'status' => MSG_STATUS_READ);
- $msg_id = $this->_insert_message($thread_id, $sender_id, $body, $priority);
- if ($this->db->trans_status() === false)
+ if ( ! is_array($recipients))
+ {
+ $participants[] = array('thread_id' => $thread_id,'user_id' => $recipients);
+ $statuses[] = array('message_id' => $msg_id, 'user_id' => $recipients, 'status' => MSG_STATUS_UNREAD);
+ }
+ else
+ {
+ foreach ($recipients as $recipient)
{
- $this->db->trans_rollback();
- return false;
+ $participants[] = array('thread_id' => $thread_id,'user_id' => $recipient);
+ $statuses[] = array('message_id' => $msg_id, 'user_id' => $recipient, 'status' => MSG_STATUS_UNREAD);
}
+ }
- //create batch inserts
- $participants[] = array('thread_id'=>$thread_id,'user_id'=> $sender_id);
- $statuses[] = array('message_id'=>$msg_id, 'user_id'=> $sender_id,'status'=> MSG_STATUS_READ);
+ $this->_insert_participants($participants);
+ $this->_insert_statuses($statuses);
- if (!is_array($recipients))
- {
- $participants[] = array('thread_id'=>$thread_id,'user_id'=>$recipients);
- $statuses[] = array('message_id'=>$msg_id, 'user_id'=>$recipients, 'status'=>MSG_STATUS_UNREAD);
- }
- else
- {
- foreach ($recipients as $recipient)
- {
- $participants[] = array('thread_id'=>$thread_id,'user_id'=>$recipient);
- $statuses[] = array('message_id'=>$msg_id, 'user_id'=>$recipient, 'status'=>MSG_STATUS_UNREAD);
- }
- }
- $this->_insert_participants($participants);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ $this->db->trans_complete();
- $this->_insert_statuses($statuses);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ return FALSE;
+ }
- $this->db->trans_complete();
- return true;
+ return $thread_id;
}
- //reply to message
+ // ------------------------------------------------------------------------
+
+ /**
+ * Reply to Message
+ *
+ * @param integer $reply_msg_id
+ * @param integer $sender_id
+ * @param string $body
+ * @param integer $priority
+ * @return boolean
+ */
function reply_to_message($reply_msg_id, $sender_id, $body, $priority)
{
- $this->db->trans_start();
+ $this->db->trans_start();
- //get the thread id to keep messages together
- if (!($thread_id = $this->_get_thread_id_from_message($reply_msg_id)))
- {
- return false;
- }
+ // Get the thread id to keep messages together
+ if ( ! $thread_id = $this->_get_thread_id_from_message($reply_msg_id))
+ {
+ return FALSE;
+ }
- //add this message
- $msg_id = $this->_insert_message($thread_id, $sender_id, $body, $priority);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ // Add this message
+ $msg_id = $this->_insert_message($thread_id, $sender_id, $body, $priority);
+
+ if ($recipients = $this->_get_thread_participants($thread_id, $sender_id))
+ {
+ $statuses[] = array('message_id' => $msg_id, 'user_id' => $sender_id,'status' => MSG_STATUS_READ);
- if ($recipients = $this->_get_thread_participants($thread_id, $sender_id))
+ foreach ($recipients as $recipient)
{
- $statuses[] = array('message_id'=>$msg_id, 'user_id'=> $sender_id,'status'=> MSG_STATUS_READ);
- foreach ($recipients as $recipient)
- {
- $statuses[] = array('message_id'=>$msg_id, 'user_id'=>$recipient['user_id'], 'status'=>MSG_STATUS_UNREAD);
- }
- $this->_insert_statuses($statuses);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ $statuses[] = array('message_id' => $msg_id, 'user_id' => $recipient['user_id'], 'status' => MSG_STATUS_UNREAD);
}
- $this->db->trans_complete();
- return true;
+ $this->_insert_statuses($statuses);
+ }
+
+ $this->db->trans_complete();
+
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ return FALSE;
+ }
+
+ return TRUE;
}
- //get a single message
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get a Single Message
+ *
+ * @param integer $msg_id
+ * @param integer $user_id
+ * @return array
+ */
function get_message($msg_id, $user_id)
{
- $sql = 'SELECT m.*, s.status, t.subject, '.USER_TABLE_USERNAME .
- ' FROM msg_messages m ' .
- ' JOIN msg_threads t ON (m.thread_id = t.id) ' .
- ' JOIN ' .USER_TABLE_TABLENAME. ' ON ('.USER_TABLE_ID.' = m.sender_id) '.
- ' JOIN msg_status s ON (s.message_id = m.id AND s.user_id = ? ) ' .
- ' WHERE m.id = ? ' ;
-
- $query = $this->db->query($sql, array($user_id, $msg_id));
- return $query->result_array();
- }
+ $sql = 'SELECT m.*, s.status, t.subject, ' . USER_TABLE_USERNAME .
+ ' FROM ' . $this->db->dbprefix . 'msg_messages m ' .
+ ' JOIN ' . $this->db->dbprefix . 'msg_threads t ON (m.thread_id = t.id) ' .
+ ' JOIN ' . $this->db->dbprefix . USER_TABLE_TABLENAME . ' ON (' . USER_TABLE_ID . ' = m.sender_id) '.
+ ' JOIN ' . $this->db->dbprefix . 'msg_status s ON (s.message_id = m.id AND s.user_id = ? ) ' .
+ ' WHERE m.id = ? ' ;
- //get full thread
- function get_full_thread($thread_id, $user_id, $full_thread = false, $order_by='asc'){
- $sql = 'SELECT m.*, s.status, t.subject, '.USER_TABLE_USERNAME .
- ' FROM msg_participants p ' .
- ' JOIN msg_threads t ON (t.id = p.thread_id) ' .
- ' JOIN msg_messages m ON (m.thread_id = t.id) ' .
- ' JOIN ' .USER_TABLE_TABLENAME. ' ON ('.USER_TABLE_ID.' = m.sender_id) '.
- ' JOIN msg_status s ON (s.message_id = m.id AND s.user_id = ? ) ' .
- ' WHERE p.user_id = ? ' .
- ' AND p.thread_id = ? ';
- if (!$full_thread)
- {
- $sql .= ' AND m.cdate >= p.cdate';
- }
- $sql .= ' ORDER BY m.cdate '.$order_by;
+ $query = $this->db->query($sql, array($user_id, $msg_id));
- $query = $this->db->query($sql, array($user_id, $user_id, $thread_id)); //echo $this->db->last_query();
- return $query->result_array();
+ return $query->result_array();
}
- //get all threads
- function get_all_threads($user_id, $full_thread = false, $order_by='asc'){
- $sql = 'SELECT m.*, s.status, t.subject, '.USER_TABLE_USERNAME .
- ' FROM msg_participants p ' .
- ' JOIN msg_threads t ON (t.id = p.thread_id) ' .
- ' JOIN msg_messages m ON (m.thread_id = t.id) ' .
- ' JOIN ' .USER_TABLE_TABLENAME. ' ON ('.USER_TABLE_ID.' = m.sender_id) '.
- ' JOIN msg_status s ON (s.message_id = m.id AND s.user_id = ? ) ' .
- ' WHERE p.user_id = ? ' ;
- if (!$full_thread)
- {
- $sql .= ' AND m.cdate >= p.cdate';
- }
- $sql .= ' ORDER BY t.id '.$order_by. ', m.cdate '.$order_by;
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get a Full Thread
+ *
+ * @param integer $thread_id
+ * @param integer $user_id
+ * @param boolean $full_thread
+ * @param string $order_by
+ * @return array
+ */
+ function get_full_thread($thread_id, $user_id, $full_thread = FALSE, $order_by = 'asc')
+ {
+ $sql = 'SELECT m.*, s.status, t.subject, '.USER_TABLE_USERNAME .
+ ' FROM ' . $this->db->dbprefix . 'msg_participants p ' .
+ ' JOIN ' . $this->db->dbprefix . 'msg_threads t ON (t.id = p.thread_id) ' .
+ ' JOIN ' . $this->db->dbprefix . 'msg_messages m ON (m.thread_id = t.id) ' .
+ ' JOIN ' . $this->db->dbprefix . USER_TABLE_TABLENAME . ' ON (' . USER_TABLE_ID . ' = m.sender_id) '.
+ ' JOIN ' . $this->db->dbprefix . 'msg_status s ON (s.message_id = m.id AND s.user_id = ? ) ' .
+ ' WHERE p.user_id = ? ' .
+ ' AND p.thread_id = ? ';
+
+ if ( ! $full_thread)
+ {
+ $sql .= ' AND m.cdate >= p.cdate';
+ }
- $query = $this->db->query($sql, array($user_id, $user_id));
- return $query->result_array();
+ $sql .= ' ORDER BY m.cdate ' . $order_by;
+
+ $query = $this->db->query($sql, array($user_id, $user_id, $thread_id));
+
+ return $query->result_array();
}
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get All Threads
+ *
+ * @param integer $user_id
+ * @param boolean $full_thread
+ * @param string $order_by
+ * @return array
+ */
+ function get_all_threads($user_id, $full_thread = FALSE, $order_by = 'asc')
+ {
+ $sql = 'SELECT m.*, s.status, t.subject, '.USER_TABLE_USERNAME .
+ ' FROM ' . $this->db->dbprefix . 'msg_participants p ' .
+ ' JOIN ' . $this->db->dbprefix . 'msg_threads t ON (t.id = p.thread_id) ' .
+ ' JOIN ' . $this->db->dbprefix . 'msg_messages m ON (m.thread_id = t.id) ' .
+ ' JOIN ' . $this->db->dbprefix . USER_TABLE_TABLENAME . ' ON (' . USER_TABLE_ID . ' = m.sender_id) '.
+ ' JOIN ' . $this->db->dbprefix . 'msg_status s ON (s.message_id = m.id AND s.user_id = ? ) ' .
+ ' WHERE p.user_id = ? ' ;
+
+ if (!$full_thread)
+ {
+ $sql .= ' AND m.cdate >= p.cdate';
+ }
+
+ $sql .= ' ORDER BY t.id ' . $order_by. ', m.cdate '. $order_by;
- //change message status
- function update_message_status($msg_id, $user_id, $status_id )
+ $query = $this->db->query($sql, array($user_id, $user_id));
+
+ return $query->result_array();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Change Message Status
+ *
+ * @param integer $msg_id
+ * @param integer $user_id
+ * @param integer $status_id
+ * @return integer
+ */
+ function update_message_status($msg_id, $user_id, $status_id)
{
- $this->db->where(array('message_id'=>$msg_id, 'user_id'=>$user_id ));
- $this->db->update('msg_status', array('status'=>$status_id ));
- return $this->db->affected_rows();
+ $this->db->where(array('message_id' => $msg_id, 'user_id' => $user_id ));
+ $this->db->update('msg_status', array('status' => $status_id ));
+
+ return $this->db->affected_rows();
}
+ // ------------------------------------------------------------------------
- //add participant
+ /**
+ * Add a Participant
+ *
+ * @param integer $thread_id
+ * @param integer $user_id
+ * @return boolean
+ */
function add_participant($thread_id, $user_id)
{
- $this->db->trans_start();
+ $this->db->trans_start();
- $participants[] = array('thread_id'=>$thread_id,'user_id'=>$user_id);
- $this->_insert_participants($participants);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ $participants[] = array('thread_id' => $thread_id,'user_id' => $user_id);
- //get messages by thread
- $messages = $this->_get_messages_by_thread_id($thread_id);
+ $this->_insert_participants($participants);
- foreach ($messages as $message)
- {
- $statuses[] = array('message_id'=>$message['id'], 'user_id'=>$user_id, 'status'=>MSG_STATUS_UNREAD);
- }
-
- $this->_insert_statuses($statuses);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ // Get Messages by Thread
+ $messages = $this->_get_messages_by_thread_id($thread_id);
- $this->db->trans_complete();
- return true;
+ foreach ($messages as $message)
+ {
+ $statuses[] = array('message_id' => $message['id'], 'user_id' => $user_id, 'status' => MSG_STATUS_UNREAD);
+ }
+
+ $this->_insert_statuses($statuses);
+
+ $this->db->trans_complete();
+
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ return FALSE;
+ }
+
+ return TRUE;
}
+ // ------------------------------------------------------------------------
+
+ /**
+ * Remove a Participant
+ *
+ * @param integer $thread_id
+ * @param integer $user_id
+ * @return boolean
+ */
function remove_participant($thread_id, $user_id)
{
- $this->db->trans_start();
+ $this->db->trans_start();
- $return = $this->_delete_participant($thread_id, $user_id);
- if (($return === false) || $this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ $this->_delete_participant($thread_id, $user_id);
+ $this->_delete_statuses($thread_id, $user_id);
- $this->_delete_statuses($thread_id, $user_id);
- if ($this->db->trans_status() === false)
- {
- $this->db->trans_rollback();
- return false;
- }
+ $this->db->trans_complete();
+
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ return FALSE;
+ }
- $this->db->trans_complete();
- return true;
+ return TRUE;
}
- // because of CodeIgniter's DB Class return style, it is safer to check for uniqueness first
+ // ------------------------------------------------------------------------
+
+ /**
+ * Valid New Participant - because of CodeIgniter's DB Class return style,
+ * it is safer to check for uniqueness first
+ *
+ * @param integer $thread_id
+ * @param integer $user_id
+ * @return boolean
+ */
function valid_new_participant($thread_id, $user_id)
{
- $sql = 'SELECT COUNT(*) AS count ' .
- ' FROM msg_participants p ' .
- ' WHERE p.thread_id = ? ' .
- ' AND p.user_id = ? ';
- $query = $this->db->query($sql, array($thread_id, $user_id));
- if ($query->row()->count)
- {
- return false;
- }
- return true;
+ $sql = 'SELECT COUNT(*) AS count ' .
+ ' FROM ' . $this->db->dbprefix . 'msg_participants p ' .
+ ' WHERE p.thread_id = ? ' .
+ ' AND p.user_id = ? ';
+
+ $query = $this->db->query($sql, array($thread_id, $user_id));
+
+ if ($query->row()->count)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
}
+ // ------------------------------------------------------------------------
+
+ /**
+ * Application User
+ *
+ * @param integer $user_id`
+ * @return boolean
+ */
function application_user($user_id)
{
- $sql = 'SELECT COUNT(*) AS count ' .
- ' FROM ' . USER_TABLE_TABLENAME .
- ' WHERE ' . USER_TABLE_ID . ' = ?' ;
- $query = $this->db->query($sql, array($user_id));
- if ($query->row()->count)
- {
- return true;
- }
- return false;
- }
+ $sql = 'SELECT COUNT(*) AS count ' .
+ ' FROM ' . $this->db->dbprefix . USER_TABLE_TABLENAME .
+ ' WHERE ' . USER_TABLE_ID . ' = ?' ;
+
+ $query = $this->db->query($sql, array($user_id));
+
+ if ($query->row()->count)
+ {
+ return TRUE;
+ }
- function get_participant_list($thread_id, $sender_id =0)
+ return FALSE;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get Participant List
+ *
+ * @param integer $thread_id
+ * @param integer $sender_id
+ * @return mixed
+ */
+ function get_participant_list($thread_id, $sender_id = 0)
{
- if ($results = $this->_get_thread_participants($thread_id, $sender_id)) {
+ if ($results = $this->_get_thread_participants($thread_id, $sender_id))
+ {
return $results;
}
- return false;
+ return FALSE;
}
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get Message Count
+ *
+ * @param integer $user_id
+ * @param integer $status_id
+ * @return integer
+ */
function get_msg_count($user_id, $status_id = MSG_STATUS_UNREAD)
{
- $query = $this->db->select('COUNT(*) AS msg_count')->where(array('user_id'=>$user_id, 'status'=>$status_id ))->get('msg_status');
+ $query = $this->db->select('COUNT(*) AS msg_count')->where(array('user_id' => $user_id, 'status' => $status_id ))->get('msg_status');
+
return $query->row()->msg_count;
}
+ // ------------------------------------------------------------------------
+ // Private Functions from here out!
+ // ------------------------------------------------------------------------
- //
- //***** private functions *****//
- //
-
+ /**
+ * Insert Thread
+ *
+ * @param string $subject
+ * @return integer
+ */
private function _insert_thread($subject)
{
- $insert_id = $this->db->insert('msg_threads', array('subject'=>$subject));
- return $this->db->insert_id();
+ $insert_id = $this->db->insert('msg_threads', array('subject' => $subject));
+
+ return $this->db->insert_id();
}
+ /**
+ * Insert Message
+ *
+ * @param integer $thread_id
+ * @param integer $sender_id
+ * @param string $body
+ * @param integer $priority
+ * @return integer
+ */
private function _insert_message($thread_id, $sender_id, $body, $priority)
{
- $insert['thread_id'] = $thread_id;
- $insert['sender_id'] = $sender_id;
- $insert['body'] = $body;
- $insert['priority'] = $priority;
+ $insert['thread_id'] = $thread_id;
+ $insert['sender_id'] = $sender_id;
+ $insert['body'] = $body;
+ $insert['priority'] = $priority;
- $insert_id = $this->db->insert('msg_messages', $insert);
- return $this->db->insert_id();
+ $insert_id = $this->db->insert('msg_messages', $insert);
+
+ return $this->db->insert_id();
}
+ /**
+ * Insert Participants
+ *
+ * @param array $participants
+ * @return bool
+ */
private function _insert_participants($participants)
{
- return $this->db->insert_batch('msg_participants', $participants);
+ return $this->db->insert_batch('msg_participants', $participants);
}
+ /**
+ * Insert Statuses
+ *
+ * @param array $statuses
+ * @return bool
+ */
private function _insert_statuses($statuses)
{
- return $this->db->insert_batch('msg_status', $statuses);
+ return $this->db->insert_batch('msg_status', $statuses);
}
- private function _get_thread_id_from_message($msg_id){
- $query = $this->db->select('thread_id')->get_where('msg_messages', array('id' => $msg_id));
- if ($query->num_rows()){
- return $query->row()->thread_id;
- }
- return 0;
+ /**
+ * Get Thread ID from Message
+ *
+ * @param integer $msg_id
+ * @return integer
+ */
+ private function _get_thread_id_from_message($msg_id)
+ {
+ $query = $this->db->select('thread_id')->get_where('msg_messages', array('id' => $msg_id));
+
+ if ($query->num_rows())
+ {
+ return $query->row()->thread_id;
+ }
+ return 0;
}
+ /**
+ * Get Messages by Thread
+ *
+ * @param integer $thread_id
+ * @return array
+ */
private function _get_messages_by_thread_id($thread_id)
{
- $query = $this->db->get_where('msg_messages', array('thread_id' => $thread_id));
- return $query->result_array();
+ $query = $this->db->get_where('msg_messages', array('thread_id' => $thread_id));
+
+ return $query->result_array();
}
- private function _get_thread_participants($thread_id, $sender_id=0)
+ /**
+ * Get Thread Particpiants
+ *
+ * @param integer $thread_id
+ * @param integer $sender_id
+ * @return array
+ */
+ private function _get_thread_participants($thread_id, $sender_id = 0)
{
- $array['thread_id'] = $thread_id;
- if ($sender_id) //if $sender_id 0, no one to exclude
- {
- $array['msg_participants.user_id != '] = $sender_id;
- }
-
- $this->db->select('msg_participants.user_id, '.USER_TABLE_USERNAME, false);
- $this->db->join(USER_TABLE_TABLENAME,'msg_participants.user_id ='.USER_TABLE_ID);
- $query = $this->db->get_where('msg_participants', $array);
-
- return $query->result_array();
+ $array['thread_id'] = $thread_id;
+
+ if ($sender_id) // If $sender_id 0, no one to exclude
+ {
+ $array['msg_participants.user_id != '] = $sender_id;
+ }
+
+ $this->db->select('msg_participants.user_id, '.USER_TABLE_USERNAME, FALSE);
+ $this->db->join(USER_TABLE_TABLENAME, 'msg_participants.user_id = ' . USER_TABLE_ID);
+
+ $query = $this->db->get_where('msg_participants', $array);
+
+ return $query->result_array();
}
+ /**
+ * Delete Participant
+ *
+ * @param integer $thread_id
+ * @param integer $user_id
+ * @return boolean
+ */
private function _delete_participant($thread_id, $user_id)
{
- $this->db->delete('msg_participants', array('thread_id'=>$thread_id, 'user_id'=>$user_id));
- if ($this->db->affected_rows() > 0)
- {
- return true;
- }
- return false;
+ $this->db->delete('msg_participants', array('thread_id' => $thread_id, 'user_id' => $user_id));
+
+ if ($this->db->affected_rows() > 0)
+ {
+ return TRUE;
+ }
+ return FALSE;
}
+ /**
+ * Delete Statuses
+ *
+ * @param integer $thread_id
+ * @param integer $user_id
+ * @return boolean
+ */
private function _delete_statuses($thread_id, $user_id)
{
- $sql = 'DELETE s FROM msg_status s ' .
- ' JOIN msg_messages m ON (m.id = s.message_id) ' .
- ' WHERE m.thread_id = ? ' .
- ' AND s.user_id = ? ';
- $query = $this->db->query($sql, array($thread_id, $user_id));
- return true;
+ $sql = 'DELETE s FROM msg_status s ' .
+ ' JOIN ' . $this->db->dbprefix . 'msg_messages m ON (m.id = s.message_id) ' .
+ ' WHERE m.thread_id = ? ' .
+ ' AND s.user_id = ? ';
+
+ $query = $this->db->query($sql, array($thread_id, $user_id));
+
+ return TRUE;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.