Skip to content

Commit

Permalink
Group Grouping for WG
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Jul 6, 2021
1 parent 0ea9436 commit b3161bb
Show file tree
Hide file tree
Showing 14 changed files with 1,235 additions and 123 deletions.
116 changes: 97 additions & 19 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function beforeFilter() {
$this->setConnection();
}

//Need to verify if user is part of
}

/**
Expand Down Expand Up @@ -180,8 +179,8 @@ public function groupOwner() {
//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
'page' => ($this->passedArgs['page'] ?? $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ?? $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand All @@ -195,12 +194,24 @@ public function groupOwner() {
$scope['searchpage'] = 'ownerGroups';

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

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}

$this->set('groupsowners', $notWGData);
$this->set('wgowners', $wgData);

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

$this->set('groupergroupsowner', array());
$this->set('groupsowners', array());
$this->Flash->set(_txt('pl.grouperlite.message.flash.owner-group-failed'), array('key' => 'error'));
return;
}
Expand All @@ -209,12 +220,25 @@ public function groupOwner() {
$scope['method'] = 'ownerGroups';

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

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}

$this->set('groupsowners', $notWGData);
$this->set('wgowners', $wgData);

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

$this->set('groupergroupsowner', array());
$this->set('groupsowners', array());
$this->set('wgowners', array());
$this->Flash->set(_txt('pl.grouperlite.message.flash.owner-group-failed'), array('key' => 'error'));
return;
}
Expand All @@ -235,8 +259,8 @@ public function groupMember() {
//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
'page' => ($this->passedArgs['page'] ?? $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ?? $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand All @@ -250,13 +274,26 @@ public function groupMember() {
$scope['searchpage'] = 'filteredMemberOfGroups';

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

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}

$this->set('groupmemberships', $notWGData);
$this->set('wgmemberships', $wgData);

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

$this->Flash->set("Your Search Group cannot be found, please try again later.", array('key' => 'error'));
$this->set('groupergroupmemberships', array());
$this->set('groupmemberships', array());
$this->set('wgmemberships', array());
return;
}
} else {
Expand All @@ -265,13 +302,26 @@ public function groupMember() {
$scope['method'] = 'filteredMemberOfGroups';

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

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}

$this->set('groupmemberships', $notWGData);
$this->set('wgmemberships', $wgData);

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

$this->Flash->set("Your Member Group cannot be found, please try again later.", array('key' => 'error'));
$this->set('groupergroupmemberships', array());
$this->set('groupmemberships', array());
$this->set('wgmemberships', array());
return;
}
}
Expand All @@ -288,8 +338,8 @@ public function groupOptin() {
//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
'page' => ($this->passedArgs['page'] ?? $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ?? $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand All @@ -303,13 +353,27 @@ public function groupOptin() {
$scope['searchpage'] = 'optinGroups';

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

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}

$this->set('groupoptins', $notWGData);
$this->set('wgoptins', $wgData);

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

$this->Flash->set("Your Optin Group Search cannot be found, please try again later.", array('key' => 'error'));
$this->set('groupergroupoptin', array());
$this->set('groupoptins', array());
$this->set('wgoptins', array());
return;
}
} else {
Expand All @@ -318,12 +382,26 @@ public function groupOptin() {
$scope['method'] = 'optinGroups';

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

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}

$this->set('groupoptins', $notWGData);
$this->set('wgoptins', $wgData);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
$this->Flash->set("An error occurred with the Optin Groups, please try again later.", array('key' => 'error'));
$this->set('groupergroupoptin', array());
$this->set('groupoptins', array());
$this->set('wgoptins', array());
return;
}
}
Expand Down
Loading

0 comments on commit b3161bb

Please sign in to comment.