From fdb4f26587308ebd4f7643d46d9ddb4a47b7530d Mon Sep 17 00:00:00 2001 From: axman Date: Wed, 31 Mar 2021 15:14:14 -0700 Subject: [PATCH] fixed issues in ticket --- Lib/GrouperApiAccess.php | 51 ++++++------------- Lib/lang.php | 1 + Model/GrouperGroup.php | 7 +-- .../Elements/Components/navigation-groups.ctp | 15 ++++++ View/GrouperGroups/emaillistinfo.ctp | 2 +- View/GrouperGroups/groupinfo.ctp | 2 +- 6 files changed, 35 insertions(+), 43 deletions(-) diff --git a/Lib/GrouperApiAccess.php b/Lib/GrouperApiAccess.php index 1d7a845..c43a156 100644 --- a/Lib/GrouperApiAccess.php +++ b/Lib/GrouperApiAccess.php @@ -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. @@ -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. @@ -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) { @@ -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( @@ -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(); } } diff --git a/Lib/lang.php b/Lib/lang.php index fc692eb..8b5af83 100644 --- a/Lib/lang.php +++ b/Lib/lang.php @@ -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', diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index bf12999..fb3c7f4 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -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) { diff --git a/View/Elements/Components/navigation-groups.ctp b/View/Elements/Components/navigation-groups.ctp index 4b54c44..aadcef4 100644 --- a/View/Elements/Components/navigation-groups.ctp +++ b/View/Elements/Components/navigation-groups.ctp @@ -52,6 +52,21 @@ + +
+ Html->url( + array( + 'controller' => 'grouper_groups', + 'action' => 'groupcreatetemplate' + ) + ); + ?> + +   + +
+
Html->url( diff --git a/View/GrouperGroups/emaillistinfo.ctp b/View/GrouperGroups/emaillistinfo.ctp index daa4379..4eaa7f7 100644 --- a/View/GrouperGroups/emaillistinfo.ctp +++ b/View/GrouperGroups/emaillistinfo.ctp @@ -62,7 +62,7 @@ $attrUrlBase = $baseUrl . $path . $attrOperation; element('Components/subscriberList', array('subscribers' => $groupergroupssubscribers)); ?>
diff --git a/View/GrouperGroups/groupinfo.ctp b/View/GrouperGroups/groupinfo.ctp index c668513..a989fa0 100644 --- a/View/GrouperGroups/groupinfo.ctp +++ b/View/GrouperGroups/groupinfo.ctp @@ -63,7 +63,7 @@ $attrUrlBase = $baseUrl . $path . $attrOperation; element('Components/subscriberList', array('subscribers' => $groupergroupssubscribers)); ?>