Rev 13532 | Rev 13595 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** UserUrls Controller** @property UserUrl $UserUrl* @property PaginatorComponent $Paginator*/class UserUrlsController 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() {throw new NotFoundException(__('Access Denied'));$this->UserUrl->recursive = 0;$this->set('userUrls', $this->Paginator->paginate());}/*** view method** @throws NotFoundException* @param string $id* @return void*/public function view($id = null) {throw new NotFoundException(__('Access Denied'));if (!$this->UserUrl->exists($id)) {throw new NotFoundException(__('Invalid user url'));}$options = array('conditions' => array('UserUrl.' . $this->UserUrl->primaryKey => $id));$this->set('userUrl', $this->UserUrl->find('first', $options));}/*** add method** @return void*/public function add() {if ($this->request->is('post')) {$this->UserUrl->create();if ($this->UserUrl->saveAll($this->request->data)) {$result = array('success' => true,'message'=>__('The url has been saved.'));} else {$result = array('success' => false,'message'=>__('The url could not be saved. Please, try again.'));}$this->response->type('json');$this->layout = 'ajax';$this->set(array('result' => $result,// 'callback' => $callback,'_serialize' => array('result')));$this->render('/Elements/json');}}/*** edit method** @throws NotFoundException* @param string $id* @return void*/public function edit($id = null) {throw new NotFoundException(__('Access Denied'));if (!$this->UserUrl->exists($id)) {throw new NotFoundException(__('Invalid user url'));}if ($this->request->is(array('post', 'put'))) {if ($this->UserUrl->save($this->request->data)) {$this->Session->setFlash(__('The user url has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The user url could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('UserUrl.' . $this->UserUrl->primaryKey => $id));$this->request->data = $this->UserUrl->find('first', $options);}$users = $this->UserUrl->User->find('list');$this->set(compact('users'));}/*** delete method** @throws NotFoundException* @param string $id* @return void*/public function delete($id = null) {throw new NotFoundException(__('Access Denied'));$this->UserUrl->id = $id;if (!$this->UserUrl->exists()) {throw new NotFoundException(__('Invalid user url'));}$this->request->onlyAllow('post', 'delete');if ($this->UserUrl->delete()) {$this->Session->setFlash(__('The user url has been deleted.'));} else {$this->Session->setFlash(__('The user url could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}/*** admin_index method** @return void*/public function admin_index() {$this->UserUrl->recursive = 0;$this->set('userUrls', $this->Paginator->paginate());}/*** admin_view method** @throws NotFoundException* @param string $id* @return void*/public function admin_view($id = null) {if (!$this->UserUrl->exists($id)) {throw new NotFoundException(__('Invalid user url'));}$options = array('conditions' => array('UserUrl.' . $this->UserUrl->primaryKey => $id));$this->set('userUrl', $this->UserUrl->find('first', $options));}/*** admin_add method** @return void*/public function admin_add() {if ($this->request->is('post')) {$this->UserUrl->create();if ($this->UserUrl->save($this->request->data)) {$this->Session->setFlash(__('The user url has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The user url could not be saved. Please, try again.'));}}$users = $this->UserUrl->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->UserUrl->exists($id)) {throw new NotFoundException(__('Invalid user url'));}if ($this->request->is(array('post', 'put'))) {if ($this->UserUrl->save($this->request->data)) {$this->Session->setFlash(__('The user url has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The user url could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('UserUrl.' . $this->UserUrl->primaryKey => $id));$this->request->data = $this->UserUrl->find('first', $options);}$users = $this->UserUrl->User->find('list');$this->set(compact('users'));}/*** admin_delete method** @throws NotFoundException* @param string $id* @return void*/public function admin_delete($id = null) {$this->UserUrl->id = $id;if (!$this->UserUrl->exists()) {throw new NotFoundException(__('Invalid user url'));}$this->request->onlyAllow('post', 'delete');if ($this->UserUrl->delete()) {$this->Session->setFlash(__('The user url has been deleted.'));} else {$this->Session->setFlash(__('The user url could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}}