Skip to content

Commit

Permalink
work for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Feb 24, 2021
1 parent 9cf6b9b commit 7c255b5
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 247 deletions.
75 changes: 68 additions & 7 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@
class GrouperGroupsController extends GrouperLiteAppController
{
public $helpers = array('Html', 'Form', 'Flash');
public $components = array('Flash');
public $components = array('Flash', 'Paginator');

public $name = 'GrouperGroups';

//Unfortunately we cannot go below 20 since that is the default and if change to below 20 will not show
//page navigation unless change record count and go back to lower number on Display record selection!! Sucks!
public $paginate = array(
//Default records per page.
'limit' => 20,
'maxlimit' => 60,
'page' => 1
);


/**
* Overrides parent beforeFilter to verify that Session contains the correct API settings.
*
Expand Down Expand Up @@ -121,12 +131,25 @@ public function groupInfo() {
public function groupOwner() {
$this->set('title', _txt('pl.grouperlite.title.groupowner'));

//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
$searchCriteria = urldecode($this->request->data['search']);
$this->set('searchcriteria', $searchCriteria);

try {
$this->set('groupergroupsowner', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOwner'));
//Add settings for search Owned Groups
$scope['method'] = 'getSearchedGroups';
$scope['searchcriteria'] = $searchCriteria;
$scope['searchpage'] = 'ownerGroups';

$data = $this->Paginator->paginate('GrouperGroup', $scope);
$this->set('groupergroupsowner', $data);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ' Search: ' . var_export($e->getMessage(), true));
Expand All @@ -137,7 +160,11 @@ public function groupOwner() {
}
} else {
try {
$this->set('groupergroupsowner', $this->GrouperGroup->ownerGroups($this->userId));
$scope['method'] = 'ownerGroups';

$data = $this->Paginator->paginate('GrouperGroup', $scope);
$this->set('groupergroupsowner', $data);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));

Expand All @@ -158,12 +185,25 @@ public function groupOwner() {
public function groupMember() {
$this->set('title', _txt('pl.grouperlite.title.groupmember'));

//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
$searchCriteria = urldecode($this->request->data['search']);
$this->set('searchcriteria', $searchCriteria);

try {
$this->set('groupergroupmemberships', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupMember'));
//Add settings for search Member Groups
$scope['method'] = 'getSearchedGroups';
$scope['searchcriteria'] = $searchCriteria;
$scope['searchpage'] = 'filteredMemberOfGroups';

$data = $this->Paginator->paginate('GrouperGroup', $scope);
$this->set('groupergroupmemberships', $data);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ' Search: ' . var_export($e->getMessage(), true));
Expand All @@ -174,7 +214,11 @@ public function groupMember() {
}
} else {
try {
$this->set('groupergroupmemberships', $this->GrouperGroup->filteredMemberOfGroups($this->userId));
//Add setting for Group Membership
$scope['method'] = 'filteredMemberOfGroups';

$data = $this->Paginator->paginate('GrouperGroup', $scope);
$this->set('groupergroupmemberships', $data);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
Expand All @@ -193,12 +237,25 @@ public function groupMember() {
public function groupOptin() {
$this->set('title', _txt('pl.grouperlite.title.groupoptin'));

//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
$searchCriteria = urldecode($this->request->data['search']);
$this->set('searchcriteria', $searchCriteria);

try {
$this->set('groupergroupoptin', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOptin'));
//Add settings for search Optin's
$scope['method'] = 'getSearchedGroups';
$scope['searchcriteria'] = $searchCriteria;
$scope['searchpage'] = 'optinGroups';

$data = $this->Paginator->paginate('GrouperGroup', $scope);
$this->set('groupergroupoptin', $data);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . 'Search: ' . var_export($e->getMessage(), true));
Expand All @@ -209,7 +266,11 @@ public function groupOptin() {
}
} else {
try {
$this->set('groupergroupoptin', $this->GrouperGroup->optinGroups($this->userId));
//Add settings for optinGroups
$scope['method'] = 'optinGroups';

$data = $this->Paginator->paginate('GrouperGroup', $scope);
$this->set('groupergroupoptin', $data);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
Expand Down
32 changes: 16 additions & 16 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct() {
*/
public function getGrouperUser(array $queryData) {

$userId = $queryData['conditions']['userId'];
$userId = $queryData['userId'];
$this->http->setHeader(array('Content-Type' => 'application/json', 'Accept' => 'application/json'));

// Create attributes want returned from call to Grouper WS
Expand Down Expand Up @@ -127,7 +127,7 @@ public function getGrouperUser(array $queryData) {
public function getGrouperMemberOfGroups(array $queryData) {

//Build request logic
$userId = $queryData['conditions']['userId'];
$userId = $queryData['userId'];
$connectionUrl = "{$this->config['fullUrl']}/subjects/{$userId}/groups";

try {
Expand All @@ -154,9 +154,9 @@ public function getGrouperMemberOfGroups(array $queryData) {
*/
public function grouperGroupLeaveOrJoin(array $queryData) {

$groupName = $queryData['conditions']['groupName'];
$userId = $queryData['conditions']['userId'];
$groupLeaveOrJoin = $queryData['conditions']['LeaveJoin'];
$groupName = $queryData['groupName'];
$userId = $queryData['userId'];
$groupLeaveOrJoin = $queryData['LeaveJoin'];
$groupName = urlencode($groupName);

if ($groupLeaveOrJoin == "Leave") {
Expand Down Expand Up @@ -216,7 +216,7 @@ public function grouperGroupLeaveOrJoin(array $queryData) {
*
*/
public function getOptinGroups(array $queryData) {
$queryData['conditions']['groupType'] = 'Optins';
$queryData['groupType'] = 'Optins';

try {
$results = $this->useMembershipUrl($queryData);
Expand All @@ -240,7 +240,7 @@ public function getOptinGroups(array $queryData) {
*
*/
public function getOwnerGroups(array $queryData) {
$queryData['conditions']['groupType'] = 'Owner';
$queryData['groupType'] = 'Owner';

try {
$results = $this->useMembershipUrl($queryData);
Expand All @@ -263,7 +263,7 @@ public function getOwnerGroups(array $queryData) {
* @throws GrouperLiteException
*/
public function getOwnerStems(array $queryData) {
$queryData['conditions']['groupType'] = 'StemOwner';
$queryData['groupType'] = 'StemOwner';

try {
$results = $this->useMembershipUrl($queryData);
Expand All @@ -290,8 +290,8 @@ public function getOwnerStems(array $queryData) {
* @throws GrouperLiteException
*/
private function useMembershipUrl(array $queryData) {
$groupType = $queryData['conditions']['groupType'];
$userId = $queryData['conditions']['userId'];
$groupType = $queryData['groupType'];
$userId = $queryData['userId'];

if ($groupType == 'Optins') {
$fieldName = "optins";
Expand Down Expand Up @@ -335,7 +335,7 @@ private function useMembershipUrl(array $queryData) {
* @throws GrouperLiteException
*/
public function getGrouperGroupDescription(array $queryData) {
$groupName = $queryData['conditions']['groupName'];
$groupName = $queryData['groupName'];

//Build request logic
$groupName = urlencode($groupName);
Expand Down Expand Up @@ -367,10 +367,10 @@ public function createUpdateGroup(array $queryData) {
//TODO - Need to add checking for missing ':'
//Currently only supporting create group, need to test if update a group will work!

$groupName = $queryData['conditions']['groupName'];
$stemName = $queryData['conditions']['stemName'];
$userId = $queryData['conditions']['userId'];
$groupDescription = $queryData['conditions']['groupDescription'];
$groupName = $queryData['groupName'];
$stemName = $queryData['stemName'];
$userId = $queryData['userId'];
$groupDescription = $queryData['groupDescription'];

$newGroupToSave = $stemName . $groupName;

Expand Down Expand Up @@ -420,7 +420,7 @@ public function createUpdateGroup(array $queryData) {
*/
public function getGroupAttributes(array $queryData) {
// Need to pass in the full stem path, so thing like sandbox:app:sympa are good!
$groupName = $queryData['conditions']['groupName'];
$groupName = $queryData['groupName'];

//Build request logic
$stemToFind = array(
Expand Down
11 changes: 11 additions & 0 deletions Model/CoManagePerson.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

App::uses('CoPersonRole', 'Model/');

class CoManagePerson extends GrouperLiteAppModel
{

public $name = "CoManagePerson";


}
2 changes: 1 addition & 1 deletion Model/GrouperAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getGroupAttributes(string $groupName) {

try {
$args = array();
$args['conditions']['groupName'] = $groupName;
$args['groupName'] = $groupName;

return $this->grouperAPI->getGroupAttributes($args);

Expand Down
Loading

0 comments on commit 7c255b5

Please sign in to comment.