Index: /extensions/Subscribe_to_comments/admin.php
===================================================================
--- /extensions/Subscribe_to_comments/admin.php	(revision 26138)
+++ /extensions/Subscribe_to_comments/admin.php	(revision 26139)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!');
+defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!');
 
 global $template, $page, $conf;
@@ -8,5 +8,5 @@
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'subscriptions';
-  
+
 $tabsheet = new tabsheet();
 $tabsheet->add('subscriptions', l10n('Manage'), SUBSCRIBE_TO_ADMIN . '-subscriptions');
@@ -24,6 +24,4 @@
   'SUBSCRIBE_TO_ADMIN' => SUBSCRIBE_TO_ADMIN,
   ));
-  
+
 $template->assign_var_from_handle('ADMIN_CONTENT', 'stc_admin');
-
-?>
Index: /extensions/Subscribe_to_comments/admin/config.php
===================================================================
--- /extensions/Subscribe_to_comments/admin/config.php	(revision 26138)
+++ /extensions/Subscribe_to_comments/admin/config.php	(revision 26139)
@@ -1,9 +1,6 @@
 <?php
-if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!');
+defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!');
 
-// +-----------------------------------------------------------------------+
-//                         Save configuration                              |
-// +-----------------------------------------------------------------------+
-if (isset($_POST['config_submit'])) 
+if (isset($_POST['config_submit']))
 {
   $conf['Subscribe_to_Comments'] = array(
@@ -11,16 +8,11 @@
     'allow_global_subscriptions' => isset($_POST['allow_global_subscriptions']),
     );
-  
+
   conf_update_param('Subscribe_to_Comments', serialize($conf['Subscribe_to_Comments']));
-  array_push($page['infos'], l10n('Information data registered in database'));
-}  
+  $page['infos'][] = l10n('Information data registered in database');
+}
 
 
-// +-----------------------------------------------------------------------+
-//                               Template                                  |
-// +-----------------------------------------------------------------------+  
 $template->assign($conf['Subscribe_to_Comments']);
 
 $template->set_filename('stc_admin', realpath(SUBSCRIBE_TO_PATH . 'admin/template/config.tpl'));
-
-?>
Index: /extensions/Subscribe_to_comments/admin/subscriptions.php
===================================================================
--- /extensions/Subscribe_to_comments/admin/subscriptions.php	(revision 26138)
+++ /extensions/Subscribe_to_comments/admin/subscriptions.php	(revision 26139)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!');
+defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!');
 
 if (isset($_GET['delete']))
@@ -64,5 +64,5 @@
       );
   }
-  
+
   $row['type'] = str_replace('-', '_', $row['type']); // fields are accessed in Smarty, incompatible with keys containing a '-'
   $users[ $row['email'] ]['subs'][ $row['type'] ]++;
@@ -76,5 +76,5 @@
   {
     uasort($users, 'stc_sort_'.$_POST['order_by']);
-    
+
     if ($_POST['direction'] == 'DESC')
     {
@@ -156,4 +156,2 @@
   return strcasecmp($a['username'].$a['email'], $b['username'].$b['email']);
 }
-
-?>
Index: /extensions/Subscribe_to_comments/admin/template/config.tpl
===================================================================
--- /extensions/Subscribe_to_comments/admin/template/config.tpl	(revision 26138)
+++ /extensions/Subscribe_to_comments/admin/template/config.tpl	(revision 26139)
@@ -5,21 +5,21 @@
 <form method="post" action="" class="properties">
   <fieldset>
-    <legend>{'Configuration'|@translate}</legend>
+    <legend>{'Configuration'|translate}</legend>
     <ul>
       <li>
         <label>
-          <span class="property">{'Notify administrators when a user take a new subscription'|@translate}</span>
           <input type="checkbox" name="notify_admin_on_subscribe" value="1" {if $notify_admin_on_subscribe}checked="checked"{/if}>
+          <b>{'Notify administrators when a user take a new subscription'|translate}</b>
         </label>
       </li>
       <li>
         <label>
-          <span class="property">{'Allow users to subscribe to global notifications'|@translate}</span>
           <input type="checkbox" name="allow_global_subscriptions" value="1" {if $allow_global_subscriptions}checked="checked"{/if}>
+          <b>{'Allow users to subscribe to global notifications'|translate}</b>
         </label>
-      </li>  
+      </li>
     </ul>
   </fieldset>
 
-  <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="config_submit"/></p>
+  <p><input class="submit" type="submit" value="{'Submit'|translate}" name="config_submit"/></p>
 </form>
Index: /extensions/Subscribe_to_comments/admin/template/subscriptions.tpl
===================================================================
--- /extensions/Subscribe_to_comments/admin/template/subscriptions.tpl	(revision 26138)
+++ /extensions/Subscribe_to_comments/admin/template/subscriptions.tpl	(revision 26139)
@@ -1,3 +1,3 @@
-{combine_css path=$SUBSCRIBE_TO_PATH|@cat:"admin/template/style.css"}
+{combine_css path=$SUBSCRIBE_TO_PATH|cat:'admin/template/style.css'}
 
 <div class="titrePage">
@@ -7,18 +7,18 @@
 <form class="filter" method="post" name="filter" action="{$F_FILTER_ACTION}">
 <fieldset>
-  <legend>{'Filter'|@translate}</legend>
+  <legend>{'Filter'|translate}</legend>
 
   <label>
-    {'User'|@translate}
+    {'User'|translate}
     <input type="text" name="username" value="{$F_USERNAME}" size="30">
   </label>
 
   <label>
-    {'Sort by'|@translate}
+    {'Sort by'|translate}
     {html_options name=order_by options=$order_options selected=$order_selected}
   </label>
 
   <label>
-    {'Sort order'|@translate}
+    {'Sort order'|translate}
     {html_options name=direction options=$direction_options selected=$direction_selected}
   </label>
@@ -26,5 +26,5 @@
   <label>
     &nbsp;
-    <span><input class="submit" type="submit" name="filter" value="{'Submit'|@translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|@translate}</a></span>
+    <span><input class="submit" type="submit" name="filter" value="{'Submit'|translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|translate}</a></span>
   </label>
 
@@ -36,10 +36,10 @@
   <thead>
     <tr class="throw">
-      <td class="user">{'User'|@translate}</td>
-      <td class="date">{'First subscription'|@translate}</td>
-      <td class="date">{'Last subscription'|@translate}</td>
-      <td class="total">{'Photos'|@translate}</td>
-      <td class="total" style="font-size:0.7em;">{'All album photos'|@translate}</td>
-      {if $COA_ACTIVATED}<td class="total">{'Albums'|@translate}</td>{/if}
+      <td class="user">{'User'|translate}</td>
+      <td class="date">{'First subscription'|translate}</td>
+      <td class="date">{'Last subscription'|translate}</td>
+      <td class="total">{'Photos'|translate}</td>
+      <td class="total" style="font-size:0.7em;">{'All album photos'|translate}</td>
+      {if $COA_ACTIVATED}<td class="total">{'Albums'|translate}</td>{/if}
       <td class="action">&nbsp;</td>
     </tr>
@@ -52,5 +52,5 @@
     <td style="text-align:center;">{$user.nice_max_date}</td>
   {if $user.subs.all_images}
-    <td colspan="2" class="all">{'All'|@translate}
+    <td colspan="2" class="all">{'All'|translate}
   {else}
     <td>{$user.subs.image}</td>
@@ -58,18 +58,16 @@
   {/if}
   {if $user.subs.all_albums && $COA_ACTIVATED}
-    <td class="all">{'All'|@translate}
-  {elseif $COA_ACTIVATED}
+    <td class="all">{'All'|translate}
+  {else if $COA_ACTIVATED}
     <td>{$user.subs.album}</td>
   {/if}
-    <td><a href="{$user.u_delete}" title="{'delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'delete'|@translate}"></a>
+    <td><a href="{$user.u_delete}" title="{'delete'|translate}" onclick="return confirm('{'Are you sure?'|translate}');"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'delete'|translate}"></a>
+  </tr>
+  {foreachelse}
+  <tr class="row2">
+    <td colspan="6" style="text-align:center;font-style:italic;">{'No result'|translate}</td>
   </tr>
   {/foreach}
-  
-  {if not $USERS}
-  <tr class="row2">
-    <td colspan="6" style="text-align:center;font-style:italic;">{'No result'|@translate}</td>
-  </tr>
-  {/if}
 </table>
 
-<p>{'&#9733; : registered users'|@translate}</p>
+<p>{'&#9733; : registered users'|translate}</p>
Index: /extensions/Subscribe_to_comments/include/events.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/events.inc.php	(revision 26139)
+++ /extensions/Subscribe_to_comments/include/events.inc.php	(revision 26139)
@@ -0,0 +1,408 @@
+<?php
+defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!');
+
+/**
+ * detect 'subscriptions' section and load the page
+ */
+function stc_detect_section()
+{
+  global $tokens, $page, $conf;
+
+  if ($tokens[0] == 'subscriptions')
+  {
+    $page['section'] = 'subscriptions';
+    $page['body_id'] = 'theSubscriptionsPage';
+    $page['is_homepage'] = false;
+    $page['is_external'] = true;
+
+    $page['title'] = l10n('Comments notifications');
+  }
+}
+
+function stc_load_section()
+{
+  global $page;
+
+  if (isset($page['section']) and $page['section'] == 'subscriptions')
+  {
+    include(SUBSCRIBE_TO_PATH.'include/subscriptions_page.inc.php');
+  }
+}
+
+
+/**
+ * send notifications and/or add subscriber on comment insertion
+ * @param: array comment
+ */
+function stc_comment_insertion($comm)
+{
+  global $page, $template;
+
+  if ($comm['action'] == 'validate')
+  {
+    send_comment_to_subscribers($comm);
+  }
+
+  if (!empty($_POST['stc_mode']) and $_POST['stc_mode'] != -1)
+  {
+    if ($comm['action'] != 'reject')
+    {
+      if (isset($comm['image_id']))
+      {
+        switch ($_POST['stc_mode'])
+        {
+          case 'all-images':
+            subscribe_to_comments(@$_POST['email'], 'all-images');
+            break;
+          case 'album-images':
+            if (!empty($page['category']['id']))
+            {
+              subscribe_to_comments(@$_POST['email'], 'album-images', $page['category']['id']);
+            }
+            break;
+          case 'image':
+            subscribe_to_comments(@$_POST['email'], 'image', $comm['image_id']);
+            break;
+        }
+      }
+      else if (isset($comm['category_id']))
+      {
+        switch ($_POST['stc_mode'])
+        {
+          case 'all-albums':
+            subscribe_to_comments(@$_POST['email'], 'all-albums');
+            break;
+          case 'album':
+            subscribe_to_comments(@$_POST['email'], 'album', $comm['category_id']);
+            break;
+        }
+      }
+    }
+    else
+    {
+      $template->assign('STC_MODE', $_POST['stc_mode']);
+    }
+  }
+}
+
+
+/**
+ * send notifications on comment validation
+ * @param: array|int comment_id
+ * @param: string type (image|category)
+ */
+function stc_comment_validation($comm_ids, $type='image')
+{
+  if (!is_array($comm_ids))
+  {
+    $comm_ids = array($comm_ids);
+  }
+
+  if ($type == 'image')
+  {
+    $query = '
+SELECT
+    id,
+    image_id,
+    author,
+    content
+  FROM '.COMMENTS_TABLE.'
+  WHERE id IN('.implode(',', $comm_ids).')
+;';
+  }
+  else if ($type == 'album' && defined('COA_TABLE'))
+  {
+    $query = '
+SELECT
+    id,
+    category_id,
+    author,
+    content
+  FROM '.COA_TABLE.'
+  WHERE id IN('.implode(',', $comm_ids).')
+;';
+  }
+
+  if (isset($query))
+  {
+    $comms = query2array($query);
+    foreach ($comms as $comm)
+    {
+      send_comment_to_subscribers($comm);
+    }
+  }
+}
+
+
+/**
+ * add field and link on picture page
+ */
+function stc_on_picture()
+{
+  global $template, $picture, $page, $user, $conf;
+
+  // standalone subscription
+  if (isset($_POST['stc_submit']))
+  {
+    switch ($_POST['stc_mode'])
+    {
+      case 'all-images':
+        subscribe_to_comments(@$_POST['stc_mail'], 'all-images');
+        break;
+      case 'album-images':
+        if (!empty($page['category']['id']))
+        {
+          subscribe_to_comments(@$_POST['stc_mail'], 'album-images', $page['category']['id']);
+        }
+        break;
+      case 'image':
+        subscribe_to_comments(@$_POST['stc_mail'], 'image', $picture['current']['id']);
+        break;
+    }
+  }
+  else if (isset($_GET['stc_unsubscribe']))
+  {
+    if (un_subscribe_to_comments(null, $_GET['stc_unsubscribe']))
+    {
+      $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.');
+    }
+  }
+
+  // if registered user with mail we check if already subscribed
+  if (!is_a_guest() and !empty($user['email']))
+  {
+    $subscribed = false;
+
+    $base_query = '
+SELECT id
+  FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE
+    email = "'.$user['email'].'"
+    AND validated = "true"
+';
+
+    // registered to all pictures
+    if (!$subscribed)
+    {
+      $result = pwg_query($base_query . 'AND type = "all-images";');
+
+      if (pwg_db_num_rows($result))
+      {
+        list($stc_id) = pwg_db_fetch_row($result);
+        $subscribed = 'all-images';
+      }
+    }
+
+    // registered to pictures in this album
+    if (!$subscribed and !empty($page['category']['id']))
+    {
+      $result = pwg_query($base_query . 'AND type = "album-images" AND element_id = '.$page['category']['id'].';');
+
+      if (pwg_db_num_rows($result))
+      {
+        list($stc_id) = pwg_db_fetch_row($result);
+        $subscribed = 'album-images';
+      }
+    }
+
+    // registered to this picture
+    if (!$subscribed)
+    {
+      $result = pwg_query($base_query . 'AND type = "image" AND element_id = '.$picture['current']['id'].';');
+
+      if (pwg_db_num_rows($result))
+      {
+        list($stc_id) = pwg_db_fetch_row($result);
+        $subscribed = 'image';
+      }
+    }
+
+    if ($subscribed)
+    {
+      $template->assign(array(
+        'SUBSCRIBED' => $subscribed,
+        'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)),
+        ));
+    }
+  }
+  else
+  {
+    $template->assign('STC_ASK_MAIL', true);
+  }
+
+  $template->assign(array(
+    'STC_ON_PICTURE' => true,
+    'STC_ALLOW_ALBUM_IMAGES' => !empty($page['category']['id']),
+    'STC_ALLOW_GLOBAL' => $conf['Subscribe_to_Comments']['allow_global_subscriptions'] || is_admin(),
+    'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
+    ));
+
+  $template->set_prefilter('picture', 'stc_main_prefilter');
+}
+
+
+/**
+ * add field and link on album page
+ */
+function stc_on_album()
+{
+  global $page, $template, $user, $conf;
+
+  if (
+      !defined('COA_ID') or script_basename() != 'index' or
+      @$page['section'] != 'categories' or !isset($page['category'])
+    )
+  {
+    return;
+  }
+
+	// standalone subscription
+  if (isset($_POST['stc_submit']))
+  {
+    switch ($_POST['stc_mode'])
+    {
+      case 'all-albums':
+        subscribe_to_comments(@$_POST['stc_mail'], 'all-albums');
+        break;
+      case 'album':
+        subscribe_to_comments(@$_POST['stc_mail'], 'album', $page['category']['id']);
+        break;
+    }
+  }
+  else if (isset($_GET['stc_unsubscribe']))
+  {
+    if (un_subscribe_to_comments(null, $_GET['stc_unsubscribe']))
+    {
+      $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.');
+    }
+  }
+
+  // if registered user we check if already subscribed
+  if ( !is_a_guest() and !empty($user['email']) )
+  {
+    $element_url = make_index_url(array(
+      'section' => 'categories',
+      'category' => $page['category'],
+      ));
+
+    $subscribed = false;
+
+    $base_query = '
+SELECT id
+  FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE
+    email = "'.$user['email'].'"
+    AND validated = "true"
+';
+
+    // registered to all albums
+    if (!$subscribed)
+    {
+      $result = pwg_query($base_query . 'AND type = "all-albums"');
+
+      if (pwg_db_num_rows($result))
+      {
+        list($stc_id) = pwg_db_fetch_row($result);
+        $subscribed = 'all-albums';
+      }
+    }
+
+    // registered to this album
+    if (!$subscribed)
+    {
+      $result = pwg_query($base_query . 'AND type = "album" AND element_id = '.$page['category']['id'].';');
+
+      if (pwg_db_num_rows($result))
+      {
+        list($stc_id) = pwg_db_fetch_row($result);
+        $subscribed = 'album';
+      }
+    }
+
+    if ($subscribed)
+    {
+      $template->assign(array(
+        'SUBSCRIBED' => $subscribed,
+        'UNSUB_LINK' => add_url_params($element_url, array('stc_unsubscribe'=>$stc_id)),
+        ));
+    }
+  }
+  else
+  {
+    $template->assign('STC_ASK_MAIL', true);
+  }
+
+  $template->assign(array(
+    'STC_ON_ALBUM' => true,
+    'STC_ALLOW_GLOBAL' => $conf['Subscribe_to_Comments']['allow_global_subscriptions'] || is_admin(),
+    'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
+    ));
+
+  $template->set_prefilter('comments_on_albums', 'stc_main_prefilter');
+}
+
+
+/**
+ * main prefilter
+ */
+function stc_main_prefilter($content, &$smarty)
+{
+  ## subscribe at any moment ##
+  $search = '{if isset($comments)}';
+  $replace = file_get_contents(SUBSCRIBE_TO_PATH.'template/form_standalone.tpl');
+  $content = str_replace($search, $replace.$search, $content);
+
+  ## subscribe while add a comment ##
+  $search = '{$comment_add.CONTENT}</textarea></p>';
+  $replace = file_get_contents(SUBSCRIBE_TO_PATH.'template/form_comment.tpl');
+  $content = str_replace($search, $search.$replace, $content);
+
+  return $content;
+}
+
+
+/**
+ * delete subscriptions to deleted images or categories
+ */
+function stc_delete_elements($ids)
+{
+  $query = '
+DELETE FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE
+    element_id IN ('.implode(',', $ids).')
+    AND type = "image"
+';
+  pwg_query($query);
+}
+function stc_delete_categories($ids)
+{
+  $query = '
+DELETE FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE
+    element_id IN ('.implode(',', $ids).')
+    AND (type = "album" OR type = "album-images")
+';
+  pwg_query($query);
+}
+
+
+/**
+ * add link to management page for registered users
+ */
+function stc_profile_link()
+{
+  global $template, $user;
+
+  if (!empty($user['email']))
+  {
+    $template->assign('MANAGE_LINK', make_stc_url('manage', $user['email']) );
+    $template->set_prefilter('profile_content', 'stc_profile_link_prefilter');
+  }
+}
+function stc_profile_link_prefilter($content, &$smarty)
+{
+  $search = '<p class="bottomButtons">';
+  $replace = '<p style="font-size:1.1em;text-decoration:underline;"><a href="{$MANAGE_LINK}" rel="nofollow">{\'Manage my subscriptions\'|@translate}</a></p>';
+
+  return str_replace($search, $replace.$search, $content);
+}
Index: /extensions/Subscribe_to_comments/include/functions.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/functions.inc.php	(revision 26138)
+++ /extensions/Subscribe_to_comments/include/functions.inc.php	(revision 26139)
@@ -1,6 +1,4 @@
 <?php
-if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!');
-
-include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!');
 
 /**
@@ -10,12 +8,12 @@
 function send_comment_to_subscribers($comm)
 {
-  if ( empty($comm) or !is_array($comm) )
-  {
-    trigger_error('send_comment_to_subscribers: undefineded comm', E_USER_WARNING);
-    return false;
-  }
-  
+  if (empty($comm) or !is_array($comm))
+  {
+    trigger_error('send_comment_to_subscribers: undefined comm', E_USER_WARNING);
+    return false;
+  }
+
   global $conf, $page, $user, $template;
-  
+
   // create search clauses
   $where_clauses = array();
@@ -24,8 +22,11 @@
     $element_id = $comm['image_id'];
     $element_type = 'image';
-    
-    array_push($where_clauses, 'type = "image" AND element_id = '.$element_id.'');
-    if (!empty($page['category']['id'])) array_push($where_clauses, 'type = "album-images" AND element_id = '.$page['category']['id'].'');
-    array_push($where_clauses, 'type = "all-images"');
+
+    $where_clauses[] = '(type = "image" AND element_id = '.$element_id.')';
+    $where_clauses[] = 'type = "all-images"';
+    if (!empty($page['category']['id']))
+    {
+      $where_clauses[] = '(type = "album-images" AND element_id = '.$page['category']['id'].')';
+    }
   }
   else if (isset($comm['category_id']))
@@ -33,7 +34,7 @@
     $element_id = $comm['category_id'];
     $element_type = 'category';
-    
-    array_push($where_clauses, 'type = "album" AND element_id = '.$element_id.'');
-    array_push($where_clauses, 'type = "all-albums"');
+
+    $where_clauses[] = '(type = "album" AND element_id = '.$element_id.')';
+    $where_clauses[] = 'type = "all-albums"';
   }
   else
@@ -41,5 +42,5 @@
     return;
   }
-  
+
   // exclude current user
   $exclude = null;
@@ -52,5 +53,5 @@
     $exclude = $user['email'];
   }
-  
+
   // get subscribers datas
   $query = '
@@ -61,15 +62,19 @@
   FROM '.SUBSCRIBE_TO_TABLE.'
   WHERE (
-      ('.implode(")\n      OR (", $where_clauses).')
+      '.implode("\n      OR ", $where_clauses).'
     )
     AND validated = true
     AND email != "'.$exclude.'"
+  GROUP BY email
 ';
-  $subscriptions = hash_from_query($query, 'id');
-  
-  if (count($subscriptions)==0) return;
-  
+  $subscriptions = query2array($query);
+
+  if (count($subscriptions)==0)
+  {
+    return;
+  }
+
   set_make_full_url();
-  
+
   // get element infos
   if ($element_type == 'image')
@@ -81,14 +86,15 @@
     $element = get_category_infos($comm['category_id']);
   }
-  
+
   // format comment
-  if ($comm['author'] == 'guest') $comm['author'] = l10n('guest');
+  if ($comm['author'] == 'guest')
+  {
+    $comm['author'] = l10n('guest');
+  }
+
   $comm['author'] = trigger_event('render_comment_author', $comm['author']);
   $comm['content'] = trigger_event('render_comment_content', $comm['content']);
-  
-  // mail content
-  $subject = '['.strip_tags($conf['gallery_title']).'] Re:'.$element['name'];
-    
-  $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/notification.tpl'));
+
+  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
 
   foreach ($subscriptions as $row)
@@ -103,5 +109,5 @@
       $row['user_id'] = $conf['guest_id'];
     }
-    
+
     // check permissions
     if (!user_can_view_element($row['user_id'], $element_id, $element_type))
@@ -109,25 +115,29 @@
       continue;
     }
-    
-    // send mail
-    switch_lang_to($row['language']);
-    load_language('plugin.lang', SUBSCRIBE_TO_PATH);
-    
-    $comm['caption'] = sprintf('<b>%s</b> wrote on <i>%s</i>', $comm['author'], format_date(date('Y-m-d H:i:s')));
-    
-    $template->assign('STC', array(
-      'element' => $element,
-      'comment' => $comm,
-      'UNSUB_URL' => make_stc_url('unsubscribe', $row['email'], $row['id']),
-      'MANAGE_URL' => make_stc_url('manage', $row['email']),
-      'GALLERY_TITLE' => $conf['gallery_title'],
-      ));
-    
-    $content = $template->parse('stc_mail', true);
-
-    stc_send_mail($row['email'], $content, $subject);
+
+    switch_lang_to($language);
+
+    $comm['date'] = format_date(date('Y-m-d H:i:s'));
+
+    pwg_mail(
+      $row['email'],
+      array(
+        'subject' => '['.strip_tags($conf['gallery_title']).'] Re:'.$element['name'],
+        ),
+      array(
+        'filename' => 'notification',
+        'dirname' => SUBSCRIBE_TO_PATH . 'template',
+        'assign' => array(
+          'ELEMENT' => $element,
+          'COMMENT' => $comm,
+          'UNSUB_URL' => make_stc_url('unsubscribe', $row['email'], $row['id']),
+          'MANAGE_URL' => make_stc_url('manage', $row['email']),
+          ),
+        )
+      );
+
     switch_lang_back();
   }
-  
+
   load_language('plugin.lang', SUBSCRIBE_TO_PATH);
   unset_make_full_url();
@@ -149,30 +159,30 @@
     return false;
   }
-  
-  if ( !in_array($type, array('all-images','all-albums')) and $element_id == 'NULL' )
+
+  if (!in_array($type, array('all-images','all-albums')) and $element_id == 'NULL')
   {
     trigger_error('subscribe_to_comment: missing element_id', E_USER_WARNING);
     return false;
   }
-  
+
   global $page, $conf, $user, $template, $picture;
-  
+
   // check email
-  if ( !empty($email) and !email_check_format($email) )
-  {
-    array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));
-    return false;
-  }
-  if ( ( is_a_guest() or empty($user['email']) ) and empty($email) )
-  {
-    array_push($page['errors'], l10n('Invalid email adress, your are not subscribed to comments.'));
-    return false;
-  }
-  else if ( !is_a_guest() and empty($email) )
+  if (!empty($email) and !email_check_format($email))
+  {
+    $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)');
+    return false;
+  }
+  if ( (is_a_guest() or empty($user['email'])) and empty($email) )
+  {
+    $page['errors'][] = l10n('Invalid email address, your are not subscribed to comments.');
+    return false;
+  }
+  else if (!is_a_guest() and empty($email))
   {
     $email = $user['email'];
   }
-  
-  // search if already registered (can't use ODKU because we want to get the id of inserted OR updated row)
+
+  // search if already registered
   $query = '
 SELECT id
@@ -184,12 +194,11 @@
 ;';
   $result = pwg_query($query);
-  
+
   if (pwg_db_num_rows($result))
   {
-    list($inserted_id) = pwg_db_fetch_row($result);
-  }
-  else
-  {
-    $query = '
+    return false;
+  }
+
+  $query = '
 INSERT INTO '.SUBSCRIBE_TO_TABLE.'(
     type,
@@ -209,33 +218,23 @@
   )
 ;';
-    pwg_query($query);
-    
-    $inserted_id = pwg_db_insert_id();
-  }
-  
-  // notify admins
-  if ( pwg_db_changes() != 0 and $conf['Subscribe_to_Comments']['notify_admin_on_subscribe'] )
-  {
-    stc_mail_notification_admins($email, $type, $element_id, $inserted_id);
-  }
-  
-  // send validation mail
-  if ( is_a_guest() and pwg_db_changes() != 0 )
-  {
-    set_make_full_url();
-    
-    $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/confirm.tpl'));
-    
-    $subject = '['.strip_tags($conf['gallery_title']).'] '.l10n('Confirm your subscribtion to comments');
-      
+  pwg_query($query);
+
+  $stc_id = pwg_db_insert_id();
+
+  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+
+  set_make_full_url();
+
+  if (!is_a_guest() or $conf['Subscribe_to_Comments']['notify_admin_on_subscribe'])
+  {
     switch ($type)
     {
       case 'image':
         $element = get_picture_infos($element_id);
-        $element['on'] = sprintf(l10n('the picture <a href="%s">%s</a>'), $element['url'], $element['name']);
+        $element['on'] = l10n('the picture <a href="%s">%s</a>', $element['url'], $element['name']);
         break;
       case 'album-images':
         $element = get_category_infos($element_id);
-        $element['on'] = sprintf(l10n('all pictures of the album <a href="%s">%s</a>'), $element['url'], $element['name']);
+        $element['on'] = l10n('all pictures of the album <a href="%s">%s</a>', $element['url'], $element['name']);
         break;
       case 'all-images':
@@ -245,5 +244,5 @@
       case 'album':
         $element = get_category_infos($element_id);
-        $element['on'] = sprintf(l10n('the album <a href="%s">%s</a>'), $element['url'], $element['name']);
+        $element['on'] = l10n('the album <a href="%s">%s</a>', $element['url'], $element['name']);
         break;
       case 'all-albums':
@@ -252,28 +251,55 @@
         break;
     }
-    
-    $template->assign('STC', array(
-      'element' => $element,
-      'VALIDATE_URL' => make_stc_url('validate', $email, $inserted_id),
-      'MANAGE_URL' => make_stc_url('manage', $email),
-      'GALLERY_TITLE' => $conf['gallery_title'],
-      ));
-    
-    $content = $template->parse('stc_mail', true);
-
-    stc_send_mail($email, $content, $subject);
-    unset_make_full_url();
-    
-    array_push($page['infos'], l10n('Please check your email inbox to confirm your subscription.'));
-    return true;
+  }
+
+  // send validation mail
+  if (is_a_guest())
+  {
+    pwg_mail(
+      $email,
+      array(
+        'subject' => '['.strip_tags($conf['gallery_title']).'] '.l10n('Confirm your subscription to comments'),
+        ),
+      array(
+        'filename' => 'confirm',
+        'dirname' => SUBSCRIBE_TO_PATH . 'template',
+        'assign' => array(
+          'ELEMENT' => $element,
+          'VALIDATE_URL' => make_stc_url('validate', $email, $stc_id),
+          'MANAGE_URL' => make_stc_url('manage', $email),
+          ),
+        )
+      );
+
+    $page['infos'][] = l10n('Please check your email in-box to confirm your subscription.');
   }
   // just display confirmation message
-  else if (pwg_db_changes() != 0)
-  {
-    array_push($page['infos'], l10n('You have been added to the list of subscribers.'));
-    return true;
-  }
-  
-  return false;
+  else
+  {
+    $page['infos'][] = l10n('You have been added to the list of subscribers.');
+  }
+
+  // notify admins
+  if ($conf['Subscribe_to_Comments']['notify_admin_on_subscribe'])
+  {
+    $keyargs_content = array(
+      get_l10n_args('Hi administrators,'),
+      get_l10n_args(''),
+      get_l10n_args('%s has subscribed to comments on %s.', array($email, $element['on'])),
+      get_l10n_args('', ''),
+      get_l10n_args('Connected user: %s', stripslashes($user['username'])),
+      get_l10n_args('IP: %s', $_SERVER['REMOTE_ADDR']),
+      get_l10n_args('Browser: %s', $_SERVER['HTTP_USER_AGENT']),
+      );
+
+    pwg_mail_notification_admins(
+      get_l10n_args('%s has subscribed to comments on %s.', array($email, '')),
+      $keyargs_content
+      );
+  }
+
+  unset_make_full_url();
+
+  return true;
 }
 
@@ -285,39 +311,44 @@
  * @return: bool
  */
-function un_subscribe_to_comments($email, $id)
-{  
-  if ( !empty($email) and !email_check_format($email) )
+function un_subscribe_to_comments($email, $ids)
+{
+  if (!empty($email) and !email_check_format($email))
   {
     trigger_error('un_subscribe_to_comment: bad email', E_USER_WARNING);
     return false;
   }
-  
-  if (!preg_match('#^[0-9]+$#', $id))
+  if (empty($ids))
   {
     trigger_error('un_subscribe_to_comment: bad id', E_USER_WARNING);
     return false;
   }
-  
-  global $template, $user;
-  
+
+  global $user;
+
   // check email
-  if ( ( is_a_guest() or empty($user['email']) ) and empty($email) )
-  {
-    return false;
-  }
-  else if ( !is_a_guest() and empty($email) )
+  if ( (is_a_guest() or empty($user['email'])) and empty($email) )
+  {
+    return false;
+  }
+  else if (!is_a_guest() and empty($email))
   {
     $email = $user['email'];
   }
-  
+
+  if (!is_array($ids))
+  {
+    $ids = array($ids);
+  }
+  $ids = array_map('intval', $ids);
+
   // delete subscription
   $query = '
 DELETE FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE 
+  WHERE
     email = "'.pwg_db_real_escape_string($email).'"
-    AND id = '.$id.'
+    AND id IN('. implode(',', $ids) .')
 ;';
   pwg_query($query);
-  
+
   return (pwg_db_changes() != 0);
 }
@@ -330,5 +361,5 @@
  * @return: bool
  */
-function validate_subscriptions($email, $id)
+function validate_subscriptions($email, $ids)
 {
   if (!email_check_format($email))
@@ -337,86 +368,26 @@
     return false;
   }
-  
-  if (!preg_match('#^[0-9]+$#', $id))
+  if (empty($ids))
   {
     trigger_error('validate_subscriptions: bad id', E_USER_WARNING);
     return false;
   }
-  
+
+  if (!is_array($ids))
+  {
+    $ids = array($ids);
+  }
+  $ids = array_map('intval', $ids);
+
   $query = '
 UPDATE '.SUBSCRIBE_TO_TABLE.'
   SET validated = "true"
-  WHERE 
+  WHERE
     email = "'.pwg_db_real_escape_string($email).'"
-    AND id = '.$id.'
+    AND id IN('. implode(',', $ids) .')
 ;';
   pwg_query($query);
-  
+
   return (pwg_db_changes() != 0);
-}
-
-
-/**
- * send notification to admins
- * @param: string email
- * @param: string type (image|album-images|all-images|album|all-albums)
- * @param: int element_id
- * @param: int subscription id
- */
-function stc_mail_notification_admins($email, $type, $element_id, $inserted_id)
-{
-  global $user, $conf, $template;
-  
-  $admins = get_admins_email();
-  if (empty($admins)) return;
-  
-  set_make_full_url();
-  switch_lang_to(get_default_language());
-  load_language('plugin.lang', SUBSCRIBE_TO_PATH);
-  
-  $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/admin.tpl'));
-    
-  $subject = '['.strip_tags($conf['gallery_title']).'] '.sprintf(l10n('%s has subscribed to comments on %s.'), is_a_guest()?$email:$user['username'], null);
-    
-  switch ($type)
-  {
-    case 'image':
-      $element = get_picture_infos($element_id, false);
-      $element['on'] = sprintf(l10n('the picture <a href="%s">%s</a>'), $element['url'], $element['name']);
-      break;
-    case 'album-images':
-      $element = get_category_infos($element_id, false);
-      $element['on'] = sprintf(l10n('all pictures of the album <a href="%s">%s</a>'), $element['url'], $element['name']);
-      break;
-    case 'all-images':
-      $element['on'] = l10n('all pictures of the gallery');
-      break;
-    case 'album':
-      $element = get_category_infos($element_id, false);
-      $element['on'] = sprintf(l10n('the album <a href="%s">%s</a>'), $element['url'], $element['name']);
-      break;
-    case 'all-albums':
-      $element['on'] = l10n('all albums of the gallery');
-      break;
-  }
-  
-  $technical_infos[] = sprintf(l10n('Connected user: %s'), stripslashes($user['username']));
-  $technical_infos[] = sprintf(l10n('IP: %s'), $_SERVER['REMOTE_ADDR']);
-  $technical_infos[] = sprintf(l10n('Browser: %s'), $_SERVER['HTTP_USER_AGENT']);
-  
-  $template->assign('STC', array(
-    'ELEMENT' => $element['on'],
-    'USER' => is_a_guest() ? '<b>'.$email.'</b>' : '<b>'.$user['username'].'</b> ('.$email.')', 
-    'GALLERY_TITLE' => $conf['gallery_title'],
-    'TECHNICAL' => implode('<br>', $technical_infos),
-    ));
-  
-  $content = $template->parse('stc_mail', true);
-
-  stc_send_mail($admins, $content, $subject);
-  
-  unset_make_full_url();
-  switch_lang_back();
-  load_language('plugin.lang', SUBSCRIBE_TO_PATH);
 }
 
@@ -431,115 +402,31 @@
 function make_stc_url($action, $email, $id=null)
 {
-  if ( empty($action) or empty($email) )
+  if (empty($action) or empty($email))
   {
     trigger_error('make_stc_url: missing action and/or mail', E_USER_WARNING);
     return null;
   }
-  
+
   global $conf;
   set_make_full_url();
-  
-  $url_params = array(
-    'action' => $action,
-    'email' => $email,
-    );
-  
+
+  $url_params = compact('action', 'email');
   if (!empty($id))
   {
     $url_params['id'] = $id;
   }
-  
+
   $url_params['key'] = crypt_value(
-    $action.$email.(isset($url_params['id'])?$url_params['id']:null), 
+    $action.$email.$id,
     $conf['secret_key']
     );
-  
+
   $url = add_url_params(
-    make_index_url( array('section' => 'subscriptions') ),
+    make_index_url(array('section' => 'subscriptions')),
     $url_params
     );
-    
+
   unset_make_full_url();
   return $url;
-}
-
-
-/**
- * send mail with STC style
- * @param: string to
- * @param: string content
- * @param: string subject
- * @return: bool
- */
-function stc_send_mail($to, $content, $subject)
-{
-  global $conf, $conf_mail, $page, $template;
-  
-  // inputs
-  if (empty($to))
-  {
-    return false;
-  }
-
-  if (empty($content))
-  {
-    return false;
-  }
-  
-  if (empty($subject))
-  {
-    $subject = 'Piwigo';
-  }
-  else
-  {
-    $subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
-    $subject = encode_mime_header($subject);
-  }
-  
-  if (!isset($conf_mail))
-  {
-    $conf_mail = get_mail_configuration();
-  }
-
-  $args['from'] = $conf_mail['formated_email_webmaster'];
-  
-  set_make_full_url();
-  
-  // hearders
-  $headers = 'From: '.$args['from']."\n";  
-  $headers.= 'MIME-Version: 1.0'."\n";
-  $headers.= 'X-Mailer: Piwigo Mailer'."\n";
-  $headers.= 'Content-Transfer-Encoding: 8bit'."\n";
-  $headers.= 'Content-Type: text/html; charset="'.get_pwg_charset().'";'."\n";
-  
-  // template
-  $template->set_filenames(array(
-    'stc_mail_header' => realpath(SUBSCRIBE_TO_PATH . 'template/mail/header.tpl'),
-    'stc_mail_footer' => realpath(SUBSCRIBE_TO_PATH . 'template/mail/footer.tpl'),
-    ));
-  $stc_mail_css = file_get_contents(realpath(SUBSCRIBE_TO_PATH . 'template/mail/style.css'));
-    
-  $template->assign(array(
-    'GALLERY_URL' => get_gallery_home_url(),
-    'PHPWG_URL' => PHPWG_URL,
-    'STC_MAIL_CSS' => str_replace("\n", null, $stc_mail_css),
-    ));
-  
-  $content = $template->parse('stc_mail_header', true) . $content . $template->parse('stc_mail_footer', true);
-  
-  $content = wordwrap($content, 70, "\n", false);
-
-  unset_make_full_url();
-  
-  // send mail
-  return
-    trigger_event('send_mail',
-      false, /* Result */
-      trigger_event('send_mail_to', get_strict_email_list($to)),
-      trigger_event('send_mail_subject', $subject),
-      trigger_event('send_mail_content', $content),
-      trigger_event('send_mail_headers', $headers),
-      $args
-    );
 }
 
@@ -553,6 +440,9 @@
 function get_picture_infos($image_id, $with_thumb=true)
 {
-  if (empty($image_id)) return array();
-  
+  if (empty($image_id))
+  {
+    return array();
+  }
+
   $query = '
 SELECT
@@ -565,5 +455,5 @@
 ;';
   $element = pwg_db_fetch_assoc(pwg_query($query));
-    
+
   if (empty($element['name']))
   {
@@ -571,14 +461,14 @@
   }
   $element['name'] = trigger_event('render_element_name', $element['name']);
-  
+
   $element['url'] = make_picture_url(array(
     'image_id'=>$element['id']
     ));
-  
+
   if ($with_thumb)
   {
     $element['thumbnail'] = DerivativeImage::thumb_url($element);
   }
-  
+
   return $element;
 }
@@ -593,7 +483,10 @@
 {
   global $conf;
-  
-  if ($user_id===null) $user_id = $conf['guest_id'];
-  
+
+  if ($user_id===null)
+  {
+    $user_id = $conf['guest_id'];
+  }
+
   $query = '
 SELECT
@@ -606,5 +499,5 @@
     img.path
   FROM '.CATEGORIES_TABLE.' AS cat
-    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc 
+    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc
       ON ucc.cat_id = cat.id AND ucc.user_id = '.$user_id.'
     LEFT JOIN '.IMAGES_TABLE.' AS img
@@ -613,12 +506,12 @@
 ;';
   $element = pwg_db_fetch_assoc(pwg_query($query));
-  
+
   $element['url'] = make_index_url(array(
     'section'=>'categories',
     'category'=>$element,
     ));
-    
+
   $element['name'] = trigger_event('render_category_name', $element['name']);
-  
+
   if ($with_thumb)
   {
@@ -636,5 +529,5 @@
     }
   }
-  
+
   return $element;
 }
@@ -647,7 +540,7 @@
 {
   global $conf, $user;
-  
+
   $admins = array();
-  
+
   $query = '
 SELECT
@@ -655,5 +548,5 @@
     u.'.$conf['user_fields']['email'].' AS email
   FROM '.USERS_TABLE.' AS u
-    JOIN '.USER_INFOS_TABLE.' AS i 
+    JOIN '.USER_INFOS_TABLE.' AS i
       ON i.user_id =  u.'.$conf['user_fields']['id'].'
   WHERE i.status IN ("webmaster", "admin")
@@ -686,10 +579,10 @@
 {
   global $conf;
-  
+
   $old_conf = $conf['external_authentification'];
   $conf['external_authentification'] = false;
   $user = getuserdata($user_id, true);
   $conf['external_authentification'] = $old_conf;
-  
+
   if ($type == 'image')
   {
@@ -715,5 +608,5 @@
  */
 function crypt_value($value, $key)
-{  
+{
   if (extension_loaded('mcrypt'))
   {
@@ -733,7 +626,7 @@
     }
   }
-  
+
   $result = base64url_encode($result);
-  return trim($result); 
+  return trim($result);
 }
 
@@ -746,6 +639,6 @@
 function decrypt_value($value, $key)
 {
-  $value = base64url_decode($value); 
-  
+  $value = base64url_decode($value);
+
   if (extension_loaded('mcrypt'))
   {
@@ -765,5 +658,5 @@
     }
   }
-  
+
   return trim($result);
 }
@@ -773,12 +666,13 @@
  * http://php.net/manual/en/function.base64-encode.php#103849
  */
-function base64url_encode($data)
-{
-  return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
-}
-function base64url_decode($data)
-{
-  return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
-} 
-
-?>
+if (!function_exists('base64url_encode'))
+{
+  function base64url_encode($data)
+  {
+    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
+  }
+  function base64url_decode($data)
+  {
+    return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
+  }
+}
Index: tensions/Subscribe_to_comments/include/install.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/install.inc.php	(revision 26138)
+++ 	(revision )
@@ -1,94 +1,0 @@
-<?php
-defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
-
-function stc_install() 
-{
-  global $conf, $prefixeTable;
-  
-  $stc_table = $prefixeTable . 'subscribe_to_comments';
-  
-  // config parameter
-  if (empty($conf['Subscribe_to_Comments']))
-  {
-    $stc_default_config = serialize(array(
-      'notify_admin_on_subscribe' => false,
-      'allow_global_subscriptions' => true,
-      ));
-  
-    conf_update_param('Subscribe_to_Comments', $stc_default_config);
-    $conf['Subscribe_to_Comments'] = $stc_default_config;
-  }
-  
-  // subscriptions table
-	pwg_query('
-CREATE TABLE IF NOT EXISTS `'.$stc_table.'` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `type` enum("image","album-images","album","all-images","all-albums") NOT NULL DEFAULT "image",
-  `element_id` mediumint(8) DEFAULT NULL,
-  `language` varchar(64) NOT NULL,
-  `email` varchar(255) NOT NULL,
-  `registration_date` datetime NOT NULL,
-  `validated` enum("true","false") NOT NULL DEFAULT "false",
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `UNIQUE` (`email` , `type` , `element_id`)
-) DEFAULT CHARSET=utf8
-;');
-
-  // table structure upgrade in 1.1
-  $result = pwg_query('SHOW COLUMNS FROM `'.$stc_table.'` LIKE "element_id";');
-  if (!pwg_db_num_rows($result))
-  {
-    // backup subscriptions
-    $query = 'SELECT * FROM `'.$stc_table.'` ORDER BY registration_date;';
-    $subscriptions = hash_from_query($query, 'id');
-    
-    // upgrade the table
-    pwg_query('TRUNCATE TABLE `'.$stc_table.'`;');
-    pwg_query('ALTER TABLE `'.$stc_table.'` DROP `image_id`, DROP `category_id`;');
-    pwg_query('ALTER TABLE `'.$stc_table.'` AUTO_INCREMENT = 1;');
-    
-    $query = '
-ALTER TABLE `'.$stc_table.'` 
-  ADD `type` enum("image", "album-images", "album", "all-images", "all-albums") NOT NULL DEFAULT "image" AFTER `id`,
-  ADD `element_id` mediumint(8) NULL AFTER `type`,
-  ADD `language` varchar(64) NOT NULL AFTER `element_id` 
-;';
-    pwg_query($query);
-    
-    pwg_query('ALTER TABLE `'.$stc_table.'`  DROP INDEX `UNIQUE`, ADD UNIQUE `UNIQUE` (`email`, `type`, `element_id`);');
-    
-    // convert datas and fill the table
-    $inserts = array();
-    
-    foreach ($subscriptions as $row)
-    {
-      if (!empty($row['category_id']))
-      {
-        $row['type'] = 'album';
-        $row['element_id'] = $row['category_id'];
-      }
-      else if (!empty($row['image_id']))
-      {
-        $row['type'] = 'image';
-        $row['element_id'] = $row['image_id'];
-      }
-      else
-      {
-        continue;
-      }
-      
-      unset($row['id'], $row['image_id'], $row['category_id']);
-      $row['language'] = 'en_UK';
-      
-      array_push($inserts, $row);
-    }
-    
-    if (count($inserts) > 0)
-    {
-      $dbfields = array('type', 'element_id', 'language', 'email', 'registration_date', 'validated');
-      mass_inserts($stc_table, $dbfields, $inserts);
-    }
-  }
-}
-
-?>
Index: tensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php	(revision 26138)
+++ 	(revision )
@@ -1,436 +1,0 @@
-<?php
-if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!');
-
-/**
- * detect 'subscriptions' section and load the page
- */
-function stc_detect_section()
-{
-  global $tokens, $page, $conf;
-  
-  if ($tokens[0] == 'subscriptions')
-  {
-    add_event_handler('loc_begin_page_header', 'stc_page_header');
-    
-    $page['section'] = 'subscriptions';
-    $page['title'] = l10n('Comments notifications');
-    $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].l10n('Comments notifications');
-  }
-}
-
-function stc_page_header()
-{
-  global $page;
-  $page['body_id'] = 'theSubscriptionsPage';
-}
-
-function stc_load_section()
-{
-  global $page;
-
-  if (isset($page['section']) and $page['section'] == 'subscriptions')
-  {
-    include(SUBSCRIBE_TO_PATH.'include/subscribtions_page.inc.php');
-  }
-}
-
-
-/**
- * send notifications and/or add subscriber on comment insertion
- * @param: array comment
- */
-function stc_comment_insertion($comm)
-{
-  global $page, $template;
-  
-  if ($comm['action'] == 'validate')
-  {
-    send_comment_to_subscribers($comm);
-  }
-  
-  if ( !empty($_POST['stc_mode']) and $_POST['stc_mode'] != -1 )
-  {
-    if ($comm['action'] != 'reject')
-    {
-      if (isset($comm['image_id']))
-      {
-        switch ($_POST['stc_mode'])
-        {
-          case 'all-images':
-            subscribe_to_comments(@$_POST['email'], 'all-images');
-            break;
-          case 'album-images':
-            if (empty($page['category']['id'])) break;
-            subscribe_to_comments(@$_POST['email'], 'album-images', $page['category']['id']);
-            break;
-          case 'image':
-            subscribe_to_comments(@$_POST['email'], 'image', $comm['image_id']);
-            break;
-        }
-      }
-      else if (isset($comm['category_id']))
-      {
-        switch ($_POST['stc_mode'])
-        {
-          case 'all-albums':
-            subscribe_to_comments(@$_POST['email'], 'all-albums');
-            break;
-          case 'album':
-            subscribe_to_comments(@$_POST['email'], 'album', $comm['category_id']);
-            break;
-        }
-      }
-    }
-    else
-    {
-      $template->assign('STC_MODE', $_POST['stc_mode']);
-    }
-  }
-}
-
-
-/**
- * send notifications on comment validation
- * @param: array|int comment_id
- * @param: string type (image|category)
- */
-function stc_comment_validation($comm_ids, $type='image')
-{
-  if (!is_array($comm_ids)) $comm_ids = array($comm_ids);
-  
-  if ($type == 'image')
-  {
-    $query = '
-SELECT
-    id,
-    image_id,
-    author,
-    content
-  FROM '.COMMENTS_TABLE.'
-  WHERE id IN('.implode(',', $comm_ids).')
-;';
-  }
-  else if ($type == 'category')
-  {
-    $query = '
-SELECT
-    id,
-    category_id,
-    author,
-    content
-  FROM '.COA_TABLE.'
-  WHERE id IN('.implode(',', $comm_ids).')
-;';
-  }
-  
-  $comms = hash_from_query($query, 'id');
-  foreach ($comms as $comm)
-  {
-    send_comment_to_subscribers($comm);
-  }
-}
-
-
-/**
- * add field and link on picture page
- */
-function stc_on_picture()
-{
-  global $template, $picture, $page, $user, $conf;
-  
-  // standalone subscription
-  if (isset($_POST['stc_submit']))
-  {
-    switch ($_POST['stc_mode'])
-    {
-      case 'all-images':
-        subscribe_to_comments(@$_POST['stc_mail'], 'all-images');
-        break;
-      case 'album-images':
-        if (empty($page['category']['id'])) break;
-        subscribe_to_comments(@$_POST['stc_mail'], 'album-images', $page['category']['id']);
-        break;
-      case 'image':
-        subscribe_to_comments(@$_POST['stc_mail'], 'image', $picture['current']['id']);
-        break;
-    }
-  }
-  else if (isset($_GET['stc_unsubscribe']))
-  {    
-    if (un_subscribe_to_comments(null, $_GET['stc_unsubscribe']))
-    {
-      array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.'));
-    }
-  }
-  
-  // if registered user with mail we check if already subscribed
-  if ( !is_a_guest() and !empty($user['email']) )
-  {
-    $subscribed = false;
-    
-    // registered to all pictures
-    if (!$subscribed)
-    {
-      $query = '
-SELECT id
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE
-    email = "'.$user['email'].'"
-    AND type = "all-images"
-    AND validated = "true"
-;';
-      $result = pwg_query($query);
-      
-      if (pwg_db_num_rows($result))
-      {
-        list($stc_id) = pwg_db_fetch_row($result);
-        $template->assign(array(
-          'SUBSCRIBED' => 'all-images',
-          'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)),
-          ));
-        $subscribed = true;
-      }
-    }
-
-    // registered to pictures in this album
-    if ( !$subscribed and !empty($page['category']['id']) )
-    {
-      $query = '
-SELECT id
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE
-    email = "'.$user['email'].'"
-    AND element_id = '.$page['category']['id'].'
-    AND type = "album-images"
-    AND validated = "true"
-;';
-      $result = pwg_query($query);
-      
-      if (pwg_db_num_rows($result))
-      {
-        list($stc_id) = pwg_db_fetch_row($result);
-        $template->assign(array(
-          'SUBSCRIBED' => 'album-images',
-          'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)),
-          ));
-        $subscribed = true;
-      }
-    }
-    
-    // registered to this picture
-    if (!$subscribed)
-    {
-      $query = '
-SELECT id
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE
-    email = "'.$user['email'].'"
-    AND element_id = '.$picture['current']['id'].'
-    AND type = "image"
-    AND validated = "true"
-;';
-      $result = pwg_query($query);
-      
-      if (pwg_db_num_rows($result))
-      {
-        list($stc_id) = pwg_db_fetch_row($result);
-        $template->assign(array(
-          'SUBSCRIBED' => 'image',
-          'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)),
-          ));
-        $subscribed = true;
-      }
-    }
-  }
-  else
-  {
-    $template->assign('STC_ASK_MAIL', true);
-  }
-  
-  $template->assign(array(
-    'STC_ON_PICTURE' => true,
-    'STC_ALLOW_ALBUM_IMAGES' => !empty($page['category']['id']),
-    'STC_ALLOW_GLOBAL' => $conf['Subscribe_to_Comments']['allow_global_subscriptions'] || is_admin(),
-    'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
-    ));
-  
-  $template->set_prefilter('picture', 'stc_main_prefilter');
-}
-
-
-/**
- * add field and link on album page
- */
-function stc_on_album()
-{
-  global $page, $template, $user, $conf;
-  
-  if (
-      !defined('COA_ID') or script_basename() != 'index' or
-      @$page['section'] != 'categories' or !isset($page['category'])
-    )
-  {
-    return;
-  }
-  
-	// standalone subscription
-  if (isset($_POST['stc_submit']))
-  {
-    switch ($_POST['stc_mode'])
-    {
-      case 'all-albums':
-        subscribe_to_comments(@$_POST['stc_mail'], 'all-albums');
-        break;
-      case 'album':
-        subscribe_to_comments(@$_POST['stc_mail'], 'album', $page['category']['id']);
-        break;
-    }
-  }
-  else if (isset($_GET['stc_unsubscribe']))
-  {
-    if (un_subscribe_to_comments(null, $_GET['stc_unsubscribe']))
-    {
-      array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.'));
-    }
-  }
-  
-  // if registered user we check if already subscribed
-  if ( !is_a_guest() and !empty($user['email']) )
-  {
-    $element_url = make_index_url(array(
-      'section' => 'categories',
-      'category' => $page['category'],
-      ));
-          
-    $subscribed = false;
-    
-    // registered to all albums
-    if (!$subscribed)
-    {
-      $query = '
-SELECT id
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE
-    email = "'.$user['email'].'"
-    AND type = "all-albums"
-    AND validated = "true"
-;';
-      $result = pwg_query($query);
-      
-      if (pwg_db_num_rows($result))
-      {
-        list($stc_id) = pwg_db_fetch_row($result);
-        $template->assign(array(
-          'SUBSCRIBED' => 'all-albums',
-          'UNSUB_LINK' => add_url_params($element_url, array('stc_unsubscribe'=>$stc_id)),
-          ));
-        $subscribed = true;
-      }
-    }
-    
-    // registered to this album
-    if (!$subscribed)
-    {
-      $query = '
-SELECT id
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE
-    email = "'.$user['email'].'"
-    AND element_id = '.$page['category']['id'].'
-    AND type = "album"
-    AND validated = "true"
-;';
-      $result = pwg_query($query);
-      
-      if (pwg_db_num_rows($result))
-      {
-        list($stc_id) = pwg_db_fetch_row($result);
-        $template->assign(array(
-          'SUBSCRIBED' => 'album',
-          'UNSUB_LINK' => add_url_params($element_url, array('stc_unsubscribe'=>$stc_id)),
-          ));
-        $subscribed = true;
-      }
-    }
-  }
-  else
-  {
-    $template->assign('STC_ASK_MAIL', true);
-  }
-  
-  $template->assign(array(
-    'STC_ON_ALBUM' => true,
-    'STC_ALLOW_GLOBAL' => $conf['Subscribe_to_Comments']['allow_global_subscriptions'] || is_admin(),
-    'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
-    ));
-
-  $template->set_prefilter('comments_on_albums', 'stc_main_prefilter');
-}
-
-
-/**
- * main prefilter
- */
-function stc_main_prefilter($content, &$smarty)
-{
-  ## subscribe at any moment ##
-  $search = '{if isset($comments)}';
-  $replace = file_get_contents(SUBSCRIBE_TO_PATH.'template/form_standalone.tpl');
-  $content = str_replace($search, $replace.$search, $content);
-  
-  ## subscribe while add a comment ##
-  $search = '{$comment_add.CONTENT}</textarea></p>';
-  $replace = file_get_contents(SUBSCRIBE_TO_PATH.'template/form_comment.tpl');
-  $content = str_replace($search, $search.$replace, $content);
-  
-  return $content;
-}
-
-
-/**
- * delete subscriptions to deleted images or categories
- */
-function stc_delete_elements($ids)
-{
-  $query = '
-DELETE FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE 
-    element_id IN ('.implode(',', $ids).')
-    AND type = "image"
-';
-  pwg_query($query);
-}
-function stc_delete_categories($ids)
-{
-  $query = '
-DELETE FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE 
-    element_id IN ('.implode(',', $ids).')
-    AND (type = "album" OR type = "album-images")
-';
-  pwg_query($query);
-}
-
-
-/**
- * add link to management page for registered users
- */
-function stc_profile_link()
-{
-  global $template, $user;
-  
-  if (!empty($user['email']))
-  {
-    $template->assign('MANAGE_LINK', make_stc_url('manage', $user['email']) );
-    $template->set_prefilter('profile_content', 'stc_profile_link_prefilter');
-  }
-}
-function stc_profile_link_prefilter($content, &$smarty)
-{
-  $search = '<p class="bottomButtons">';
-  $replace = '<p style="font-size:1.1em;text-decoration:underline;"><a href="{$MANAGE_LINK}" rel="nofollow">{\'Manage my subscriptions\'|@translate}</a></p>';
-  
-  return str_replace($search, $replace.$search, $content);
-}
-
-?>
Index: tensions/Subscribe_to_comments/include/subscribtions_page.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/subscribtions_page.inc.php	(revision 26138)
+++ 	(revision )
@@ -1,255 +1,0 @@
-<?php 
-if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!');
-
-global $template, $conf, $page, $user;
-
-// check input parameters
-if ( empty($_GET['action']) or empty($_GET['email']) or empty($_GET['key']) )
-{
-  $_GET['action'] = null;
-}
-else
-{
-  $_GET['verif_key'] = $_GET['action'].$_GET['email'].(isset($_GET['id'])?$_GET['id']:null);
-
-  if ( decrypt_value($_GET['key'], $conf['secret_key']) !== $_GET['verif_key'] )
-  {
-    $_GET['action'] = null;
-  }
-}
-
-
-
-if ( !empty($_GET['action']) )
-{
-  // unsubscribe all
-  if ( isset($_POST['unsubscribe_all']) and isset($_POST['unsubscribe_all_check']) )
-  {
-    $query = '
-DELETE FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE email = "'.$_GET['email'].'"
-;';
-    pwg_query($query);
-  }
-  
-  // bulk action
-  else if (isset($_POST['apply_bulk']) and !empty($_POST['selected']))
-  {
-    foreach ($_POST['selected'] as $id)
-    {
-      switch ($_POST['action'])
-      {
-        case 'unsubscribe':
-          un_subscribe_to_comments($_GET['email'], $id);
-          break;
-        case 'validate':
-          validate_subscriptions($_GET['email'], $id);
-          break;
-      }
-    }
-  }
-  
-  // unsubscribe from manage page
-  else if (isset($_GET['unsubscribe']))
-  {
-    if (un_subscribe_to_comments($_GET['email'], $_GET['unsubscribe']))
-    {
-      array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.'));
-    }
-    else
-    {
-      array_push($page['errors'], l10n('Not found.'));
-    }
-  }
-  
-  // validate from manage page
-  else if (isset($_GET['validate']))
-  {
-    if (validate_subscriptions($_GET['email'], $_GET['validate']))
-    {
-      array_push($page['infos'], l10n('Your subscribtion has been validated, thanks you.'));
-    }
-    else
-    {
-      array_push($page['infos'], l10n('Already validated.'));
-    }
-  }
-  
-  $template->assign('MANAGE_LINK', make_stc_url('manage', $_GET['email']));
-}
-
-
-switch ($_GET['action'])
-{
-  /* validate */
-  case 'validate':
-  {
-    // don't need to sanitize inputs, already checked with the unique key
-    $query = '
-SELECT type, element_id
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE 
-    email = "'.$_GET['email'].'"
-    AND id = '.$_GET['id'].'
-;';
-    $result = pwg_query($query);
-    
-    if (!pwg_db_num_rows($result))
-    {
-      array_push($page['errors'], l10n('Not found.'));
-    }
-    else
-    {
-      if (validate_subscriptions($_GET['email'], $_GET['id']))
-      {
-        array_push($page['infos'], l10n('Your subscribtion has been validated, thanks you.'));
-      }
-      else
-      {
-        array_push($page['infos'], l10n('Already validated.'));
-      }
-      
-      list($type, $element_id) = pwg_db_fetch_row($result);
-      
-      switch ($type)
-      {
-        case 'image':
-          $element = get_picture_infos($element_id, false);
-          break;
-        case 'album-images':
-        case 'album':
-          $element = get_category_infos($element_id, false);
-          break;
-        default:
-          $element = null;
-      }
-      
-      $template->assign(array(
-        'type' => $type,
-        'element' => $element,
-        ));
-    }
-    
-    $template->assign('IN_VALIDATE', true);
-    break;
-  }
-  
-  /* unsubscribe */
-  case 'unsubscribe':
-  {
-    $query = '
-SELECT
-    type,
-    element_id
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE 
-    email = "'.$_GET['email'].'"
-    AND id = '.$_GET['id'].'
-;';
-    $result = pwg_query($query);
-    
-    if (!pwg_db_num_rows($result))
-    {
-      array_push($page['errors'], l10n('Not found.'));
-    }
-    else
-    {
-      if (un_subscribe_to_comments($_GET['email'], $_GET['id']))
-      {
-        array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.'));
-      }
-      else
-      {
-        array_push($page['errors'], l10n('Not found.'));
-      }
-      
-      list($type, $element_id) = pwg_db_fetch_row($result);
-      
-      switch ($type)
-      {
-        case 'image':
-          $element = get_picture_infos($element_id);
-          break;
-        case 'album-images':
-        case 'album':
-          $element = get_category_infos($element_id);
-          break;
-        default:
-          $element = null;
-      }
-      
-      $template->assign(array(
-        'type' => $type,
-        'element' => $element,
-        ));
-    }
-    
-    $template->assign('IN_UNSUBSCRIBE', true);
-    break;
-  }
-  
-  /* manage */
-  case 'manage':
-  {
-    $query = '
-SELECT *
-  FROM '.SUBSCRIBE_TO_TABLE.'
-  WHERE email = "'.$_GET['email'].'"
-  ORDER BY registration_date DESC
-;';
-    $result = pwg_query($query);
-    
-    if (pwg_db_num_rows($result))
-    {
-      while ($subscription = pwg_db_fetch_assoc($result))
-      {
-        $subscription['registration_date'] = format_date($subscription['registration_date'], true);
-        
-        switch ($subscription['type'])
-        {
-          case 'image':
-            $subscription['infos'] = get_picture_infos($subscription['element_id']);
-            break;
-          case 'album-images':
-          case 'album':
-            $subscription['infos'] = get_category_infos($subscription['element_id'], true, $user['id']);
-            break;
-          default:
-            $subscription['infos'] = null;
-            $template->append('global_subscriptions', $subscription);
-            continue(2);
-        }
-        
-        $template->append('subscriptions', $subscription);
-      }
-    }
-    else
-    {
-      array_push($page['infos'], l10n('You are not subscribed to any comment.'));
-    }
-    break;
-  }
-  
-  default:
-  {
-    set_status_header(403);
-    array_push($page['errors'], l10n('Bad query'));
-  }
-}
-
-
-$template->assign(array(
-  'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
-  'SUBSCRIBE_TO_ABS_PATH' => realpath(SUBSCRIBE_TO_PATH).'/',
-  'COA_ACTIVATED' => defined('COA_ID'),
-  ));
-  
-if (!empty($_GET['email']))
-{
-  $template->assign('TITLE', '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].
-                              sprintf(l10n('Subscriptions of %s'), '<i>'.$_GET['email'].'</i>'));
-}
-
-$template->set_filename('index', realpath(SUBSCRIBE_TO_PATH . 'template/subscribtions_page.tpl'));
-
-?>
Index: /extensions/Subscribe_to_comments/include/subscriptions_page.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/include/subscriptions_page.inc.php	(revision 26139)
+++ /extensions/Subscribe_to_comments/include/subscriptions_page.inc.php	(revision 26139)
@@ -0,0 +1,250 @@
+<?php
+defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!');
+
+global $template, $conf, $page, $user;
+
+// check input parameters
+if (empty($_GET['action']) or empty($_GET['email']) or empty($_GET['key']))
+{
+  $_GET['action'] = null;
+}
+else
+{
+  $verif_key = $_GET['action'].$_GET['email'].(isset($_GET['id'])?$_GET['id']:null);
+
+  if (decrypt_value($_GET['key'], $conf['secret_key']) !== $verif_key)
+  {
+    $_GET['action'] = null;
+  }
+}
+
+
+
+if (!empty($_GET['action']))
+{
+  // unsubscribe all
+  if (isset($_POST['unsubscribe_all']) and isset($_POST['unsubscribe_all_check']))
+  {
+    $query = '
+DELETE FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE email = "'.$_GET['email'].'"
+;';
+    pwg_query($query);
+  }
+
+  // bulk action
+  else if (isset($_POST['apply_bulk']) and !empty($_POST['selected']))
+  {
+    switch ($_POST['action'])
+    {
+      case 'unsubscribe':
+        un_subscribe_to_comments($_GET['email'], $_POST['selected']);
+        break;
+      case 'validate':
+        validate_subscriptions($_GET['email'], $_POST['selected']);
+        break;
+    }
+  }
+
+  // unsubscribe from manage page
+  else if (isset($_GET['unsubscribe']))
+  {
+    if (un_subscribe_to_comments($_GET['email'], $_GET['unsubscribe']))
+    {
+      $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.');
+    }
+    else
+    {
+      $page['errors'][] = l10n('Not found.');
+    }
+  }
+
+  // validate from manage page
+  else if (isset($_GET['validate']))
+  {
+    if (validate_subscriptions($_GET['email'], $_GET['validate']))
+    {
+      $page['infos'][] = l10n('Your subscribtion has been validated, thanks you.');
+    }
+    else
+    {
+      $page['infos'][] = l10n('Already validated.');
+    }
+  }
+
+  $template->assign('MANAGE_LINK', make_stc_url('manage', $_GET['email']));
+}
+
+
+switch ($_GET['action'])
+{
+  /* validate */
+  case 'validate':
+  {
+    // don't need to sanitize inputs, already checked with the unique key
+    $query = '
+SELECT type, element_id
+  FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE
+    email = "'.$_GET['email'].'"
+    AND id = '.$_GET['id'].'
+;';
+    $result = pwg_query($query);
+
+    if (!pwg_db_num_rows($result))
+    {
+      $page['errors'][] = l10n('Not found.');
+    }
+    else
+    {
+      if (validate_subscriptions($_GET['email'], $_GET['id']))
+      {
+        $page['infos'][] = l10n('Your subscription has been validated, thanks you.');
+      }
+      else
+      {
+        $page['infos'][] = l10n('Already validated.');
+      }
+
+      list($type, $element_id) = pwg_db_fetch_row($result);
+
+      switch ($type)
+      {
+        case 'image':
+          $element = get_picture_infos($element_id, false);
+          break;
+        case 'album-images':
+        case 'album':
+          $element = get_category_infos($element_id, false);
+          break;
+        default:
+          $element = null;
+      }
+
+      $template->assign(array(
+        'type' => $type,
+        'element' => $element,
+        ));
+    }
+
+    $template->assign('IN_VALIDATE', true);
+    break;
+  }
+
+  /* unsubscribe */
+  case 'unsubscribe':
+  {
+    $query = '
+SELECT
+    type,
+    element_id
+  FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE
+    email = "'.$_GET['email'].'"
+    AND id = '.$_GET['id'].'
+;';
+    $result = pwg_query($query);
+
+    if (!pwg_db_num_rows($result))
+    {
+      $page['errors'][] = l10n('Not found.');
+    }
+    else
+    {
+      if (un_subscribe_to_comments($_GET['email'], $_GET['id']))
+      {
+        $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.');
+      }
+      else
+      {
+        $page['errors'][] = l10n('Not found.');
+      }
+
+      list($type, $element_id) = pwg_db_fetch_row($result);
+
+      switch ($type)
+      {
+        case 'image':
+          $element = get_picture_infos($element_id);
+          break;
+        case 'album-images':
+        case 'album':
+          $element = get_category_infos($element_id);
+          break;
+        default:
+          $element = null;
+      }
+
+      $template->assign(array(
+        'type' => $type,
+        'element' => $element,
+        ));
+    }
+
+    $template->assign('IN_UNSUBSCRIBE', true);
+    break;
+  }
+
+  /* manage */
+  case 'manage':
+  {
+    $query = '
+SELECT *
+  FROM '.SUBSCRIBE_TO_TABLE.'
+  WHERE email = "'.$_GET['email'].'"
+  ORDER BY registration_date DESC
+;';
+    $result = pwg_query($query);
+
+    if (pwg_db_num_rows($result))
+    {
+      while ($subscription = pwg_db_fetch_assoc($result))
+      {
+        $subscription['registration_date'] = format_date($subscription['registration_date'], true);
+
+        switch ($subscription['type'])
+        {
+          case 'image':
+            $subscription['infos'] = get_picture_infos($subscription['element_id']);
+            break;
+          case 'album-images':
+          case 'album':
+            $subscription['infos'] = get_category_infos($subscription['element_id'], true, $user['id']);
+            break;
+          default:
+            $subscription['infos'] = null;
+            $template->append('global_subscriptions', $subscription);
+            continue(2);
+        }
+
+        $template->append('subscriptions', $subscription);
+      }
+    }
+    else
+    {
+      $page['infos'][] = l10n('You are not subscribed to any comment.');
+    }
+    break;
+  }
+
+  default:
+  {
+    set_status_header(403);
+    $page['errors'][] = l10n('Bad query');
+  }
+}
+
+
+$template->assign(array(
+  'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
+  'SUBSCRIBE_TO_ABS_PATH' => realpath(SUBSCRIBE_TO_PATH).'/',
+  'COA_ACTIVATED' => defined('COA_ID'),
+  ));
+
+if (!empty($_GET['email']))
+{
+  $template->concat('TITLE', $conf['level_separator'] . l10n('Subscriptions of %s', '<i>'.$_GET['email'].'</i>'));
+}
+
+$template->set_filename('subscribe_to_comments', realpath(SUBSCRIBE_TO_PATH . 'template/subscriptions_page.tpl'));
+$template->assign_var_from_handle('CONTENT', 'subscribe_to_comments');
Index: /extensions/Subscribe_to_comments/main.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/main.inc.php	(revision 26138)
+++ /extensions/Subscribe_to_comments/main.inc.php	(revision 26139)
@@ -1,17 +1,17 @@
-<?php 
+<?php
 /*
 Plugin Name: Subscribe To Comments
 Version: auto
 Description: This plugin allows to subscribe to comments by email.
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=587
+Plugin URI: auto
 Author: Mistic
 Author URI: http://www.strangeplanet.fr
 */
 
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
 global $prefixeTable;
 
-defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__)));
+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');
@@ -25,77 +25,60 @@
 function stc_init()
 {
-  global $conf, $user, $pwg_loaded_plugins;
-  
+  global $conf, $user;
+
   // no comments on luciano
-  if ($user['theme'] == 'luciano') return;
-  
-  // apply upgrade if needed
-  if (
-    SUBSCRIBE_TO_VERSION == 'auto' or
-    $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] == 'auto' or
-    version_compare($pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'], SUBSCRIBE_TO_VERSION, '<')
-  )
+  if ($user['theme'] == 'luciano')
   {
-    include_once(SUBSCRIBE_TO_PATH . 'include/install.inc.php');
-    stc_install();
-    
-    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_ID .'"';
-      pwg_query($query);
-      
-      $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] = SUBSCRIBE_TO_VERSION;
-      
-      if (defined('IN_ADMIN'))
-      {
-        $_SESSION['page_infos'][] = 'Subscribe to comments updated to version '. SUBSCRIBE_TO_VERSION;
-      }
-    }
+    return;
   }
-  
-  // load language and conf
+
+  include_once(SUBSCRIBE_TO_PATH . 'maintain.inc.php');
+  $maintain = new Subscribe_to_Comments_maintain(SUBSCRIBE_TO_ID);
+  $maintain->autoUpdate(SUBSCRIBE_TO_VERSION, 'install');
+
+
   load_language('plugin.lang', SUBSCRIBE_TO_PATH);
   $conf['Subscribe_to_Comments'] = unserialize($conf['Subscribe_to_Comments']);
-  
-  
+
+
   include_once(SUBSCRIBE_TO_PATH.'include/functions.inc.php');
-  include_once(SUBSCRIBE_TO_PATH.'include/subscribe_to_comments.inc.php');
+  include_once(SUBSCRIBE_TO_PATH.'include/events.inc.php');
 
-  
+
+  if (!defined('IN_ADMIN'))
+  {
+    // subscribe
+    add_event_handler('loc_end_picture', 'stc_on_picture');
+    add_event_handler('loc_begin_coa', 'stc_on_album');
+
+    // management
+    add_event_handler('loc_end_section_init', 'stc_detect_section');
+    add_event_handler('loc_begin_page_header', 'stc_load_section');
+
+    // profile link
+    add_event_handler('loc_begin_profile', 'stc_profile_link');
+  }
+  else
+  {
+    // config page
+    add_event_handler('get_admin_plugin_menu_links', 'stc_admin_menu');
+  }
+
   // send mails
   add_event_handler('user_comment_insertion', 'stc_comment_insertion');
   add_event_handler('user_comment_validation', 'stc_comment_validation', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
 
-  // subscribe
-  add_event_handler('loc_end_picture', 'stc_on_picture');
-  add_event_handler('loc_begin_coa', 'stc_on_album');
-
-  // management
-  add_event_handler('loc_end_section_init', 'stc_detect_section');
-  add_event_handler('loc_begin_page_header', 'stc_load_section');
-  
   // items deletion
   add_event_handler('begin_delete_elements', 'stc_delete_elements');
   add_event_handler('delete_categories', 'stc_delete_categories');
-
-  // profile link
-  add_event_handler('loc_begin_profile', 'stc_profile_link');
-  
-  // config page
-  add_event_handler('get_admin_plugin_menu_links', 'stc_admin_menu');
 }
 
 
-function stc_admin_menu($menu) 
+function stc_admin_menu($menu)
 {
-  array_push($menu, array(
+  $menu[] = array(
     'NAME' => 'Subscribe to Comments',
     'URL' => SUBSCRIBE_TO_ADMIN,
-  ));
+    );
   return $menu;
 }
-
-?>
Index: /extensions/Subscribe_to_comments/maintain.inc.php
===================================================================
--- /extensions/Subscribe_to_comments/maintain.inc.php	(revision 26138)
+++ /extensions/Subscribe_to_comments/maintain.inc.php	(revision 26139)
@@ -1,29 +1,126 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__)));
-include_once(PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/include/install.inc.php');
-  
+class Subscribe_to_Comments_maintain extends PluginMaintain
+{
+  private $installed = false;
 
-function plugin_install() 
-{
-  stc_install();
-  define('stc_installed', true);
-}
+  private $default_conf = array(
+    'notify_admin_on_subscribe' => false,
+    'allow_global_subscriptions' => true,
+    );
 
-function plugin_activate()
-{
-  if (!defined('stc_installed'))
+  private $table;
+
+  function __construct($plugin_id)
   {
-    stc_install();
+    parent::__construct($plugin_id);
+
+    global $prefixeTable;
+    $this->table = $prefixeTable . 'subscribe_to_comments';
+  }
+
+  function install($plugin_version, &$errors=array())
+  {
+    global $conf;
+
+    // config parameter
+    if (empty($conf['Subscribe_to_Comments']))
+    {
+      $conf['Subscribe_to_Comments'] = serialize($this->default_config);
+      conf_update_param('Subscribe_to_Comments', $conf['Subscribe_to_Comments']);
+    }
+
+    // subscriptions table
+    pwg_query('
+CREATE TABLE IF NOT EXISTS `'. $this->table .'` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `type` enum("image","album-images","album","all-images","all-albums") NOT NULL DEFAULT "image",
+  `element_id` mediumint(8) DEFAULT NULL,
+  `language` varchar(64) NOT NULL,
+  `email` varchar(255) NOT NULL,
+  `registration_date` datetime NOT NULL,
+  `validated` enum("true","false") NOT NULL DEFAULT "false",
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `UNIQUE` (`email` , `type` , `element_id`)
+) DEFAULT CHARSET=utf8
+;');
+
+    // table structure upgrade in 1.1
+    $result = pwg_query('SHOW COLUMNS FROM `'. $this->table .'` LIKE "element_id";');
+    if (!pwg_db_num_rows($result))
+    {
+      // backup subscriptions
+      $query = 'SELECT * FROM `'. $this->table .'` ORDER BY registration_date;';
+      $subscriptions = query2array($query, 'id');
+
+      // upgrade the table
+      pwg_query('TRUNCATE TABLE `'. $this->table .'`;');
+      pwg_query('ALTER TABLE `'. $this->table .'` DROP `image_id`, DROP `category_id`;');
+      pwg_query('ALTER TABLE `'. $this->table .'` AUTO_INCREMENT = 1;');
+
+      $query = '
+ALTER TABLE `'. $this->table .'`
+  ADD `type` enum("image", "album-images", "album", "all-images", "all-albums") NOT NULL DEFAULT "image" AFTER `id`,
+  ADD `element_id` mediumint(8) NULL AFTER `type`,
+  ADD `language` varchar(64) NOT NULL AFTER `element_id`
+;';
+      pwg_query($query);
+
+      pwg_query('ALTER TABLE `'. $this->table .'`  DROP INDEX `UNIQUE`, ADD UNIQUE `UNIQUE` (`email`, `type`, `element_id`);');
+
+      // convert datas and fill the table
+      $inserts = array();
+
+      foreach ($subscriptions as $row)
+      {
+        if (!empty($row['category_id']))
+        {
+          $row['type'] = 'album';
+          $row['element_id'] = $row['category_id'];
+        }
+        else if (!empty($row['image_id']))
+        {
+          $row['type'] = 'image';
+          $row['element_id'] = $row['image_id'];
+        }
+        else
+        {
+          continue;
+        }
+
+        unset($row['id'], $row['image_id'], $row['category_id']);
+        $row['language'] = 'en_UK';
+
+        array_push($inserts, $row);
+      }
+
+      if (count($inserts) > 0)
+      {
+        $dbfields = array('type', 'element_id', 'language', 'email', 'registration_date', 'validated');
+        mass_inserts($this->table, $dbfields, $inserts);
+      }
+    }
+
+    $this->installed = true;
+  }
+
+  function activate($plugin_version, &$errors=array())
+  {
+    if (!$this->installed)
+    {
+      $this->install($plugin_version, $errors);
+    }
+  }
+
+  function deactivate()
+  {
+  }
+
+  function uninstall()
+  {
+    conf_delete_param('Subscribe_to_Comments');
+
+    pwg_query('DROP TABLE `'. $this->table .'`;');
   }
 }
-
-function plugin_uninstall() 
-{
-  global $prefixeTable;
-  
-  pwg_query('DROP TABLE `'. $prefixeTable . 'subscribe_to_comments`;');
-  pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "Subscribe_to_Comments" LIMIT 1;');
-}
-?>
Index: /extensions/Subscribe_to_comments/template/form_comment.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/form_comment.tpl	(revision 26138)
+++ /extensions/Subscribe_to_comments/template/form_comment.tpl	(revision 26139)
@@ -2,20 +2,20 @@
 
 <p>
-  {'Notify me of followup comments'|@translate} :<br>
-  <label><input type="radio" name="stc_mode" value="-1" {if !$STC_MODE}checked="checked"{/if}> {'No'|@translate}</label>
+  {'Notify me of followup comments'|translate} :<br>
+  <label><input type="radio" name="stc_mode" value="-1" {if !$STC_MODE}checked{/if}> {'No'|translate}</label>
   {if $STC_ON_PICTURE}
-    {if $STC_ALLOW_GLOBAL} 
-      <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked="checked"{/if}> {'this picture'|@translate}</label>
-      {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images" {if $STC_MODE=="album-images"}checked="checked"{/if}> {'all pictures of this album'|@translate}</label>{/if}
-      <label><input type="radio" name="stc_mode" value="all-images" {if $STC_MODE=="all-images"}checked="checked"{/if}> {'all pictures of the gallery'|@translate}</label>
+    {if $STC_ALLOW_GLOBAL}
+      <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked{/if}> {'this picture'|translate}</label>
+      {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images" {if $STC_MODE=="album-images"}checked{/if}> {'all pictures of this album'|translate}</label>{/if}
+      <label><input type="radio" name="stc_mode" value="all-images" {if $STC_MODE=="all-images"}checked{/if}> {'all pictures of the gallery'|translate}</label>
     {else}
-      <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked="checked"{/if}> {'Yes'|@translate}</label>
+      <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked{/if}> {'Yes'|translate}</label>
     {/if}
   {elseif $STC_ON_ALBUM}
     {if $STC_ALLOW_GLOBAL}
-      <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked="checked"{/if}> {'this album'|@translate}</label>
-      <label><input type="radio" name="stc_mode" value="all-albums" {if $STC_MODE=="all-albums"}checked="checked"{/if}> {'all albums of the gallery'|@translate}</label>
+      <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked{/if}> {'this album'|translate}</label>
+      <label><input type="radio" name="stc_mode" value="all-albums" {if $STC_MODE=="all-albums"}checked{/if}> {'all albums of the gallery'|translate}</label>
     {else}
-      <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked="checked"{/if}> {'Yes'|@translate}</label>
+      <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked{/if}> {'Yes'|translate}</label>
     {/if}
   {/if}
@@ -23,8 +23,9 @@
 
 {if $STC_ASK_MAIL}
-{footer_script require="jquery"}{literal}
+{footer_script require='jquery'}
+(function($){
 	var $stc_email_input = $("#addComment input[name='email']");
   var stc_bordercolor = $stc_email_input.css('border-color');
-  
+
   $("#addComment input[name='stc_mode']").change(function() {
     if ($(this).val() != "-1") {
@@ -40,5 +41,6 @@
     $(this).css('border-color', stc_bordercolor);
   });
-{/literal}{/footer_script}
+}(jQuery));
+{/footer_script}
 {/if}
 
Index: /extensions/Subscribe_to_comments/template/form_standalone.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/form_standalone.tpl	(revision 26138)
+++ /extensions/Subscribe_to_comments/template/form_standalone.tpl	(revision 26139)
@@ -1,11 +1,11 @@
-{combine_css path=$SUBSCRIBE_TO_PATH|@cat:'template/style_form.css'}
+{combine_css path=$SUBSCRIBE_TO_PATH|cat:'template/style_form.css'}
 
 {if $STC_ALLOW_GLOBAL}
-  {footer_script require="jquery"}{literal}
+{footer_script require='jquery'}
   jQuery("#stc_submit").hide();
   jQuery("#stc_standalone input[name='stc_mode']").change(function() {
     jQuery("#stc_submit").show();
   });
-  {/literal}{/footer_script}
+{/footer_script}
 {/if}
 
@@ -16,24 +16,24 @@
   {if $SUBSCRIBED}
     {if $SUBSCRIBED=='all-images'}
-      {assign var=str value='all pictures of the gallery'|@translate}
+      {assign var=str value='all pictures of the gallery'|translate}
     {elseif $SUBSCRIBED=='album-images'}
-      {assign var=str value='all pictures of this album'|@translate}
+      {assign var=str value='all pictures of this album'|translate}
     {elseif $SUBSCRIBED=='image'}
-      {assign var=str value='this picture'|@translate}
+      {assign var=str value='this picture'|translate}
     {elseif $SUBSCRIBED=='all-albums'}
-      {assign var=str value='all albums of the gallery'|@translate}
+      {assign var=str value='all albums of the gallery'|translate}
     {elseif $SUBSCRIBED=='album'}
-      {assign var=str value='this album'|@translate}
+      {assign var=str value='this album'|translate}
     {/if}
-    
-    {'You are currently subscribed to comments on %s.'|@translate|sprintf:$str}
-    <a href="{$UNSUB_LINK}">{'Unsubscribe'|@translate}</a>
+
+    {'You are currently subscribed to comments on %s.'|translate|sprintf:$str}
+    <a href="{$UNSUB_LINK}">{'Unsubscribe'|translate}</a>
   {else}
-    <legend>{'Subscribe to mail notifications'|@translate}</legend>
+    <legend>{'Subscribe to mail notifications'|translate}</legend>
     {if $STC_ON_PICTURE}
       {if $STC_ALLOW_GLOBAL}
-        <label><input type="radio" name="stc_mode" value="image"> {'this picture'|@translate}</label>
-        {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images"> {'all pictures of this album'|@translate}</label>{/if}
-        <label><input type="radio" name="stc_mode" value="all-images"> {'all pictures of the gallery'|@translate}</label>
+        <label><input type="radio" name="stc_mode" value="image"> {'this picture'|translate}</label>
+        {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images"> {'all pictures of this album'|translate}</label>{/if}
+        <label><input type="radio" name="stc_mode" value="all-images"> {'all pictures of the gallery'|translate}</label>
       {else}
         <input type="hidden" name="stc_mode" value="image">
@@ -41,6 +41,6 @@
     {elseif $STC_ON_ALBUM}
       {if $STC_ALLOW_GLOBAL}
-        <label><input type="radio" name="stc_mode" value="album"> {'this album'|@translate}</label>
-        <label><input type="radio" name="stc_mode" value="all-albums"> {'all albums of the gallery'|@translate}</label>
+        <label><input type="radio" name="stc_mode" value="album"> {'this album'|translate}</label>
+        <label><input type="radio" name="stc_mode" value="all-albums"> {'all albums of the gallery'|translate}</label>
       {else}
         <input type="hidden" name="stc_mode" value="album">
@@ -50,7 +50,7 @@
     <span id="stc_submit">
     {if $STC_ASK_MAIL}
-        <label>{'Email'|@translate} <input type="text" name="stc_mail" size="30"></label>
+        <label>{'Email'|translate} <input type="text" name="stc_mail" size="30"></label>
     {/if}
-      <label><input type="submit" name="stc_submit" value="{'Subscribe'|@translate}"></label>
+      <label><input type="submit" name="stc_submit" value="{'Subscribe'|translate}"></label>
     </span>
   {/if}
Index: /extensions/Subscribe_to_comments/template/style.css
===================================================================
--- /extensions/Subscribe_to_comments/template/style.css	(revision 26138)
+++ /extensions/Subscribe_to_comments/template/style.css	(revision 26139)
@@ -35,5 +35,5 @@
     vertical-align:top;
   }
-  
+
 .subscriptions_list tr.row2 { background-color:#222; }
 .subscriptions_list tr.row1 { background-color:#333; }
@@ -46,8 +46,7 @@
 }
 .subscriptions_list tr.header th, .subscriptions_list tr.footer.row1 td {
-  
+
   background: #333333;
   background: -moz-linear-gradient(top,  #333333 0%, #222222 100%);
-  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#333333), color-stop(100%,#222222));
   background: -webkit-linear-gradient(top,  #333333 0%,#222222 100%);
   background: -o-linear-gradient(top,  #333333 0%,#222222 100%);
@@ -59,5 +58,4 @@
   background: #222222;
   background: -moz-linear-gradient(top,  #222222 0%, #333333 100%);
-  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#222222), color-stop(100%,#333333));
   background: -webkit-linear-gradient(top,  #222222 0%,#333333 100%);
   background: -o-linear-gradient(top,  #222222 0%,#333333 100%);
@@ -67,16 +65,13 @@
 }
 
-
-.stc p {
-  text-align:center;
-}
-
-.stc label {
-  display:block;
-}
-
-img.thumbnail {
+.subscriptions_list img.thumbnail {
   max-width:120px;
   max-height:90px;
 }
 
+.subscriptions_list a.unsub  {
+  color:#f66;
+}
+.subscriptions_list a.unsub:hover {
+  color:#f11;
+}
Index: tensions/Subscribe_to_comments/template/subscribtions_page.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/subscribtions_page.tpl	(revision 26138)
+++ 	(revision )
@@ -1,122 +1,0 @@
-{combine_css path=$SUBSCRIBE_TO_PATH|@cat:'template/style.css'}
-
-{* <!-- Menubar & titrePage --> *}
-{if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}
-  {include file=$SUBSCRIBE_TO_ABS_PATH|@cat:'template/themes/stripped.tpl'}
-  {assign var="clear" value="true"}
-{elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}
-  {include file=$SUBSCRIBE_TO_ABS_PATH|@cat:'template/themes/simple.tpl'}
-  {assign var="clear" value="true"}
-{else}
-  {include file=$SUBSCRIBE_TO_ABS_PATH|@cat:'template/themes/default.tpl'}
-{/if}
-
-{include file='infos_errors.tpl'}
-
- 
-{if $IN_VALIDATE or $IN_UNSUBSCRIBE}
-<p>
-  {if !empty($element)}<a href="{$element.url}" title="{$element.name}">{'Return to item page'|@translate}</a><br>{/if}
-  <a href="{$MANAGE_LINK}">{'Manage my subscriptions'|@translate}</a>
-</p>
-{/if}
-  
-<form action="{$MANAGE_LINK}" method="post">
-  {if !empty($global_subscriptions)}
-  <fieldset>
-    <legend>{'Global subscriptions'|@translate}</legend>
-    <table class="subscriptions_list">
-      {foreach from=$global_subscriptions item=sub name=subs_loop}
-      <tr class="{if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if}">
-        <td>
-          {if $sub.type == 'all-images'}
-            {assign var=str value='all pictures of the gallery'|@translate}
-            <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png"> 
-          {else $sub.type == 'all-albums'}
-            {assign var=str value='all albums of the gallery'|@translate}
-            <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album.png">
-          {/if}
-          {'You are currently subscribed to comments on %s.'|@translate|sprintf:$str}
-        </td>
-        <td style="white-space:nowrap;">
-          <div class="actions">
-            <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}">{'Unsubscribe'|@translate}</a>
-            {if $sub.validated == 'false'}<br> <a href="{$MANAGE_LINK}&amp;validate={$sub.id}">{'Validate'|@translate}</a>{/if}
-          </div>
-        </td>
-        <td style="white-space:nowrap;">
-          <i>{$sub.registration_date}</i>
-        </td>
-      </tr>
-      {/foreach}
-    </table>
-  </fieldset>
-  {/if}
-  
-  {if !empty($subscriptions)}
-  <fieldset>
-    <legend>{'Manage my subscriptions'|@translate}</legend>
-    <table class="subscriptions_list">
-      <tr class="header">
-        <th class="chkb"><input type="checkbox" id="check_all"></th>
-        <th colspan="2" class="info">{'Subject'|@translate}</th>
-        <th class="date">{'Followed on'|@translate}</th>
-      </tr>
-      
-      {foreach from=$subscriptions item=sub name=subs_loop}
-      <tr class="{if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if} {if $sub.validated == 'false'}not-validated{/if}">
-        <td class="chkb"><input type="checkbox" name="selected[]" value="{$sub.id}" id="sub-{$sub.id}"></td>
-        <td class="thumb"><label for="sub-{$sub.id}"><img src="{$sub.infos.thumbnail}" alt="{$sub.infos.name}" class="thumbnail"></label></td>
-        <td class="info">
-          <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/{$sub.type}.png">
-          <b><a href="{$sub.infos.url}">{$sub.infos.name}</a></b>
-
-          <div class="actions">
-            <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}">{'Unsubscribe'|@translate}</a>
-            {if $sub.validated == 'false'}| <a href="{$MANAGE_LINK}&amp;validate={$sub.id}">{'Validate'|@translate}</a>{/if}
-          </div>
-        </td>
-        <td class="date">
-          <i>{$sub.registration_date}</i>
-        </td>
-      </tr>
-      {/foreach}
-      
-      <tr class="footer {if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if}"><td colspan="4">
-        <select name="action">
-          <option value="-1">{'Choose an action'|@translate}</option>
-          <option value="unsubscribe">{'Unsubscribe'|@translate}</option>
-          <option value="validate">{'Validate'|@translate}</option>
-        </select>
-        <input type="submit" name="apply_bulk" value="{'Apply action'|@translate}">
-      </td></tr>
-    </table>
-    
-    <p>
-      <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png"> {'comments on a picture'|@translate}. 
-      <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album-images.png"> {'comments on all pictures of an album'|@translate}.
-      {if $COA_ACTIVATED}<img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album.png"> {'comments on an album'|@translate}.{/if}
-    </p>
-  </fieldset>
-  {/if}
-  
-  {if !empty($global_subscriptions) or !empty($subscriptions)}
-    <p>
-      <label><input type="checkbox" name="unsubscribe_all_check" value="1"> {'Unsubscribe from all email notifications'|@translate}</label>
-      <input type="submit" name="unsubscribe_all" value="{'Submit'|@translate}">
-    </p>
-  {/if}
-</form>
-
-{footer_script require="jquery"}{literal}
-jQuery("#check_all").change(function() {
-  if ($(this).is(":checked"))
-    $("input[name^='selected']").attr('checked', 'checked');
-  else
-    $("input[name^='selected']").removeAttr('checked');
-});
-{/literal}{/footer_script}
-
-{if $clear}<div style="clear: both;"></div>
-</div>{/if}
-</div> <!-- content -->
Index: /extensions/Subscribe_to_comments/template/subscriptions_page.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/subscriptions_page.tpl	(revision 26139)
+++ /extensions/Subscribe_to_comments/template/subscriptions_page.tpl	(revision 26139)
@@ -0,0 +1,109 @@
+{combine_css path=$SUBSCRIBE_TO_PATH|cat:'template/style.css'}
+
+
+{if $IN_VALIDATE or $IN_UNSUBSCRIBE}
+<p>
+  {if !empty($element)}<a href="{$element.url}" title="{$element.name}">{'Return to item page'|@translate}</a><br>{/if}
+  <a href="{$MANAGE_LINK}">{'Manage my subscriptions'|@translate}</a>
+</p>
+
+{else}
+<form action="{$MANAGE_LINK}" method="post">
+  {if !empty($global_subscriptions)}
+  <fieldset>
+    <legend>{'Global subscriptions'|@translate}</legend>
+    <table class="subscriptions_list">
+      {foreach from=$global_subscriptions item=sub name=subs_loop}
+      <tr class="{if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if}">
+        <td>
+          {if $sub.type == 'all-images'}
+            {assign var=str value='all pictures of the gallery'|@translate}
+            <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png">
+          {else $sub.type == 'all-albums'}
+            {assign var=str value='all albums of the gallery'|@translate}
+            <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album.png">
+          {/if}
+          {'You are currently subscribed to comments on %s.'|@translate|sprintf:$str}
+        </td>
+        <td style="white-space:nowrap;">
+          <div class="actions">
+            <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}" class="unsub">{'Unsubscribe'|@translate}</a>
+            {if $sub.validated == 'false'}<br> <a href="{$MANAGE_LINK}&amp;validate={$sub.id}">{'Validate'|@translate}</a>{/if}
+          </div>
+        </td>
+        <td style="white-space:nowrap;">
+          <i>{$sub.registration_date}</i>
+        </td>
+      </tr>
+      {/foreach}
+    </table>
+  </fieldset>
+  {/if}
+
+  {if !empty($subscriptions)}
+  <fieldset>
+    <legend>{'Manage my subscriptions'|@translate}</legend>
+    <table class="subscriptions_list">
+      <tr class="header">
+        <th class="chkb"><input type="checkbox" id="check_all"></th>
+        <th colspan="2" class="info">{'Subject'|@translate}</th>
+        <th class="date">{'Followed on'|@translate}</th>
+      </tr>
+
+      {foreach from=$subscriptions item=sub name=subs_loop}
+      <tr class="{if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if} {if $sub.validated == 'false'}not-validated{/if}">
+        <td class="chkb"><input type="checkbox" name="selected[]" value="{$sub.id}" id="sub-{$sub.id}"></td>
+        <td class="thumb"><label for="sub-{$sub.id}"><img src="{$sub.infos.thumbnail}" alt="{$sub.infos.name}" class="thumbnail"></label></td>
+        <td class="info">
+          <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/{$sub.type}.png">
+          <b><a href="{$sub.infos.url}">{$sub.infos.name}</a></b>
+
+          <div class="actions">
+            <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}" class="unsub">{'Unsubscribe'|@translate}</a>
+            {if $sub.validated == 'false'}| <a href="{$MANAGE_LINK}&amp;validate={$sub.id}">{'Validate'|@translate}</a>{/if}
+          </div>
+        </td>
+        <td class="date">
+          <i>{$sub.registration_date}</i>
+        </td>
+      </tr>
+      {/foreach}
+
+      <tr class="footer {if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if}"><td colspan="4">
+        <select name="action">
+          <option value="-1">{'Choose an action'|@translate}</option>
+          <option value="unsubscribe">{'Unsubscribe'|@translate}</option>
+          <option value="validate">{'Validate'|@translate}</option>
+        </select>
+        <input type="submit" name="apply_bulk" value="{'Apply action'|@translate}">
+      </td></tr>
+    </table>
+
+    <p>
+      <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png"> {'comments on a picture'|@translate}.
+      <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album-images.png"> {'comments on all pictures of an album'|@translate}.
+      {if $COA_ACTIVATED}<img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album.png"> {'comments on an album'|@translate}.{/if}
+    </p>
+  </fieldset>
+  {/if}
+
+  {if !empty($global_subscriptions) or !empty($subscriptions)}
+    <p>
+      <label><input type="checkbox" name="unsubscribe_all_check" value="1"> {'Unsubscribe from all email notifications'|@translate}</label>
+      <input type="submit" name="unsubscribe_all" value="{'Submit'|@translate}">
+    </p>
+  {/if}
+</form>
+
+{footer_script require="jquery"}
+jQuery("#check_all").change(function() {
+  if (jQuery(this).is(":checked")) {
+    jQuery("input[name^='selected']").attr('checked', 'checked');
+  }
+  else {
+    jQuery("input[name^='selected']").removeAttr('checked');
+  }
+});
+{/footer_script}
+
+{/if}
Index: /extensions/Subscribe_to_comments/template/text/html/confirm.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/text/html/confirm.tpl	(revision 26139)
+++ /extensions/Subscribe_to_comments/template/text/html/confirm.tpl	(revision 26139)
@@ -0,0 +1,23 @@
+<style>
+.button {
+  padding:8px 15px;
+  background:#A80D24;
+  color:#bbb;
+  border:1px solid #CE2E5A;
+  text-decoration:none;
+  font-size:14px;
+  font-weight:bold;
+}
+</style>
+
+<p>{'You requested to subscribe by email to comments on %s'|translate:$ELEMENT.on}.</p>
+
+{if not empty($ELEMENT.thumbnail)}
+<p><img src="{$ELEMENT.thumbnail}" alt="{$ELEMENT.name}" class="photo"></p>
+{/if}
+
+<p>{'To activate, click the confirm button. If you believe this is an error, please just ignore this message.'|translate}</p>
+
+<p><a href="{$VALIDATE_URL}" class="button">{'Confirm subscription'|translate}</a></p>
+
+<p>{'Want to edit your notifications options?'|translate} <a href="{$MANAGE_URL}">{'Manage my subscriptions'|translate}</a>.</p>
Index: /extensions/Subscribe_to_comments/template/text/html/notification.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/text/html/notification.tpl	(revision 26139)
+++ /extensions/Subscribe_to_comments/template/text/html/notification.tpl	(revision 26139)
@@ -0,0 +1,14 @@
+<p>
+  <a href="{$ELEMENT.url}">{$ELEMENT.name}<br>
+  <img src="{$ELEMENT.thumbnail}" alt="{$ELEMENT.name}" class="photo"></a>
+</p>
+
+<p>
+  {'<b>%s</b> wrote on <i>%s</i>'|translate:$COMMENT.author:$COMMENT.date} :
+  <blockquote>{$COMMENT.content}</blockquote>
+</p>
+
+<p>
+  <a href="{$UNSUB_URL}">{'Stop receiving notifications'|translate}</a><br>
+  <a href="{$MANAGE_URL}">{'Manage my subscriptions'|translate}</a>
+</p>
Index: /extensions/Subscribe_to_comments/template/text/plain/confirm.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/text/plain/confirm.tpl	(revision 26139)
+++ /extensions/Subscribe_to_comments/template/text/plain/confirm.tpl	(revision 26139)
@@ -0,0 +1,6 @@
+{'You requested to subscribe by email to comments on %s'|translate:$ELEMENT.on}.
+
+{'To activate, click the confirm button. If you believe this is an error, please just ignore this message.'|translate}
+{$VALIDATE_URL}
+
+{'Manage my subscriptions'|translate} ({$MANAGE_URL})
Index: /extensions/Subscribe_to_comments/template/text/plain/notification.tpl
===================================================================
--- /extensions/Subscribe_to_comments/template/text/plain/notification.tpl	(revision 26139)
+++ /extensions/Subscribe_to_comments/template/text/plain/notification.tpl	(revision 26139)
@@ -0,0 +1,9 @@
+{$ELEMENT.name} ({$ELEMENT.url)
+
+{'<b>%s</b> wrote on <i>%s</i>'|translate:$COMMENT.author:$COMMENT.date} :
+--------------------
+{$COMMENT.content}
+--------------------
+
+{'Stop receiving notifications'|translate} ({$UNSUB_URL})
+{'Manage my subscriptions'|translate} ({$MANAGE_URL})
