Rev 15503 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** SearchTerms Controller** @property SearchTerm $SearchTerm* @property PaginatorComponent $Paginator*/class SearchTermsController extends AppController {/*** Components** @var array*/public $components = array('Paginator');/*** index method** @return void*/public function index() {$this->SearchTerm->recursive = 0;$this->set('searchTerms', $this->Paginator->paginate());}/*** view method** @throws NotFoundException* @param string $id* @return void*/public function view($id = null) {if (!$this->SearchTerm->exists($id)) {throw new NotFoundException(__('Invalid search term'));}$options = array('conditions' => array('SearchTerm.' . $this->SearchTerm->primaryKey => $id));$this->set('searchTerm', $this->SearchTerm->find('first', $options));}/*** add method** @return void*/public function add() {if ($this->request->is('post')) {$this->SearchTerm->create();if ($this->SearchTerm->save($this->request->data)) {$this->Session->setFlash(__('The search term has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The search term could not be saved. Please, try again.'));}}$users = $this->SearchTerm->User->find('list');$this->set(compact('users'));}/*** edit method** @throws NotFoundException* @param string $id* @return void*/public function edit($id = null) {if (!$this->SearchTerm->exists($id)) {throw new NotFoundException(__('Invalid search term'));}if ($this->request->is(array('post', 'put'))) {if ($this->SearchTerm->save($this->request->data)) {$this->Session->setFlash(__('The search term has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The search term could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('SearchTerm.' . $this->SearchTerm->primaryKey => $id));$this->request->data = $this->SearchTerm->find('first', $options);}$users = $this->SearchTerm->User->find('list');$this->set(compact('users'));}/*** delete method** @throws NotFoundException* @param string $id* @return void*/public function delete($id = null) {$this->SearchTerm->id = $id;if (!$this->SearchTerm->exists()) {throw new NotFoundException(__('Invalid search term'));}$this->request->onlyAllow('post', 'delete');if ($this->SearchTerm->delete()) {$this->Session->setFlash(__('The search term has been deleted.'));} else {$this->Session->setFlash(__('The search term could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}/*** admin_index method** @return void*/public function admin_index() {$this->SearchTerm->recursive = 0;$this->Paginator->settings = array('order' => array('id'=>'desc'));$this->set('searchTerms', $this->Paginator->paginate());}/*** admin_view method** @throws NotFoundException* @param string $id* @return void*/public function admin_view($id = null) {if (!$this->SearchTerm->exists($id)) {throw new NotFoundException(__('Invalid search term'));}$options = array('conditions' => array('SearchTerm.' . $this->SearchTerm->primaryKey => $id));$this->set('searchTerm', $this->SearchTerm->find('first', $options));}/*** admin_add method** @return void*/public function admin_add() {if ($this->request->is('post')) {$this->SearchTerm->create();if ($this->SearchTerm->save($this->request->data)) {$this->Session->setFlash(__('The search term has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The search term could not be saved. Please, try again.'));}}$users = $this->SearchTerm->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->SearchTerm->exists($id)) {throw new NotFoundException(__('Invalid search term'));}if ($this->request->is(array('post', 'put'))) {if ($this->SearchTerm->save($this->request->data)) {$this->Session->setFlash(__('The search term has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The search term could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('SearchTerm.' . $this->SearchTerm->primaryKey => $id));$this->request->data = $this->SearchTerm->find('first', $options);}$users = $this->SearchTerm->User->find('list');$this->set(compact('users'));}/*** admin_delete method** @throws NotFoundException* @param string $id* @return void*/public function admin_delete($id = null) {$this->SearchTerm->id = $id;if (!$this->SearchTerm->exists()) {throw new NotFoundException(__('Invalid search term'));}$this->request->onlyAllow('post', 'delete');if ($this->SearchTerm->delete()) {$this->Session->setFlash(__('The search term has been deleted.'));} else {$this->Session->setFlash(__('The search term could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}public function admin_user($id=null){$options = array('conditions' => array('User.id'=> $id));$list = $this->SearchTerm->find('all',$options);$this->set('searchTerms', $list);$this->set('userId', $id);}}