$query,
'firstname' => $query,
'lastname' => $query,
];
$users = UserManager::get_user_list_like($conditions, [], false, 'OR');
$result = [];
if (!empty($users)) {
foreach ($users as $user) {
$result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')'];
}
$result['items'] = $result;
}
echo json_encode($result);
break;
case 'get_user_popup':
$user_info = api_get_user_info($_REQUEST['user_id']);
$ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
if (api_get_setting('allow_message_tool') == 'true') {
echo '';
echo MessageManager::generate_message_form();
echo '
';
}
break;
case 'user_id_exists':
if (api_is_anonymous()) {
echo '';
} else {
if (UserManager::is_user_id_valid($_GET['user_id'])) {
echo 1;
} else {
echo 0;
}
}
break;
case 'search_tags':
header('Content-Type: application/json');
$result = ['items' => []];
if (api_is_anonymous()) {
echo json_encode($result);
break;
}
if (!isset($_GET['q'], $_GET['field_id'])) {
echo json_encode($result);
break;
}
$result['items'] = UserManager::get_tags($_GET['q'], $_GET['field_id'], null, '10');
echo json_encode($result);
break;
case 'generate_api_key':
if (api_is_anonymous()) {
echo '';
} else {
$array_list_key = array();
$user_id = api_get_user_id();
$api_service = 'dokeos';
$num = UserManager::update_api_key($user_id, $api_service);
$array_list_key = UserManager::get_api_keys($user_id, $api_service);
?>
SmsPlugin::ACCOUNT_APPROVED_CONNECT,
'userId' => $user_id
);
$result = api_mail_html(
$recipient_name,
$user_info['mail'],
$emailsubject,
$emailbody,
$sender_name,
$email_admin,
null,
null,
$additionalParameters
);
Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $user_id);
} else {
Event::addEvent(LOG_USER_DISABLE, LOG_USER_ID, $user_id);
}
echo $status;
}
} else {
echo '-1';
}
break;
case 'user_by_role':
api_block_anonymous_users(false);
$criteria = new Criteria();
$criteria
->where(
Criteria::expr()->orX(
Criteria::expr()->contains('username', $_REQUEST['q']),
Criteria::expr()->contains('firstname', $_REQUEST['q']),
Criteria::expr()->contains('lastname', $_REQUEST['q'])
)
)
->andWhere(
Criteria::expr()->eq('status', DRH)
);
$users = UserManager::getRepository()->matching($criteria);
if (!$users->count()) {
echo json_encode([]);
break;
}
$items = [];
/** @var User $user */
foreach ($users as $user) {
$items[] = [
'id' => $user->getId(),
'text' => $user->getCompleteNameWithUsername()
];
}
header('Content-Type: application/json');
echo json_encode(['items' => $items]);
break;
case 'teacher_to_basis_course':
api_block_anonymous_users(false);
$sortByFirstName = api_sort_by_first_name();
$urlId = api_get_current_access_url_id();
$qb = UserManager::getRepository()->createQueryBuilder('u');
$qb->where(
$qb->expr()->orX(
$qb->expr()->like('u.username', ':q'),
$qb->expr()->like('u.firstname', ':q'),
$qb->expr()->like('u.lastname', ':q')
)
);
if (api_is_multiple_url_enabled()) {
$qb
->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'uru', Join::WITH, 'u.userId = uru.userId')
->andWhere('uru.accessUrlId = '.$urlId);
}
$qb
->andWhere('u.status != '.DRH.' AND u.status != '.ANONYMOUS)
->orderBy(
$sortByFirstName
? 'u.firstname, u.firstname'
: 'u.firstname, u.lastname'
)
->setParameter('q', '%'.$_REQUEST['q'].'%');
$users = $qb->getQuery()->getResult();
if (!$users) {
echo json_encode([]);
break;
}
$items = [];
/** @var User $user */
foreach ($users as $user) {
$items[] = [
'id' => $user->getId(),
'text' => $user->getCompleteNameWithUsername()
];
}
header('Content-Type: application/json');
echo json_encode(['items' => $items]);
break;
default:
echo '';
}
exit;