Subversion Repositories SmartDukaan

Rev

Rev 13532 | Rev 13583 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13532 Rev 13562
Line 13... Line 13...
13
 *
13
 *
14
 * @var array
14
 * @var array
15
 */
15
 */
16
	public $components = array('Paginator');
16
	public $components = array('Paginator');
17
 
17
 
-
 
18
	public function beforeFilter() {
-
 
19
		parent::beforeFilter();
-
 
20
		$this->Auth->allow('update','by','rem');
-
 
21
	}
-
 
22
 
-
 
23
	public function update($user_id,$store_product_id,$action) {
-
 
24
		if(!empty($user_id) && !empty($store_product_id) && !empty($action)) {
-
 
25
			$data = array('user_id'=>$user_id,'store_product_id'=>$store_product_id);
-
 
26
			$this->UserAction->deleteAll(array($data),false);
-
 
27
			$this->response->type('json');
-
 
28
			$this->layout = 'ajax';
-
 
29
			$callback = $this->request->query('callback');
-
 
30
			$data['action'] = $action;
-
 
31
			$this->UserAction->create();
-
 
32
			if ($this->UserAction->save($data)) {
-
 
33
				$result = array('success'=>true,'message'=>(__('The user action has been saved.')));
-
 
34
			} else {
-
 
35
				$result = array('success'=>false,(__('The user action could not be saved. Please, try again.')));
-
 
36
			}
-
 
37
			$this->set(array(
-
 
38
			    'result' => $result,
-
 
39
			    'callback' => $callback,
-
 
40
			    '_serialize' => array('result')
-
 
41
			));
-
 
42
			$this->render('/Elements/jsonp');
-
 
43
		}		
-
 
44
	}
-
 
45
 
-
 
46
	public function rem($user_id,$store_product_id,$action) {
-
 
47
		if(!empty($user_id) && !empty($store_product_id) && !empty($action)) {
-
 
48
			$data = array('user_id'=>$user_id,'store_product_id'=>$store_product_id);
-
 
49
			$this->UserAction->deleteAll(array($data),false);
-
 
50
			$this->response->type('json');
-
 
51
			$this->layout = 'ajax';
-
 
52
			$callback = $this->request->query('callback');			
-
 
53
			$result = array('success'=>true,'message'=>(__('The user action has been deleted.')));
-
 
54
			$this->set(array(
-
 
55
			    'result' => $result,
-
 
56
			    'callback' => $callback,
-
 
57
			    '_serialize' => array('result')
-
 
58
			));
-
 
59
			$this->render('/Elements/jsonp');
-
 
60
		}		
-
 
61
	}
-
 
62
 
-
 
63
	public function by($user_id=null){
-
 
64
		if(!empty($user_id)){
-
 
65
			$this->response->type('json');
-
 
66
			$this->layout = 'ajax';
-
 
67
			$callback = $this->request->query('callback');
-
 
68
			$this->UserAction->recursive = -1;
-
 
69
			$conditions = array('user_id' => $user_id);
-
 
70
			$result['actions'] = $this->UserAction->find('all',$conditions);
-
 
71
			$this->set(array(
-
 
72
			    'result' => $result,
-
 
73
			    'callback' => $callback,
-
 
74
			    '_serialize' => array('result')
-
 
75
			));
-
 
76
			$this->render('/Elements/jsonp');
-
 
77
		}
-
 
78
	}
18
/**
79
/**
19
 * index method
80
 * index method
20
 *
81
 *
21
 * @return void
82
 * @return void
22
 */
83
 */
Line 53... Line 114...
53
				return $this->redirect(array('action' => 'index'));
114
				return $this->redirect(array('action' => 'index'));
54
			} else {
115
			} else {
55
				$this->Session->setFlash(__('The user action could not be saved. Please, try again.'));
116
				$this->Session->setFlash(__('The user action could not be saved. Please, try again.'));
56
			}
117
			}
57
		}
118
		}
58
		$users = $this->UserAction->User->find('list');
119
		// $users = $this->UserAction->User->find('list');
59
		$storeProducts = $this->UserAction->StoreProduct->find('list');
120
		// $storeProducts = $this->UserAction->StoreProduct->find('list');
60
		$this->set(compact('users', 'storeProducts'));
121
		// $this->set(compact('users', 'storeProducts'));
61
	}
122
	}
62
 
123
 
63
/**
124
/**
64
 * edit method
125
 * edit method
65
 *
126
 *