<?php
/**
 * Ajax tag autocomplete
 * 
 * Auto-complete tags based on user inputs
 * 
 * @package linea21\modules\workshop
 * @author $Author$ - Simon Georget <simon@linea21.com>
 * @version $Id$ 
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

$noplugin = true; // flag for ../config/define.php file
include_once('../config/define.php');
session_start();

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

include_once('../admin/'.SQL.'.inc.php');

$data = $sql_object->DBSelect(SQL_getTagsList());

$response = array();

foreach ($data as $i => $value)
{
  $fullname = '';
  if(!empty($value['tag_name'])) {
  	$fullname = formatText($value['tag_name'], '2HTML');
  	//$str_id = $value['tag_id'];
  	$str_id = $fullname;
  }
  $response[] = array($str_id, $fullname, null, $fullname);
}

header('Content-type: application/json');
echo json_encode($response, JSON_UNESCAPED_UNICODE);