Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15580 manas 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Useractives Controller
5
 *
6
 * @property Useractive $Useractive
7
 * @property PaginatorComponent $Paginator
8
 */
9
class UseractivesController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
/**
19
 * admin_index method
20
 *
21
 * @return void
22
 */
23
	public function admin_index() {
24
		$this->Paginator->settings = array('order' => array('user_id'=>'desc'));
25
		$this->Useractive->recursive = 0;
26
		$this->set('useractives', $this->Paginator->paginate());
27
	}
28
 
29
/**
30
 * admin_view method
31
 *
32
 * @throws NotFoundException
33
 * @param string $id
34
 * @return void
35
 */
36
	public function admin_view($id = null) {
37
		if (!$this->Useractive->exists($id)) {
38
			throw new NotFoundException(__('Invalid useractive'));
39
		}
40
		$options = array('conditions' => array('Useractive.' . $this->Useractive->primaryKey => $id));
41
		$this->set('useractive', $this->Useractive->find('first', $options));
42
	}
43
 
44
/**
45
 * admin_add method
46
 *
47
 * @return void
48
 */
49
	public function admin_add() {
50
		if ($this->request->is('post')) {
51
			$this->Useractive->create();
52
			if ($this->Useractive->save($this->request->data)) {
53
				$this->Session->setFlash(__('The useractive has been saved.'));
54
				return $this->redirect(array('action' => 'index'));
55
			} else {
56
				$this->Session->setFlash(__('The useractive could not be saved. Please, try again.'));
57
			}
58
		}
59
	}
60
 
61
/**
62
 * admin_edit method
63
 *
64
 * @throws NotFoundException
65
 * @param string $id
66
 * @return void
67
 */
68
	public function admin_edit($id = null) {
69
		if (!$this->Useractive->exists($id)) {
70
			throw new NotFoundException(__('Invalid useractive'));
71
		}
72
		if ($this->request->is(array('post', 'put'))) {
73
			if ($this->Useractive->save($this->request->data)) {
74
				$this->Session->setFlash(__('The useractive has been saved.'));
75
				return $this->redirect(array('action' => 'index'));
76
			} else {
77
				$this->Session->setFlash(__('The useractive could not be saved. Please, try again.'));
78
			}
79
		} else {
80
			$options = array('conditions' => array('Useractive.' . $this->Useractive->primaryKey => $id));
81
			$this->request->data = $this->Useractive->find('first', $options);
82
		}
83
	}
84
 
85
/**
86
 * admin_delete method
87
 *
88
 * @throws NotFoundException
89
 * @param string $id
90
 * @return void
91
 */
92
	public function admin_delete($id = null) {
93
		$this->Useractive->id = $id;
94
		if (!$this->Useractive->exists()) {
95
			throw new NotFoundException(__('Invalid useractive'));
96
		}
97
		$this->request->onlyAllow('post', 'delete');
98
		if ($this->Useractive->delete()) {
99
			$this->Session->setFlash(__('The useractive has been deleted.'));
100
		} else {
101
			$this->Session->setFlash(__('The useractive could not be deleted. Please, try again.'));
102
		}
103
		return $this->redirect(array('action' => 'index'));
104
	}
105
 
106
	public function admin_show($id = null) {
107
 
108
		$options = array('conditions' => array('Useractive.user_id'  => $id));
109
		$this->set('useractive', $this->Useractive->find('first', $options));
110
 
111
	}
112
 
113
}