Changeset 648 for trunk/include/user.inc.php
- Timestamp:
- Dec 20, 2004, 1:30:36 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/user.inc.php
r647 r648 26 26 // +-----------------------------------------------------------------------+ 27 27 28 // retrieving user informations 29 // $infos array is used to know the fields to retrieve in the table "users" 30 // Each field becomes an information of the array $user. 31 // Example : 32 // status --> $user['status'] 33 $infos = array('id','username','mail_address','nb_image_line','nb_line_page', 34 'status','language','maxwidth','maxheight','expand', 35 'show_nb_comments','recent_period','template', 36 'forbidden_categories'); 37 38 $query_user = 'SELECT * FROM '.USERS_TABLE; 39 $query_done = false; 40 $user['is_the_guest'] = false; 28 // retrieving connected user informations 41 29 42 30 if (isset($_COOKIE['id'])) … … 80 68 else 81 69 { 82 $ query_user .= ' WHERE id = '.$row['user_id'];83 $ query_done = true;70 $user['id'] = $row['user_id']; 71 $user['is_the_guest'] = false; 84 72 } 85 73 } 86 74 } 87 if (! $query_done)75 if (!isset($user['id'])) 88 76 { 89 $ query_user .= ' WHERE id = 2';77 $user['id'] = 2; 90 78 $user['is_the_guest'] = true; 91 79 } 92 $query_user .= ';';93 $row = mysql_fetch_array(pwg_query($query_user));94 80 95 // affectation of each value retrieved in the users table into a variable 96 // of the array $user. 97 foreach ($infos as $info) { 98 if (isset($row[$info])) 81 $query = ' 82 SELECT u.*, uf.* 83 FROM '.USERS_TABLE.' AS u LEFT JOIN '.USER_FORBIDDEN_TABLE.' AS uf 84 ON id = user_id 85 WHERE u.id = '.$user['id'].' 86 ;'; 87 $row = mysql_fetch_array(pwg_query($query)); 88 89 // affectation of each value retrieved in the users table into a variable of 90 // the array $user. 91 foreach ($row as $key => $value) 92 { 93 if (!is_numeric($key)) 99 94 { 100 95 // If the field is true or false, the variable is transformed into a 101 96 // boolean value. 102 if ($row[$info] == 'true' or $row[$info] == 'false') 103 $user[$info] = get_boolean($row[$info]); 97 if ($value == 'true' or $value == 'false') 98 { 99 $user[$key] = get_boolean($value); 100 } 104 101 else 105 $user[$info] = $row[$info]; 102 { 103 $user[$key] = $value; 104 } 106 105 } 107 else 108 { 109 $user[$info] = ''; 110 } 106 } 107 108 // if no information were found about user in user_forbidden table OR the 109 // forbidden categories must be updated 110 if (!isset($user['need_update']) 111 or !is_bool($user['need_update']) 112 or $user['need_update'] == true) 113 { 114 $user['forbidden_categories'] = calculate_permissions($user['id']); 115 } 116 117 // forbidden_categories is a must be empty, at least 118 if (!isset($user['forbidden_categories'])) 119 { 120 $user['forbidden_categories'] = ''; 111 121 } 112 122 … … 121 131 if ($user['status'] == 'admin') 122 132 { 123 $isadmin = true;133 $isadmin = true; 124 134 } 125 135 // calculation of the number of picture to display per page 126 136 $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; 137 127 138 init_userprefs($user); 128 139 ?>
Note: See TracChangeset
for help on using the changeset viewer.