Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WIP needed to become a plugin for COmanage
axel committed Dec 11, 2020
0 parents commit 10d1487
Showing 109 changed files with 105,459 additions and 0 deletions.
Empty file added Config/Schema/empty
Empty file.
19 changes: 19 additions & 0 deletions Config/bootstrap.php
@@ -0,0 +1,19 @@
<?php
/**
* Application settings to access Grouper instance.
\ */
Configure::write('GrouperLite.connUrl', 'https://grouper.staging.at.internet2.edu');
/**
* Grouper version used in url schema
*/
Configure::write('GrouperLite.connVer', 'v2_4_000');

/**
* Grouper API user
*/
Configure::write('GrouperLite.connUser', 'comanage_provision');

/**
* Grouper API password
*/
Configure::write('GrouperLite.connPass', 'WHe6KVK9GeSjyiVUcPv92POIaIzWKsDCwQVgOpd8tMMCnihjciHiqdsNnIZryXf');
12 changes: 12 additions & 0 deletions Controller/CoGrouperLitesController.php
@@ -0,0 +1,12 @@
<?php

App::uses("SDWController", "Controller");

class CoGrouperLitesController extends SDWController {

// Class name, used by Cake
public $name = "CoGrouperLites";

//TODO - need to add the call $this->calculateParentPermissions($roles); for authorization

}
Empty file added Controller/Component/empty
Empty file.
143 changes: 143 additions & 0 deletions Controller/GrouperGroupsController.php
@@ -0,0 +1,143 @@
<?php

App::uses('Validator', 'Vendor/cakephp/Validation');


class GrouperGroupsController extends GrouperLiteAppController
{
public $helpers = array('Html', 'Form', 'Flash');
public $components = array('Flash');

public $name = 'GrouperGroups';
public $userId = '';

public function index() {
return $this->redirect(array('controller' => 'GrouperGroups', 'action' => 'groupoptin'));
}


public function groupUser()
{
$this->set('title', 'Grouper Groups:');
//TODO - Change to get userid somehow
$this->set('groupergroupsmember', $this->GrouperGroup->optinGroups($this->userId));
}

public function groupInfo()
{
$name = urldecode($this->request->query['groupname']);
$details = $this->GrouperGroup->groupDescriptions($name);

$this->set('groupname', $name);
$this->set('title', 'Grouper Groups Info and Attributes:');
$this->set('groupergroupsdetail', $details[0]);
}

public function groupOwner()
{
$this->set('title', 'Grouper Groups I Manage:');
if (isset($this->request->data['search'])){
$searchCriteria = urldecode($this->request->data['search']);
$this->set('groupergroupsowner', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOwner'));
} else {
$this->set('groupergroupsowner', $this->GrouperGroup->ownerGroups($this->userId));
}

}

public function groupOptin()
{
$this->set('title', 'Grouper Groups I Can Join:');

if (isset($this->request->data['search'])){
$searchCriteria = urldecode($this->request->data['search']);
$this->set('groupergroupoptin', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOptin'));
$this->set('searchcriteria', $searchCriteria);
} else {
$this->set('groupergroupoptin', $this->GrouperGroup->optinGroups($this->userId));
}
}

public function groupCreateForm() {
$this->set('title', 'Create Grouper Group');
}

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));
}

public function joinGroup()
{
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->joinGroup($this->userId, $name)) {
$this->Flash->success(__('You have been added to the group!'));
} else {
$this->Flash->error(__('You are unable to join the group!'));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(__('An error occurred in joining the group, please try again later.'));

}

public function leaveGroup()
{
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->leaveGroup($this->userId, $name)) {
$this->Flash->success(__('You have been deleted from the group!'));
} else {
$this->Flash->error(__('You are unable to delete the group!'));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(__('An error occurred in leaving the group, please try again later.'));
}

/**
* Authorization for this Controller, called by Auth component
* - precondition: Session.Auth holds data used for authz decisions
* - postcondition: $permissions set with calculated permissions
*
* @since COmanage Registry v3.2.0
* @return Array Permissions
*/
function isAuthorized() {
//TODO - I am not sure how much of COmanage roles will be needed, but will need to tweak this to meet our needs.
//TODO - Use Grouper user controller to pull in user information.
$roles = $this->Role->calculateCMRoles();

//TODO - this is about all we need right now.
if($this->Session->check('Auth.User.username')) {
$this->userId = $this->Session->read('Auth.User.username');
}

// Construct the permission set for this user, which will also be passed to the view.
$p = array();

// Determine what operations this user can perform

// Delete an existing CO Provisioning Target?
$p['delete'] = ($roles['cmadmin'] || $roles['coadmin']);

// Edit an existing CO Provisioning Target?
$p['edit'] = ($roles['cmadmin'] || $roles['coadmin']);

// View all existing CO Provisioning Targets?
$p['index'] = ($roles['cmadmin'] || $roles['coadmin']);

// View an existing CO Provisioning Target?
$p['view'] = ($roles['cmadmin'] || $roles['coadmin']);

$this->set('permissions', $p);
//return($p[$this->action]);
return true;
}

}
7 changes: 7 additions & 0 deletions Controller/GrouperLiteAppController.php
@@ -0,0 +1,7 @@
<?php

App::uses('AppController', 'Controller');

class GrouperLiteAppController extends AppController {

}
14 changes: 14 additions & 0 deletions Controller/GrouperUsersController.php
@@ -0,0 +1,14 @@
<?php


class GrouperUsersController extends GrouperLiteAppController
{
public $helpers = array('Html', 'Form');
public $name = 'GrouperUsers';

public function index()
{
//TODO - verify change this to correct source for user!! Right now returning same value.
$this->set('grouperuser', $this->GrouperUser->getUser('axel.stohn@at.internet2.edu'));
}
}

0 comments on commit 10d1487

Please sign in to comment.