68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
class IssuesController extends AppController {
|
|
|
|
var $name = 'Issues';
|
|
var $helpers = array('Html', 'Form');
|
|
|
|
function index() {
|
|
$this->Issue->recursive = 0;
|
|
$this->set('issues', $this->paginate());
|
|
|
|
|
|
}
|
|
|
|
function view($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid Issue.', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
$this->set('issue', $this->Issue->read(null, $id));
|
|
}
|
|
|
|
function add() {
|
|
if (!empty($this->data)) {
|
|
$this->Issue->create();
|
|
if ($this->Issue->save($this->data)) {
|
|
$this->Session->setFlash(__('The Issue has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The Issue could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
$users = $this->Issue->User->find('list');
|
|
$this->set(compact('users'));
|
|
}
|
|
|
|
function edit($id = null) {
|
|
if (!$id && empty($this->data)) {
|
|
$this->Session->setFlash(__('Invalid Issue', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if (!empty($this->data)) {
|
|
if ($this->Issue->save($this->data)) {
|
|
$this->Session->setFlash(__('The Issue has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The Issue could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
if (empty($this->data)) {
|
|
$this->data = $this->Issue->read(null, $id);
|
|
}
|
|
$users = $this->Issue->User->find('list');
|
|
$this->set(compact('users'));
|
|
}
|
|
|
|
function delete($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid id for Issue', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if ($this->Issue->del($id)) {
|
|
$this->Session->setFlash(__('Issue deleted', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|