Blame | 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->response->type('json');$this->layout = 'ajax';$this->Auth->allow();}/*** index method** @return void*/public function index() {$this->Userurl->recursive = 0;$this->set('userurls', $this->Paginator->paginate());}/*** view method** @throws NotFoundException* @param string $id* @return void*/public function view($id = null) {if (!$this->Userurl->exists($id)) {throw new NotFoundException(__('Invalid userurl'));}$options = array('conditions' => array('Userurl.' . $this->Userurl->primaryKey => $id));$this->set('userurl', $this->Userurl->find('first', $options));}/*** add method** @return void*/public function add() {$data = array('url'=>$this->request->query('url'),'user_id'=>$this->request->query('user_id'));$this->Userurl->create();if ($this->Userurl->save($data)) {$message = 'The url has been saved.';} else {$message = 'The url could not be saved. Please, try again.';}$result = array('success'=>true,'message'=>$message);$this->set(array('result' => $result,'callback' => $callback,'_serialize' => array('result')));$this->render('/Elements/jsonp');}/*** edit method** @throws NotFoundException* @param string $id* @return void*/public function edit($id = null) {if (!$this->Userurl->exists($id)) {throw new NotFoundException(__('Invalid userurl'));}if ($this->request->is(array('post', 'put'))) {if ($this->Userurl->save($this->request->data)) {$this->Session->setFlash(__('The userurl has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The userurl 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);}}/*** delete method** @throws NotFoundException* @param string $id* @return void*/public function delete($id = null) {$this->Userurl->id = $id;if (!$this->Userurl->exists()) {throw new NotFoundException(__('Invalid userurl'));}$this->request->onlyAllow('post', 'delete');if ($this->Userurl->delete()) {$this->Session->setFlash(__('The userurl has been deleted.'));} else {$this->Session->setFlash(__('The userurl 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 userurl'));}$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 userurl has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The userurl could not be saved. Please, try again.'));}}}/*** 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 userurl'));}if ($this->request->is(array('post', 'put'))) {if ($this->Userurl->save($this->request->data)) {$this->Session->setFlash(__('The userurl has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The userurl 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);}}/*** 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 userurl'));}$this->request->onlyAllow('post', 'delete');if ($this->Userurl->delete()) {$this->Session->setFlash(__('The userurl has been deleted.'));} else {$this->Session->setFlash(__('The userurl could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}}