Skip to content

Commit

Permalink
Merged ICPCO-119 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Mar 31, 2021
2 parents 270ad2c + fdb4f26 commit 19294fb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 43 deletions.
51 changes: 16 additions & 35 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
class GrouperApiAccess
{
// Array for storing settings needed in call to Grouper
private $config;
private array $config;

// Instance of Grouper HTTP Wrapper class
private $http;
private GrouperHTTPWrapper $http;

// String used to build out Grouper WS URL
private $_urlServlet = '/grouper-ws/servicesRest/';
private string $_urlServlet = '/grouper-ws/servicesRest/';

/**
* GrouperApiAccess constructor.
Expand Down Expand Up @@ -364,32 +364,6 @@ private function useMembershipUrl(array $queryData) {
}
}

/**
* 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
* @throws GrouperLiteException
*/
public function getGrouperGroupDescription(array $queryData) {
$groupName = $queryData['groupName'];

//Build request logic
$groupName = urlencode($groupName);
$connectionUrl = "{$this->config['fullUrl']}/groups/{$groupName}/memberships";

try {
$results = $this->http->sendRequest('GET', $connectionUrl);

if (isset($results['WsGetMembershipsResults']['wsGroups']) && $results['WsGetMembershipsResults']['wsGroups'] != NULL) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': An error occurred');
throw $e;
}
return array();
}

/**
* Method used to CREATE a new Group in Grouper via the Template method.
Expand Down Expand Up @@ -481,7 +455,7 @@ public function deleteGroupWithTemplate(array $queryData) {
$connectionUrl = "{$this->config['fullUrl']}/gshTemplateExec";

try {
$results = $this->http->sendRequest('POST', $connectionUrl, json_encode($groupToSave));
$results = $this->http->sendRequest('POST', $connectionUrl, json_encode($groupToDelete));

if (isset($results['WsGshTemplateExecResult']['resultMetadata']['resultCode'])) {
if (stripos($results['WsGshTemplateExecResult']['resultMetadata']['resultCode'], "SUCCESS", 0) !== false) {
Expand Down Expand Up @@ -558,15 +532,15 @@ public function createUpdateGroup(array $queryData) {
}

/**
* Listing of attributes in Grouper for a given Group Name
* Grouper Group information plus a listing of attributes in Grouper for that given Group
*
* @param array $queryData Array of conditions for querying
* @return array Record of Grouper attributes for given GroupName
* @throws GrouperLiteException
*/
public function getGroupAttributes(array $queryData) {
// Need to pass in the full stem path, so thing like sandbox:app:sympa are good!
public function getGrouperGroupInfo(array $queryData) {
$groupName = $queryData['groupName'];
$groupInfo = array();

//Build request logic
$stemToFind = array(
Expand All @@ -586,14 +560,21 @@ public function getGroupAttributes(array $queryData) {
try {
$results = $this->http->sendRequest('POST', $connectionUrl, json_encode($stemToFind));

//Get the group information
if (isset($results['WsGetAttributeAssignmentsResults']['wsGroups']) && $results['WsGetAttributeAssignmentsResults']['wsGroups'] != NULL) {
$groupInfo = $results['WsGetAttributeAssignmentsResults']['wsGroups'];
}

//Now get the Group Attributes and add them to group
if (isset($results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns']) && $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'] != NULL) {
return $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'];
$groupInfo[0]["attributes"] = $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'];
}

return $groupInfo;
} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': An error occurred');
throw $e;
}
return array();
}

}
1 change: 1 addition & 0 deletions Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'pl.grouperlite.nav.emaillists-member' => 'My email lists',
'pl.grouperlite.nav.emaillists-manage' => 'Email lists I manage',
'pl.grouperlite.nav.create-group' => 'Create group',
'pl.grouperlite.nav.create-working-group' => 'Create working group',
'pl.grouperlite.nav.create-email' => 'Create email list',
'pl.grouperlite.nav.emaillists' => 'Email Lists',
'pl.grouperlite.nav.groups' => 'Groups',
Expand Down
7 changes: 1 addition & 6 deletions Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,9 @@ public function groupDescriptions(string $groupName) {
$args = array();
$args['groupName'] = $groupName;

$groupDescription = $this->grouperAPI->getGrouperGroupDescription($args);
$groupDescription = $this->grouperAPI->getGrouperGroupInfo($args);
$groupInfo = $this->getFriendlyName($groupDescription);

//make call to get attributes for group
$grouperAtt = new GrouperAttribute();
$groupAttributes = $grouperAtt->getGroupAttributes($groupName);

$groupInfo[0]["attributes"] = $groupAttributes;
return $groupInfo;

} catch (Exception $e) {
Expand Down
15 changes: 15 additions & 0 deletions View/Elements/Components/navigation-groups.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@
</a>
</div>
<?php } ?>
<?php if ($isuserowner === 'T') { ?>
<div class="align-self-center">
<?php
$createTemplateGroupUrl = $this->Html->url(
array(
'controller' => 'grouper_groups',
'action' => 'groupcreatetemplate'
)
);
?>
<a href="<?php echo $createTemplateGroupUrl; ?>" class="btn btn-grouper btn btn-link px-3 py-2">
<i class="fa fa-plus-circle"></i>&nbsp; <?php echo _txt('pl.grouperlite.nav.create-working-group'); ?>
</a>
</div>
<?php } ?>
<div class="align-self-center ml-auto">
<?php
$gotoEmailListsUrl = $this->Html->url(
Expand Down
2 changes: 1 addition & 1 deletion View/GrouperGroups/emaillistinfo.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $attrUrlBase = $baseUrl . $path . $attrOperation;
<?php echo $this->element('Components/subscriberList', array('subscribers' => $groupergroupssubscribers)); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-grouper btn btn-link" data-dismiss="modal"><?php echo ('pl.grouperlite.action.close'); ?></button>
<button type="button" class="btn btn-grouper btn btn-link" data-dismiss="modal"><?php echo _txt('pl.grouperlite.action.close'); ?></button>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion View/GrouperGroups/groupinfo.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $attrUrlBase = $baseUrl . $path . $attrOperation;
<?php echo $this->element('Components/subscriberList', array('subscribers' => $groupergroupssubscribers)); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-grouper btn btn-link" data-dismiss="modal"><?php echo ('pl.grouperlite.action.close'); ?></button>
<button type="button" class="btn btn-grouper btn btn-link" data-dismiss="modal"><?php echo _txt('pl.grouperlite.action.close'); ?></button>
</div>
</div>
</div>
Expand Down

0 comments on commit 19294fb

Please sign in to comment.