Changeset 56
- Timestamp:
- 04/12/07 04:57:54
- Files:
-
- FreakAuth/trunk/www/system/application/controllers/example.php (modified) (1 diff)
- FreakAuth/trunk/www/system/application/helpers/freakauth_light_helper.php (modified) (1 diff)
- FreakAuth/trunk/www/system/application/libraries/Freakauth_light.php (modified) (9 diffs)
- FreakAuth/trunk/www/system/language/english/freakauth_lang.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
FreakAuth/trunk/www/system/application/controllers/example.php
r2 r56 16 16 17 17 echo '<h1>You can view this message because you logged in and are at least an user!</h1>'; 18 } 19 18 echo 'You are <b>'.getUserName().'</b> (role:<b>'.getUserProperty('role').'</b>),'; 19 echo ' your id is <b>'.getUserProperty('id').'</b>.<br />'; 20 echo 'Your superadmin is <b>'.getUserPropertyFromId(1,'user_name').'</b>.'; 21 } 20 22 } 21 23 ?> FreakAuth/trunk/www/system/application/helpers/freakauth_light_helper.php
r7 r56 35 35 $obj =& get_instance(); 36 36 return $obj->freakauth_light->getUserName(); 37 } 38 39 // ------------------------------------------------------------------------ 40 // 41 // Returns the currently logged on user's prop. 42 // Returns an empty string if no user is logged in. 43 // 44 function getUserProperty($prop) 45 { 46 $obj =& get_instance(); 47 return $obj->freakauth_light->getUserProperty($prop); 48 } 49 50 // ------------------------------------------------------------------------ 51 // 52 // Returns the prop of the user identified by $id 53 // Returns a message if the user does not exist 54 // Returns an empty string if $prop is unknown. 55 // 56 function getUserPropertyFromId($id, $prop) 57 { 58 $obj =& get_instance(); 59 return $obj->freakauth_light->getUserPropertyFromId($id, $prop); 37 60 } 38 61 FreakAuth/trunk/www/system/application/libraries/Freakauth_light.php
r20 r56 194 194 if ($this->CI->db_session AND $this->CI->config->item('FAL')) 195 195 { 196 $_username = $this->CI->db_session->userdata('user name');196 $_username = $this->CI->db_session->userdata('user_name'); 197 197 $_role = $this->CI->db_session->userdata('role'); 198 198 … … 222 222 if ($this->CI->db_session AND $this->CI->config->item('FAL')) 223 223 { 224 $_username = $this->CI->db_session->userdata('user name');224 $_username = $this->CI->db_session->userdata('user_name'); 225 225 $_role = $this->CI->db_session->userdata('role'); 226 226 … … 246 246 if ($this->CI->db_session AND $this->CI->config->item('FAL')) 247 247 { 248 $_username = $this->CI->db_session->userdata('user name');248 $_username = $this->CI->db_session->userdata('user_name'); 249 249 $_role = $this->CI->db_session->userdata('role'); 250 250 … … 281 281 if ($this->CI->db_session AND $this->CI->config->item('FAL')) 282 282 { 283 $_username = $this->CI->db_session->userdata('user name');283 $_username = $this->CI->db_session->userdata('user_name'); 284 284 $_who_is = $this->CI->db_session->userdata('role'); 285 285 … … 369 369 { 370 370 $row = $query->row(); 371 $ userdata['id'] = $row->{'id'};372 $userdata['username'] = $row->{'user_name'};373 $userdata['role'] = $row->{'role'};374 $banned = $row->{'banned'}; 371 $fields = array('id', 'user_name', 'country_id', 'email', 372 'role', 'last_visit', 'created', 'modified'); 373 foreach($fields as $field) $userdata[$field] = $row->{$field}; 374 375 375 //verifies if an user has not been banned from the site (i.e. user table, banned=1) 376 if ($ banned== 0)376 if ($row->{'banned'} == 0) 377 377 { 378 378 $this->_set_logindata($userdata); … … 408 408 if ($this->CI->db_session) 409 409 { 410 $_username = $this->CI->db_session->userdata('user name');410 $_username = $this->CI->db_session->userdata('user_name'); 411 411 412 412 if ($_username != false) … … 705 705 function _unset_user($_username) 706 706 { 707 $users = $this->CI->db_session->userdata('user name');707 $users = $this->CI->db_session->userdata('user_name'); 708 708 709 709 if (isset($users)) … … 712 712 //is better to do a 1 call to unset_userdata passing an array? 713 713 $this->CI->db_session->unset_userdata('id'); 714 $this->CI->db_session->unset_userdata('user name');714 $this->CI->db_session->unset_userdata('user_name'); 715 715 $this->CI->db_session->unset_userdata('role'); 716 716 } … … 764 764 765 765 // returns username string of currently logged in user 766 return $this->CI->db_session->userdata('user name');766 return $this->CI->db_session->userdata('user_name'); 767 767 768 768 // returns empty string if user not logged in 769 769 return ''; 770 } 771 772 // -------------------------------------------------------------------- 773 774 /** 775 * Returns the currently logged in user's prop 776 * Returns an empty string if no user is logged in 777 * uses function isValidUser() 778 * and Class db_session method "userdata". 779 * 780 * @return prop string of currently logged in user 781 * @return empty string if user not logged in 782 */ 783 function getUserProperty($prop) 784 { 785 if ($this->CI->config->item('FAL') && $this->CI->db_session && ($this->isValidUser() OR $this->isAdmin())) 786 787 // returns property string of currently logged in user 788 return $this->CI->db_session->userdata($prop); 789 790 // returns empty string if user not logged in 791 return ''; 792 } 793 794 795 /** 796 * Returns the prop of the user identified by $id 797 * Returns an empty string if no user is logged in 798 * uses function isValidUser() 799 * and Class db_session method "userdata". 800 * 801 * @return prop string of currently logged in user 802 * @return empty string if user not logged in 803 */ 804 function getUserPropertyFromId($id, $prop) 805 { 806 $query = $this->CI->usermodel->getUserById($id); 807 if ($query->num_rows() == 1) 808 { 809 $row = $query->row(); 810 if (isset($row->{$prop})) return $row->{$prop}; 811 else return ''; 812 } 813 else 814 { 815 $this->CI->lang->load('freakauth'); 816 return $this->CI->lang->line('FAL_unknown_user'); 817 } 770 818 } 771 819 FreakAuth/trunk/www/system/language/english/freakauth_lang.php
r40 r56 38 38 $lang['FAL_citation_message'] = 'Thank You!'; 39 39 $lang['FAL_already_logged_in_msg'] = 'you have already logged in!'; 40 41 $lang['FAL_unknown_user'] = 'utilisateur inconnu'; 40 42 41 43 //------------------------------------------------------------------
