<?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
 */

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

SetHTMLTitle(_t('workshop','section'));

$GLOBALS['filters'][LANGUAGE]['theme']['active'] = 1; // filter activation
$GLOBALS['filters'][LANGUAGE]['level']['active'] = 1; // filter activation


/* Post Values instances */
//filter theme & scale
$filter= isset($_REQUEST['filter']) ? $_REQUEST['filter'] : '';
//value of pagination
$debut= isset($_REQUEST['debut']) ? $_REQUEST['debut'] : 0;
//id for workgroup
$workshop_id= isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
//body for topic
$body= isset($_REQUEST['body']) ? $_REQUEST['body'] : '';
//title for topic
$title= isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
// case for test integrity for update a post or add a topic
$confirm= isset($_REQUEST['confirm']) ? $_REQUEST['confirm'] : '';


if(ActiveItemKey($GLOBALS['activeitem']) == 'topic' || ActiveItemKey($GLOBALS['activeitem']) == 'post-add') {
  $topic_id=$_REQUEST['id'];
  $workshop_id=$_REQUEST['parentid'];
}

if (ActiveItemKey($GLOBALS['activeitem']) == 'post-update') {
  $topic_id=$_REQUEST['parentparentid'];
  $workshop_id=$_REQUEST['parentid'];
  $post_id=$_REQUEST['id'];
}

$is_authenticated=CookieWorkshopid($workshop_id);


//display list workgroup
if (!isset($_REQUEST['id']) || isset($_REQUEST['filter']))
{
  echo "<h1>"._t('workshop','h1_public')."</h1>";
 echo "<div class=\"h1_comment\" id=\"h1_workshop\">"._t('workshop','h1_public_comment')."</div>";
  DisplayListWorkshop($workshop_id, $filter);
}
else
{
  //display one workgroup

  $result=$GLOBALS['sql_object']->DBSelect(SQL_getWorkshopDenomination($workshop_id));
  $workshop_name = formatText($result[0]['workshop_denomination'], '2HTML');
  SetHTMLTitle($workshop_name);
  DisplayOneWorkshop($workshop_id, "title");
  ?>
<!-- workgroup data -->
<div id="workshop"><?php DisplayOneWorkshop($workshop_id);?> <?php if (!$is_authenticated) DisplayUrlInscription($workshop_id, $is_authenticated); ?>
</div>
<!-- end workgroup data -->

<div class="barre_list">
<ul>
	<li><?php  DisplayUrlCalendar($workshop_id, $workshop_name); ?></li>
	<?php if ($is_authenticated){?>
	<li><?php DisplayUrlTopicList($workshop_id, $workshop_name );?></li>
	<?}?>
	<li><?php  DisplayUrlListerapport($workshop_id, $workshop_name); ?></li>
	<li><?php  DisplayUrlListeutilisateur($workshop_id, $workshop_name); ?>
	</li>
</ul>
</div>
<!-- end barre_list -->

<div class="<?php echo ActiveItemKey($GLOBALS['activeitem']); ?>"><?php
switch( ActiveItemKey($GLOBALS['activeitem']) )
{
  case "topic-list":
    if($is_authenticated){
      echo "<h2>"._t('workshop','com')."</h2>";
      DisplayListTopic($workshop_id, $debut);
    }
    break;

  case "topic":
    if($is_authenticated){
      echo "<h2>"._t('workshop','com')."</h2>";
      DisplayTopic($workshop_id, $topic_id, $debut);
    }
    break;
    
  case "topic-add":
    if($is_authenticated){
      echo "<h2>"._t('workshop','com')."</h2>";
      AddTopic($workshop_id, $debut, $body, $title, $confirm);
    }
    break;
    
  case "post-add":
    if($is_authenticated){
      echo "<h2>"._t('workshop','com')."</h2>";
      AddPost($workshop_id, $topic_id, $debut, $body, $title);
    }
    break;

  case "post-update":
    if($is_authenticated){
      echo "<h2>"._t('workshop','com')."</h2>";
      UpdatePost($workshop_id, $topic_id, $debut, $body, $title, $post_id, $confirm);
    }
    break;
    
  case "user-all":
    echo "<h2>"._t('workshop','participant')."</h2>";
    DisplayUserWorkshop($workshop_id);
    break;

  case "report-all":
    echo "<h2>"._t('workshop','report')."</h2>";
    DisplayListReport($workshop_id);
    break;
    
  case "subscribe-workgroup":
    echo "<h2>"._t('workshop','creainscription')."</h2>";
    DisplayInscription($workshop_id);
    break;

  default:
    echo "<h2>"._t('workshop','calendar')."</h2>";
    DisplayCalendar($workshop_id);
    break;
}?></div>
<?php
}
?>

