Changeset 648
- Timestamp:
- Dec 20, 2004, 1:30:36 PM (20 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/constants.php
r593 r648 58 58 define('IMAGE_METADATA_TABLE', $table_prefix.'image_metadata'); 59 59 define('RATE_TABLE', $table_prefix.'rate'); 60 define('USER_FORBIDDEN_TABLE', $table_prefix.'user_forbidden'); 60 61 ?> -
trunk/include/functions_user.inc.php
r647 r648 277 277 } 278 278 } 279 280 /** 281 * update table user_forbidden for the given user 282 * 283 * table user_forbidden contains calculated data. Calculation is based on 284 * private categories minus categories authorized to the groups the user 285 * belongs to minus the categories directly authorized to the user 286 * 287 * @param int user_id 288 * @return string forbidden_categories 289 */ 290 function calculate_permissions($user_id) 291 { 292 $private_array = array(); 293 $authorized_array = array(); 294 295 $query = ' 296 SELECT id 297 FROM '.CATEGORIES_TABLE.' 298 WHERE status = \'private\' 299 ;'; 300 $result = pwg_query($query); 301 while ($row = mysql_fetch_array($result)) 302 { 303 array_push($private_array, $row['id']); 304 } 305 306 // retrieve category ids directly authorized to the user 307 $query = ' 308 SELECT cat_id 309 FROM '.USER_ACCESS_TABLE.' 310 WHERE user_id = '.$user_id.' 311 ;'; 312 $result = pwg_query($query); 313 while ($row = mysql_fetch_array($result)) 314 { 315 array_push($authorized_array, $row['cat_id']); 316 } 317 318 // retrieve category ids authorized to the groups the user belongs to 319 $query = ' 320 SELECT cat_id 321 FROM '.USER_GROUP_TABLE.' AS ug INNER JOIN '.GROUP_ACCESS_TABLE.' AS ga 322 ON ug.group_id = ga.group_id 323 WHERE ug.user_id = '.$user_id.' 324 ;'; 325 $result = pwg_query($query); 326 while ($row = mysql_fetch_array($result)) 327 { 328 array_push($authorized_array, $row['cat_id']); 329 } 330 331 // uniquify ids : some private categories might be authorized for the 332 // groups and for the user 333 $authorized_array = array_unique($authorized_array); 334 335 // only unauthorized private categories are forbidden 336 $forbidden_array = array_diff($private_array, $authorized_array); 337 338 $query = ' 339 DELETE FROM '.USER_FORBIDDEN_TABLE.' 340 WHERE user_id = '.$user_id.' 341 ;'; 342 pwg_query($query); 343 344 $forbidden_categories = implode(',', $forbidden_array); 345 346 $query = ' 347 INSERT INTO '.USER_FORBIDDEN_TABLE.' 348 (user_id,need_update,forbidden_categories) 349 VALUES 350 ('.$user_id.',\'false\',\''.$forbidden_categories.'\') 351 ;'; 352 pwg_query($query); 353 354 return $forbidden_categories; 355 } 279 356 ?> -
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 ?> -
trunk/install/dbscheme.txt
r647 r648 13 13 table:sites 14 14 table:user_access 15 table:user_forbidden 15 16 table:user_group 16 17 table:users … … 84 85 column:user_id table:user_access type:smallint nullable:N length:5 signed:N 85 86 column:cat_id table:user_access type:smallint nullable:N length:5 signed:N 87 column:user_id table:user_forbidden type:smallint nullable:N length:5 signed:N 88 column:need_update table:user_forbidden type:enum('true','false') nullable:N 89 column:forbidden_categories table:user_forbidden type:text nullable:Y 86 90 column:user_id table:user_group type:smallint nullable:N length:5 signed:N 87 91 column:group_id table:user_group type:smallint nullable:N length:5 signed:N … … 100 104 column:recent_period table:users type:tinyint nullable:N length:3 signed:N 101 105 column:template table:users type:varchar nullable:N length:255 binary:N 102 column:forbidden_categories table:users type:text nullable:Y103 106 column:id table:waiting type:int nullable:N length:10 signed:N 104 107 column:storage_category_id table:waiting type:smallint nullable:N length:5 signed:N … … 128 131 PK:user_access_pk table:user_access column:user_id 129 132 PK:user_access_pk table:user_access column:cat_id 133 PK:user_forbidden_pk table:user_forbidden column:user_id 130 134 PK:user_group_pk table:user_group column:group_id 131 135 PK:user_group_pk table:user_group column:user_id -
trunk/install/phpwebgallery_structure.sql
r647 r648 199 199 200 200 -- 201 -- Table structure for table 'phpwebgallery_user_forbidden' 202 -- 203 204 DROP TABLE IF EXISTS phpwebgallery_user_forbidden; 205 CREATE TABLE phpwebgallery_user_forbidden ( 206 user_id smallint(5) unsigned NOT NULL default '0', 207 need_update enum('true','false') NOT NULL default 'true', 208 forbidden_categories text, 209 PRIMARY KEY (user_id) 210 ) TYPE=MyISAM; 211 212 -- 201 213 -- Table structure for table 'phpwebgallery_user_group' 202 214 -- … … 229 241 recent_period tinyint(3) unsigned NOT NULL default '7', 230 242 template varchar(255) NOT NULL default 'default', 231 forbidden_categories text,232 243 PRIMARY KEY (id), 233 244 UNIQUE KEY users_ui1 (username) -
trunk/picture.php
r642 r648 417 417 } 418 418 419 $picture_size = get_picture_size( 420 $user['maxwidth'], $user['maxheight']);419 $picture_size = get_picture_size($original_width, $original_height, 420 @$user['maxwidth'], @$user['maxheight']); 421 421 422 422 // metadata -
trunk/template/default/footer.tpl
r531 r648 1 1 <div class="copyright"> 2 2 <!-- BEGIN debug --> 3 {L_GEN_TIME} {TIME} ::3 {L_GEN_TIME} {TIME} - 4 4 <!-- END debug --> 5 5 … … 9 9 10 10 Powered by <a href="http://www.phpwebgallery.net" class="back">PhpWebGallery</a> 11 {VERSION} ::11 {VERSION} - 12 12 13 13 {L_SEND_MAIL}
Note: See TracChangeset
for help on using the changeset viewer.