Index: /extensions/Subscribe_to_comments/include/functions.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/functions.inc.php	(revision 21440)
+++ /extensions/Subscribe_to_comments/include/functions.inc.php	(revision 21441)
@@ -66,5 +66,7 @@
     AND email != "'.$exclude.'"
 ';
-  $subscriptions = hash_from_query($query, 'email');
+  $subscriptions = hash_from_query($query, 'id');
+  
+  if (count($subscriptions)==0) return;
   
   set_make_full_url();
@@ -551,4 +553,6 @@
 function get_picture_infos($image_id, $with_thumb=true)
 {
+  if (empty($image_id)) return array();
+  
   $query = '
 SELECT
@@ -584,7 +588,9 @@
  * @return: array (id, name, url, thumbnail)
  */
-function get_category_infos($cat_id, $with_thumb=true)
+function get_category_infos($cat_id, $with_thumb=true, $user_id=null)
 {
   global $conf;
+  
+  if ($user_id===null) $user_id = $conf['guest_id'];
   
   $query = '
@@ -593,9 +599,11 @@
     cat.name,
     cat.permalink,
+    ucc.count_images,
+    cat.uppercats,
     img.id AS image_id,
     img.path
   FROM '.CATEGORIES_TABLE.' AS cat
     LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc 
-      ON ucc.cat_id = cat.id AND ucc.user_id = '.$conf['guest_id'].'
+      ON ucc.cat_id = cat.id AND ucc.user_id = '.$user_id.'
     LEFT JOIN '.IMAGES_TABLE.' AS img
       ON img.id = ucc.user_representative_picture_id
@@ -603,5 +611,4 @@
 ;';
   $element = pwg_db_fetch_assoc(pwg_query($query));
-  // we use guest_id for user_cache because we don't know the status of recipient
   
   $element['url'] = make_index_url(array(
@@ -612,8 +619,16 @@
   if ($with_thumb)
   {
-    $element['thumbnail'] = DerivativeImage::thumb_url(array(
-      'id'=>$element['image_id'],
-      'path'=>$element['path'],
-      ));
+    if (empty($element['image_id']) and $conf['allow_random_representative'])
+    {
+      $image = get_picture_infos(get_random_image_in_category($element));
+      $element['thumbnail'] = $image['thumbnail'];
+    }
+    else
+    {
+      $element['thumbnail'] = DerivativeImage::thumb_url(array(
+        'id'=>$element['image_id'],
+        'path'=>$element['path'],
+        ));
+    }
   }
   
Index: /extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php	(revision 21440)
+++ /extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php	(revision 21441)
@@ -264,10 +264,9 @@
 function stc_on_album()
 {
-  global $page, $template, $pwg_loaded_plugins, $user, $conf;
+  global $page, $template, $user, $conf;
   
   if (
-      script_basename() != 'index' or !isset($page['section']) or
-      !isset($pwg_loaded_plugins['Comments_on_Albums']) or 
-      $page['section'] != 'categories' or !isset($page['category'])
+      !defined('COA_ID') or script_basename() != 'index' or
+      @$page['section'] != 'categories' or !isset($page['category'])
     )
   {
Index: /extensions/Subscribe_to_comments/include/subscribtions_page.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/subscribtions_page.inc.php	(revision 21440)
+++ /extensions/Subscribe_to_comments/include/subscribtions_page.inc.php	(revision 21441)
@@ -2,5 +2,5 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-global $template, $conf, $page, $pwg_loaded_plugins;
+global $template, $conf, $page, $user;
 
 // check input parameters
@@ -213,5 +213,5 @@
           case 'album-images':
           case 'album':
-            $subscription['infos'] = get_category_infos($subscription['element_id']);
+            $subscription['infos'] = get_category_infos($subscription['element_id'], true, $user['id']);
             break;
           default:
@@ -238,12 +238,9 @@
 }
 
-if (isset($pwg_loaded_plugins['Comments_on_Albums']))
-{
-  $template->assign('COA_ACTIVATED', true);
-}
 
 $template->assign(array(
   'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
   'SUBSCRIBE_TO_ABS_PATH' => realpath(SUBSCRIBE_TO_PATH).'/',
+  'COA_ACTIVATED' => defined('COA_ID'),
   ));
   
Index: /extensions/Subscribe_to_comments/main.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/main.inc.php	(revision 21440)
+++ /extensions/Subscribe_to_comments/main.inc.php	(revision 21441)
@@ -9,9 +9,15 @@
 */
 
+/*
+ * potential problem : if the permissions of a user change, he receives notifications
+ * about photos and albums he can't see anymore
+ */
+
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
 global $prefixeTable;
 
-define('SUBSCRIBE_TO_PATH' ,   PHPWG_PLUGINS_PATH . 'Subscribe_to_Comments/');
+defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__)));
+define('SUBSCRIBE_TO_PATH' ,   PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/');
 define('SUBSCRIBE_TO_TABLE',   $prefixeTable . 'subscribe_to_comments');
 define('SUBSCRIBE_TO_VERSION', 'auto');
@@ -31,6 +37,6 @@
   if (
     SUBSCRIBE_TO_VERSION == 'auto' or
-    $pwg_loaded_plugins['Subscribe_to_Comments']['version'] == 'auto' or
-    version_compare($pwg_loaded_plugins['Subscribe_to_Comments']['version'], SUBSCRIBE_TO_VERSION, '<')
+    $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] == 'auto' or
+    version_compare($pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'], SUBSCRIBE_TO_VERSION, '<')
   )
   {
@@ -38,13 +44,13 @@
     stc_install();
     
-    if ( $pwg_loaded_plugins['Subscribe_to_Comments']['version'] != 'auto' and SUBSCRIBE_TO_VERSION != 'auto' )
+    if ( $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] != 'auto' and SUBSCRIBE_TO_VERSION != 'auto' )
     {
       $query = '
 UPDATE '. PLUGINS_TABLE .'
 SET version = "'. SUBSCRIBE_TO_VERSION .'"
-WHERE id = "Subscribe_to_Comments"';
+WHERE id = "'. SUBSCRIBE_TO_ID .'"';
       pwg_query($query);
       
-      $pwg_loaded_plugins['Subscribe_to_Comments']['version'] = SUBSCRIBE_TO_VERSION;
+      $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] = SUBSCRIBE_TO_VERSION;
       
       if (defined('IN_ADMIN'))
@@ -92,5 +98,5 @@
   array_push($menu, array(
     'NAME' => 'Subscribe to Comments',
-    'URL' => get_root_url().'admin.php?page=plugin-' . basename(dirname(__FILE__))
+    'URL' => get_root_url().'admin.php?page=plugin-' . SUBSCRIBE_TO_ID,
   ));
   return $menu;
Index: /extensions/Subscribe_to_comments/maintain.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/maintain.inc.php	(revision 21440)
+++ /extensions/Subscribe_to_comments/maintain.inc.php	(revision 21441)
@@ -2,5 +2,6 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-include_once(PHPWG_PLUGINS_PATH . 'Subscribe_to_Comments/include/install.inc.php');
+defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__)));
+include_once(PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/include/install.inc.php');
   
 
