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',