airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [1/3] airavata-php-gateway git commit: AIRAVATA-2195 Project owner can't be removed from experiment
Date Tue, 29 Nov 2016 21:50:02 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop ef1cf42e9 -> 3a2de3072


AIRAVATA-2195 Project owner can't be removed from experiment


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

Branch: refs/heads/develop
Commit: 5738c357b2ade22835fef5e240dc6d279408dbf9
Parents: ef1cf42
Author: Marcus Christie <machrist@iu.edu>
Authored: Fri Nov 11 13:04:16 2016 -0500
Committer: Marcus Christie <machrist@iu.edu>
Committed: Tue Nov 29 15:41:24 2016 -0500

----------------------------------------------------------------------
 app/controllers/ExperimentController.php     |  7 +++++++
 app/libraries/SharingUtilities.php           |  2 +-
 app/views/partials/experiment-info.blade.php |  1 +
 public/js/sharing/share.js                   | 14 ++++++++++++++
 public/js/sharing/sharing_utils.js           |  6 ++++--
 5 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5738c357/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index cc8602d..a4d3238 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -162,10 +162,16 @@ class ExperimentController extends BaseController
                 $users = SharingUtilities::getProfilesForSharedUsers(Input::get("expId"),
ResourceType::EXPERIMENT);
 
                 $owner = array();
+                $projectOwner = array();
                 if (strcmp(Session::get("username"), $experiment->userName) !== 0) {
                     $owner[$experiment->userName] = $users[$experiment->userName];
                     $users = array_diff_key($users, $owner);
                 }
+                // TODO: figure out the owner of the project using sharing API
+                if ($project != null && strcmp(Session::get("username"), $project->owner)
!== 0) {
+                    $projectOwner[$project->owner] = $users[$project->owner];
+                    $users = array_diff_key($users, $projectOwner);
+                }
                 // Only allow editing sharing on the summary page if the owner
                 // and the experiment isn't editable. If the experiment is
                 // editable, the sharing can be edited on the edit page.
@@ -173,6 +179,7 @@ class ExperimentController extends BaseController
                 $data['can_write'] = SharingUtilities::userCanWrite(Session::get("username"),
$experiment->experimentId, ResourceType::EXPERIMENT);
                 $data["users"] = json_encode($users);
                 $data["owner"] = json_encode($owner);
+                $data["projectOwner"] = json_encode($projectOwner);
                 $data["canEditSharing"] = $canEditSharing;
                 // The summary page has it's own Update Sharing button
                 $data["updateSharingViaAjax"] = true;

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5738c357/app/libraries/SharingUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php
index 477cec5..a0a1380 100755
--- a/app/libraries/SharingUtilities.php
+++ b/app/libraries/SharingUtilities.php
@@ -127,7 +127,7 @@ class SharingUtilities {
         $users = GrouperUtilities::getAllGatewayUsers();
         $read = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::READ);
 
-        $unshared = array_diff_key($users, $read);
+        $unshared = array_diff($users, $read);
 
         return SharingUtilities::getUserProfiles($unshared);
     }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5738c357/app/views/partials/experiment-info.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/experiment-info.blade.php b/app/views/partials/experiment-info.blade.php
index 614f68c..a346a6c 100644
--- a/app/views/partials/experiment-info.blade.php
+++ b/app/views/partials/experiment-info.blade.php
@@ -422,6 +422,7 @@
     <script>
         var users = {{ $users }};
         var owner = {{ $owner }};
+        var projectOwner = {{ $projectOwner }};
         $('#update-sharing').data({url: "{{URL::to('/')}}/experiment/unshared-users", resourceId:
"{{Input::get('expId')}}"})
         @if($updateSharingViaAjax)
         $('#share-box-button').data({ajaxUpdateUrl: "{{URL::to('/')}}/experiment/update-sharing?expId={{Input::get('expId')}}",
resourceId: "{{Input::get('expId')}}"})

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5738c357/public/js/sharing/share.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js
index ed5d160..c99b833 100755
--- a/public/js/sharing/share.js
+++ b/public/js/sharing/share.js
@@ -68,6 +68,20 @@ $(function() {
             }
         }
 
+        // projectOwner is only present for experiment sharing
+        if (typeof projectOwner !== 'undefined') {
+
+            for (var po in projectOwner) {
+                if (projectOwner.hasOwnProperty(po)) {
+                    var podata = projectOwner[po];
+                    $projectOwner = createThumbnail(po, podata.firstname, podata.lastname,
podata.email, access_enum.PROJECT_OWNER, false);
+                    $projectOwner.find(".sharing-thumbnail-unshare").detach();
+                    $projectOwner.addClass("share-box-share-item owner");
+                    $share.prepend($projectOwner);
+                }
+            }
+        }
+
         if ($share.children().length === 0) {
             $share.append($('<p>This has not been shared</p>')).addClass('text-align-center');
         }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5738c357/public/js/sharing/sharing_utils.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/sharing_utils.js b/public/js/sharing/sharing_utils.js
index 550576a..f96f0bf 100644
--- a/public/js/sharing/sharing_utils.js
+++ b/public/js/sharing/sharing_utils.js
@@ -2,14 +2,16 @@ var access_enum = {
     NONE: 0,
     READ: 1,
     WRITE: 2,
-    OWNER: 3
+    OWNER: 3,
+    PROJECT_OWNER: 4
 };
 
 var access_text = [
   'Cannot access',
   'Can read',
   'Can write',
-  'Owner'
+  'Owner',
+  'Project Owner'
 ];
 
 var createThumbnail = function(username, firstname, lastname, email, access, share) {


Mime
View raw message