Skip to content

Commit

Permalink
Removed unused code and removed pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Stohn authored and Axel Stohn committed May 14, 2023
1 parent 716989b commit 579c98d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 525 deletions.
242 changes: 17 additions & 225 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ class GrouperGroupsController extends GrouperLiteAppController

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' => 100,
'page' => 1
);

/**
* Overrides parent beforeFilter to verify that Session contains the correct API settings.
*
Expand Down Expand Up @@ -404,13 +395,10 @@ public function removeSubscriber()
*/
public function groupOwner()
{
$this->set('title', _txt('pl.grouperlite.title.groupowner'));

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

if (isset($this->request->data['search']) || isset($this->request->query['search'])) {
Expand All @@ -428,7 +416,7 @@ public function groupOwner()
$scope['searchcriteria'] = $searchCriteria;
$scope['searchpage'] = 'ownerGroups';

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

$this->set('groupsowners', $data);

Expand All @@ -443,7 +431,7 @@ public function groupOwner()
try {
$scope['method'] = 'ownerGroups';

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

$this->set('groupsowners', $data);

Expand Down Expand Up @@ -479,13 +467,9 @@ public function groupOwner()
*/
public function groupMember()
{
$this->set('title', _txt('pl.grouperlite.title.groupmember'));

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

if (isset($this->request->data['search']) || isset($this->request->query['search'])) {
Expand All @@ -504,7 +488,7 @@ public function groupMember()
$scope['searchpage'] = 'filteredMemberOfGroups';
$scope['ContainsWG'] = true;

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

$finalData = $this->breakoutGroups($data);

Expand All @@ -524,7 +508,7 @@ public function groupMember()
//Add setting for Group Membership
$scope['method'] = 'filteredMemberOfGroups';

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

$finalData = $this->breakoutGroups($data);

Expand Down Expand Up @@ -558,14 +542,10 @@ public function groupMember()
*/
public function groupOptin()
{
$this->set('title', _txt('pl.grouperlite.title.groupoptin'));


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

if (isset($this->request->data['search']) || isset($this->request->query['search'])) {
Expand All @@ -583,7 +563,7 @@ public function groupOptin()
$scope['searchcriteria'] = $searchCriteria;
$scope['searchpage'] = 'optinGroups';

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

$this->set('groupoptins', $data);

Expand All @@ -600,7 +580,7 @@ public function groupOptin()
//Add settings for optinGroups
$scope['method'] = 'optinGroups';

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

$this->set('groupoptins', $data);

Expand All @@ -624,6 +604,7 @@ public function groupOptin()
$this->set('config', $config);
}


/**
* Create a new Grouper Group via Grouper Template
* Note: This is tightly coupled code to requirements, so view is hardcoded to reflect current reqs. Will need
Expand Down Expand Up @@ -653,61 +634,6 @@ public function groupCreateTemplate()
$this->set('title', _txt('pl.grouperlite.title.templatecreate'));
}

/**
* ======================== NOT BEING USED ========================
*
* Delete a Grouper Group via Grouper Template
*/
public function groupDeleteTemplate()
{
if (!$this->GrouperGroup->deleteGroupWithTemplate($this->userId, $this->request->data)) {
$this->Flash->set("Error in deleting group!", array('key' => 'error'));
return $this->redirect(array('action' => 'groupoptin'));
}

$this->set('title', _txt('pl.grouperlite.title.templatecreate'));
}

/**
* ======================== NOT BEING USED ========================
*
* @return CakeResponse|void|null
* @deprecated
*
*/
public function groupCreate()
{
if ($this->request->is('post')) {
if (!$this->GrouperGroup->createUpdateGroup($this->userId, $this->request->data)) {
$this->Flash->set("Error in creating group!", array('key' => 'error'));
} else {
$this->Flash->set("Your Group has been created!", array('key' => 'success'));
}
return $this->redirect(array('action' => 'groupOwner'));
}

$this->set('title', _txt('pl.grouperlite.title.groupcreate'));
$this->set('grouperstems', $this->GrouperGroup->getOwnedStems($this->userId));
}


/**
* ======================== NOT BEING USED ========================
*
* @return CakeResponse|null
*/
public function groupDelete()
{
if (!$this->GrouperGroup->deleteGroup($this->userId, $this->request->data)) {
$this->Flash->set("Error in deleting group!", array('key' => 'error'));
} else {
$this->Flash->set("Your Group has been deleted!", array('key' => 'success'));
}

$this->set('grouperstems', $this->GrouperGroup->getOwnedStems($this->userId));
return $this->redirect(array('action' => 'groupOwner'));
}


/**
* Process to join a group displayed on the "Optin" page
Expand Down Expand Up @@ -789,18 +715,18 @@ function isAuthorized()

//TODO - This is needed for my dev enviro since I do not log in via I2 IdP
// BEGIN ===============================================
/*

if ($this->Session->check('Auth.User.username')) {
$this->userId = $this->Session->read('Auth.User.username');
}
*/

// END ===============================================

//TODO - Need to make the following code configurable in getting the user ID. In this case the code is
// specific to the needs of I2.
// BEGIN ===============================================


/*
$uid=$this->Session->read('Auth.User.co_person_id');
$username=$this->Session->read('Auth.User.username');
error_log("HUBING ================ " . $username);
Expand Down Expand Up @@ -839,7 +765,7 @@ function isAuthorized()
} else {
$this->userId = $this->getUserId($uid);
$this->Session->write('Plugin.Grouper.UserId', $this->userId);
}
} */
// END ===============================================


Expand All @@ -858,9 +784,6 @@ function isAuthorized()
$p['findSubscriber'] = true;
$p['removeSubscriber'] = true;
$p['groupoptin'] = true;
$p['emaillistsoptin'] = true;
$p['emaillistsmember'] = true;
$p['emaillistsmanage'] = true;
$p['groupcreate'] = true;
$p['groupdelete'] = true;
$p['joingroup'] = true;
Expand All @@ -872,137 +795,6 @@ function isAuthorized()
return ($p[$this->action]);
}

public function emaillistsOptin()
{
$this->set('title', _txt('pl.grouperlite.title.emaillists-join'));

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

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

try {
//Add setting for Group Membership
$scope['method'] = 'getSearchedGroups';
$scope['searchcriteria'] = $searchCriteria;
$scope['searchpage'] = 'optinEmailGroups';
$scope['emailonly'] = true;

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

$this->set('emailgroups', $data);

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

$this->Flash->set("Your Email Optin List cannot be found, please try again later.", array('key' => 'error'));
$this->set('emailgroups', array());
return;
}
} else {
try {
//Add setting for Group Membership
$scope['method'] = 'optinEmailGroups';
$scope['emailonly'] = true;

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

$this->set('emailgroups', $data);

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

$this->Flash->set("An error occurred with the Optin Email Lists, please try again later.", array('key' => 'error'));
$this->set('emailgroups', array());
return;
}
}

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
$this->set('isGrouperVisible', $this->GrouperGroup->isGrouperVisible($this->userId));
}

public function emaillistsMember()
{
$this->set('title', _txt('pl.grouperlite.title.emaillists-member'));

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

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

try {
//Add setting for Group Membership
$scope['method'] = 'getSearchedGroups';
$scope['searchcriteria'] = $searchCriteria;
$scope['searchpage'] = 'filteredMemberOfEmails';
$scope['emailonly'] = true;

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

$this->set('emailgroups', $data);

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

$this->Flash->set("Your Email Group cannot be found, please try again later.", array('key' => 'error'));
$this->set('emailgroups', array());
return;
}
} else {
try {
//Add setting for Group Membership
$scope['method'] = 'filteredMemberOfEmails';
$scope['emailonly'] = true;

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

$this->set('emailgroups', $data);

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

$this->Flash->set("Your Email Group cannot be found, please try again later.", array('key' => 'error'));
$this->set('emailgroups', array());
return;
}
}

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
$this->set('isGrouperVisible', $this->GrouperGroup->isGrouperVisible($this->userId));
}

public function emaillistsManage()
{
$this->set('title', _txt('pl.grouperlite.title.emaillists-manage'));
// mock data
$this->set('group', array(
'member' => true,
'name' => 'Email List 1',
'domain' => 'internet2',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'enabled' => 'T'
));

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
$this->set('isGrouperVisible', $this->GrouperGroup->isGrouperVisible($this->userId));
}


private function getUserId($id)
{
Expand Down
Loading

0 comments on commit 579c98d

Please sign in to comment.