Skip to content

Commit

Permalink
Merged feature/ICPCO-87 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Feb 10, 2021
2 parents 765768d + 4644e29 commit 2ca391e
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 145 deletions.
66 changes: 57 additions & 9 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
<?php
/**
* COmanage Registry Grouper Lite Widget Groups 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-plugin
* @since COmanage Registry v3.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

App::uses('Validator', 'Vendor/cakephp/Validation');
App::uses('CoGrouperLite', 'GrouperLite.Model/');
Expand Down Expand Up @@ -53,31 +78,54 @@ private function setConnection() {
*
* @return CakeResponse Redirect to Optin page
*/
public function index() {
public function index()
{
return $this->redirect(
array('controller' => 'GrouperGroups', 'action' => 'groupoptin')
);
}


public function groupInfo() {
/**
* Display of Grouper Group Information, such as Group Properties, Members and Attributes
*
*/
public function groupInfo()
{
$name = urldecode($this->request->query['groupname']);

$details = $this->GrouperGroup->groupDescriptions($name);

$this->set('groupname', $name);
$this->set('title', _txt('pl.grouperlite.title.groupinfo'));
$this->set('groupergroupsdetail', $details[0]);

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
try {
$this->set('groupergroupsdetail', $details[0]);
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite Controller - groupInfo: ' . var_export($e->getMessage(), true));
$this->set('groupergroupsdetail', array());
$this->Flash->set(_txt('pl.grouperlite.message.flash.info-group-failed'), array('key' => 'error'));
}
}

public function groupOwner() {
/**
* Listing of all Grouper Groups owned/admin by User Or search those Grouper Groups
*/
public function groupOwner()
{
$this->set('title', _txt('pl.grouperlite.title.groupowner'));

if (isset($this->request->data['search'])){
$searchCriteria = urldecode($this->request->data['search']);
$this->set('groupergroupsowner', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOwner'));
$this->set('searchcriteria', $searchCriteria);

try {
$this->set('groupergroupsowner', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOwner'));
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite Controller - groupOwner Search: ' . var_export($e->getMessage(), true));
$this->set('groupergroupsowner', array());
$this->Flash->set(_txt('pl.grouperlite.message.flash.owner-group-failed'), array('key' => 'error'));
}

} else {
$this->set('groupergroupsowner', $this->GrouperGroup->ownerGroups($this->userId));
}
Expand Down
33 changes: 12 additions & 21 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public function getGrouperUser(array $queryData) {
}

} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGrouperUser: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGrouperUser: An error occurred');
throw $e;
}

Expand Down Expand Up @@ -139,8 +138,7 @@ public function getGrouperMemberOfGroups(array $queryData) {
return $results['WsGetGroupsLiteResult']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGrouperMemberOfGroups: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGrouperMemberOfGroups: An error occurred');
throw $e;
}

Expand Down Expand Up @@ -187,6 +185,7 @@ public function grouperGroupLeaveOrJoin(array $queryData) {
)
)
);

$this->http->setHeader(array('Content-Type' => 'application/json', 'Accept' => 'application/json'));
$connectionUrl = "{$this->config['fullUrl']}/groups/{$groupName}/members";

Expand All @@ -200,8 +199,7 @@ public function grouperGroupLeaveOrJoin(array $queryData) {
}
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - grouperGroupLeaveOrJoin: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - grouperGroupLeaveOrJoin: An error occurred');
throw $e;
}

Expand All @@ -228,8 +226,7 @@ public function getOptinGroups(array $queryData) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getOptinGroups: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getOptinGroups: An error occurred');
throw $e;
}
return array();
Expand All @@ -253,8 +250,7 @@ public function getOwnerGroups(array $queryData) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getOwnerGroups: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getOwnerGroups: An error occurred');
throw $e;
}
return array();
Expand All @@ -277,8 +273,7 @@ public function getOwnerStems(array $queryData) {
return $results['WsGetMembershipsResults']['wsStems'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getOwnerStems: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getOwnerStems: An error occurred');
throw $e;
}
return array();
Expand Down Expand Up @@ -329,14 +324,13 @@ private function useMembershipUrl(array $queryData) {
try {
return $this->http->sendRequest('POST', $connectionUrl, json_encode($groupsToShow));
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - useMembershipUrl: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - useMembershipUrl: An error occurred');
throw $e;
}
}

/**
* Returns a Distinct Grouper Group with its associated attributes and values
* Returns a Distinct Grouper Group with its associated values
*
* @param array $queryData Array of conditions for querying
* @return array Array of attributes for a Group
Expand All @@ -356,8 +350,7 @@ public function getGrouperGroupDescription(array $queryData) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGrouperGroupDescription: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGrouperGroupDescription: An error occurred');
throw $e;
}
return array();
Expand Down Expand Up @@ -414,8 +407,7 @@ public function createUpdateGroup(array $queryData) {
}
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - createUpdateGroup: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - createUpdateGroup: An error occurred');
throw $e;
}
return false;
Expand Down Expand Up @@ -454,8 +446,7 @@ public function getGroupAttributes(array $queryData) {
return $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGroupAttributes: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGroupAttributes: An error occurred');
throw $e;
}
return array();
Expand Down
11 changes: 8 additions & 3 deletions Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@
'pl.grouperlite.message.flash.join-group-success' => 'You have been added to the group!',
'pl.grouperlite.message.flash.join-group-failed' => 'You are unable to join the group!',
'pl.grouperlite.message.flash.join-group-error' => 'An error occurred in joining the group, please try again later.',
'pl.grouperlite.message.flash.info-group-failed' => 'Error in viewing group info, please try again later.',

'pl.grouperlite.message.flash.leave-group-success' => 'You have been deleted from the group!',
'pl.grouperlite.message.flash.leave-group-failed' => 'You are unable to delete the group!',
'pl.grouperlite.message.flash.leave-group-error' => 'An error occurred in leaving the group, please try again later.',
'pl.grouperlite.message.flash.owner-group-failed' => 'Error occurred in viewing groups you manage, please try again later.',
'pl.grouperlite.message.flash.member-group-failed' => 'Error occurred in viewing groups you are a member, please try again later.',
'pl.grouperlite.message.flash.optin-group-failed' => 'Error occurred in viewing Optin groups, please try again later.',

'pl.grouperlite.message.flash.leave-group-success' => 'You have been deleted from the group!',
'pl.grouperlite.message.flash.leave-group-failed' => 'You are unable to delete the group!',
'pl.grouperlite.message.flash.leave-group-error' => 'An error occurred in leaving the group, please try again later.',

'pl.grouperlite.table.name' => 'Name',
'pl.grouperlite.table.description' => 'Description',
Expand Down
12 changes: 9 additions & 3 deletions Model/GrouperAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ private function initApi() {
public function getGroupAttributes(string $groupName) {
$this->initApi();

$args = array();
$args['conditions']['groupName'] = $groupName;
try {
$args = array();
$args['conditions']['groupName'] = $groupName;

return $this->grouperAPI->getGroupAttributes($args);
return $this->grouperAPI->getGroupAttributes($args);

} catch (Exception $e) {
CakeLog::write('error', 'GrouperLite Attribute Model - getGroupAttributes: An error occurred');
throw $e;
}
}

}
Loading

0 comments on commit 2ca391e

Please sign in to comment.