Browse Source

create log functions

change
artem 6 years ago
parent
commit
e11792e7e1
  1. 1
      application/config/aauth.php
  2. 30
      application/libraries/Aauth.php
  3. 1
      sql/Aauth_v2_BCrypt.sql

1
application/config/aauth.php

@ -100,6 +100,7 @@ $config_aauth["default"] = array(
'pms' => 'aauth_chatmsg', 'pms' => 'aauth_chatmsg',
'user_variables' => 'aauth_user_variables', 'user_variables' => 'aauth_user_variables',
'login_attempts' => 'aauth_login_attempts', 'login_attempts' => 'aauth_login_attempts',
'log' => 'aauth_log',
'remember' => ' +3 days', 'remember' => ' +3 days',

30
application/libraries/Aauth.php

@ -2618,6 +2618,36 @@ class Aauth {
return true; return true;
} }
} }
/**
* Add log user text info
* @param string $text ; is a log text
* @param int $user_id ; if not given current user
*/
public function add_log_user($text,$user_id=false){
if (!$user_id){
$user_id=$this->CI->session->userdata('id');
}
$data=array(
'user_id'=>$user_id,
'text'=>$text,
);
$this->aauth_db->insert($this->config_vars['log'], $data);
}
/**
* List User logs by UserID
* Return array log or FALSE
* @param int $user_id ; if not given current user
* @return bool|array, FALSE if no user vars, otherwise array
*/
public function get_log_user($user_id=false){
$this->aauth_db->select('*')->from($this->config_vars['log']);
if ($user_id){
$this->aauth_db->where("user_id",$user_id);
}
$query = $this->aauth_db->get();
return $query->result();
}
} // end class } // end class

1
sql/Aauth_v2_BCrypt.sql

@ -85,6 +85,7 @@ CREATE TABLE `aauth_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL,
`text` text NOT NULL, `text` text NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `aauth_log_FK` (`user_id`), KEY `aauth_log_FK` (`user_id`),
CONSTRAINT `aauth_log_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE CONSTRAINT `aauth_log_FK` FOREIGN KEY (`user_id`) REFERENCES `aauth_users` (`id`) ON DELETE CASCADE

Loading…
Cancel
Save