You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/11/29 21:50:02 UTC
[1/3] airavata-php-gateway git commit: AIRAVATA-2195 Project owner
can't be removed from experiment
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 <ma...@iu.edu>
Authored: Fri Nov 11 13:04:16 2016 -0500
Committer: Marcus Christie <ma...@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) {
[3/3] airavata-php-gateway git commit: AIRAVATA-2195 Use sharing API
to figure out project owner
Posted by sc...@apache.org.
AIRAVATA-2195 Use sharing API to figure out project owner
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/3a2de307
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/3a2de307
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/3a2de307
Branch: refs/heads/develop
Commit: 3a2de30726cdaa07bce260a02333f88b25b18887
Parents: 4d546cf
Author: Marcus Christie <ma...@iu.edu>
Authored: Tue Nov 29 16:02:47 2016 -0500
Committer: Marcus Christie <ma...@iu.edu>
Committed: Tue Nov 29 16:02:47 2016 -0500
----------------------------------------------------------------------
app/controllers/ExperimentController.php | 38 ++++++++++++++-------------
app/libraries/SharingUtilities.php | 10 +++++++
2 files changed, 30 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3a2de307/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 392383b..6d06aad 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -78,10 +78,9 @@ class ExperimentController extends BaseController
$owner = array();
$projectOwner = array();
- $project = ProjectUtilities::get_project($_POST['project']);
- // 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];
+ $sharedProjectOwner = SharingUtilities::getSharedResourceOwner($_POST['project'], ResourceType::PROJECT);
+ if (strcmp(Session::get("username"), $sharedProjectOwner) !== 0) {
+ $projectOwner[$sharedProjectOwner] = $users[$sharedProjectOwner];
$users = array_diff_key($users, $projectOwner);
}
@@ -170,18 +169,21 @@ class ExperimentController extends BaseController
);
if(Config::get('pga_config.airavata')["data-sharing-enabled"]){
$users = SharingUtilities::getProfilesForSharedUsers(Input::get("expId"), ResourceType::EXPERIMENT);
+ $sharedProjectOwner = SharingUtilities::getSharedResourceOwner($experiment->projectId, ResourceType::PROJECT);
$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);
+ if (strcmp(Session::get("username"), $sharedProjectOwner) !== 0) {
+ $projectOwner[$sharedProjectOwner] = $users[$sharedProjectOwner];
}
+ // Subtract out the owner and project owner from list of users
+ $users = array_diff_key($users, $owner);
+ $users = array_diff_key($users, $projectOwner);
+ // If project owner is the same as owner, just show the owner, not the project owner
+ $projectOwner = array_diff_key($projectOwner, $owner);
// 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.
@@ -294,22 +296,22 @@ class ExperimentController extends BaseController
if(Config::get('pga_config.airavata')["data-sharing-enabled"]){
if (SharingUtilities::userCanWrite(Session::get("username"), $_GET['expId'], ResourceType::EXPERIMENT) === true) {
$users = SharingUtilities::getProfilesForSharedUsers($_GET['expId'], ResourceType::EXPERIMENT);
+ $sharedProjectOwner = SharingUtilities::getSharedResourceOwner($experiment->projectId, ResourceType::PROJECT);
$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
- $project = null;
- if (SharingUtilities::userCanRead(Session::get("username"), $experiment->projectId, ResourceType::PROJECT)) {
- $project = ProjectUtilities::get_project($experiment->projectId);
}
- if ($project != null && strcmp(Session::get("username"), $project->owner) !== 0) {
- $projectOwner[$project->owner] = $users[$project->owner];
- $users = array_diff_key($users, $projectOwner);
+ if (strcmp(Session::get("username"), $sharedProjectOwner) !== 0) {
+ $projectOwner[$sharedProjectOwner] = $users[$sharedProjectOwner];
}
+ // Subtract out owner and project owner from list of users
+ $users = array_diff_key($users, $owner);
+ $users = array_diff_key($users, $projectOwner);
+ // If project owner is the same as owner, just show the owner, not the project owner
+ $projectOwner = array_diff_key($projectOwner, $owner);
+
$canEditSharing = $this->isExperimentOwner($experiment, Session::get('username'));
return View::make("experiment/edit", array("expInputs" => $experimentInputs,
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3a2de307/app/libraries/SharingUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php
index a0a1380..b689b24 100755
--- a/app/libraries/SharingUtilities.php
+++ b/app/libraries/SharingUtilities.php
@@ -175,6 +175,16 @@ class SharingUtilities {
return $users;
}
+
+ public static function getSharedResourceOwner($resourceId, $dataResourceType) {
+ $owners = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::OWNER);
+ if (count($owners) != 1) {
+ Log::error("Got more than one shared resource owner!", array($resourceId, $dataResourceType, $owners));
+ throw new Exception("Expected exactly 1 owner for $resourceId of type $dataResourceType!");
+ } else {
+ return $owners[0];
+ }
+ }
}
?>
[2/3] airavata-php-gateway git commit: AIRAVATA-2195 Project owner
can't be removed when creating/editing experiment
Posted by sc...@apache.org.
AIRAVATA-2195 Project owner can't be removed when creating/editing 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/4d546cf7
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/4d546cf7
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/4d546cf7
Branch: refs/heads/develop
Commit: 4d546cf7652499b9b0351708303e07ef0653e373
Parents: 5738c35
Author: Marcus Christie <ma...@iu.edu>
Authored: Fri Nov 11 14:58:51 2016 -0500
Committer: Marcus Christie <ma...@iu.edu>
Committed: Tue Nov 29 15:44:22 2016 -0500
----------------------------------------------------------------------
app/controllers/ExperimentController.php | 23 ++++++++++++++++++++-
app/views/experiment/create-complete.blade.php | 1 +
app/views/experiment/edit.blade.php | 1 +
3 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4d546cf7/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index a4d3238..392383b 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -77,9 +77,19 @@ class ExperimentController extends BaseController
$users = SharingUtilities::getProfilesForSharedUsers($_POST['project'], ResourceType::PROJECT);
$owner = array();
+ $projectOwner = array();
+ $project = ProjectUtilities::get_project($_POST['project']);
+ // 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);
+ }
+
return View::make("experiment/create-complete", array("expInputs" => $experimentInputs,
"users" => json_encode($users), "owner" => json_encode($owner),
- "canEditSharing" => true, "updateSharingViaAjax" => false));
+ "canEditSharing" => true,
+ "projectOwner" => json_encode($projectOwner),
+ "updateSharingViaAjax" => false));
}else{
return View::make("experiment/no-sharing-create-complete", array("expInputs" => $experimentInputs));
}
@@ -286,15 +296,26 @@ class ExperimentController extends BaseController
$users = SharingUtilities::getProfilesForSharedUsers($_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
+ $project = null;
+ if (SharingUtilities::userCanRead(Session::get("username"), $experiment->projectId, ResourceType::PROJECT)) {
+ $project = ProjectUtilities::get_project($experiment->projectId);
+ }
+ if ($project != null && strcmp(Session::get("username"), $project->owner) !== 0) {
+ $projectOwner[$project->owner] = $users[$project->owner];
+ $users = array_diff_key($users, $projectOwner);
+ }
$canEditSharing = $this->isExperimentOwner($experiment, Session::get('username'));
return View::make("experiment/edit", array("expInputs" => $experimentInputs,
"users" => json_encode($users), "owner" => json_encode($owner),
"canEditSharing" => $canEditSharing,
+ "projectOwner" => json_encode($projectOwner),
"updateSharingViaAjax" => false
));
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4d546cf7/app/views/experiment/create-complete.blade.php
----------------------------------------------------------------------
diff --git a/app/views/experiment/create-complete.blade.php b/app/views/experiment/create-complete.blade.php
index 78de55b..657af95 100755
--- a/app/views/experiment/create-complete.blade.php
+++ b/app/views/experiment/create-complete.blade.php
@@ -47,6 +47,7 @@
<script>
var users = {{ $users }};
var owner = {{ $owner }};
+ var projectOwner = {{ $projectOwner }};
$('#entity-share').data({url: "{{URL::to('/')}}/project/unshared-users", resourceId: "{{$expInputs['project']}}"})
</script>
{{ HTML::script('js/sharing/sharing_utils.js') }}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4d546cf7/app/views/experiment/edit.blade.php
----------------------------------------------------------------------
diff --git a/app/views/experiment/edit.blade.php b/app/views/experiment/edit.blade.php
index 7aaf7b3..54ea5cb 100755
--- a/app/views/experiment/edit.blade.php
+++ b/app/views/experiment/edit.blade.php
@@ -55,6 +55,7 @@
<script>
var users = {{ $users }};
var owner = {{ $owner }};
+ var projectOwner = {{ $projectOwner }};
$('#entity-share').data({url: "{{URL::to('/')}}/experiment/unshared-users", resourceId: "{{Input::get('expId')}}"})
</script>
{{ HTML::script('js/sharing/sharing_utils.js') }}