Repository: airavata-php-gateway Updated Branches: refs/heads/develop 555cf68a3 -> 26ed2cfda
AIRAVATA-2164 Remove pending role from user when given access Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/f41820ea Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f41820ea Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f41820ea Branch: refs/heads/develop Commit: f41820eae9e2cc48e7a8993dab60b0d3f84aec3d Parents: 6254204 Author: Marcus Christie <marc.chris...@gmail.com> Authored: Fri Oct 7 15:49:21 2016 -0400 Committer: Marcus Christie <marc.chris...@gmail.com> Committed: Thu Oct 13 08:42:17 2016 -0400 ---------------------------------------------------------------------- app/controllers/AdminController.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f41820ea/app/controllers/AdminController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index b66b5a4..91156c1 100644 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -213,12 +213,20 @@ class AdminController extends BaseController { $username = Input::all()["username"]; WSIS::updateUserRoles($username, $roles); - $roles = WSIS::getUserRoles(Input::get("username")); - if(in_array(Config::get("pga_config.wsis")["admin-role-name"], $roles) || in_array(Config::get("pga_config.wsis")["read-only-admin-role-name"], $roles) - || in_array(Config::get("pga_config.wsis")["user-role-name"], $roles)){ - $userProfile = WSIS::getUserProfile(Input::get("username")); - $recipients = array($userProfile["email"]); - $this->sendAccessGrantedEmailToTheUser(Input::get("username"), $recipients); + $newCurrentRoles = WSIS::getUserRoles(Input::get("username")); + if(in_array(Config::get("pga_config.wsis")["admin-role-name"], $newCurrentRoles) || in_array(Config::get("pga_config.wsis")["read-only-admin-role-name"], $newCurrentRoles) + || in_array(Config::get("pga_config.wsis")["user-role-name"], $newCurrentRoles)){ + $userProfile = WSIS::getUserProfile(Input::get("username")); + $recipients = array($userProfile["email"]); + $this->sendAccessGrantedEmailToTheUser(Input::get("username"), $recipients); + + // remove the pending role when access is granted, unless + // the admin is trying to add the user to the pending role + if(in_array("user-pending", $newCurrentRoles) && !in_array("user-pending", $roles["new"])) { + $userRoles["new"] = array(); + $userRoles["deleted"] = "user-pending"; + WSIS::updateUserRoles( $username, $userRoles); + } } return Redirect::to("admin/dashboard/roles")->with( "message", "Roles has been added."); }