Index: extensions/Comments_on_Albums/include/coa_admin_comments.php
===================================================================
--- extensions/Comments_on_Albums/include/coa_admin_comments.php	(revision 9624)
+++ extensions/Comments_on_Albums/include/coa_admin_comments.php	(revision 9634)
@@ -127,5 +127,5 @@
 
 	// template
-	$template->set_filename('comments', dirname(__FILE__) .'/../template/coa_admin.tpl');
+	$template->set_filename('comments', dirname(__FILE__) .'/../template/coa_admin_comments.tpl');
 	$template->assign(array(
 		'F_ACTION' => get_root_url().'admin.php?page=comments&amp;section=albums',
Index: extensions/Comments_on_Albums/include/coa_admin_intro.php
===================================================================
--- extensions/Comments_on_Albums/include/coa_admin_intro.php	(revision 9624)
+++ extensions/Comments_on_Albums/include/coa_admin_intro.php	(revision 9634)
@@ -10,5 +10,5 @@
 list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
 
-$template->assign('NB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments) .' ('. l10n('Albums') .')');
+$template->assign('DB_COMMENTS_ALBUMS', l10n_dec('%d comment', '%d comments', $nb_comments));
 
 // unvalidated comments
@@ -28,5 +28,5 @@
 
 // template
-$template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/coa_intro.tpl');
+$template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/coa_admin_intro.tpl');
 $template->concat('ADMIN_CONTENT', $template->parse('comments_on_albums', true));
 
Index: extensions/Comments_on_Albums/include/coa_albums.php
===================================================================
--- extensions/Comments_on_Albums/include/coa_albums.php	(revision 9624)
+++ extensions/Comments_on_Albums/include/coa_albums.php	(revision 9634)
@@ -27,9 +27,9 @@
 			include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions
 			check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID);
-			$author_id = get_comment_author_id($_GET['comment_to_edit']);
+			$author_id = get_comment_author_id_albums($_GET['comment_to_edit']);
 
 			if (can_manage_comment('edit', $author_id)) {
 				if (!empty($_POST['content'])) {
-					update_user_comment(array(
+					update_user_comment_albums(array(
 						'comment_id' => $_GET['comment_to_edit'],
 						'image_id' => $category['id'],
@@ -49,8 +49,8 @@
 			include_once(COA_PATH.'include/functions_comment.inc.php');
 			check_input_parameter('comment_to_delete', $_GET, false, PATTERN_ID);
-			$author_id = get_comment_author_id($_GET['comment_to_delete']);
+			$author_id = get_comment_author_id_albums($_GET['comment_to_delete']);
 
 			if (can_manage_comment('delete', $author_id)) {
-				delete_user_comment($_GET['comment_to_delete']);
+				delete_user_comment_albums($_GET['comment_to_delete']);
 			}
 
@@ -62,8 +62,8 @@
 			include_once(COA_PATH.'include/functions_comment.inc.php');
 			check_input_parameter('comment_to_validate', $_GET, false, PATTERN_ID);
-			$author_id = get_comment_author_id($_GET['comment_to_validate']);
+			$author_id = get_comment_author_id_albums($_GET['comment_to_validate']);
 
 			if (can_manage_comment('validate', $author_id)) {
-				validate_user_comment($_GET['comment_to_validate']);
+				validate_user_comment_albums($_GET['comment_to_validate']);
 			}
 
@@ -124,5 +124,5 @@
 	}
 
-	// number of comments for this picture
+	// number of comments for this category
 	$query = 'SELECT COUNT(*) AS nb_comments
 		FROM '.COA_TABLE.'
Index: extensions/Comments_on_Albums/include/coa_comments_page.php
===================================================================
--- extensions/Comments_on_Albums/include/coa_comments_page.php	(revision 9634)
+++ extensions/Comments_on_Albums/include/coa_comments_page.php	(revision 9634)
@@ -0,0 +1,255 @@
+<?php 
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$template->assign(array(
+	'COA_PATH' => COA_PATH,
+	'ICON_COLOR' => 'ff3363',
+	'ICON_COLOR_OVER' => 'ff7700',
+));
+
+// ajout d'un bouton sur la page principale
+if (!isset($_GET['display_mode'])) {	
+	
+	$template->set_prefilter('comments', 'coa_add_button');
+
+	function coa_add_button($content, &$smarty) {
+		$search = '#<ul class="categoryActions">#';
+
+		$replacement = '
+		{html_head}
+			<style type="text/css">
+				.pwg-icon-comments-albums {ldelim}
+					background-image: url({$COA_PATH}template/s26/outline_{$ICON_COLOR}.png);
+					background-position: -26px 0;
+				}
+				a:hover .pwg-icon-comments-albums {ldelim}
+					background-image: url({$COA_PATH}template/s26/outline_{$ICON_COLOR_OVER}.png);
+					background-position: -26px 0;
+				}
+			</style>
+		{/html_head}
+
+		<ul class="categoryActions">
+			<li><a href="comments.php?display_mode=albums" title="Commentaires albums" class="pwg-state-default pwg-button">
+				<span class="pwg-icon pwg-icon-comments-albums">&nbsp;</span><span class="pwg-button-text">Commentaires albums</span>
+			</a></li>';
+
+		return preg_replace($search, $replacement, $content);
+	}
+	
+// page modifiée pour les commentaires albums
+} else if ($_GET['display_mode'] == 'albums') {
+	$template->clear_assign(array('comments', 'navbar', 'sort_by_options'));
+	
+// sort_by : database fields proposed for sorting comments list
+$sort_by = array(
+	'date' => l10n('comment date'),
+	'category_id' => l10n('album')
+);
+$template->assign('sort_by_options', $sort_by);
+
+// +-----------------------------------------------------------------------+
+// |                         comments management                           |
+// +-----------------------------------------------------------------------+
+
+$comment_id = null;
+$action = null;
+
+$actions = array('delete_albums', 'validate_albums', 'edit_albums');
+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)) {
+	include_once(COA_PATH.'include/functions_comment.inc.php');
+	check_pwg_token();
+	$comment_author_id = get_comment_author_id_albums($comment_id);
+	$true_action = str_replace('_albums', null, $action);
+
+	if (can_manage_comment($true_action, $comment_author_id)) {
+		$perform_redirect = false;
+
+		if ('delete_albums' == $action) {
+			delete_user_comment_albums($comment_id);
+			$perform_redirect = true;
+		}
+
+		if ('validate_albums' == $action) {
+			validate_user_comment_albums($comment_id);
+			$perform_redirect = true;
+		}
+
+		if ('edit_albums' == $action) {
+			if (!empty($_POST['content'])) {
+				update_user_comment_albums(array(
+					'comment_id' => $_GET['edit_albums'],
+					'image_id' => $_POST['image_id'],
+					'content' => $_POST['content']
+					), $_POST['key']
+				);
+				$perform_redirect = true;
+			} else {
+				$edit_comment = $_GET['edit_albums'];
+			}
+		}
+
+		if ($perform_redirect) {
+			$redirect_url = PHPWG_ROOT_PATH.'comments.php'.get_query_string_diff(array('delete_albums','validate_albums','edit_albums','pwg_token'));
+			redirect($redirect_url);
+		}
+	}
+}
+
+// +-----------------------------------------------------------------------+
+// |                            navigation bar                             |
+// +-----------------------------------------------------------------------+
+
+if (isset($_GET['start']) and is_numeric($_GET['start'])) {
+	$start = $_GET['start'];
+} else {
+	$start = 0;
+}
+
+$query = 'SELECT COUNT(DISTINCT(com.id))
+	FROM '.COA_TABLE.' AS com
+	LEFT JOIN '.USERS_TABLE.' As u
+	ON u.'.$conf['user_fields']['id'].' = com.author_id
+	WHERE '.implode('
+	AND ', $page['where_clauses']).'
+;';
+
+list($counter) = pwg_db_fetch_row(pwg_query($query));
+
+$url = PHPWG_ROOT_PATH . 'comments.php' . get_query_string_diff(array('start','delete','validate','pwg_token'));
+$navbar = create_navigation_bar($url, $counter, $start, $page['items_number'], '');
+$template->assign('navbar', $navbar);
+
+// +-----------------------------------------------------------------------+
+// |                        last comments display                          |
+// +-----------------------------------------------------------------------+
+
+$comments = array();
+$element_ids = array();
+$category_ids = array();
+
+$query = '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
+	WHERE '.implode('
+	AND ', $page['where_clauses']).'
+	GROUP BY
+		comment_id,
+		com.category_id,
+		com.author,
+		com.author_id,
+		com.date,
+		com.content,
+		com.validated
+	ORDER BY '.$page['sort_by'].' '.$page['sort_order'];
+	if ('all' != $page['items_number']) {
+		$query.= '
+		LIMIT '.$page['items_number'].' OFFSET '.$start;
+	}
+	$query.= '
+;';
+$result = pwg_query($query);
+
+while ($row = pwg_db_fetch_assoc($result)) {
+	array_push($comments, $row);
+	array_push($element_ids, $row['category_id']);
+}
+
+if (count($comments) > 0) {
+	// retrieving category informations
+	$query = 'SELECT 
+			cat.id, 
+			cat.name, 
+			cat.permalink, 
+			cat.uppercats, 
+			com.id as comment_id
+		FROM '.CATEGORIES_TABLE.' AS cat
+		LEFT JOIN '.COA_TABLE.' AS com
+		ON cat.id=com.category_id
+		'.get_sql_condition_FandF(array(
+			'forbidden_categories' => 'cat.id',
+			'visible_categories' => 'cat.id'
+		), 'WHERE').'
+		AND cat.id IN ('.implode(',', $element_ids).')
+	;';
+	$categories = hash_from_query($query, 'comment_id');
+
+	foreach ($comments as $comment) {
+		$name = $categories[$comment['comment_id']]['name'];
+
+		$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'],
+			),array('start')
+		));
+
+		$tpl_comment = array(
+			'U_PICTURE' => $url,
+			'TN_SRC' => $url,
+			'ALT' => $name,
+			'AUTHOR' => trigger_event('render_comment_author', $comment['author']),
+			'DATE' => format_date($comment['date'], true),
+			'CONTENT' => trigger_event('render_comment_content',$comment['content']),
+		);
+
+		if (can_manage_comment('delete', $comment['author_id'])) {
+			$url = get_root_url().'comments.php'.get_query_string_diff(array('delete','validate','edit', 'pwg_token'));
+
+			$tpl_comment['U_DELETE'] = add_url_params($url, array(
+				'delete_albums' => $comment['comment_id'],
+				'pwg_token' => get_pwg_token(),
+			));
+		}
+		if (can_manage_comment('edit', $comment['author_id'])) {
+			$url = get_root_url().'comments.php'.get_query_string_diff(array('edit', 'delete','validate', 'pwg_token'));
+
+			$tpl_comment['U_EDIT'] = add_url_params($url, array(
+				'edit_albums' => $comment['comment_id'],
+				'pwg_token' => get_pwg_token(),
+			));
+
+			if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment)) {
+				$key = get_ephemeral_key(2, $comment['category_id']);
+				$tpl_comment['IN_EDIT'] = true;
+				$tpl_comment['KEY'] = $key;
+				$tpl_comment['IMAGE_ID'] = $comment['category_id'];
+				$tpl_comment['CONTENT'] = $comment['content'];
+			}
+		}
+		if (can_manage_comment('validate', $comment['author_id'])) {
+			if ('true' != $comment['validated']) {
+				$tpl_comment['U_VALIDATE'] = add_url_params($url, array(
+					'validate_albums'=> $comment['comment_id'],
+					'pwg_token' => get_pwg_token(),
+				));
+			}
+		}
+		
+		$template->append('comments', $tpl_comment);
+	}
+}
+
+	
+	$template->set_filenames(array('comments'=> dirname(__FILE__).'/../template/coa_comments_page.tpl'));
+}
+
+?>
Index: extensions/Comments_on_Albums/include/functions_comment.inc.php
===================================================================
--- extensions/Comments_on_Albums/include/functions_comment.inc.php	(revision 9624)
+++ extensions/Comments_on_Albums/include/functions_comment.inc.php	(revision 9634)
@@ -3,32 +3,34 @@
 
 //returns string action to perform on a new comment: validate, moderate, reject
-function user_comment_check($action, $comment)
-{
-  global $conf,$user;
-
-  if ($action=='reject')
-    return $action;
-
-  $my_action = $conf['comment_spam_reject'] ? 'reject':'moderate';
-
-  if ($action==$my_action)
-    return $action;
-
-  // we do here only BASIC spam check (plugins can do more)
-  if ( !is_a_guest() )
-    return $action;
-
-  $link_count = preg_match_all( '/https?:\/\//',
-    $comment['content'], $matches);
-
-  if ( strpos($comment['author'], 'http://')!==false )
-  {
-    $link_count++;
-  }
-
-  if ( $link_count>$conf['comment_spam_max_links'] )
-    return $my_action;
-
-  return $action;
+if (!function_exists('user_comment_check')) {
+	function user_comment_check($action, $comment)
+	{
+	  global $conf,$user;
+
+	  if ($action=='reject')
+		return $action;
+
+	  $my_action = $conf['comment_spam_reject'] ? 'reject':'moderate';
+
+	  if ($action==$my_action)
+		return $action;
+
+	  // we do here only BASIC spam check (plugins can do more)
+	  if ( !is_a_guest() )
+		return $action;
+
+	  $link_count = preg_match_all( '/https?:\/\//',
+		$comment['content'], $matches);
+
+	  if ( strpos($comment['author'], 'http://')!==false )
+	  {
+		$link_count++;
+	  }
+
+	  if ( $link_count>$conf['comment_spam_max_links'] )
+		return $my_action;
+
+	  return $action;
+	}
 }
 
@@ -44,5 +46,5 @@
  * @param array infos out array of messages
  */
-function insert_user_comment( &$comm, $key, &$infos )
+function insert_user_comment_albums( &$comm, $key, &$infos )
 {
   global $conf, $user;
@@ -185,5 +187,5 @@
  * @param comment_id
  */
-function delete_user_comment($comment_id) {
+function delete_user_comment_albums($comment_id) {
   $user_where_clause = '';
   if (!is_admin())
@@ -216,5 +218,5 @@
  */
 
-function update_user_comment($comment, $post_key)
+function update_user_comment_albums($comment, $post_key)
 {
   global $conf;
@@ -259,38 +261,40 @@
 }
 
-function email_admin($action, $comment)
-{
-  global $conf;
-
-  if (!in_array($action, array('edit', 'delete'))
-      or (($action=='edit') and !$conf['email_admin_on_comment_edition'])
-      or (($action=='delete') and !$conf['email_admin_on_comment_deletion']))
-  {
-    return;
-  }
-
-  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
-
-  $keyargs_content = array();
-  $keyargs_content[] = get_l10n_args('Author: %s', $comment['author']);
-  if ($action=='delete')
-  {
-    $keyargs_content[] = get_l10n_args('This author removed the comment with id %d',
-				       $comment['comment_id']
-				       );
-  }
-  else
-  {
-    $keyargs_content[] = get_l10n_args('This author modified following comment:', '');
-    $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']);
-  }
-
-  pwg_mail_notification_admins(get_l10n_args('Comment by %s',
-					     $comment['author']),
-			       $keyargs_content
-			       );
-}
-
-function get_comment_author_id($comment_id, $die_on_error=true)
+if (!function_exists('email_admin')) {
+	function email_admin($action, $comment)
+	{
+	  global $conf;
+
+	  if (!in_array($action, array('edit', 'delete'))
+		  or (($action=='edit') and !$conf['email_admin_on_comment_edition'])
+		  or (($action=='delete') and !$conf['email_admin_on_comment_deletion']))
+	  {
+		return;
+	  }
+
+	  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+
+	  $keyargs_content = array();
+	  $keyargs_content[] = get_l10n_args('Author: %s', $comment['author']);
+	  if ($action=='delete')
+	  {
+		$keyargs_content[] = get_l10n_args('This author removed the comment with id %d',
+						   $comment['comment_id']
+						   );
+	  }
+	  else
+	  {
+		$keyargs_content[] = get_l10n_args('This author modified following comment:', '');
+		$keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']);
+	  }
+
+	  pwg_mail_notification_admins(get_l10n_args('Comment by %s',
+							 $comment['author']),
+					   $keyargs_content
+					   );
+	}
+}
+
+function get_comment_author_id_albums($comment_id, $die_on_error=true)
 {
   $query = '
@@ -318,5 +322,5 @@
 }
 
-function validate_user_comment($comment_id)
+function validate_user_comment_albums($comment_id)
 {
   $query = '
