Exemplo n.º 1
0
 function __construct()
 {
     parent::__construct();
     if ($this->_history === '') {
         $this->_history = $this->_name . '_hist';
     }
 }
Exemplo n.º 2
0
 function __construct()
 {
     parent::__construct();
     $this->hooks->add_hook('user:post_login', function (&$user = null) {
         if (!isset($user)) {
             return;
         }
         $CI =& get_instance();
         $that = $CI->_model('user');
         if (!empty($user['id'])) {
             // add roles
             $sql = '
                 SELECT g.*, g.id role_id FROM ' . $that->_db()->dbprefix . 'user_role ug
                 JOIN ' . $that->_db()->_protect_identifiers($that->_db()->dbprefix . 'role') . ' g ON ug.role_id = g.id
                 WHERE user_id = ?
                 AND g.status = 1
             ';
             $user['roles'] = $that->_db()->query($sql, array($user['id']))->result_array();
             // add organization
             $sql = '
                 SELECT o.*, o.id org_id FROM ' . $that->_db()->dbprefix . 'user_organization uo
                 JOIN ' . $that->_db()->dbprefix . 'organization o ON uo.org_id = o.id
                 WHERE user_id = ?
             ';
             $user['organization'] = $that->_db()->query($sql, array($user['id']))->result_array();
             $user['is_top_member'] = false;
             foreach ($user['organization'] as $org) {
                 if ($org['id'] == 1) {
                     $user['is_top_member'] = true;
                     break;
                 }
             }
             $d = array('last_login' => date('Y-m-d H:i:s'));
             $user['last_login'] = $d['last_login'];
             $that->save($d, $user['id']);
         }
     });
 }