/**
* returns array of all users
* [userID] => 23103741
* [name] => admin
* [mail] => 0
* [active] => 0
*
* @param int $trash
* @param array $groups list of group ids the users must be a member of
* @return array
* @author th
*/
public function get_users($trash = 0, array $groups = null)
{
$p = $this->kga['server_prefix'];
$trash = MySQL::SQLValue($trash, MySQL::SQLVALUE_NUMBER);
if (empty($groups)) {
$query = "SELECT * FROM {$p}users\n WHERE trash = {$trash}\n ORDER BY name ;";
} else {
$query = "SELECT DISTINCT u.* FROM {$p}users AS u\n JOIN {$p}groups_users AS g_u USING(userID)\n WHERE g_u.groupID IN (" . implode($groups, ',') . ") AND\n trash = {$trash}\n ORDER BY name ;";
}
$this->conn->Query($query);
$rows = $this->conn->RowArray(0, MYSQLI_ASSOC);
$i = 0;
$arr = array();
$this->conn->MoveFirst();
while (!$this->conn->EndOfSeek()) {
$row = $this->conn->Row();
$arr[$i]['userID'] = $row->userID;
$arr[$i]['name'] = $row->name;
$arr[$i]['globalRoleID'] = $row->globalRoleID;
$arr[$i]['mail'] = $row->mail;
$arr[$i]['active'] = $row->active;
$arr[$i]['trash'] = $row->trash;
if ($row->password != '' && $row->password != '0') {
$arr[$i]['passwordSet'] = "yes";
} else {
$arr[$i]['passwordSet'] = "no";
}
$i++;
}
return $arr;
}