Index: /extensions/Comments_on_Albums/trunk/include/coa_admin_comments.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/include/coa_admin_comments.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/include/coa_admin_comments.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/include/coa_admin_intro.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/include/coa_admin_intro.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/include/coa_admin_intro.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/include/coa_albums.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/include/coa_albums.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/include/coa_albums.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/include/functions_comment.inc.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/include/functions_comment.inc.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/include/functions_comment.inc.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/language/ca_ES/plugin.lang.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/language/ca_ES/plugin.lang.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/language/ca_ES/plugin.lang.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/language/da_DK/plugin.lang.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/language/da_DK/plugin.lang.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/language/da_DK/plugin.lang.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/language/en_UK/plugin.lang.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/language/en_UK/plugin.lang.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/language/fi_FI/plugin.lang.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/language/fi_FI/plugin.lang.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/language/fi_FI/plugin.lang.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/language/fr_FR/plugin.lang.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/language/fr_FR/plugin.lang.php	(revision 21347)
Index: /extensions/Comments_on_Albums/trunk/main.inc.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/main.inc.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/main.inc.php	(revision 21347)
@@ -10,4 +10,9 @@
 
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+if (mobile_theme())
+{
+  return;
+}
 
 global $prefixeTable;
Index: /extensions/Comments_on_Albums/trunk/stuffs_module/config.inc.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/stuffs_module/config.inc.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/stuffs_module/config.inc.php	(revision 21347)
@@ -13,7 +13,11 @@
   else
   {
+    if (!isset($_POST['show_admin_buttons']))
+    {
+      $_POST['show_admin_buttons'] = 'off';
+    }
     $datas = array(
       $_POST['nb_comments'],
-      isset($_POST['show_admin_buttons']),
+      $_POST['show_admin_buttons'],
       $_POST['nb_cadres'],
       $_POST['width'],
@@ -33,5 +37,5 @@
   'HEIGHT'      => $datas[4]
 ));
-if ($datas[1])
+if ($datas[1] == 'on')
 {
   $template->assign(array('SHOW_ADMIN_BUTTONS' => 'checked="checked"'));
Index: /extensions/Comments_on_Albums/trunk/stuffs_module/config.tpl
===================================================================
--- /extensions/Comments_on_Albums/trunk/stuffs_module/config.tpl	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/stuffs_module/config.tpl	(revision 21347)
@@ -1,29 +1,29 @@
 <table>
+	<tr>
+		<td align="right"><br>{'lastcoms_nb_comments'|@translate} &nbsp;&nbsp;</td>
+		<td><br>
+		<input type="text" size="3" maxlength="2" value="{$NB_COMMENTS}" name="nb_comments"/></td>
+	</tr>
+	<tr>
+		<td align="right"><br>{'lastcoms_show_buttons'|@translate} &nbsp;&nbsp;</td>
+		<td><br>
+		<input type="checkbox" name="show_admin_buttons" value="on" {$SHOW_ADMIN_BUTTONS}/></td>
+	</tr>
   <tr>
-    <td align="right"><br>{'lastcoms_nb_comments'|@translate} &nbsp;&nbsp;</td>
-    <td><br>
-    <input type="text" size="3" maxlength="2" value="{$NB_COMMENTS}" name="nb_comments"/></td>
-  </tr>
-  <tr>
-    <td align="right"><br>{'lastcoms_show_buttons'|@translate} &nbsp;&nbsp;</td>
-    <td><br>
-    <input type="checkbox" name="show_admin_buttons" value="on" {$SHOW_ADMIN_BUTTONS}/></td>
-  </tr>
-  <tr>
-    <td align="right"><br>{'lastcoms_nb_cadres'|@translate} &nbsp;&nbsp;</td>
-    <td><br>
+		<td align="right"><br>{'lastcoms_nb_cadres'|@translate} &nbsp;&nbsp;</td>
+		<td><br>
     {html_options name=nb_cadres options=$nb_cadres.OPTIONS selected=$nb_cadres.SELECTED}
     </td>
-  </tr>
+	</tr>
   <tr>
-    <td align="right"><br>{'lastcoms_dim'|@translate} : &nbsp;&nbsp; {'lastcoms_width'|@translate} &nbsp;&nbsp;</td>
-    <td><br>
-    <input type="text" size="3" maxlength="3" value="{$WIDTH}" name="width"/>&nbsp;px</td>
-  </tr>
-  <tr>
-    <td align="right">{'lastcoms_height'|@translate} &nbsp;&nbsp;</td>
-    <td>
-    <input type="text" size="3" maxlength="3" value="{$HEIGHT}" name="height"/>&nbsp;px</td>
-  </tr>
+		<td align="right"><br>{'lastcoms_dim'|@translate} : &nbsp;&nbsp; {'lastcoms_width'|@translate} &nbsp;&nbsp;</td>
+		<td><br>
+		<input type="text" size="3" maxlength="3" value="{$WIDTH}" name="width"/>&nbsp;px</td>
+	</tr>
+	<tr>
+		<td align="right">{'lastcoms_height'|@translate} &nbsp;&nbsp;</td>
+		<td>
+		<input type="text" size="3" maxlength="3" value="{$HEIGHT}" name="height"/>&nbsp;px</td>
+	</tr>
 </table>
 <br>
Index: tensions/Comments_on_Albums/trunk/stuffs_module/cr_stuffs.tpl
===================================================================
--- /extensions/Comments_on_Albums/trunk/stuffs_module/cr_stuffs.tpl	(revision 21346)
+++ 	(revision )
@@ -1,35 +1,0 @@
-{combine_css path=$block.CR_PATH|@cat:'template/style.css'}
-
-<ul class="thumbnailCategories">
-  {foreach from=$block.contests item=contest}
-  <li class="{$block.SIZE_CLASS} {if !$contest.VISIBLE}novisible{/if}">
-    <div class="thumbnailCategory">
-      <div class="illustration">
-        <a href="{$contest.URL}">
-        {if $contest.STATUS != 'finished' AND !empty($contest.LOGO)}
-          <img src="{$contest.LOGO}" alt="{$contest.NAME}" style="max-height:120px;max-width:120px;">
-        {elseif !empty($contest.RESULTS.1.TN_SRC)}
-          <img src="{$contest.RESULTS.1.TN_SRC}" alt="{$contest.NAME|@replace:'"':' '}">
-        {/if}
-        </a>
-      </div>
-      <div class="description">
-        <h3><a href="{$contest.URL}">{$contest.NAME}</a></h3>
-        <div class="text">
-          <p class="Nb_images">{$contest.DATE_BEGIN} - {$contest.DATE_END}</p>
-          <span class="CR_finished">({$contest.DAYS})</span>
-          <p>
-          {if $contest.STATUS != 'finished' AND !empty($contest.SUMMARY)}
-            {$contest.SUMMARY}
-          {else}
-            {foreach from=$contest.RESULTS item=result}
-              {'CR_order_'|cat:$result.RANK|@translate} {'CR_place'|@translate} - <u>{$result.AUTHOR}</u><br>
-            {/foreach}
-          {/if}
-          </p>
-        </div>
-      </div>
-    </div>
-  </li>
-  {/foreach}
-</ul>
Index: /extensions/Comments_on_Albums/trunk/stuffs_module/main.inc.php
===================================================================
--- /extensions/Comments_on_Albums/trunk/stuffs_module/main.inc.php	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/stuffs_module/main.inc.php	(revision 21347)
@@ -2,4 +2,6 @@
 
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+include_once(COA_PATH.'include/functions_comment.inc.php');
+
 global $user, $conf;
 
@@ -7,28 +9,74 @@
 // |                         comments management                           |
 // +-----------------------------------------------------------------------+
-// comments deletion
-if (isset($_GET['delete_album']) and is_numeric($_GET['delete_album']) and is_admin())
-{
-    check_status(ACCESS_ADMINISTRATOR);
-    check_pwg_token();
-    $query = '
-DELETE FROM ' . COA_TABLE . '
-  WHERE id=' . $_GET['delete_album'] . '
-;';
-    pwg_query($query);
-}
-
-// comments validation
-if (isset($_GET['validate_album']) and is_numeric($_GET['validate_album']) and is_admin())
-{
-    check_status(ACCESS_ADMINISTRATOR);
-    check_pwg_token();
-    $query = '
-UPDATE ' . COA_TABLE . '
-  SET validated = \'true\'
-  , validation_date = NOW()
-  WHERE id=' . $_GET['validate_album'] . '
-;';
-    pwg_query($query);
+
+$comment_id = null;
+$action = null;
+
+$actions = array('delete_comment_album', 'validate_comment_album', 'edit_comment_album');
+foreach ($actions as $loop_action)
+{
+  if (isset($_GET[$loop_action]))
+  {
+    $action = $loop_action;
+    check_input_parameter($action, $_GET, false, PATTERN_ID);
+    $comment_id = $_GET[$action];
+    break;
+  }
+}
+
+if (isset($action))
+{
+  check_pwg_token();
+
+  $comment_author_id = get_comment_author_id_albums($comment_id);
+  $action = str_replace('_comment_album', '', $action);
+
+  if (can_manage_comment($action, $comment_author_id))
+  {
+    $perform_redirect = false;
+
+    if ('delete' == $action)
+    {
+      delete_user_comment_albums($comment_id);
+      $perform_redirect = true;
+    }
+
+    if ('validate' == $action)
+    {
+      validate_user_comment_albums($comment_id);
+      $perform_redirect = true;
+    }
+
+    if ('edit' == $action)
+    {
+      if (!empty($_POST['content']))
+      {
+        update_user_comment_albums(
+          array(
+            'comment_id' => $_GET['edit_comment_album'],
+            'category_id' => $_POST['image_id'],
+            'content' => $_POST['content']
+            ),
+          $_POST['key']
+          );
+
+        $perform_redirect = true;
+      }
+      else
+      {
+        $edit_comment = $_GET['edit_comment_album'];
+      }
+    }
+
+    if ($perform_redirect)
+    {
+      $redirect_url =
+        PHPWG_ROOT_PATH
+        .'index.php'
+        .get_query_string_diff(array('delete_comment_album','validate_comment_album','edit_comment_album','pwg_token'));
+
+      redirect(rtrim($redirect_url, '='));
+    }
+  }
 }
 
@@ -36,39 +84,50 @@
 // |                        last comments display                          |
 // +-----------------------------------------------------------------------+
+if ( !is_admin() )
+{
+  $page['where_clauses'][] = 'validated=\'true\'';
+}
+
+$page['where_clauses'][] = get_sql_condition_FandF
+  (
+    array
+      (
+        'forbidden_categories' => 'category_id',
+        'visible_categories' => 'category_id',
+      ),
+    '', true
+  );
+
 $comments = array();
 $element_ids = array();
 $category_ids = array();
-$max_width = 0;
-if (!is_admin())
-{
-  $clauses[] = 'validated="true"';
-}
-$clauses[] = get_sql_condition_FandF (
-    array ('forbidden_categories' => 'category_id',
-        'visible_categories' => 'category_id'), '', true);
 
 $query = '
-SELECT
-    com.id AS comment_id,
-    com.category_id,
-    com.author,
-    com.author_id,
-    '.$conf['user_fields']['username'].' AS username,
-    com.date,
-    com.content,
-    com.validated
+SELECT com.id AS comment_id,
+       com.category_id,
+       com.author,
+       com.author_id,
+       com.date,
+       com.content,
+       com.validated
   FROM '.COA_TABLE.' AS com
-    LEFT JOIN '.USERS_TABLE.' As u
-      ON u.'.$conf['user_fields']['id'].' = com.author_id
+    LEFT JOIN '.USERS_TABLE.' AS u
+    ON u.'.$conf['user_fields']['id'].' = com.author_id
   WHERE '.implode('
-    AND ', $clauses).'
-  GROUP BY
-    comment_id
+    AND ', $page['where_clauses']).'
+  GROUP BY comment_id,
+       com.category_id,
+       com.author,
+       com.author_id,
+       com.date,
+       com.content,
+       com.validated
   ORDER BY date DESC
-  LIMIT 0, ' . $datas[0] . '
+  LIMIT 0, ' . $datas[0] . ';';
+
+$query.= '
 ;';
-
 $result = pwg_query($query);
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
 {
   array_push($comments, $row);
@@ -78,7 +137,22 @@
 if (count($comments) > 0)
 {
+  $block['TEMPLATE'] = 'stuffs_lastcoms.tpl';
   $block['TITLE_URL'] = 'comments.php?display_mode=albums';
   $block['comments'] = array();
-
+  $block['MAX_WIDTH'] = $datas[3];
+  $block['MAX_HEIGHT'] = $datas[4];
+  switch ($datas[2])
+  {
+    case 1 :
+      $block['NB_COMMENTS_LINE'] = '99%';
+      break;
+    case 2 :
+      $block['NB_COMMENTS_LINE'] = '49%';
+      break;
+    case 3 :
+      $block['NB_COMMENTS_LINE'] = '32.4%';
+      break;
+  }
+  
   // retrieving category informations
   $query = '
@@ -90,6 +164,5 @@
     com.id as comment_id,
     img.id AS image_id,
-    img.path,
-    img.tn_ext
+    img.path
   FROM '.CATEGORIES_TABLE.' AS cat
     LEFT JOIN '.COA_TABLE.' AS com
@@ -115,68 +188,84 @@
     $comment['cat_url'] = duplicate_index_url(
       array(
-        'category' => array(
-          'id' => $categories[$comment['comment_id']]['id'], 
-          'name' => $categories[$comment['comment_id']]['name'], 
-          'permalink' => $categories[$comment['comment_id']]['permalink'],
-          ),
+        'category' => $categories[$comment['comment_id']],
         array('start')
         )
       );
-     
-    // category thumbnail
-    $comment['thumb'] = get_thumbnail_url(
-      array(
-        'id' => $categories[$comment['comment_id']]['image_id'],
-        'path' => $categories[$comment['comment_id']]['path'],
-        'tn_ext' => @$categories[$comment['comment_id']]['tn_ext'],
-        )
-     );
+
+    // source of the thumbnail picture
+    $src_image = new SrcImage(array(
+      'id' => $categories[$comment['comment_id']]['image_id'],
+      'path' => $categories[$comment['comment_id']]['path'],
+      ));
 
     // author
-    $author = $comment['author'];
     if (empty($comment['author']))
     {
-      $author = l10n('guest');
-    }
-    
-    // comment content
+      $comment['author'] = l10n('guest');
+    }
+
     $tpl_comment = array(
       'ID' => $comment['comment_id'],
       'U_PICTURE' => $comment['cat_url'],
+      'src_image' => $src_image,
       'ALT' => trigger_event('render_category_name', $categories[$comment['comment_id']]['name']),
-      'TN_SRC' => $comment['thumb'],
-      'AUTHOR' => trigger_event('render_comment_author', $author),
-      'DATE' => format_date($comment['date'], true),
-      'CONTENT' => trigger_event('render_comment_content', $comment['content'], 'album'),
+      'AUTHOR' => trigger_event('render_comment_author', $comment['author']),
+      'DATE'=>format_date($comment['date'], true),
+      'CONTENT'=>trigger_event('render_comment_content',$comment['content']),
       'WIDTH' => $datas[3],
       'HEIGHT' => $datas[4],
       );
-
-    switch ($datas[2])
-    {
-      case 1 :
-        $tpl_comment['CLASS'] = 'one_comment';
-        break;
-      case 2 :
-        $tpl_comment['CLASS'] = 'two_comment';
-        break;
-      case 3 :
-        $tpl_comment['CLASS'] = 'three_comment';
-        break;
-    }
-
-    // actions
-    if ( is_admin() and $datas[1])
-    {
-      $url = get_root_url().'index.php'.get_query_string_diff(array('delete_album','validate_album'));
-      $tpl_comment['U_DELETE'] = add_url_params($url, array(
-            'delete_album' => $comment['comment_id'],
-            'pwg_token' => get_pwg_token()));
-
-      if ($comment['validated'] != 'true')
-      {
-        $tpl_comment['U_VALIDATE'] = add_url_params($url, array(
-            'validate_album' => $comment['comment_id'],
-            'pwg_token' => get_pwg_token()));
+    
+    if ($datas[1] == 'on')
+    {
+      $url =
+        get_root_url()
+        .'index.php'
+        .get_query_string_diff(array('edit_comment_album', 'delete_comment_album','validate_comment_album', 'pwg_token'));
+
+      if (can_manage_comment('delete', $comment['author_id']))
+      {
+        $tpl_comment['U_DELETE'] = add_url_params(
+          $url,
+          array(
+            'delete_comment_album' => $comment['comment_id'],
+            'pwg_token' => get_pwg_token(),
+            )
+          );
+      }
+
+      if (can_manage_comment('edit', $comment['author_id']))
+      {
+        $tpl_comment['U_EDIT'] = add_url_params(
+          $url,
+          array(
+            'edit_comment_album' => $comment['comment_id'],
+            'pwg_token' => get_pwg_token(),
+            )
+          );
+
+        if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment))
+        {
+          $tpl_comment['IN_EDIT'] = true;
+          $key = get_ephemeral_key(2, $comment['category_id']);
+          $tpl_comment['KEY'] = $key;
+          $tpl_comment['IMAGE_ID'] = $comment['category_id'];
+          $tpl_comment['CONTENT'] = $comment['content'];
+          $tpl_comment['PWG_TOKEN'] = get_pwg_token();
+        }
+      }
+
+      if (can_manage_comment('validate', $comment['author_id']))
+      {
+        if ('true' != $comment['validated'])
+        {
+          $tpl_comment['U_VALIDATE'] = add_url_params(
+            $url,
+            array(
+              'validate_comment_album'=> $comment['comment_id'],
+              'pwg_token' => get_pwg_token(),
+              )
+            );
+        }
       }
     }
@@ -184,5 +273,5 @@
     array_push($block['comments'], $tpl_comment);
   }
-  $block['TEMPLATE'] = dirname(__FILE__).'/stuffs_lastcoms.tpl';
+  $block['derivative_params'] = ImageStdParams::get_by_type(IMG_THUMB);
 }
 
Index: tensions/Comments_on_Albums/trunk/stuffs_module/stuffs_lastcoms.tpl
===================================================================
--- /extensions/Comments_on_Albums/trunk/stuffs_module/stuffs_lastcoms.tpl	(revision 21346)
+++ 	(revision )
@@ -1,40 +1,0 @@
-<div id="comments">
-<ul class="thumbnailCategories">
-{foreach from=$block.comments item=comment}
-<li {if isset($comment.CLASS)}class="{$comment.CLASS}"{/if}>
-  <div class="thumbnailCategory">
-    {if isset($comment.TN_SRC)}
-    <div class="illustration">
-      <a href="{$comment.U_PICTURE}">
-        <img src="{$comment.TN_SRC}" alt="{$comment.ALT}"
-          style="{if !empty($comment.WIDTH)}max-width: {$comment.WIDTH}px; {/if}{if !empty($comment.HEIGHT)}max-height: {$comment.HEIGHT}px; {/if}"/>
-        <br>{$comment.ALT}
-      </a>
-    </div>
-    {/if}
-    <div class="description">
-      {if isset($comment.U_DELETE) or isset($comment.U_VALIDATE) }
-      <div class="actions" style="float:right">
-        {if !empty($comment.U_DELETE)}
-          <a href="{$comment.U_DELETE}" title="{'delete this comment'|@translate}" onClick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">
-            <img src="{$ROOT_URL}{$themeconf.icon_dir}/delete.png" class="button" alt="[delete]" />
-          </a>
-        {/if}
-        {if !empty($comment.U_VALIDATE)}
-          <a href="{$comment.U_VALIDATE}" title="validate this comment">
-            <img src="{$ROOT_URL}{$themeconf.icon_dir}/validate_s.png" class="button" alt="[validate]" />
-          </a>
-        {/if}
-      </div>
-      {/if}
-      <span class="author">{$comment.AUTHOR}</span> - <span class="date">{$comment.DATE}</span>
-      <blockquote>{$comment.CONTENT}</blockquote>
-    </div>
-  </div>
-</li>
-{if isset($comment_separator)}
-<hr/>
-{/if}
-{/foreach}
-</ul>
-</div>
Index: /extensions/Comments_on_Albums/trunk/template/admin_comments.tpl
===================================================================
--- /extensions/Comments_on_Albums/trunk/template/admin_comments.tpl	(revision 21346)
+++ /extensions/Comments_on_Albums/trunk/template/admin_comments.tpl	(revision 21347)
