<?php
/**
 * @package linea21.core
 * @subpackage public
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

include_once('../workshop/display.php');

SetHTMLTitle($GLOBALS['lang']['workshop']['section']);

//if($GLOBALS['activeitem']=='dossier') {
  $GLOBALS['filters'][LANGUAGE]['theme']['active'] = 1; // filter activation
  $GLOBALS['filters'][LANGUAGE]['level']['active'] = 1; // filter activation
//}

if(ActiveItemKey($GLOBALS['activeitem']) == 'subject') {
   $workshop_id=$_REQUEST['parentid'];
   $discussion_id=$_REQUEST['id'];
}
elseif (ActiveItemKey($GLOBALS['activeitem']) == 'message') {
  if (isset($_REQUEST['parentparentid'])) $discussion_id=$_REQUEST['parentparentid'];
  $workshop_id=$_REQUEST['parentid'];
  $subject_id=$_REQUEST['id'];
}
else {
 $workshop_id= isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
}

//if (isset($_REQUEST['parentid']) &&  ActiveItemKey($GLOBALS['activeitem']) == 'message')
//{
//  if (isset($_REQUEST['parentparentid'])) $discussion_id=$_REQUEST['parentparentid'];
//  $workshop_id=$_REQUEST['parentid'];
//  $subject_id=$_REQUEST['id'];
//}
//else
//if (isset($_REQUEST['parentid']))
//{
//  $workshop_id=$_REQUEST['parentid'];
//  $discussion_id=$_REQUEST['id'];
//}
//else if (isset($_REQUEST['id'])) $workshop_id=$_REQUEST['id'];
//else $workshop_id="";

if (isset($_REQUEST['filter'])) $filter=$_REQUEST['filter'];
else $filter="";
if (isset($_REQUEST['debut']) && ActiveItemKey($GLOBALS['activeitem'])=='discussion') $debut=$_REQUEST['debut'];
else {
  if (isset($_REQUEST['debut']) && ActiveItemKey($GLOBALS['activeitem'])=='subject') $debut=$_REQUEST['debut'];
  else $debut=0;
}
if (isset($_POST['body'])) $body=$_POST['body'];
else $body='';
if (isset($_POST['title'])) $title=$_POST['title'];
else $title='';

if (isset($_POST['type_message'])) $type_message=$_POST['type_message'];
else $type_message='';

$test_cookie=CookieWorkshopid($workshop_id);
?>
<div id="contenu">
<?php
if (isset($_REQUEST['id']) && !isset($_REQUEST['filter']) && ActiveItemAlias($GLOBALS['activeitem'])=='workgroup' && ActiveItemKey($GLOBALS['activeitem'])!='subscribe-workgroup') {
?> 
<?php
  ////////////////////////////////////////////////////
  /////affichage titre groupe de travail
  ///////////////////////////////////////////////////
  
    // set HTML Title
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getWorkshopDenomination($workshop_id));
    $workshop_name = formatText($result[0]['workshop_denomination'], '2HTML');
    SetHTMLTitle($workshop_name);
  
    DisplayOneWorkshop($workshop_id, "title");

  ?>
<div id="workshop"><?php DisplayOneWorkshop($workshop_id);?> <?php if ($test_cookie<>true) DisplayUrlInscription($workshop_id, $test_cookie); ?>
</div>
<br />
<div class="barre_list">
<ul>
	<li><?php  DisplayUrlCalendar($workshop_id, $workshop_name); ?>
	</li>
	<?php if ($test_cookie==true) {
	  echo "<li>";
	  DisplayUrlDiscussion($workshop_id, $workshop_name );
	  echo "</li>";
	} ?>
	<li><?php  DisplayUrlListerapport($workshop_id, $workshop_name); ?>
	</li>
	<li><?php  DisplayUrlListeutilisateur($workshop_id, $workshop_name); ?>
	</li>
</ul>
</div>
<br />
	  <?php 
	  if (ActiveItemKey($GLOBALS['activeitem'])=='calendar' || ActiveItemKey($GLOBALS['activeitem'])=='workgroup') {
      ?>
        <div id="calendar">
        <h2><?php echo $GLOBALS['lang']['workshop']['calendar']; ?></h2>
  	    <?php DisplayCalendar($workshop_id, "ALL"); ?>
  	  	</div>
	  <?php 
	  }
	  //////////////////////////////////////////
	  /////affichage discussions
	  //////////////////////////////////////////
	  if ((ActiveItemKey($GLOBALS['activeitem'])=='discussion' || ActiveItemKey($GLOBALS['activeitem'])=='subject' || ActiveItemKey($GLOBALS['activeitem'])=='message') && $test_cookie==true) {

    	  //////////////////////////////////////////
    	  /////affichage liste des discussions
    	  //////////////////////////////////////////
    	  if (ActiveItemKey($GLOBALS['activeitem'])=='discussion') { ?>
          <div id="discussion"><?php DisplayListDiscussion($workshop_id, $debut); ?></div>
    	  <?php }
    	  
    	  //////////////////////////////////////////
    	  /////affichage d'un sujet
    	  //////////////////////////////////////////
    	  if (ActiveItemKey($GLOBALS['activeitem'])=='subject') { ?>
          <div id="sujet"><?php DisplayOneDiscussion($workshop_id, $discussion_id, $debut,-1, $body, $title, $type_message); ?></div>
          <?php }
          
          //////////////////////////////////////////
          /////affichage d'un message
          //////////////////////////////////////////
          if (ActiveItemKey($GLOBALS['activeitem'])== 'message' ){
            if (isset($_POST['parentparentid'])) {
              DisplayOneDiscussion($workshop_id, $discussion_id, $debut, "ONE", $body, $title, $type_message);
              DisplayFormMessageMod($workshop_id, $discussion_id, $subject_id, $body, $title);
            }
            else {
              DisplayOneDiscussion($workshop_id, $discussion_id, $debut, "ONE", $body, $title, $type_message);
              DisplayFormMessageMod($workshop_id, $discussion_id, $subject_id, $body, $title, "NOPOST");
            }
            ?>
      		<hr />
          <?php }
	    }

        //////////////////////////////////////////
        /////affichage utilisateurs et rapport d'un groupe de travail
        //////////////////////////////////////////
        if (ActiveItemKey($GLOBALS['activeitem'])=='user-all') { ?>
        
        <div id="user">
        <h2><?php echo $GLOBALS['lang']['workshop']['participant']; ?></h2>
        <?php DisplayUserWorkshop($workshop_id);?>
        </div>
        <?php }
        if (ActiveItemKey($GLOBALS['activeitem'])=='report-all') {
          ?>
        <div id="report">
        <h2><?php echo $GLOBALS['lang']['workshop']['report']; ?></h2>
        <?php DisplayListReport($workshop_id);?>
        </div>
        <?php }
}

//////////////////////////////////////////
/////affichage liste des groupes de travail
//////////////////////////////////////////

else {
  if (ActiveItemKey($GLOBALS['activeitem'])=='subscribe-workgroup') {
  ?>
    <h1><?php echo $GLOBALS['lang']['workshop']['creainscription']; ?></h1>
    <?php DisplayInscription($workshop_id);
  } else{
  ?>
    <h1><?php echo $GLOBALS['lang']['workshop']['h1_public']; ?></h1>
    <div class="h1_comment" id="h1_workshop"><?php echo $GLOBALS['lang']['workshop']['h1_public_comment']; ?>
    </div>
    <?php DisplayListWorkshop($workshop_id, $filter);
  }
}
?>
</div>
