Skip to content

Commit

Permalink
fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Apr 1, 2021
2 parents af0d470 + 9e33c04 commit 28815b5
Show file tree
Hide file tree
Showing 25 changed files with 401 additions and 208 deletions.
2 changes: 1 addition & 1 deletion Controller/CoGrouperLitesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function display($id) {

$this->set('pl_grouperlite_index_url', Router::url([
'plugin' => "grouper_lite",
'controller' => 'GrouperGroups',
'controller' => 'grouper_groups',
'action' => 'index',
'co' => $this->cur_co['Co']['id'],
'glid' => $id
Expand Down
144 changes: 108 additions & 36 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function setConnection() {
*/
public function index() {
return $this->redirect(
array('controller' => 'GrouperGroups', 'action' => 'groupoptin')
array('controller' => 'grouper_groups', 'action' => 'groupoptin')
);
}

Expand Down Expand Up @@ -137,6 +137,8 @@ public function groupInfo() {
$this->set('groupergroupssubscribers', array());
$this->Flash->set(_txt('pl.grouperlite.message.flash.group-detail-members-failed'), array('key' => 'error'));
}

$this->set('grouperbaseurl', $this->Session->read('Plugin.Grouper.Api.url'));
}

/**
Expand Down Expand Up @@ -178,8 +180,8 @@ public function 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']),
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand Down Expand Up @@ -233,8 +235,8 @@ public function 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']),
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand Down Expand Up @@ -286,8 +288,8 @@ public function 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']),
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand Down Expand Up @@ -337,31 +339,62 @@ public function groupOptin() {
* Editing via a template will not be supported in this version of the plugin - Bill Kaufman
*
*/
public function groupCreateTemplateForm() {
public function groupCreateTemplate() {
if ($this->request->is('post')){
if(!$this->GrouperGroup->createGroupFromTemplate($this->userId, $this->request->data)){
if(!$this->GrouperGroup->createGroupWithTemplate($this->userId, $this->request->data)){
$this->Flash->set("Error in creating group!", array('key' => 'error'));
return $this->redirect(array('action' => 'groupoptin'));
} else {
$this->Flash->set("Success in creating group!", array('key' => 'success'));
return $this->redirect(array('action' => 'groupoptin'));
}
}
$this->set('title', _txt('pl.grouperlite.title.templatecreate'));
}

/**
* 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'));
}


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'));
return $this->redirect(array('action' => 'groupOwner'));
} else {
$this->Flash->set("Your Group has been created!", array('key' => 'success'));
return $this->redirect(array('action' => 'groupOwner'));
}
}

//TODO - Need to combine this form with code below for groupCreate
public function groupCreateForm() {
$this->set('title', _txt('pl.grouperlite.title.groupcreate'));
$this->set('grouperstems', $this->GrouperGroup->getOwnedStems($this->userId));
}

public function groupCreate() {
$name = urldecode($this->request->data['name']);
$set = urldecode($this->request->data['set']);
$descr = urldecode($this->request->data['description']);
// Debugger::dump($this->request->data);
$this->set('groupergroupadded', $this->GrouperGroup->createGroup($this->userId, $name, $set, $descr));
//TODO - Finish this call
public function groupDelete() {
if(!$this->GrouperGroup->deleteGroup($this->userId, $this->request->data)){
$this->Flash->set("Error in deleting group!", array('key' => 'error'));
return $this->redirect(array('action' => 'groupOwner'));
} else {
$this->Flash->set("Your Group has been deleted!", array('key' => 'success'));
return $this->redirect(array('action' => 'groupOwner'));
}

$this->set('grouperstems', $this->GrouperGroup->getOwnedStems($this->userId));
}


/**
* Process to join a group displayed on the "Optin" page
*
Expand Down Expand Up @@ -430,11 +463,19 @@ public function leaveGroup() {
function isAuthorized() {
$roles = $this->Role->calculateCMRoles();

//Need to pull in UserID for access to Grouper
//This call just pulls in user ID from comanage but not Grouper, need the Grouper Id for API calls.

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

/*
if ($this->Session->check('Plugin.Grouper.UserId')) {
$this->userId = $this->Session->read('Plugin.Grouper.UserId');
} else {
$this->userId = $this->GrouperGroup->getGrouperUserId();
$this->Session->write('Plugin.Grouper.UserId', $this->userId);
}
*/
// Determine what operations this user can perform

// Construct the permission set for this user, which will also be passed to the view.
Expand All @@ -451,11 +492,11 @@ function isAuthorized() {
$p['emaillistsmember'] = true;
$p['emaillistsmanage'] = true;
$p['emaillistsinfo'] = true;
$p['groupcreateform'] = true;
$p['groupcreate'] = true;
$p['groupdelete'] = true;
$p['joingroup'] = true;
$p['leavegroup'] = true;
$p['groupcreatetemplateform'] = true;
$p['groupcreatetemplate'] = true;

$this->set('permissions', $p);

Expand All @@ -464,13 +505,27 @@ function isAuthorized() {

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

//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']),
];

try {
//Add settings for optinEmailLists
$scope['method'] = 'optinEmailGroups';

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

} 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('emailgroups', array());
return;
}

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
Expand All @@ -479,19 +534,34 @@ public function emaillistsOptin() {
public function emaillistsMember()
{
$this->set('title', _txt('pl.grouperlite.title.emaillists-member'));
// 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'
));

//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']),
];

try {
//Add setting for Group Membership
$scope['method'] = 'filteredMemberOfEmails';

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

} 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('emailgroups', array());
return;
}

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


public function emaillistsManage() {
$this->set('title', _txt('pl.grouperlite.title.emaillists-manage'));
// mock data
Expand Down Expand Up @@ -523,5 +593,7 @@ public function emaillistInfo() {
'enabled' => 'T',
'attributes' => array()
));
$this->set('grouperbaseurl', $this->Session->read('Plugin.Grouper.Api.url'));

}
}
Loading

0 comments on commit 28815b5

Please sign in to comment.