Subversion Repositories SmartDukaan

Rev

Rev 14776 | Rev 14781 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
App::uses('AppController', 'Controller');
/**
 * Pushnotifications Controller
 *
 * @property Pushnotification $Pushnotification
 * @property PaginatorComponent $Paginator
 */
class PushnotificationsController extends AppController {

/**
 * Components
 *
 * @var array
 */
        public $components = array('Paginator');

        public function beforeFilter() {
                parent::beforeFilter();
                $this->Auth->allow('add');
        }
/**
 * index method
 *
 * @return void
 */
        public function index() {
                $this->Pushnotification->recursive = 0;
                $this->set('pushnotifications', $this->Paginator->paginate());
        }

/**
 * view method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function view($id = null) {
                if (!$this->Pushnotification->exists($id)) {
                        throw new NotFoundException(__('Invalid pushnotification'));
                }
                $options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
                $this->set('pushnotification', $this->Pushnotification->find('first', $options));
        }

/**
 * add method
 *
 * @return void
 */
        public function add() {
                if ($this->request->is('post')) {
                        $this->log(print_r($this->request->data,1),'pushnotifications');
                        $this->Pushnotification->create();
                        if ($this->Pushnotification->save($this->request->data)) {
                                $this->Session->setFlash(__('The pushnotification has been saved.'));
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
                        }
                }
                $users = $this->Pushnotification->User->find('list');
                $this->set(compact('users'));
        }

/**
 * edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function edit($id = null) {
                if (!$this->Pushnotification->exists($id)) {
                        throw new NotFoundException(__('Invalid pushnotification'));
                }
                if ($this->request->is(array('post', 'put'))) {
                        if ($this->Pushnotification->save($this->request->data)) {
                                $this->Session->setFlash(__('The pushnotification has been saved.'));
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
                        }
                } else {
                        $options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
                        $this->request->data = $this->Pushnotification->find('first', $options);
                }
                $users = $this->Pushnotification->User->find('list');
                $this->set(compact('users'));
        }

/**
 * delete method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function delete($id = null) {
                $this->Pushnotification->id = $id;
                if (!$this->Pushnotification->exists()) {
                        throw new NotFoundException(__('Invalid pushnotification'));
                }
                $this->request->onlyAllow('post', 'delete');
                if ($this->Pushnotification->delete()) {
                        $this->Session->setFlash(__('The pushnotification has been deleted.'));
                } else {
                        $this->Session->setFlash(__('The pushnotification could not be deleted. Please, try again.'));
                }
                return $this->redirect(array('action' => 'index'));
        }

/**
 * admin_index method
 *
 * @return void
 */
        public function admin_index() {
                $this->Pushnotification->recursive = 0;
                $this->set('pushnotifications', $this->Paginator->paginate());
        }

/**
 * admin_view method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function admin_view($id = null) {
                if (!$this->Pushnotification->exists($id)) {
                        throw new NotFoundException(__('Invalid pushnotification'));
                }
                $options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
                $this->set('pushnotification', $this->Pushnotification->find('first', $options));
        }

/**
 * admin_add method
 *
 * @return void
 */
        public function admin_add() {
                if ($this->request->is('post')) {
                        $this->Pushnotification->create();
                        if ($this->Pushnotification->save($this->request->data)) {
                                $this->Session->setFlash(__('The pushnotification has been saved.'));
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
                        }
                }
                $users = $this->Pushnotification->User->find('list');
                $this->set(compact('users'));
        }

/**
 * admin_edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function admin_edit($id = null) {
                if (!$this->Pushnotification->exists($id)) {
                        throw new NotFoundException(__('Invalid pushnotification'));
                }
                if ($this->request->is(array('post', 'put'))) {
                        if ($this->Pushnotification->save($this->request->data)) {
                                $this->Session->setFlash(__('The pushnotification has been saved.'));
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
                        }
                } else {
                        $options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
                        $this->request->data = $this->Pushnotification->find('first', $options);
                }
                $users = $this->Pushnotification->User->find('list');
                $this->set(compact('users'));
        }

/**
 * admin_delete method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function admin_delete($id = null) {
                $this->Pushnotification->id = $id;
                if (!$this->Pushnotification->exists()) {
                        throw new NotFoundException(__('Invalid pushnotification'));
                }
                $this->request->onlyAllow('post', 'delete');
                if ($this->Pushnotification->delete()) {
                        $this->Session->setFlash(__('The pushnotification has been deleted.'));
                } else {
                        $this->Session->setFlash(__('The pushnotification could not be deleted. Please, try again.'));
                }
                return $this->redirect(array('action' => 'index'));
        }}