Subversion Repositories SmartDukaan

Rev

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

Rev 13659 Rev 13673
Line 17... Line 17...
17
 
17
 
18
	public function beforeFilter() {
18
	public function beforeFilter() {
19
		parent::beforeFilter();
19
		parent::beforeFilter();
20
		$this->Auth->allow('add');
20
		$this->Auth->allow('add');
21
		$callback = $this->request->query('callback');
21
		$callback = $this->request->query('callback');
-
 
22
		Configure::load('dev');
-
 
23
		$this->apihost = Configure::read('saholicapihost');
22
	}
24
	}
23
/**
25
/**
24
 * index method
26
 * index method
25
 *
27
 *
26
 * @return void
28
 * @return void
Line 95... Line 97...
95
				}				
97
				}				
96
			} else {
98
			} else {
97
				$result = array('success' => true, 'message' => 'Existing Social Profile','id' => $socialProfile['SocialProfile']['user_id']);
99
				$result = array('success' => true, 'message' => 'Existing Social Profile','id' => $socialProfile['SocialProfile']['user_id']);
98
			}
100
			}
99
		}
101
		}
-
 
102
		$this->updateSaholicUser($data['user_id'],$this->request->data['email']);
100
		$this->set(array(
103
		$this->set(array(
101
		    'result' => $result,
104
		    'result' => $result,
102
		    'callback' => $callback,
105
		    'callback' => $callback,
103
		    '_serialize' => array('result')
106
		    '_serialize' => array('result')
104
		));
107
		));
105
		//$this->render('/Elements/jsonp');
108
		//$this->render('/Elements/jsonp');
106
		$this->render('/Elements/json');
109
		$this->render('/Elements/json');
107
	}
110
	}
108
 
111
 
-
 
112
	private function updateSaholicUser($userId,$email=null) {
-
 
113
		if(!$email){
-
 
114
			//Handle it properly
-
 
115
			return;
-
 
116
		}
-
 
117
		$this->loadModel('UserAccount');
-
 
118
		$options = array('conditions'=>array('user_id' => $userId,'account_type' => 'saholic'),'recursive'=>-1);
-
 
119
		$exists = $this->UserAccount->find('count',$options);
-
 
120
		if(!$exists){
-
 
121
			$url = $this->saholicapihost."/register/?email=$email";
-
 
122
			$response = $this->make_request($url,null);
-
 
123
			if(!empty($response)){
-
 
124
				$data = array('account_type'=>'saholic','user_id'=>$userId,'account_key'=>$response['userId']);
-
 
125
				$this->UserAccount->create();
-
 
126
				$this->UserAccount-save($data);
-
 
127
			}
-
 
128
		}
-
 
129
	}
109
/**
130
/**
110
 * edit method
131
 * edit method
111
 *
132
 *
112
 * @throws NotFoundException
133
 * @throws NotFoundException
113
 * @param string $id
134
 * @param string $id