Changeset 23085 for extensions/community/include
- Timestamp:
- Jun 7, 2013, 2:41:14 PM (11 years ago)
- Location:
- extensions/community/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/community/include/functions_community.inc.php
r23037 r23085 24 24 function community_get_user_permissions($user_id) 25 25 { 26 // echo __FUNCTION__.' => call for user '.$user_id.'<br>'; 27 26 28 global $conf, $user; 27 29 … … 49 51 'upload_whole_gallery' => false, 50 52 'create_whole_gallery' => false, 53 'user_album' => false, 51 54 'create_categories' => array(), 52 55 'upload_categories' => array(), … … 68 71 SELECT 69 72 id, 73 type, 70 74 category_id, 75 user_album, 71 76 recursive, 72 77 create_subcategories, … … 98 103 { 99 104 array_push($return['permission_ids'], $row['id']); 100 101 if (empty($row['category_id'])) 102 { 103 $return ['upload_whole_gallery'] = true; 104 } 105 else 106 { 107 array_push($return['upload_categories'], $row['category_id']); 108 109 if ('true' == $row['recursive']) 110 { 111 array_push($recursive_categories, $row['category_id']); 105 106 if ('false' == $row['user_album']) 107 { 108 if (empty($row['category_id'])) 109 { 110 $return['upload_whole_gallery'] = true; 111 } 112 else 113 { 114 array_push($return['upload_categories'], $row['category_id']); 115 116 if ('true' == $row['recursive']) 117 { 118 array_push($recursive_categories, $row['category_id']); 119 } 112 120 } 113 121 } … … 149 157 $return['storage'] = $row['storage']; 150 158 } 159 } 160 161 if ($conf['community']['user_albums'] and 'any_visitor' != $row['type']) 162 { 163 $return['user_album'] = true; 151 164 } 152 165 } … … 237 250 } 238 251 252 if ($return['user_album']) 253 { 254 $user_album_category_id = community_get_user_album($user_id); 255 256 if (!empty($user_album_category_id) and !in_array($user_album_category_id, $return['upload_categories'])) 257 { 258 array_push($return['upload_categories'], $user_album_category_id); 259 } 260 } 261 262 // is the user allowed to use community upload? 263 if (count($return['upload_categories']) > 0 or $return['create_whole_gallery'] or $return['user_album']) 264 { 265 $return['community_enabled'] = true; 266 } 267 else 268 { 269 $return['community_enabled'] = false; 270 } 271 239 272 $_SESSION['community_user_permissions'] = $return; 240 273 $_SESSION['community_cache_key'] = $cache_key; 241 274 $_SESSION['community_user_id'] = $user_id; 242 275 276 // echo __FUNCTION__.' => cache reset for user '.$user_id.'<br>'; 277 243 278 return $_SESSION['community_user_permissions']; 279 } 280 281 /** 282 * return the user album category_id. The album is automatically created if 283 * it does not exist (or has been deleted) 284 */ 285 function community_get_user_album($user_id) 286 { 287 global $conf; 288 289 $user_album_category_id = null; 290 291 $query = ' 292 SELECT * 293 FROM '.CATEGORIES_TABLE.' 294 WHERE community_user = '.$user_id.' 295 ;'; 296 $result = pwg_query($query); 297 while ($row = pwg_db_fetch_assoc($result)) 298 { 299 $user_album_category_id = $row['id']; 300 break; 301 } 302 303 if (!isset($user_album_category_id)) 304 { 305 $user_infos = getuserdata($user_id, false); 306 307 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 308 $category_info = create_virtual_category($user_infos['username'], $conf['community']['user_albums_parent']); 309 310 single_update( 311 CATEGORIES_TABLE, 312 array('community_user' => $user_id), 313 array('id' => $category_info['id']) 314 ); 315 316 $user_album_category_id = $category_info['id']; 317 318 // in functions_html::get_cat_display_name_cache we use a cache and this 319 // cache must be reset so that new album is included inside it. 320 global $cache; 321 unset($cache['cat_names']); 322 } 323 324 return $user_album_category_id; 244 325 } 245 326 -
extensions/community/include/install.inc.php
r23037 r23085 33 33 user_id smallint(5) DEFAULT NULL, 34 34 category_id smallint(5) unsigned DEFAULT NULL, 35 user_album enum(\'true\',\'false\') NOT NULL DEFAULT \'false\', 35 36 recursive enum(\'true\',\'false\') NOT NULL DEFAULT \'true\', 36 37 create_subcategories enum(\'true\',\'false\') NOT NULL DEFAULT \'false\', … … 66 67 pwg_query('ALTER TABLE `'.$prefixeTable .'community_permissions` ADD `storage` INT DEFAULT NULL;'); 67 68 } 69 70 // column community_permissions.user_album added for version 2.5.d 71 $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'community_permissions` LIKE "user_album";'); 72 if (!pwg_db_num_rows($result)) 73 { 74 pwg_query('ALTER TABLE `'.$prefixeTable .'community_permissions` ADD `user_album` enum(\'true\',\'false\') NOT NULL DEFAULT \'false\' after `category_id`;'); 75 } 76 77 // column categories.community_user added for version 2.5.d 78 $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'categories` LIKE "community_user";'); 79 if (!pwg_db_num_rows($result)) 80 { 81 pwg_query('ALTER TABLE `'.$prefixeTable .'categories` ADD `community_user` smallint(5) DEFAULT NULL;'); 82 } 83 84 if (!isset($conf['community'])) 85 { 86 $community_default_config = serialize( 87 array( 88 'user_albums' => false, 89 ) 90 ); 91 92 conf_update_param('community', $community_default_config); 93 $conf['community'] = $community_default_config; 94 } 68 95 } 69 96 ?>
Note: See TracChangeset
for help on using the changeset viewer.