<?php
class IssueActionsController extends AppController {

	var $name = 'IssueActions';
	var $helpers = array('Html', 'Form');

	function index() {
		$this->IssueAction->recursive = 0;
		$this->set('issueActions', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid IssueAction.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('issueAction', $this->IssueAction->read(null, $id));
	}


        /**
         * Add an IssueAction to an Issue.
         * @param int $id
         */
	function add($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Issue ID', true));
			$this->redirect(array('action'=>'index'));
		}

                if (!empty($this->data)) {
			$this->IssueAction->create();
			if ($this->IssueAction->save($this->data)) {
				$this->Session->setFlash(__('The IssueAction has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The IssueAction could not be saved. Please, try again.', true));
			}
		}
		$users = $this->IssueAction->User->find('list');
		$this->set(compact('users'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid IssueAction', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->IssueAction->save($this->data)) {
				$this->Session->setFlash(__('The IssueAction has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The IssueAction could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->IssueAction->read(null, $id);
		}
		$users = $this->IssueAction->User->find('list');
		$this->set(compact('users'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for IssueAction', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->IssueAction->del($id)) {
			$this->Session->setFlash(__('IssueAction deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>