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; }