<?php
/**
 * Project module - getting users by ajax call
 * 
 * Return a json file populating users field in add/mod project page
 *  
 * @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');

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

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

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

$response = array();


if(is_array($data)) {
    foreach ($data as $i => $user)
    {
      $fullname = '';
      if(!empty($user['profile_firstname']) || $user['profile_lastname']) {
      	$fullname = ' - '. $user['profile_firstname'].' '.$user['profile_lastname'];
      }
      $str_id = $user['user_login'];
      $html_str = $user['user_login'] . $fullname . ' ('.$user['profile_email'].')';
      $response[] = array($str_id, $html_str, null, $html_str);
    }
}

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