Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Dec 23, 2020
1 parent 18b8e69 commit 4425e0b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
34 changes: 4 additions & 30 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -287,7 +260,8 @@ public function getGroupAttributes($queryData) {
"includeAssignmentsOnAssignments" => "T",
"wsOwnerGroupLookups" => array(
array(
"groupName" => $groupName
"groupName" => $groupName,

)
)
)
Expand All @@ -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();
}
Expand Down
39 changes: 33 additions & 6 deletions Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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') {
Expand All @@ -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;
}

Expand Down

0 comments on commit 4425e0b

Please sign in to comment.