Index: extensions/community/include/functions_community.inc.php
===================================================================
--- extensions/community/include/functions_community.inc.php	(revision 23037)
+++ extensions/community/include/functions_community.inc.php	(revision 23085)
@@ -24,4 +24,6 @@
 function community_get_user_permissions($user_id)
 {
+  // echo __FUNCTION__.' => call for user '.$user_id.'<br>';
+  
   global $conf, $user;
 
@@ -49,4 +51,5 @@
     'upload_whole_gallery' => false,
     'create_whole_gallery' => false,
+    'user_album' => false,
     'create_categories' => array(),
     'upload_categories' => array(),
@@ -68,5 +71,7 @@
 SELECT
     id,
+    type,
     category_id,
+    user_album,
     recursive,
     create_subcategories,
@@ -98,16 +103,19 @@
   {
     array_push($return['permission_ids'], $row['id']);
-    
-    if (empty($row['category_id']))
-    {
-      $return ['upload_whole_gallery'] = true;
-    }
-    else
-    {
-      array_push($return['upload_categories'], $row['category_id']);
-
-      if ('true' == $row['recursive'])
-      {
-        array_push($recursive_categories, $row['category_id']);
+
+    if ('false' == $row['user_album'])
+    {
+      if (empty($row['category_id']))
+      {
+        $return['upload_whole_gallery'] = true;
+      }
+      else
+      {
+        array_push($return['upload_categories'], $row['category_id']);
+
+        if ('true' == $row['recursive'])
+        {
+          array_push($recursive_categories, $row['category_id']);
+        }
       }
     }
@@ -149,4 +157,9 @@
         $return['storage'] = $row['storage'];
       }
+    }
+
+    if ($conf['community']['user_albums'] and 'any_visitor' != $row['type'])
+    {
+      $return['user_album'] = true;
     }
   }
@@ -237,9 +250,77 @@
   }
 
+  if ($return['user_album'])
+  {
+    $user_album_category_id = community_get_user_album($user_id);
+
+    if (!empty($user_album_category_id) and !in_array($user_album_category_id, $return['upload_categories']))
+    {
+      array_push($return['upload_categories'], $user_album_category_id);
+    }
+  }
+
+  // is the user allowed to use community upload?
+  if (count($return['upload_categories']) > 0 or $return['create_whole_gallery'] or $return['user_album'])
+  {
+    $return['community_enabled'] = true;
+  }
+  else
+  {
+    $return['community_enabled'] = false;
+  }
+
   $_SESSION['community_user_permissions'] = $return;
   $_SESSION['community_cache_key'] = $cache_key;
   $_SESSION['community_user_id'] = $user_id;
 
+  // echo __FUNCTION__.' => cache reset for user '.$user_id.'<br>';
+  
   return $_SESSION['community_user_permissions'];
+}
+
+/**
+ * return the user album category_id. The album is automatically created if
+ * it does not exist (or has been deleted)
+ */
+function community_get_user_album($user_id)
+{
+  global $conf;
+  
+  $user_album_category_id = null;
+  
+  $query = '
+SELECT *
+  FROM '.CATEGORIES_TABLE.'
+  WHERE community_user = '.$user_id.'
+;';
+  $result = pwg_query($query);
+  while ($row = pwg_db_fetch_assoc($result))
+  {
+    $user_album_category_id = $row['id'];
+    break;
+  }
+
+  if (!isset($user_album_category_id))
+  {
+    $user_infos = getuserdata($user_id, false);
+
+    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+    $category_info = create_virtual_category($user_infos['username'], $conf['community']['user_albums_parent']);
+
+    single_update(
+      CATEGORIES_TABLE,
+      array('community_user' => $user_id),
+      array('id' => $category_info['id'])
+      );
+
+    $user_album_category_id = $category_info['id'];
+
+    // in functions_html::get_cat_display_name_cache we use a cache and this
+    // cache must be reset so that new album is included inside it.
+    global $cache;
+    unset($cache['cat_names']);
+  }
+
+  return $user_album_category_id;
 }
 
Index: extensions/community/include/install.inc.php
===================================================================
--- extensions/community/include/install.inc.php	(revision 23037)
+++ extensions/community/include/install.inc.php	(revision 23085)
@@ -33,4 +33,5 @@
   user_id smallint(5) DEFAULT NULL,
   category_id smallint(5) unsigned DEFAULT NULL,
+  user_album enum(\'true\',\'false\') NOT NULL DEFAULT \'false\',
   recursive enum(\'true\',\'false\') NOT NULL DEFAULT \'true\',
   create_subcategories enum(\'true\',\'false\') NOT NULL DEFAULT \'false\',
@@ -66,4 +67,30 @@
     pwg_query('ALTER TABLE `'.$prefixeTable .'community_permissions` ADD `storage` INT DEFAULT NULL;');
   }
+
+  // column community_permissions.user_album added for version 2.5.d
+  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'community_permissions` LIKE "user_album";');
+  if (!pwg_db_num_rows($result))
+  {     
+    pwg_query('ALTER TABLE `'.$prefixeTable .'community_permissions` ADD `user_album` enum(\'true\',\'false\') NOT NULL DEFAULT \'false\' after `category_id`;');
+  }
+
+  // column categories.community_user added for version 2.5.d
+  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'categories` LIKE "community_user";');
+  if (!pwg_db_num_rows($result))
+  {     
+    pwg_query('ALTER TABLE `'.$prefixeTable .'categories` ADD `community_user`  smallint(5) DEFAULT NULL;');
+  }
+
+  if (!isset($conf['community']))
+  {
+    $community_default_config = serialize(
+      array(
+        'user_albums' => false,
+        )
+      );
+    
+    conf_update_param('community', $community_default_config);
+    $conf['community'] = $community_default_config;
+  }
 }
 ?>
