<?php
/**
 * @package linea21.modules
 * @subpackage comment
 * @author Simon Georget <simon@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */
session_start();

include_once('../config/define.php');
include_once('../languages/' . U_L . '/lang_common.' . CHARSET . '.php');
include_once('../languages/' . U_L . '/lang_comment.' . CHARSET . '.php');
include_once(override('../comment/display.php'));

$a['module'] = $_GET['module'];
$a['module_id'] = $_GET['id'];
$a['rub'] = $_GET['rub'];
if ($a['module'] == 'files') {
  $path = explode('/', $a['module_id']); // retrieve workgroup id
  $wgid = $path[1];
  $a['id']=$wgid; // we set the id
}
isset($_GET['order_by']) ? $a['order_by'] = $_GET['order_by'] : 'DESC';


//////////// Check user rights on workgroups ////////////
if ($a['module'] == 'files') {
  if(!isset($_SESSION['authenticated'])) die('<p class="error">'._t('divers', 'noauth').'</p>');
  if($wgid != 'shared' && !$l21auth->isWorkgroupUser($wgid, $sql_object)) die('<p class="error">'._t('divers', 'noauth').'</p>');
}
////////////

echo '<h2>'. basename($a['module_id']) .'</h2>';
echo '<h3>' ._t('comment', 'section').'</h3>';
echo '<div id="comments-view">';
displayComments($a, false, false);
displayCommentForm($a);
echo '</div>';
if($a['module']=='files') {
  echo 	'<script type="text/javascript" src="../lib/js/comment_submit.js"></script>
		<script type="text/javascript">
                  jQuery(function() {
                  	jQuery("#cbody").after("<input type=\"hidden\" id=\"file_id\" name=\"file_id\" value=\"'.$a['module_id'].'\" \/>");
                  });
     	</script>';
}
?>