2011-07-24 23:47:37 +04:00
|
|
|
<?php
|
|
|
|
$RUNTIME_NOAPPS = true;
|
|
|
|
|
|
|
|
require_once('../../../lib/base.php');
|
|
|
|
|
2011-07-25 00:07:39 +04:00
|
|
|
if (!OC_USER::isLoggedIn()) {
|
|
|
|
echo json_encode(array("status" => "error", "data" => array("message" => "Authentication error")));
|
2011-07-24 23:47:37 +04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
$query = $_GET['term'];
|
|
|
|
$length = strlen($query);
|
|
|
|
$query = strtolower($query);
|
|
|
|
$users = array();
|
|
|
|
$ocusers = OC_USER::getUsers();
|
|
|
|
$self = OC_USER::getUser();
|
2011-07-25 00:07:39 +04:00
|
|
|
$groups = OC_GROUP::getUserGroups($self);
|
2011-07-24 23:47:37 +04:00
|
|
|
foreach ($ocusers as $user) {
|
|
|
|
if ($user != $self && substr(strtolower($user), 0, $length) == $query) {
|
|
|
|
$users[] = (object)array('id' => $user, 'label' => $user, 'name' => $user);
|
|
|
|
}
|
|
|
|
}
|
2011-07-25 00:07:39 +04:00
|
|
|
foreach ($groups as $group) {
|
|
|
|
if (substr(strtolower($group), 0, $length) == $query) {
|
|
|
|
$users[] = (object)array('id' => $group, 'label' => $group, 'name' => $group);
|
|
|
|
}
|
|
|
|
}
|
2011-07-24 23:47:37 +04:00
|
|
|
echo json_encode($users);
|
|
|
|
|
|
|
|
?>
|