From 9f9a43dc069cda07d948beb43c91cf306918be38 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Tue, 15 Dec 2020 15:27:06 -0700 Subject: [PATCH 01/12] Integrated plugin with comanage processes --- Lib/lang.php | 29 +++++++++++++++++++++ Model/GrouperLite.php | 11 ++++++++ View/CoGrouperLite/display.ctp | 1 + View/Elements/Components/navigation.ctp | 15 ++++------- View/Elements/Components/optAction.ctp | 17 ++++-------- View/Elements/Components/search.ctp | 14 +++++----- View/GrouperGroups/base.ctp | 13 ++++++++-- View/GrouperGroups/emaillistsmanaged.ctp | 27 ++++++++++--------- View/GrouperGroups/emaillistsoptin.ctp | 25 ++++++++++-------- View/GrouperGroups/groupcreateform.ctp | 33 ++++++++++++------------ View/GrouperGroups/groupinfo.ctp | 1 + View/GrouperGroups/groupoptin.ctp | 14 +++++----- View/GrouperGroups/groupowner.ctp | 27 ++++++++++--------- webroot/css/bootstrap.css | 3 +-- webroot/css/co-grouper-plugin.css | 2 +- 15 files changed, 142 insertions(+), 90 deletions(-) create mode 100644 Lib/lang.php create mode 100644 View/CoGrouperLite/display.ctp diff --git a/Lib/lang.php b/Lib/lang.php new file mode 100644 index 0000000..aa89932 --- /dev/null +++ b/Lib/lang.php @@ -0,0 +1,29 @@ + 'Groups', + 'pl.grouperlite.nav.groups-presided' => 'Groups I preside over', + 'pl.grouperlite.nav.email-lists' => 'Email lists', + 'pl.grouperlite.nav.email-lists-managed' => 'Email lists I manage', + 'pl.grouperlite.nav.create-group' => 'Create group', + + 'pl.grouperlite.table.name' => 'Name', + 'pl.grouperlite.table.description' => 'Description', + 'pl.grouperlite.table.status' => 'Status', + 'pl.grouperlite.table.action' => 'Action', + + 'pl.grouperlite.value.descr.zerostate' => 'No Description', + 'pl.grouperlite.value.enabled' => 'Enabled', + 'pl.grouperlite.value.disabled' => 'Disabled', + + 'pl.grouperlite.action.join-group' => 'Join group', + 'pl.grouperlite.action.leave-group' => 'Leave group', + 'pl.grouperlite.action.edit-group' => 'Edit', + 'pl.grouperlite.action.disable-group' => 'Disable', + 'pl.grouperlite.action.subscribe' => 'Subscribe', + 'pl.grouperlite.action.unsubscribe' => 'Unsubscribe', + 'pl.grouperlite.action.search' => 'Search', + + 'pl.grouperlite.search.tags.text' => 'Search', +); \ No newline at end of file diff --git a/Model/GrouperLite.php b/Model/GrouperLite.php index 9892b1c..3123303 100644 --- a/Model/GrouperLite.php +++ b/Model/GrouperLite.php @@ -8,5 +8,16 @@ class GrouperLite extends AppModel { // Required by COmanage Plugins public $cmPluginType = "dashboardwidget"; + public function cmPluginMenus() { + return array( + "cogroups" => array( + 'Grouper groups' => array( + 'controller' => "groupergroups", + 'action' => "groupoptin" + ) + ) + ); + } + } \ No newline at end of file diff --git a/View/CoGrouperLite/display.ctp b/View/CoGrouperLite/display.ctp new file mode 100644 index 0000000..2e9664d --- /dev/null +++ b/View/CoGrouperLite/display.ctp @@ -0,0 +1 @@ +Hi I am the dashboard widget \ No newline at end of file diff --git a/View/Elements/Components/navigation.ctp b/View/Elements/Components/navigation.ctp index fc5c06c..8ec8cd1 100644 --- a/View/Elements/Components/navigation.ctp +++ b/View/Elements/Components/navigation.ctp @@ -1,14 +1,9 @@ - \ No newline at end of file diff --git a/View/Elements/Components/optAction.ctp b/View/Elements/Components/optAction.ctp index 723e54d..ba7a348 100644 --- a/View/Elements/Components/optAction.ctp +++ b/View/Elements/Components/optAction.ctp @@ -1,16 +1,9 @@ -
+Form->create(false, array( + 'url' => array('controller' => 'groupergroups', 'action' => $action) +)); ?> - Form->hidden('token', array('default' => $vv_petition_token)) . "\n"; - } - ?> -
\ No newline at end of file +Form->end(); ?> \ No newline at end of file diff --git a/View/Elements/Components/search.ctp b/View/Elements/Components/search.ctp index 4be109f..05d861f 100644 --- a/View/Elements/Components/search.ctp +++ b/View/Elements/Components/search.ctp @@ -15,8 +15,10 @@ $(document).ready(function() { }); }); - - + */ ?>
Form->label(false, 'Description:', array( 'for' => 'descr', From 93892a7a96f1058f17d687e512ce842ffeda20f8 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Thu, 17 Dec 2020 15:12:16 -0700 Subject: [PATCH 06/12] updated messaging --- Controller/GrouperGroupsController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index b0606e2..56442e1 100644 --- a/Controller/GrouperGroupsController.php +++ b/Controller/GrouperGroupsController.php @@ -119,13 +119,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('You have been added to the group!')); } else { - $this->Flash->error(__(_txt('You are unable to join the group!'))); + $this->Flash->error(_txt('You are unable to join the group!')); } 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('An error occurred in joining the group, please try again later.')); } @@ -134,13 +134,13 @@ 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('You have been deleted from the group!')); } else { - $this->Flash->error(__(_txt('You are unable to delete the group!'))); + $this->Flash->error(_txt('You are unable to delete the group!')); } 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('An error occurred in leaving the group, please try again later.')); } /** From 4425e0b761cde27e7680e073e13de760269cb20d Mon Sep 17 00:00:00 2001 From: axman Date: Wed, 23 Dec 2020 10:38:50 -0700 Subject: [PATCH 07/12] WIP --- Lib/GrouperApiAccess.php | 34 ++++------------------------------ Model/GrouperGroup.php | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Lib/GrouperApiAccess.php b/Lib/GrouperApiAccess.php index c83e57f..141f8e0 100644 --- a/Lib/GrouperApiAccess.php +++ b/Lib/GrouperApiAccess.php @@ -158,33 +158,6 @@ public function getGrouperGroups($queryData) return array(); } - public function searchGrouperGroups($queryData) { - - $subjectID = $queryData['conditions']['userId']; - $search = $queryData['conditions']['search']; - - $groupsFiltered = array( - "WsRestFindGroupsRequest" => array( - "actAsSubjectLookup" => array("subjectId" => $subjectID), - "wsQueryFilter" => array( - "queryFilterType" => "FIND_BY_GROUP_NAME_APPROXIMATE", - "groupName" => $search - ) - ) - ); - - $this->http->setHeader(array('Content-Type' => 'application/json', 'Accept' => 'application/json')); - - $connectionUrl = "{$this->config['fullUrl']}/groups"; - - $results = $this->http->sendRequest('POST', $connectionUrl, json_encode($groupsFiltered)); - - if (isset($results['WsFindGroupsResults']['groupResults']) && $results['WsFindGroupsResults']['groupResults'] != NULL) { - return $results['WsFindGroupsResults']['groupResults']; - } - - return array(); - } public function getGrouperGroupDescription($queryData) { @@ -287,7 +260,8 @@ public function getGroupAttributes($queryData) { "includeAssignmentsOnAssignments" => "T", "wsOwnerGroupLookups" => array( array( - "groupName" => $groupName + "groupName" => $groupName, + ) ) ) @@ -298,8 +272,8 @@ public function getGroupAttributes($queryData) { $results = $this->http->sendRequest('POST', $connectionUrl, json_encode($stemToFind)); - if (isset($results['WsGetAttributeAssignmentsResults']['wsAttributeDefNames']) && $results['WsGetAttributeAssignmentsResults']['wsAttributeDefNames'] != NULL) { - return $results['WsGetAttributeAssignmentsResults']['wsAttributeDefNames']; + if (isset($results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns']) && $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'] != NULL) { + return $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns']; } return array(); } diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index 322899b..0d698bf 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -32,10 +32,18 @@ class GrouperGroup extends GrouperLiteAppModel ), ); + /** + * @var string + */ + //TODO - get name of Friendly name attribute that can be used for pulling the friendly name + private $friendly = 'sandbox:testAttributeName'; + + public function __construct() { parent::__construct(); $this->grouperAPI = new GrouperApiAccess(); + } public function userGroups($userId) @@ -134,12 +142,21 @@ public function getStemGroup($userId, $stemName) { return $this->grouperAPI->getStemGroups($args); } + /** + * Search for Groups/Lists related to Search term. + * Will import all records the user can see and then do search here rather than call Grouper WS Search + * functionality. This is due to the fact that the grouperName is autogenerated and this app needs to search + * attributes which the Grouper WS does not do. + * + * @param $userId + * @param $searchCriteria + * @param $page + * @return array + */ public function getSearchedGroups($userId, $searchCriteria, $page) { $args = array(); $args['conditions']['userId'] = $userId; - $args['conditions']['search'] = $searchCriteria; - $searchResults = $this->grouperAPI->searchGrouperGroups($args); if($page == 'groupOptin') { $pageResults = $this->optinGroups($userId); } elseif ($page == 'groupOwner') { @@ -150,15 +167,25 @@ public function getSearchedGroups($userId, $searchCriteria, $page) { $returnResults = array(); - foreach ($pageResults as $pageGroup) { - foreach ($searchResults as $searchGroup) { - if ($pageGroup['uuid'] == $searchGroup['uuid']) { - $returnResults[] = $pageGroup; + //Will need to get attributes for each group + + foreach ($pageResults as &$pageGroup) { + $pageGroup['friendlyName'] = 'unkown'; + $groupResults = $this->grouperAPI->getGroupAttributes(array('conditions' => array('groupName' => $pageGroup['groupName']))); + //TODO This will need to be moved into the optinGroups and ownerGroups methods once attribute name decided on. + foreach ($groupResults as $groupResult) { + if ($groupResult['attributeDefNameName'] == $this->friendly) { + $pageGroup['friendlyName'] = $groupResults['wsAttributeAssignValues']['valueSystem']; break; } } } + //Now we can do a search on all the fields + //will search on friendly name, group, stem, + + + return $returnResults; } From b7485ec7357f31fa48424910d63560c104133ea9 Mon Sep 17 00:00:00 2001 From: axman Date: Wed, 23 Dec 2020 14:13:30 -0700 Subject: [PATCH 08/12] WIP --- Lib/GrouperApiAccess.php | 1 - Model/GrouperGroup.php | 55 +++++++++++++++++++++---------- View/GrouperGroups/groupoptin.ctp | 2 +- View/GrouperGroups/groupowner.ctp | 2 +- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/Lib/GrouperApiAccess.php b/Lib/GrouperApiAccess.php index 141f8e0..dcd7556 100644 --- a/Lib/GrouperApiAccess.php +++ b/Lib/GrouperApiAccess.php @@ -261,7 +261,6 @@ public function getGroupAttributes($queryData) { "wsOwnerGroupLookups" => array( array( "groupName" => $groupName, - ) ) ) diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index 0d698bf..2f01574 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -96,7 +96,24 @@ public function ownerGroups($userId) $args['conditions']['groupType'] = 'Owner'; $args['conditions']['userId'] = $userId; - return $this->grouperAPI->getGrouperGroups($args); + $ownGroups = $this->grouperAPI->getGrouperGroups($args); + + //Now for each group need to pull in friendly name attribute. + foreach ($ownGroups as &$ownGroup) { + $ownGroup['friendlyName'] = $ownGroup['displayName']; + $attributes = $this->grouperAPI->getGroupAttributes(array('conditions' => array('groupName' => $ownGroup['displayName']))); + foreach ($attributes as $attribute) { + if ($attribute['attributeDefNameName'] == $this->friendly) { + if (isset($attribute['wsAttributeAssignValues'][0]['valueSystem'])) { + $ownGroup['friendlyName'] = $attribute['wsAttributeAssignValues'][0]['valueSystem']; + } + break; + } + } + } + + return $ownGroups; + } public function optinGroups($userId) @@ -105,10 +122,11 @@ public function optinGroups($userId) $args['conditions']['groupType'] = 'Optins'; $args['conditions']['userId'] = $userId; - $returnsToJoinOrLeave = $this->grouperAPI->getGrouperGroups($args); + $joinOrLeave = $this->grouperAPI->getGrouperGroups($args); $userGroups = $this->userGroups($userId); - foreach ($returnsToJoinOrLeave as &$groupsJoL) { + //See if Optin group match any of the groups belong to already. + foreach ($joinOrLeave as &$groupsJoL) { foreach ($userGroups as $userGroup) { $groupsJoL['member'] = false; if ($groupsJoL['name'] == $userGroup['name']) { @@ -119,7 +137,21 @@ public function optinGroups($userId) } } - return $returnsToJoinOrLeave; + //Now for each group need to pull in friendly name attribute. + foreach ($joinOrLeave as &$jol) { + $jol['friendlyName'] = $jol['displayName']; + $attributes = $this->grouperAPI->getGroupAttributes(array('conditions' => array('groupName' => $jol['displayName']))); + foreach ($attributes as $attribute) { + if ($attribute['attributeDefNameName'] == $this->friendly) { + if (isset($attribute['wsAttributeAssignValues']['valueSystem'])) { + $jol['friendlyName'] = $attribute['wsAttributeAssignValues']['valueSystem']; + } + break; + } + } + } + + return $joinOrLeave; } public function createGroup($userId, $groupName, $stemName, $groupDesc) @@ -167,21 +199,8 @@ public function getSearchedGroups($userId, $searchCriteria, $page) { $returnResults = array(); - //Will need to get attributes for each group - - foreach ($pageResults as &$pageGroup) { - $pageGroup['friendlyName'] = 'unkown'; - $groupResults = $this->grouperAPI->getGroupAttributes(array('conditions' => array('groupName' => $pageGroup['groupName']))); - //TODO This will need to be moved into the optinGroups and ownerGroups methods once attribute name decided on. - foreach ($groupResults as $groupResult) { - if ($groupResult['attributeDefNameName'] == $this->friendly) { - $pageGroup['friendlyName'] = $groupResults['wsAttributeAssignValues']['valueSystem']; - break; - } - } - } - //Now we can do a search on all the fields + //Now we can do a search on the fields //will search on friendly name, group, stem, diff --git a/View/GrouperGroups/groupoptin.ctp b/View/GrouperGroups/groupoptin.ctp index 755beed..8197ac8 100644 --- a/View/GrouperGroups/groupoptin.ctp +++ b/View/GrouperGroups/groupoptin.ctp @@ -17,7 +17,7 @@ Html->link( - isset($group['name']) ? $group['name'] : "No Name", + isset($group['friendlyName']) ? $group['friendlyName'] : "No Name", array( 'controller' => 'groupergroups', 'action' => 'groupinfo', diff --git a/View/GrouperGroups/groupowner.ctp b/View/GrouperGroups/groupowner.ctp index 1551774..5096536 100644 --- a/View/GrouperGroups/groupowner.ctp +++ b/View/GrouperGroups/groupowner.ctp @@ -16,7 +16,7 @@ Html->link( - isset($group['name']) ? $group['name'] : "No Name", + isset($group['friendlyName']) ? $group['friendlyName'] : "No Name", array( 'controller' => 'groupergroups', 'action' => 'groupinfo', From 05060728d31051005029109304abab2f1b7f3bb9 Mon Sep 17 00:00:00 2001 From: axman Date: Thu, 24 Dec 2020 09:58:43 -0700 Subject: [PATCH 09/12] work to be tested for search --- Model/GrouperGroup.php | 11 ++++++----- View/Elements/Components/search.ctp | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index 2f01574..a69451a 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -199,11 +199,12 @@ public function getSearchedGroups($userId, $searchCriteria, $page) { $returnResults = array(); - - //Now we can do a search on the fields - //will search on friendly name, group, stem, - - + foreach($pageResults as $result) { + $match = preg_grep("/$searchCriteria/i", $result); + if (!empty($match)) { + $returnResults[] = $result; + } + } return $returnResults; } diff --git a/View/Elements/Components/search.ctp b/View/Elements/Components/search.ctp index f22b80b..19f5d71 100644 --- a/View/Elements/Components/search.ctp +++ b/View/Elements/Components/search.ctp @@ -22,7 +22,8 @@ $(function() {