From 52019b9b8ebe53432623535690b44d64302d90ac Mon Sep 17 00:00:00 2001 From: Jeff Kinnison Date: Wed, 13 Jul 2016 16:40:26 -0400 Subject: [PATCH 1/6] fixed exception thrown when no sharing and typos --- app/views/partials/sharing-display-body.blade.php | 2 +- public/js/sharing/share.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/partials/sharing-display-body.blade.php b/app/views/partials/sharing-display-body.blade.php index 8fdda20e9..c34e09f62 100644 --- a/app/views/partials/sharing-display-body.blade.php +++ b/app/views/partials/sharing-display-body.blade.php @@ -18,5 +18,5 @@
@if($form) - + @endif diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js index bf9e62c6f..12fd195d4 100755 --- a/public/js/sharing/share.js +++ b/public/js/sharing/share.js @@ -70,7 +70,7 @@ $(function() { // } // } if ($share.children().length === 0) { - $share.append($('

This project has not been shared

')).addClass('text-align-center'); + $share.append($('

This has not been shared

')).addClass('text-align-center'); } $('.user-thumbnail').show(); //$('.group-thumbnail').show(); @@ -114,7 +114,7 @@ $(function() { $shared_users.detach().appendTo('#share-box-users'); $('.order-results-selector').trigger('change'); $('#shared-users').addClass('text-align-center'); - $('#shared-users').prepend('

This project has not been shared

'); + $('#shared-users').prepend('

This has not been shared

'); }); // Filter the list as the user types @@ -205,7 +205,7 @@ $(function() { } else { $('#shared-users').addClass('text-align-center'); - $('#shared-users').prepend('

This project has not been shared

'); + $('#shared-users').prepend('

This has not been shared

'); } $('#share-box').animate({top: '100%'}); } @@ -235,7 +235,7 @@ $(function() { } else { $('#shared-users').addClass('text-align-center'); - $('#shared-users').prepend('

This project has not been shared

'); + $('#shared-users').prepend('

This has not been shared

'); } $('.sharing-updated').removeClass('sharing-updated'); $('#share-box').animate({top: "100%"}); From 3e844942d149bd352ee4053aee4b9d6a0a3dac1d Mon Sep 17 00:00:00 2001 From: Jeff Kinnison Date: Thu, 14 Jul 2016 16:04:21 -0400 Subject: [PATCH 2/6] mix project permissions with experiment --- app/controllers/ExperimentController.php | 7 +++++-- app/libraries/SharingUtilities.php | 13 +++++++++++++ app/views/group/browse.blade.php | 0 app/views/partials/experiment-inputs.blade.php | 8 ++++---- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 app/views/group/browse.blade.php diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php index 5f1edb26c..677aa0ef0 100755 --- a/app/controllers/ExperimentController.php +++ b/app/controllers/ExperimentController.php @@ -41,6 +41,7 @@ public function createSubmit() "wallTimeLimit" => Config::get('pga_config.airavata')["wall-time-limit"] ); + $clonedExp = false; $savedExp = false; if( Input::has("clonedExp")) $clonedExp = true; @@ -72,7 +73,7 @@ public function createSubmit() "allowedFileSize" => $allowedFileSize ); - $users = SharingUtilities::getAllUserProfiles(); + $users = SharingUtilities::mixProjectPermissionsWithExperiment($_POST['project']); return View::make("experiment/create-complete", array("expInputs" => $experimentInputs, "users" => json_encode($users))); } else if (isset($_POST['save']) || isset($_POST['launch'])) { @@ -235,7 +236,7 @@ public function editView() 'advancedOptions' => Config::get('pga_config.airavata')["advanced-experiment-options"] ); - $users = SharingUtilities::getAllUserProfiles($_GET['expId'], ResourceType::EXPERIMENT); + $users = SharingUtilities::mixProjectPermissionsWithExperiment($experiment->project, $_GET['expId']); return View::make("experiment/edit", array("expInputs" => $experimentInputs, "users" => json_encode($users))); } @@ -243,7 +244,9 @@ public function editView() public function cloneExperiment() { if (isset($_GET['expId'])) { + $users = getAllUserPermissions($_GET['expId'], ResourceType::EXPERIMENT); $cloneId = ExperimentUtilities::clone_experiment($_GET['expId']); + ExperimentUtilities::share_experiment($cloneId, $users); $experiment = ExperimentUtilities::get_experiment($cloneId); $project = ProjectUtilities::get_project($experiment->projectId); diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php index cba9bd58f..027355bbf 100644 --- a/app/libraries/SharingUtilities.php +++ b/app/libraries/SharingUtilities.php @@ -138,6 +138,19 @@ public static function getAllUserProfiles($resourceId=null, $dataResourceType=nu } return $profs; } + + public static function mixProjectPermissionsWithExperiment($projectId, $expId=null) { + $proj = SharingUtilities::getProfilesForSharedUsers($projectId, ResourceType::PROJECT); + $exp = SharingUtilities::getAllUserProfiles($expId, ResourceType::EXPERIMENT); + + foreach ($proj as $uid => $prof) { + if (!array_key_exists($uid, $exp)) { + $exp[$uid] = $prof; + } + } + + return $exp; + } } ?> diff --git a/app/views/group/browse.blade.php b/app/views/group/browse.blade.php new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/partials/experiment-inputs.blade.php b/app/views/partials/experiment-inputs.blade.php index 09a546c09..2a67b96b6 100644 --- a/app/views/partials/experiment-inputs.blade.php +++ b/app/views/partials/experiment-inputs.blade.php @@ -14,11 +14,11 @@
- @if( $expInputs["clonedExp"] || $expInputs["savedExp"]) + {{-- @if( $expInputs["clonedExp"] || $expInputs["savedExp"]) --}} {{ ProjectUtilities::create_project_select($expInputs["project"], false) }} - @else - {{ ProjectUtilities::create_project_select($expInputs["project"], true) }} - @endif + {{-- @else --}} + {{-- {{ ProjectUtilities::create_project_select($expInputs["project"], true) }} --}} + {{-- @endif --}}
From 8f4fd5f1ac479f7f089b8f5858a7893882abbacf Mon Sep 17 00:00:00 2001 From: Jeff Kinnison Date: Thu, 14 Jul 2016 16:31:36 -0400 Subject: [PATCH 3/6] made groups inherit sharing privileges from project --- app/controllers/ExperimentController.php | 4 ++-- app/libraries/SharingUtilities.php | 14 ++++++++++++-- public/js/sharing/share.js | 8 ++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php index 677aa0ef0..57538c2e0 100755 --- a/app/controllers/ExperimentController.php +++ b/app/controllers/ExperimentController.php @@ -73,7 +73,7 @@ public function createSubmit() "allowedFileSize" => $allowedFileSize ); - $users = SharingUtilities::mixProjectPermissionsWithExperiment($_POST['project']); + $users = SharingUtilities::getAllUserProfiles($_POST['project'], ResourceType::PROJECT); return View::make("experiment/create-complete", array("expInputs" => $experimentInputs, "users" => json_encode($users))); } else if (isset($_POST['save']) || isset($_POST['launch'])) { @@ -236,7 +236,7 @@ public function editView() 'advancedOptions' => Config::get('pga_config.airavata')["advanced-experiment-options"] ); - $users = SharingUtilities::mixProjectPermissionsWithExperiment($experiment->project, $_GET['expId']); + $users = SharingUtilities::getAllUserProfiles($_GET['expId'], ResourceType::EXPERIMENT); return View::make("experiment/edit", array("expInputs" => $experimentInputs, "users" => json_encode($users))); } diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php index 027355bbf..02832accb 100644 --- a/app/libraries/SharingUtilities.php +++ b/app/libraries/SharingUtilities.php @@ -139,9 +139,9 @@ public static function getAllUserProfiles($resourceId=null, $dataResourceType=nu return $profs; } - public static function mixProjectPermissionsWithExperiment($projectId, $expId=null) { + public static function mixProjectPermissionsWithExperiment($projectId, $expId) { $proj = SharingUtilities::getProfilesForSharedUsers($projectId, ResourceType::PROJECT); - $exp = SharingUtilities::getAllUserProfiles($expId, ResourceType::EXPERIMENT); + $exp = SharingUtilities::getProfilesForSharedUsers($expId, ResourceType::EXPERIMENT); foreach ($proj as $uid => $prof) { if (!array_key_exists($uid, $exp)) { @@ -151,6 +151,16 @@ public static function mixProjectPermissionsWithExperiment($projectId, $expId=nu return $exp; } + + public static function updateAllUsersListWithPrivileges($shared) { + $users = SharingUtilities::getAllUserProfiles(); + + foreach ($shared as $uid => $prof) { + $users[$uid] = $shared[$uid]; + } + + return $users; + } } ?> diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js index 12fd195d4..0aae84033 100755 --- a/public/js/sharing/share.js +++ b/public/js/sharing/share.js @@ -17,11 +17,13 @@ $(function() { /* Share box functions */ var createTestData = function () { - var $users, $share, $user; + var $users, $share, $user, share_settings; $users = $('#share-box-users'); $share = $('#shared-users'); + share_settings = {}; + for (var user in users) { if (users.hasOwnProperty(user)) { var data = users[user]; @@ -46,7 +48,8 @@ $(function() { } else { console.log("adding shared user"); - $user.addClass('share-box-share-item'); + $user.addClass('share-box-share-item sharing-updated'); + share_settings[user] = data.access; $share.append($user); } } @@ -72,6 +75,7 @@ $(function() { if ($share.children().length === 0) { $share.append($('

This has not been shared

')).addClass('text-align-center'); } + $('#share-settings').val(JSON.stringify(share_settings)); $('.user-thumbnail').show(); //$('.group-thumbnail').show(); } From 0d8db5d6a467c1b975abd90abae8f8198acfbcff Mon Sep 17 00:00:00 2001 From: Jeff Kinnison Date: Thu, 14 Jul 2016 16:48:22 -0400 Subject: [PATCH 4/6] enabled clone experiment permissions transfer --- app/controllers/ExperimentController.php | 2 -- app/libraries/ExperimentUtilities.php | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php index 57538c2e0..28be5e5f4 100755 --- a/app/controllers/ExperimentController.php +++ b/app/controllers/ExperimentController.php @@ -244,9 +244,7 @@ public function editView() public function cloneExperiment() { if (isset($_GET['expId'])) { - $users = getAllUserPermissions($_GET['expId'], ResourceType::EXPERIMENT); $cloneId = ExperimentUtilities::clone_experiment($_GET['expId']); - ExperimentUtilities::share_experiment($cloneId, $users); $experiment = ExperimentUtilities::get_experiment($cloneId); $project = ProjectUtilities::get_project($experiment->projectId); diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php index cc59b68c2..9f46fee0f 100644 --- a/app/libraries/ExperimentUtilities.php +++ b/app/libraries/ExperimentUtilities.php @@ -632,6 +632,10 @@ public static function clone_experiment($expId) } $experiment->userConfigurationData->experimentDataDir = ExperimentUtilities::$experimentPath; Airavata::updateExperiment(Session::get('authz-token'), $cloneId, $experiment); + + $share = json_encode(SharingUtilities::getAllUserPermissions($expId, ResourceType::EXPERIMENT)); + ExperimentUtilities::share_experiment($cloneId, json_decode($share)); + return $cloneId; } catch (InvalidRequestException $ire) { CommonUtilities::print_error_message('

There was a problem cloning the experiment. From fef8cb0330d40b9101af4fe450614ae92ebedd9f Mon Sep 17 00:00:00 2001 From: Jeff Kinnison Date: Thu, 14 Jul 2016 17:20:54 -0400 Subject: [PATCH 5/6] user experiment permissions revoked when project permissions revoked --- app/libraries/ProjectUtilities.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/libraries/ProjectUtilities.php b/app/libraries/ProjectUtilities.php index ab269dbca..0b6e93e4b 100644 --- a/app/libraries/ProjectUtilities.php +++ b/app/libraries/ProjectUtilities.php @@ -287,8 +287,10 @@ public static function get_proj_search_results_with_pagination($searchKey, $sear private static function share_project($projectId, $users) { $wadd = array(); $wrevoke = array(); + $ewrevoke = array(); $radd = array(); $rrevoke = array(); + $errevoke = array(); foreach ($users as $user => $perms) { if ($perms->write) { @@ -304,6 +306,11 @@ private static function share_project($projectId, $users) { else { $rrevoke[$user] = ResourcePermissionType::READ; } + + if (!$perms->read && !$perms->write) { + $ewrevoke[$user] = ResourcePermissionType::WRITE; + $errevoke[$user] = ResourcePermissionType::READ; + } } GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::PROJECT, $wadd); @@ -311,5 +318,12 @@ private static function share_project($projectId, $users) { GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::PROJECT, $radd); GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType::PROJECT, $rrevoke); + + $experiments = ProjectUtilities::get_experiments_in_project($projectId); + + foreach ($experiments as $exp) { + GrouperUtilities::revokeSharingOfResourceFromUsers($exp->experimentId, ResourceType::EXPERIMENT, $ewrevoke); + GrouperUtilities::revokeSharingOfResourceFromUsers($exp->experimentId, ResourceType::EXPERIMENT, $errevoke); + } } } From 06c17047b5f0f65f21ec15a8781d2f2ea34950f7 Mon Sep 17 00:00:00 2001 From: Jeff Kinnison Date: Thu, 14 Jul 2016 17:21:24 -0400 Subject: [PATCH 6/6] cosmetic fixes --- public/css/sharing.css | 2 ++ public/js/sharing/sharing_utils.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/public/css/sharing.css b/public/css/sharing.css index 5153ca344..8b194e28e 100755 --- a/public/css/sharing.css +++ b/public/css/sharing.css @@ -64,7 +64,9 @@ .sharing-thumbnail-image { width: 100%; + max-width: 100px; height: 100%; + max-width: 100px; } #share-box-button { diff --git a/public/js/sharing/sharing_utils.js b/public/js/sharing/sharing_utils.js index 6b31acdf6..03c3b6ef5 100644 --- a/public/js/sharing/sharing_utils.js +++ b/public/js/sharing/sharing_utils.js @@ -63,7 +63,7 @@ var createThumbnail = function(username, firstname, lastname, email, access = ac

\ \
\ -
\ +
\ \ \ ' + select + ' \