| 14681 |
anikendra |
1 |
<?php
|
|
|
2 |
class SaholiccheckerShell extends AppShell {
|
|
|
3 |
public $uses = array('User','UserAccount');
|
|
|
4 |
|
|
|
5 |
public function main() {
|
|
|
6 |
$apihost = Configure::read('saholicapihost');
|
|
|
7 |
$users = $this->User->find('all',array('fields'=>array('id','email'),'recursive'=>-1));
|
|
|
8 |
foreach ($users as $key => $user) {
|
|
|
9 |
$userId = $user['User']['id'];
|
|
|
10 |
$email = $user['User']['email'];
|
|
|
11 |
$options = array('conditions'=>array('user_id' => $userId,'account_type' => 'saholic'),'recursive'=>-1);
|
|
|
12 |
$exists = $this->UserAccount->find('count',$options);
|
|
|
13 |
if(!$exists){
|
|
|
14 |
$url = $apihost."register?email=$email";
|
|
|
15 |
$response = $this->make_request($url,null);
|
|
|
16 |
$this->log('response '.print_r($response,1),'registration');
|
|
|
17 |
if(!empty($response)) {
|
|
|
18 |
$data = array('account_type'=>'saholic','user_id'=>$userId,'account_key'=>$response['userId']);
|
|
|
19 |
$this->UserAccount->create();
|
|
|
20 |
$this->UserAccount->save($data);
|
|
|
21 |
$data = array('account_type'=>'cartId','user_id'=>$userId,'account_key'=>$response['cartId']);
|
|
|
22 |
$this->UserAccount->create();
|
|
|
23 |
$this->UserAccount->save($data);
|
|
|
24 |
}
|
|
|
25 |
}
|
|
|
26 |
}
|
|
|
27 |
}
|
|
|
28 |
}
|