Skip to content

Commit

Permalink
New feature: RemoteControl list_users can now search for username
Browse files Browse the repository at this point in the history
  • Loading branch information
gekkedev authored and c-schmitz committed Oct 17, 2018
1 parent f897177 commit 715bc2b
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions application/helpers/remotecontrol/remotecontrol_handle.php
Expand Up @@ -2228,30 +2228,37 @@ public function list_surveys($sSessionKey, $sUsername = null)
*
* Returns array of ids and info.
*
* Failure status : No users found, Invalid session key, No permission (super admin is required)
* Failure status : Invalid user id, Invalid username, No users found, Invalid session key, Permission denied (super admin is required)
*
* @param string $sSessionKey Auth credentials
* @param int $uid Optional parameter user id.
* @param int $uid Optional; ID of the user
* @param string $username Optional; name of the user
* @return array The list of users in case of success
*/
public function list_users($sSessionKey = null, $uid = null)
public function list_users($sSessionKey = null, $uid = null, $username = null)
{
if ($this->_checkSessionKey($sSessionKey)) {
if (Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$users = null;
if ($uid) {
$uid = (int) $uid;
$user = User::model()->findByPk($uid);
if (!$user) {
return array('status' => 'Invalid user id');
}
$users = array($user);
$uid = (int) $uid;
$user = User::model()->findByPk($uid);
if (!$user) {
return array('status' => 'Invalid user id');
}
$users = array($user);
} else if ($username) {
$user = User::model()->findByUsername($username);
if (!$user) {
return array('status' => 'Invalid username');
}
$users = array($user);
} else {
$users = User::model()->findAll();
$users = User::model()->findAll();
}

if (count($users) == 0) {
return array('status' => 'No users found');
return array('status' => 'No users found');
}

foreach ($users as $user) {
Expand Down

0 comments on commit 715bc2b

Please sign in to comment.