<?php
/**
 * Comment module
 * 
 * Allow administrator to perform ajax actions 
 * 
 * @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('../admin/mysql.inc.php');
include_once('../class/class.workshop_com.php');
include_once('../languages/' . U_L . '/lang_common.' . CHARSET . '.php');
include_once('../languages/' . U_L . '/lang_workshop.' . CHARSET . '.php');

$parameters = $_GET['parameters'];

$a = parse_url($parameters, PHP_URL_QUERY);
parse_str($a, $output);
$todo = $output['todo'];
$id = $output['id'];
$com_id = $output['com_id'];
$mes_id = $output['mes_id'];

if($com_id == $mes_id) $isroot = 'true';
else $isroot = 'false';

//////////// Check Droits utilisateur ////////////
if ($l21auth->isWorkgroupOrganiser($l21auth->GetSessionElement('id'), $sql_object, $id)<>true && !$l21auth->isSuperAdmin())
ReloadIndex('admin');
////////////

$workshop_com_object= new workshop_com;

if($todo == 'sup_com') {
	
	$r = $workshop_com_object->DeleteCom($id, $mes_id, $com_id, $GLOBALS['sql_object']);

	if($r) $msg = _t('workshop', 'confirm_sup_com'); // succeed
	else  $msg = _t('msg', 'action_failed'); // failed

}

if($r == true) {
  echo '{"status":1,"el": "#msg-'.$mes_id.'", "action": "'.$todo.'", "msg": "'.$msg.'", "isroot": "'.$isroot.'"}';
} else {
  echo '{"status":0,"el": "#msg-'.$mes_id.'", "action": "'.$todo.'", "msg": "'.$msg.'", "isroot": "'.$isroot.'"}';
}

?>