airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [45/50] [abbrv] airavata-php-gateway git commit: resolved cloning project permissions issue
Date Wed, 27 Jul 2016 17:05:53 GMT
resolved cloning project permissions issue


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

Branch: refs/heads/develop
Commit: e8a0f093585477c968599628157565814a223165
Parents: 071322e
Author: Jeff Kinnison <jeffdkinnison@gmail.com>
Authored: Sat Jul 16 12:04:15 2016 -0400
Committer: Jeff Kinnison <jeffdkinnison@gmail.com>
Committed: Sat Jul 16 12:04:15 2016 -0400

----------------------------------------------------------------------
 app/libraries/ExperimentUtilities.php | 22 +++++++++++++++++++++-
 app/libraries/SharingUtilities.php    | 16 ++++++----------
 public/js/sharing/share.js            | 17 ++++++++++++-----
 3 files changed, 39 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e8a0f093/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index 0619735..bc145ea 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -635,7 +635,10 @@ class ExperimentUtilities
 
             $share = SharingUtilities::getAllUserPermissions($expId, ResourceType::EXPERIMENT);
             $share[Session::get("username")] = array("read" => true, "write" => true);
-            ExperimentUtilities::share_experiment($cloneId, json_decode(json_encode($share)));
+            foreach ($share as $uid => $perms) {
+                $share[$uid] = (object) $perms;
+            }
+            ExperimentUtilities::share_experiment($cloneId, $share);
 
             return $cloneId;
         } catch (InvalidRequestException $ire) {
@@ -1329,6 +1332,10 @@ class ExperimentUtilities
         $radd = array();
         $rrevoke = array();
 
+        $projperms = GrouperUtilities::getAllAccessibleUsers($experiment->projectId, ResourceType::PROJECT,
ResourcePermissionType::READ);
+        $prrevoke = array();
+        $pwrevoke = array();
+
         foreach ($users as $user => $perms) {
             if ($perms->write) {
                 $wadd[$user] = ResourcePermissionType::WRITE;
@@ -1343,6 +1350,11 @@ class ExperimentUtilities
             else {
                 $rrevoke[$user] = ResourcePermissionType::READ;
             }
+
+            if (array_search($user, $projperms) === false) {
+                $prrevoke[$user] = ResourcePermissionType::READ;
+                $pwrevoke[$user] = ResourcePermissionType::WRITE;
+            }
         }
 
         GrouperUtilities::shareResourceWithUsers($expId, ResourceType::EXPERIMENT, $wadd);
@@ -1352,5 +1364,13 @@ class ExperimentUtilities
         GrouperUtilities::revokeSharingOfResourceFromUsers($expId, ResourceType::EXPERIMENT,
$rrevoke);
 
         GrouperUtilities::shareResourceWithUsers($experiment->projectId, ResourceType::PROJECT,
$radd);
+
+        $experiments = ProjectUtilities::get_experiments_in_project($experiment->projectId);
+        foreach ($experiments as $exp) {
+            if ($exp->experimentId !== $expId) {
+                GrouperUtilities::revokeSharingOfResourceFromUsers($exp->experimentId,
ResourceType::EXPERIMENT, $prrevoke);
+                GrouperUtilities::revokeSharingOfResourceFromUsers($exp->experimentId,
ResourceType::EXPERIMENT, $pwrevoke);
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e8a0f093/app/libraries/SharingUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php
index 02832ac..7b98f97 100644
--- a/app/libraries/SharingUtilities.php
+++ b/app/libraries/SharingUtilities.php
@@ -47,20 +47,16 @@ class SharingUtilities {
         $read = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::READ);
         $write = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType,
ResourcePermissionType::WRITE);
 
-        $read = array_filter($read, function($uid) {
-            return ($uid !== Session::get('username') && WSIS::usernameExists($uid));
-        });
-
-        $write = array_filter($write, function($uid) {
-            return ($uid !== Session::get('username') && WSIS::usernameExists($uid));
-        });
-
         foreach($read as $uid) {
-            $users[$uid] = array('read' => true, 'write' => false);
+            if ($uid !== Session::get('username') && WSIS::usernameExists($uid))
{
+                $users[$uid] = array('read' => true, 'write' => false);
+            }
         }
 
         foreach($write as $uid) {
-            $users[$uid]['write'] = true;
+            if ($uid !== Session::get('username') && WSIS::usernameExists($uid))
{
+                $users[$uid]['write'] = true;
+            }
         }
 
         return $users;

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e8a0f093/public/js/sharing/share.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js
index ab6b632..d8e19fc 100755
--- a/public/js/sharing/share.js
+++ b/public/js/sharing/share.js
@@ -284,11 +284,18 @@ $(function() {
         $parent = $target.closest('.sharing-thumbnail');
         data = $parent.data();
         access = parseInt($target.val());
-        if (access > 0) {
-            data.currentaccess.read = true;
-        }
-        if (access > 1) {
-            data.currentaccess.write = true;
+        switch(access) {
+            case 1:
+                data.currentaccess.read = true;
+                data.currentaccess.write = false;
+                break;
+            case 2:
+                data.currentaccess.read = true;
+                data.currentaccess.write = true;
+                break;
+            default:
+                data.currentaccess.read = false;
+                data.currentaccess.write = false;
         }
         $parent.find('.sharing-thumbnail-access-text').val(access_text[access]);
         $parent.data(data);


Mime
View raw message