<?php
/**
 * Comment module
 * 
 * Allow user to get back a view from the last comment submission
 * 
 * @package linea21\modules\comment
 * @author $Author$ - Simon Georget <simon@linea21.com>
 * @version $Id$ 
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */
session_start();

$noplugin = true; // flag for ../config/define.php file
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'];
if(isset($_GET['rub'])) $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>var mainURL = "'.SITE_ROOT_URL .'";</script>';
  echo 	'<script type="text/javascript" src="'.SITE_ROOT_URL.'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>';
}
?>