<?php
/**
 * Comment module
 * 
 * Allow user to perform ajax form 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('../admin/mysql.inc.php');
include_once('../class/class.comment.php');
include_once('../languages/' . U_L . '/lang_comment.' . CHARSET . '.php');
include_once('../languages/' . U_L . '/lang_common.' . CHARSET . '.php');
include_once(override('../comment/display.php'));

$arr = array();


//////////// Check Droits utilisateur ////////////
if (!$l21auth->isSuperAdmin()) ReloadIndex('admin');
////////////

isset($_POST['id']) ? $arr['id'] = $_POST['id'] : die('no way !');
isset($_POST['body']) ? $arr['body'] = $_POST['body'] : die('no way !');


$comm = new comment;


if(strlen($arr['body']) < 15) {
  /* Outputting the error messages */
  echo '{"status":0,"errors":{"msg":"'. _t('comment', 'error_edit') .'"}}';

} else {
  /* we modify body comment */
	$r = $comm->modify_lite($arr['id'], $arr['body'], $GLOBALS['sql_object']);
	
	if(!$r) echo '{"status":0,"msg": "'. system_error() .'"}';
	
	else echo '{"status":1,"msg": "'. _t('comment', 'successful_edit') .'"}';
  die();
}

?>