Subversion Repositories SmartDukaan

Rev

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

Rev 13685 Rev 13731
Line 73... Line 73...
73
			));
73
			));
74
			$this->render('/Elements/jsonp');
74
			$this->render('/Elements/jsonp');
75
		}		
75
		}		
76
	}
76
	}
77
 
77
 
-
 
78
	public function deletefav($user_id,$id) {
-
 
79
		if(!empty($user_id) && !empty($id)) {
-
 
80
			$loggedInUserId = $this->Auth->User('id');
-
 
81
			if($user_id != $loggedInUserId){
-
 
82
				$result = array('success'=>false,'message'=>(__('Unauthorized access. Try again later')));
-
 
83
			} else {
-
 
84
				$sql = "DELETE FROM user_actions WHERE id = $id AND user_id = $user_id";
-
 
85
				$this->UserAction->query($sql);
-
 
86
				$result = array('success'=>true,'message'=>(__('The favourite product has been removed.')));				
-
 
87
			}
-
 
88
			$this->response->type('json');
-
 
89
			$this->layout = 'ajax';
-
 
90
			$callback = $this->request->query('callback');			
-
 
91
			$this->set(array(
-
 
92
			    'result' => $result,
-
 
93
			    'callback' => $callback,
-
 
94
			    '_serialize' => array('result')
-
 
95
			));
-
 
96
			$this->render('/Elements/jsonp');
-
 
97
		}		
-
 
98
	}
-
 
99
 
-
 
100
	public function deleteallfavs($user_id) {
-
 
101
		if(!empty($user_id)) {
-
 
102
			$loggedInUserId = $this->Auth->User('id');
-
 
103
			if($user_id != $loggedInUserId){
-
 
104
				$result = array('success'=>false,'message'=>(__('Unauthorized access. Try again later')));
-
 
105
			} else {
-
 
106
				$sql = "DELETE FROM user_actions WHERE user_id = $user_id";
-
 
107
				$this->UserAction->query($sql);
-
 
108
				$result = array('success'=>true,'message'=>(__('All favourite products have been removed.')));				
-
 
109
			}
-
 
110
			$this->response->type('json');
-
 
111
			$this->layout = 'ajax';
-
 
112
			$callback = $this->request->query('callback');			
-
 
113
			$this->set(array(
-
 
114
			    'result' => $result,
-
 
115
			    'callback' => $callback,
-
 
116
			    '_serialize' => array('result')
-
 
117
			));
-
 
118
			$this->render('/Elements/jsonp');
-
 
119
		}		
-
 
120
	}
-
 
121
 
78
	public function by($user_id=null){
122
	public function by($user_id=null){
79
		if(!empty($user_id)){
123
		if(!empty($user_id)){
80
			$this->response->type('json');
124
			$this->response->type('json');
81
			$this->layout = 'ajax';
125
			$this->layout = 'ajax';
82
			$callback = $this->request->query('callback');
126
			$callback = $this->request->query('callback');