airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [2/4] airavata-php-gateway git commit: project updates
Date Mon, 11 Jul 2016 19:09:45 GMT
project updates


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/5c0b259e
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/5c0b259e
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/5c0b259e

Branch: refs/heads/grouper-integration
Commit: 5c0b259ed2a4c167e34837b9f7866d1df755686e
Parents: 9fbd302
Author: Jeff Kinnison <jeffdkinnison@gmail.com>
Authored: Mon Jul 11 12:56:30 2016 -0400
Committer: Jeff Kinnison <jeffdkinnison@gmail.com>
Committed: Mon Jul 11 12:56:30 2016 -0400

----------------------------------------------------------------------
 app/controllers/ProjectController.php | 10 +++++++-
 app/libraries/ProjectUtilities.php    | 40 ++++++++++++++++++++++--------
 app/views/project/create.blade.php    |  1 +
 3 files changed, 40 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5c0b259e/app/controllers/ProjectController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ProjectController.php b/app/controllers/ProjectController.php
index fe3a35d..eba7035 100755
--- a/app/controllers/ProjectController.php
+++ b/app/controllers/ProjectController.php
@@ -1,5 +1,7 @@
 <?php
 
+
+
 class ProjectController extends BaseController
 {
 
@@ -23,7 +25,13 @@ class ProjectController extends BaseController
 
     public function createView()
     {
-        return View::make("project/create");
+        $uids = GrouperUtilities::getAllGatewayUsers();
+        $users = array();
+        for ($i = 0; $i < count($uids); $i++) {
+            $string = $uids[$i] . '@' . Config::get('pga_config.wsis')['tenant-domain'];
+            $users[$i] = WSIS::getUserProfile($string);
+        }
+        return View::make("project/create", array("users" => json_encode($users)));
     }
 
     public function createSubmit()

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5c0b259e/app/libraries/ProjectUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ProjectUtilities.php b/app/libraries/ProjectUtilities.php
index 730deda..acb9ed3 100644
--- a/app/libraries/ProjectUtilities.php
+++ b/app/libraries/ProjectUtilities.php
@@ -118,16 +118,7 @@ class ProjectUtilities
             $share = json_decode($share);
 
             if (json_last_error() === JSON_ERROR_NONE) {
-                foreach ($share as $uname => $access) {
-                    if ($access !== 0) {
-                        $add[$uname] = $value;
-                    }
-                    else {
-                        $revoke[$uname] = $value;
-                    }
-                }
-                GrouperUtilities::shareResourceWithUsers($projectId, ResourceType.Project,
$add);
-                GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project,
$revoke);
+                $this->share_project($projectId, $share);
             }
 
             if ($projectId) {
@@ -287,4 +278,33 @@ class ProjectUtilities
 
         return $projects;
     }
+
+    private function share_project($projectId, $users) {
+        $wadd = array();
+        $wrevoke = array();
+        $radd = array();
+        $rrevoke = array();
+
+        foreach ($users as $user => $perms) {
+            if ($perms['write']) {
+                $wadd[$user] = ResourcePermissionType::WRITE;
+            }
+            else {
+                $wrevoke[$user] = ResourcePermissionType::WRITE;
+            }
+
+            GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $wadd);
+            GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$wrevoke);
+
+            if ($perms['read']) {
+                $radd[$user] = ResourcePermissionType::READ;
+            }
+            else {
+                $rrevoke[$user] = ResourcePermissionType::READ;
+            }
+
+            GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $radd);
+            GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$rrevoke);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5c0b259e/app/views/project/create.blade.php
----------------------------------------------------------------------
diff --git a/app/views/project/create.blade.php b/app/views/project/create.blade.php
index d24ab1b..94348af 100755
--- a/app/views/project/create.blade.php
+++ b/app/views/project/create.blade.php
@@ -63,6 +63,7 @@
     $(".projectName").blur(function () {
         $(this).val($.trim($(this).val()));
     });
+    var users = {{ $users }};
 </script>
 {{ HTML::script('js/sharing/sharing_utils.js') }}
 {{ HTML::script('js/sharing/share.js') }}


Mime
View raw message