Subversion Repositories SmartDukaan

Rev

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

Rev 13532 Rev 13541
Line 21... Line 21...
21
 * @return void
21
 * @return void
22
 */
22
 */
23
	public function index() {
23
	public function index() {
24
		// $this->Category->recursive = 0;
24
		// $this->Category->recursive = 0;
25
		// $this->set('categories', $this->Paginator->paginate());
25
		// $this->set('categories', $this->Paginator->paginate());
-
 
26
		$userId = $this->request->query('user_id');
-
 
27
		$this->loadModel('UserCategory');
-
 
28
		$options = array('conditions' => array('user_id'=>$userId),'recursive'=>-1);
-
 
29
		$userCategories = $this->UserCategory->find('all',$options);		
26
		$this->response->type('json');
30
		$this->response->type('json');
27
		$this->layout = 'ajax';
31
		$this->layout = 'ajax';
-
 
32
		$conditions = array(array('Category.parent_id !='=>0));
-
 
33
		if(!empty($userCategories)){
28
		$this->Category->recursive = -1;
34
			foreach ($userCategories as $key => $value) {
-
 
35
				$categoryIds[] = $value['UserCategory']['category_id'];
-
 
36
			}
29
		$conditions = array('Category.parent_id !='=>0);
37
			array_push($conditions,array('Category.id'=>$categoryIds));
-
 
38
		}
-
 
39
		$this->Category->recursive = -1;		
30
		$categories = $this->Paginator->paginate(null,$conditions);
40
		$categories = $this->Paginator->paginate(null,$conditions);
31
		$callback = $this->request->query('callback');
41
		$callback = $this->request->query('callback');
32
		$result = array('categories' => $categories);
42
		$result = array('categories' => $categories);
33
		$this->set(array(
43
		$this->set(array(
34
		    'result' => $result,
44
		    'result' => $result,