MISP/app/Controller/RolesController.php

112 lines
2.4 KiB
PHP
Raw Normal View History

<?php
App::uses('AppController', 'Controller');
/**
* Roles Controller
*
* @property Role $Role
*/
class RolesController extends AppController {
2013-01-22 15:46:39 +01:00
public $options = array('0' => 'Read Only', '1' => 'Manage My Own Events', '2' => 'Manage Organization Events', '3' => 'Manage &amp; Publish Organization Events');
public $components = array(
2012-12-19 02:48:53 +01:00
'Acl',
'Auth' => array(
'authorize' => array(
'Actions' => array('actionPath' => 'controllers/Roles')
)
),
'Security',
2013-01-22 15:46:39 +01:00
'Session', 'AdminCrud' // => array('fields' => array('name'))
2012-12-19 02:48:53 +01:00
);
public $helpers = array('Js' => array('Jquery'));
2012-12-19 02:48:53 +01:00
public $paginate = array(
'limit' => 60,
'order' => array(
'Role.name' => 'ASC'
)
);
2012-12-19 02:48:53 +01:00
public function beforeFilter() {
parent::beforeFilter();
}
2013-01-22 16:12:36 +01:00
/**
* view method
*
* @param string $id
* @return void
*/
public function view($id = null) {
$this->Role->id = $id;
if (!$this->Role->exists()) {
throw new NotFoundException(__('Invalid role'));
}
$this->set('role', $this->Role->read(null, $id));
}
/**
* admin_add method
2012-12-19 02:48:53 +01:00
*
* @return void
*/
public function admin_add() {
if($this->Auth->User['User']['org'] != 'ADMIN') $this->redirect(array('controller' => 'roles', 'action' => 'index', 'admin' => false));
$this->AdminCrud->adminAdd();
$this->set('options', $this->options);
}
/**
* admin_index method
*
* @return void
*/
public function admin_index() {
if($this->Auth->User['User']['org'] != 'ADMIN') $this->redirect(array('controller' => 'roles', 'action' => 'index', 'admin' => false));
$this->AdminCrud->adminIndex();
$this->set('options', $this->options);
}
/**
* admin_edit method
*
* @param string $id
* @return void
* @throws NotFoundException
*/
public function admin_edit($id = null) {
if($this->Auth->User['User']['org'] != 'ADMIN') $this->redirect(array('controller' => 'roles', 'action' => 'index', 'admin' => false));
$this->AdminCrud->adminEdit($id);
$this->set('options', $this->options);
}
/**
* admin_delete method
*
* @param string $id
2012-12-19 02:48:53 +01:00
*
* @throws MethodNotAllowedException
2012-12-19 02:48:53 +01:00
* @throws NotFoundException
*
* @return void
*/
public function admin_delete($id = null) {
$this->AdminCrud->adminDelete($id);
}
/**
* index method
*
* @return void
*/
public function index() {
$this->recursive = 0;
$this->set('list', Sanitize::clean($this->paginate()));
$this->set('options', $this->options);
}
}