Subversion Repositories SmartDukaan

Rev

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

Rev 13682 Rev 13688
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('mine');
-
 
21
		$callback = $this->request->query('callback');
-
 
22
	}
-
 
23
 
18
	public function brand($action='hide') {
24
	public function brand($action='hide') {
19
		$this->response->type('json');
25
		$this->response->type('json');
20
		$this->layout = 'ajax';
26
		$this->layout = 'ajax';
21
		$userId = $this->request->query('user_id');
27
		$userId = $this->request->query('user_id');
22
		$productId = $this->request->query('product_id');
28
		$productId = $this->request->query('product_id');
23
		$hide = $this->request->query('hide');
29
		$hide = $this->request->query('hide');
24
		if(isset($hide) && !empty($hide) && $hide == 1){
30
		if(isset($hide) && !empty($hide) && $hide == 1){
25
			$this->loadModel('StoreProduct');
31
			$this->loadModel('StoreProduct');
26
			$options = array('conditions'=>array('id'=>$productId),'fields'=>array('category_id','brand'),'recursive'=>-1);
32
			$options = array('conditions'=>array('id'=>$productId),'fields'=>array('category_id','brand'),'recursive'=>-1);
27
			$product = $this->StoreProduct->find('first',$options);
33
			$product = $this->StoreProduct->find('first',$options);
28
			$this->loadModel('UserCategoryHiddenBrand');
34
			$this->loadModel('HiddenBrand');
29
			$data = array('user_id' => $userId, 'category_id' => $product['StoreProduct']['category_id'],'brand'=>$product['StoreProduct']['brand']);
35
			$data = array('user_id' => $userId, 'category_id' => $product['StoreProduct']['category_id'],'brand'=>$product['StoreProduct']['brand']);
30
			$this->UserCategoryHiddenBrand->create();
36
			$this->HiddenBrand->create();
31
			if($this->UserCategoryHiddenBrand->save($data)){
37
			if($this->HiddenBrand->save($data)){
32
				$result = array('success'=>true,'message'=>'brand hidden');
38
				$result = array('success'=>true,'message'=>'brand hidden');
33
			}else{
39
			}else{
34
				$result = array('success'=>false,'message'=>'database issue');
40
				$result = array('success'=>false,'message'=>'database issue');
35
			}
41
			}
36
		}else{
42
		}else{
Line 43... Line 49...
43
		    '_serialize' => array('result')
49
		    '_serialize' => array('result')
44
		));
50
		));
45
		$this->render('/Elements/json');
51
		$this->render('/Elements/json');
46
	}
52
	}
47
 
53
 
-
 
54
	public function mine(){
-
 
55
		$userId = $this->request->query('user_id');
-
 
56
		if(isset($userId) && !empty($userId)){
-
 
57
			$this->loadModel('User');
-
 
58
			$dbuser = $this->User->findById($userId);
-
 
59
			$this->Auth->login($dbuser['User']);
-
 
60
		}
-
 
61
	}
-
 
62
 
48
/**
63
/**
49
 * index method
64
 * index method
50
 *
65
 *
51
 * @return void
66
 * @return void
52
 */
67
 */