From d5f73e3f310a50b1ba2e52be906e03bac17ed773 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 18 Mar 2007 01:26:46 +0000 Subject: [PATCH] r1486: Adding API support for multiple usergroups in UserAPI. Because we verify in the API, we no longer need to call array_strip_empty() in FetchUserPermissions() --- includes/api_user.php | 29 +++++++++++++++++++++++++++++ includes/functions.php | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/includes/api_user.php b/includes/api_user.php index cbf2c5b..872e371 100644 --- a/includes/api_user.php +++ b/includes/api_user.php @@ -45,6 +45,7 @@ class UserAPI extends API 'email' => array(TYPE_STR, REQ_YES, ':self'), 'displayname' => array(TYPE_STR, REQ_YES, ':self'), 'usergroupid' => array(TYPE_UINT, REQ_YES, ':self'), + 'groupids' => array(TYPE_STR, REQ_NO, ':self'), 'password' => array(TYPE_STR, REQ_YES), 'salt' => array(TYPE_STR, REQ_SET), 'authkey' => array(TYPE_STR, REQ_SET), @@ -189,6 +190,34 @@ class UserAPI extends API return true; } + // ################################################################### + /** + * Verify: groupids + * + * @access private + */ + function verify_groupids() + { + $groups = $this->values['groupids']; + if (!is_array($groups)) + { + $groups = explode(',', $this->values['groupids']); + } + $groups = $this->registry->funct->array_strip_empty($groups); + + foreach ($groups AS $group => $value) + { + if (!isset($this->registry->datastore['usergroup']["$group"])) + { + return false; + } + } + + $this->values['groupids'] = implode(',', $groups); + + return true; + } + // ################################################################### /** * Pre-update diff --git a/includes/functions.php b/includes/functions.php index f23d799..6a0d061 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -732,7 +732,7 @@ function FetchUserPermissions(&$user) $perms = $bugsys->datastore['usergroup']["$user[usergroupid]"]['permissions']; if (!is_array($user['groupids'])) { - $user['groupids'] = $bugsys->funct->array_strip_empty(explode(',', $bugsys->userinfo['groupids'])); + $user['groupids'] = explode(',', $bugsys->userinfo['groupids']); } foreach ($user['groupids'] AS $group) -- 2.43.5