Skip to content

Commit

Permalink
Merged feature/ICPCO-73 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Jan 19, 2021
2 parents c16170f + a135e21 commit ac8d12f
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 50 deletions.
28 changes: 19 additions & 9 deletions Controller/CoGrouperLitesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ function beforeRender()
parent::beforeRender();
}

public function display($id)
{
public function display($id) {
$cfg = $this->CoGrouperLite->getConfig();

$services_url = Router::url([
'plugin' => "grouper_lite",
'controller' => 'GrouperGroups',
'action' => 'groupoptin',
'co' => $this->cur_co['Co']['id'],
'gdId' => $id
]);

$this->set('vv_services_url', $services_url);
$this->set('title_for_layout', _txt('pl.grouperlite.config.display.title'));
// Pass the config so we know which div to overwrite
$this->set('vv_config', $cfg);
Expand All @@ -46,8 +53,7 @@ public function display($id)
* @return Array Permissions
*/

function isAuthorized()
{
function isAuthorized() {
$roles = $this->Role->calculateCMRoles();

// Determine what operations this user can perform
Expand All @@ -57,14 +63,18 @@ function isAuthorized()
// Note that the display permission is set at the Dashboard, not Dashboard Widget level.
$p = $this->calculateParentPermissions($roles);

// Delete an existing CO Announcements Widget?
$p['add'] = ($roles['cmadmin'] || $roles['coadmin']);

// Delete an existing Grouper Widget
$p['delete'] = ($roles['cmadmin'] || $roles['coadmin']);

// Edit an existing CO Announcements Widget?
// Edit an existing Grouper Widget
$p['edit'] = ($roles['cmadmin'] || $roles['coadmin']);

// View an existing CO Announcements Widget?
$p['view'] = ($roles['cmadmin'] || $roles['coadmin']);
// View an existing Grouper Widget
//Not sure the difference between view and index, so will open both to comembers.
$p['view'] = ($roles['cmadmin'] || $roles['coadmin'] || $roles['comember']);
$p['index'] = ($roles['cmadmin'] || $roles['coadmin'] || $roles['comember']);

$this->set('permissions', $p);
return ($p[$this->action]);
Expand Down
52 changes: 28 additions & 24 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function index() {

public function groupUser()
{
//TODO - Not being used, can delete?
$this->set('title', _txt('pl.grouperlite.title.root'));

$this->set('groupergroupsmember', $this->GrouperGroup->optinGroups($this->userId));
Expand Down Expand Up @@ -133,13 +134,13 @@ public function joinGroup()
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->joinGroup($this->userId, $name)) {
$this->Flash->success(_txt('You have been added to the group!'));
$this->Flash->success(_txt('pl.grouperlite.message.flash.join-group-success'));
} else {
$this->Flash->error(_txt('You are unable to join the group!'));
$this->Flash->error(_txt('pl.grouperlite.message.flash.join-group-failed'));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(_txt('An error occurred in joining the group, please try again later.'));
$this->Flash->error(_txt('pl.grouperlite.message.flash.join-group-error'));

}

Expand All @@ -148,16 +149,19 @@ public function leaveGroup()
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->leaveGroup($this->userId, $name)) {
$this->Flash->success(_txt('You have been deleted from the group!'));
$this->Flash->success(_txt('pl.grouperlite.message.flash.leave-group-success'));
} else {
$this->Flash->error(_txt('You are unable to delete the group!'));
$this->Flash->error(_txt('pl.grouperlite.message.flash.leave-group-failed'));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(_txt('An error occurred in leaving the group, please try again later.'));
$this->Flash->error(_txt('pl.grouperlite.message.flash.leave-group-error'));
}

/**
* NOTE: All permissions will be done on the Grouper side. All Authenticated users will be able to
* use this plugin for self-admin of groups.
*
* Authorization for this Controller, called by Auth component
* - precondition: Session.Auth holds data used for authz decisions
* - postcondition: $permissions set with calculated permissions
Expand All @@ -166,35 +170,35 @@ public function leaveGroup()
* @return Array Permissions
*/
function isAuthorized() {
//TODO - I am not sure how much of COmanage roles will be needed, but will need to tweak this to meet our needs.
//TODO - Use Grouper user controller to pull in user information.
$roles = $this->Role->calculateCMRoles();

//TODO - this is about all we need right now.
//Need to pull in UserID for access to Grouper
if($this->Session->check('Auth.User.username')) {
$this->userId = $this->Session->read('Auth.User.username');
}

// Construct the permission set for this user, which will also be passed to the view.
$p = array();

// Determine what operations this user can perform

// Delete an existing CO Provisioning Target?
$p['delete'] = ($roles['cmadmin'] || $roles['coadmin']);

// Edit an existing CO Provisioning Target?
$p['edit'] = ($roles['cmadmin'] || $roles['coadmin']);

// View all existing CO Provisioning Targets?
$p['index'] = ($roles['cmadmin'] || $roles['coadmin']);
// Construct the permission set for this user, which will also be passed to the view.
//Note: Leaving in this format, in case need to restrict certain pages, can just remove true and add params.
$p = array();

// View an existing CO Provisioning Target?
$p['view'] = ($roles['cmadmin'] || $roles['coadmin']);
$p['index'] = true;
$p['groupinfo'] = true;
$p['groupowner'] = true;
$p['groupmember'] = true;
$p['groupoptin'] = true;
$p['emaillistsoptin'] = true;
$p['emaillistsmanaged'] = true;
$p['emaillistsinfo'] = true;
$p['groupcreateform'] = true;
$p['groupcreate'] = true;
$p['joingroup'] = true;
$p['leavegroup'] = true;

$this->set('permissions', $p);
//return($p[$this->action]);
return true;

return ($p[$this->action]);
}

}
14 changes: 0 additions & 14 deletions Controller/GrouperUsersController.php

This file was deleted.

1 change: 0 additions & 1 deletion Model/GrouperUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
class GrouperUser extends GrouperLiteAppModel
{
//TODO - Add input validation
//TODO - Remove the returns, since just used for debugging and testing.
public $name = "GrouperGroup";
public $grouperAPI;

Expand Down
37 changes: 36 additions & 1 deletion View/CoGrouperLites/display.ctp
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
you are home
<?php
/**
* COmanage Registry Services Widget Display View
*
* This widget repurposes the Service Portal by directly
* rendering the service portal URL (as provided by the controller).
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v3.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// Figure out the widget ID so we can overwrite the dashboard's widget div
$divid = $vv_config['CoGrouperLite']['co_dashboard_widget_id'];
?>

<a rel="stylesheet" href="<?php print $vv_services_url; ?>">Click here</a>

2 changes: 1 addition & 1 deletion View/CoGrouperLites/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $args['action'] = 'index';
$args['codashboard'] = $co_grouper_lites[0]['CoDashboardWidget']['co_dashboard_id'];
$this->Html->addCrumb(_txt('ct.co_dashboard_widgets.1'), $args);

$crumbTxt = _txt('op.' . $this->action . '-a', array(filter_var($co_grouper_widgets[0]['CoDashboardWidget']['description'], FILTER_SANITIZE_SPECIAL_CHARS)));
$crumbTxt = _txt('op.' . $this->action . '-a', array(filter_var($co_grouper_lites[0]['CoDashboardWidget']['description'], FILTER_SANITIZE_SPECIAL_CHARS)));
$this->Html->addCrumb($crumbTxt);

print $this->Form->hidden('co_dashboard_widget_id', array('default' => $vv_dwid)) . "\n";
Expand Down

0 comments on commit ac8d12f

Please sign in to comment.