public function logActivity($user_id, $action, $context, $message)
{
if (method_exists($this->router, 'fetch_module')) {
$this->_module = $this->router->fetch_module();
}
if (is_numeric($user_id) and is_string($action) and is_string($message)) {
// set the current domain (e.g admin, main, module)
$domain = !empty($this->_module) ? 'module' : APPDIR;
// set user if customer is logged in and the domain is not admin
$user = 'staff';
if ($domain !== ADMINDIR) {
$this->load->library('customer');
if ($this->customer->islogged()) {
$user = 'customer';
}
}
$this->db->set('user', $user);
$this->db->set('domain', $domain);
$this->db->set('context', $context);
if (is_numeric($user_id)) {
$this->db->set('user_id', $user_id);
}
if (is_string($action)) {
$this->db->set('action', $action);
}
if (is_string($message)) {
$this->db->set('message', $message);
}
$this->db->set('date_added', mdate('%Y-%m-%d %H:%i:%s', time()));
$this->db->insert('activities');
}
}