Subversion Repositories SmartDukaan

Rev

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

Rev 13714 Rev 13736
Line 11... Line 11...
11
 
11
 
12
    public function beforeFilter() {
12
    public function beforeFilter() {
13
    	parent::beforeFilter();
13
    	parent::beforeFilter();
14
    	// $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'dashboard');
14
    	// $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'dashboard');
15
    	$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'display','home');
15
    	$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'display','home');
16
        $this->Auth->allow(array('migrate','login', 'forgotten_password', 'register', 'activate', 'checkemail','checkfbuser','registertwitteruser')); 
16
        $this->Auth->allow(array('migrate','login', 'forgotten_password', 'register', 'activate', 'checkemail','checkfbuser','registertwitteruser','skipmobileverification','reauthenticate')); 
17
	$this->Cookie->name = 'instafolow';
17
		$this->Cookie->name = 'profittill';
18
	$this->Cookie->time = 86400*30; 
18
		$this->Cookie->time = 86400*30; 
19
	$this->Cookie->path = '/';
19
		$this->Cookie->path = '/';
20
	$this->Cookie->key = 'qSI232qs*&sXOw!adre@34SAv!@*(XSL#$%)asGb$@11~_+!@#H23s~#^';
20
		$this->Cookie->key = 'qSI232qs*&sXOw!adre@34SAv!@*(XSL#$%)asGb$@11~_+!@#H23s~#^';
21
	$this->Cookie->httpOnly = true;
21
		$this->Cookie->httpOnly = true;
22
    }
22
    }
23
    
23
    
24
	public function bookmarklet() {
24
	public function bookmarklet() {
25
		$this->set('title_for_layout','Profittill Bookmarklet');
25
		$this->set('title_for_layout','Profittill Bookmarklet');
26
	}
26
	}
Line 195... Line 195...
195
        }
195
        }
196
        $this->set('result', $result);
196
        $this->set('result', $result);
197
    }
197
    }
198
 
198
 
199
/**
199
/**
200
 * index method
-
 
201
 *
-
 
202
 * @return void
-
 
203
 */
-
 
204
/*
-
 
205
	public function index() {
-
 
206
		$this->User->recursive = 0;
-
 
207
		$this->set('users', $this->paginate());
-
 
208
	}
-
 
209
*/
-
 
210
/**
-
 
211
 * view method
200
 * view method
212
 *
201
 *
213
 * @throws NotFoundException
202
 * @throws NotFoundException
214
 * @param string $id
203
 * @param string $id
215
 * @return void
204
 * @return void
Line 227... Line 216...
227
		$this->set(array(
216
		$this->set(array(
228
		    'result' => $result,
217
		    'result' => $result,
229
		    'callback' => $callback,
218
		    'callback' => $callback,
230
		    '_serialize' => array('result')
219
		    '_serialize' => array('result')
231
		));
220
		));
-
 
221
		$this->render('/Elements/json');
232
	}
222
	}
233
 
-
 
234
/**
-
 
235
 * add method
-
 
236
 *
-
 
237
 * @return void
-
 
238
 */
-
 
239
/*
-
 
240
	public function add() {
-
 
241
		if ($this->request->is('post')) {
-
 
242
			$this->User->create();
-
 
243
			if ($this->User->save($this->request->data)) {
-
 
244
				$this->Session->setFlash(__('The user has been saved'));
-
 
245
				$this->redirect(array('action' => 'index'));
-
 
246
			} else {
-
 
247
				$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
-
 
248
			}
-
 
249
		}
-
 
250
		$groups = $this->User->Group->find('list');
-
 
251
		$this->set(compact('groups'));
-
 
252
	}
-
 
253
*/
-
 
254
/**
223
/**
255
 * edit method
224
 * edit method
256
 *
225
 *
257
 * @throws NotFoundException
226
 * @throws NotFoundException
258
 * @param string $id
227
 * @param string $id
259
 * @return void
228
 * @return void
260
 */
229
 */
261
 
230
 
262
    public function edit() {
231
    public function edit($id = null) {
-
 
232
    	$this->response->type('json');
-
 
233
		$this->layout = 'ajax';
263
        $this->User->recursive = -1;
234
        $this->User->recursive = -1;
264
        $id = $this->Auth->User('id');
235
        if (!$this->User->exists($id)) {
-
 
236
			$result = array('success'=>false,'message'=>'Invalid user');
-
 
237
		} else {
265
        if ($this->request->is('post') || $this->request->is('put')) {
238
	        if ($this->request->is('post') || $this->request->is('put')) {
266
            if ($this->User->save($this->request->data)) {
239
	            if ($this->User->save($this->request->data)) {
267
                $this->Session->setFlash(__('Your profile has been saved', true),'success_message');
240
	                $result = array('success'=>true,'message'=>'Your profile has been saved');
268
                $this->redirect(array('action' => 'dashboard'));
-
 
269
            } else {
241
	            } else {
270
                $this->Session->setFlash(__('The user could not be saved. <br>'.print_r($this->User->validationErrors).' <br>Please, try again.', true),'error_message');
242
	                $result = array('success'=>false,'message'=> 'The user could not be saved. Please, try again.');
271
            }
243
	            }
272
        } else {        
244
	        }  
273
            $this->request->data = $this->User->read(null, $id);
-
 
274
        }
245
	    }
275
        $this->loadModel('Country');
246
        $this->set(array(
276
        $this->Country->recursive = -1;
-
 
277
        $fields = array('country', 'FIPS104');
-
 
278
        $result = $this->Country->find('all', array('fields' => $fields));
-
 
279
        $countries = array();
247
		    'result' => $result,
280
        foreach ($result AS $country) {
248
		    '_serialize' => array('result')
281
            $countries[$country['Country']['FIPS104']] = $country['Country']['country'];
-
 
282
        }        
249
		)); 
283
        Configure::load('constant');
-
 
284
		$this->set('timeZones' , Configure::read("timeZones"));
-
 
285
        $this->set(compact('countries','id'));
250
		$this->render('/Elements/json');      
286
        $this->set('title_for_layout', "Update Profile");
-
 
287
    }
251
    }
288
 
252
 
289
/**
253
/**
290
 * delete method
-
 
291
 *
-
 
292
 * @throws MethodNotAllowedException
-
 
293
 * @throws NotFoundException
-
 
294
 * @param string $id
-
 
295
 * @return void
-
 
296
 */
-
 
297
/*
-
 
298
	public function delete($id = null) {
-
 
299
		if (!$this->request->is('post')) {
-
 
300
			throw new MethodNotAllowedException();
-
 
301
		}
-
 
302
		$this->User->id = $id;
-
 
303
		if (!$this->User->exists()) {
-
 
304
			throw new NotFoundException(__('Invalid user'));
-
 
305
		}
-
 
306
		if ($this->User->delete()) {
-
 
307
			$this->Session->setFlash(__('User deleted'));
-
 
308
			$this->redirect(array('action' => 'index'));
-
 
309
		}
-
 
310
		$this->Session->setFlash(__('User was not deleted'));
-
 
311
		$this->redirect(array('action' => 'index'));
-
 
312
	}
-
 
313
*/
-
 
314
/**
-
 
315
 * admin_index method
254
 * admin_index method
316
 *
255
 *
317
 * @return void
256
 * @return void
318
 */
257
 */
319
	public function admin_index() {
258
	public function admin_index() {
Line 451... Line 390...
451
		    $next = $this->Session->read('next');
390
		    $next = $this->Session->read('next');
452
		    if (!empty($next)) {
391
		    if (!empty($next)) {
453
				header('location:' . $next);
392
				header('location:' . $next);
454
				exit();
393
				exit();
455
		    }
394
		    }
456
		    $user = $this->User->read(null, $this->Auth->User('id'));
395
		    $user = $this->User->read(null, $this->Auth->User('id'));		 
457
		  //   if ($user['User']['active'] == 0) {
-
 
458
				// $this->Session->setFlash(__('Your account has not been activated yet. Contact the administrator.', true),'error_message');
-
 
459
				// $this->redirect($this->Auth->logout());
-
 
460
				// exit();
-
 
461
		  //   } 
-
 
462
		    if ($user['User']['group_id'] == 2) {
396
		    if ($user['User']['group_id'] == 2) {
463
				$this->redirect(array('controller' => 'administration', 'action' => 'dashboard'));
397
				$this->redirect(array('controller' => 'administration', 'action' => 'dashboard'));
464
				exit();
398
				exit();
465
		    }
399
		    }
466
			if ($user['User']['group_id'] == 1) {
400
			if ($user['User']['group_id'] == 1) {
467
				header('location:/users/dashboard?userid='.$this->Auth->user('id'));
401
				$this->redirect(array('controller' => 'deals', 'action' => 'mine?user_id='.$user['User']['id']));
468
				exit();
402
				exit();
469
			}
403
			}
470
		} else {
404
		} else {
471
		    if (!empty($this->data)) {                
405
		    if (!empty($this->data)) {                
472
			$this->Session->setFlash(__('Invalid username or password'),'error_message');
406
				$this->Session->setFlash(__('Invalid username or password'),'error_message');
473
		    }
407
		    }
474
		}
408
		}
475
		$this->set('title_for_layout', "Login to letushaggle.com");
409
		$this->set('title_for_layout', "Login to letushaggle.com");
476
	}
410
	}
477
 
411
 
Line 492... Line 426...
492
			$result = array('success' => false);
426
			$result = array('success' => false);
493
		}
427
		}
494
		$this->set('result',$result);
428
		$this->set('result',$result);
495
	}
429
	}
496
 
430
 
497
	/*public function migrate() {
431
	public function verifymobile() {
-
 
432
		$this->layout = 'innerpages';
-
 
433
	}
-
 
434
 
-
 
435
	public function getdial2verifynumber() {
-
 
436
		$TelNumber=substr($this->request->data("phone_number"),-10);
-
 
437
 
498
		$users = $this->User->Find('all',array('fields'=>array('id','first_name','last_name'),'recursive'=>-1));
438
	  // Replace with your Dial2Verify API Passkey generated using ( http://kb.dial2verify.in/?q=5 )
-
 
439
	    $API_KEY = Configure::read("dial2verifyapikey");
-
 
440
  
-
 
441
	  	//Get API Image Response
-
 
442
	    $url ="http://engine.dial2verify.in/Integ/API.dvf?mobile=$TelNumber&passkey=$API_KEY&notify=http://engine.dial2verify.in/Integ/CatchAll.dvf&e-notify=support@dial2verify.in&out=JSON&cn=IN";
-
 
443
	    // $json=file_get_contents($APIUrl);
-
 
444
	    $json = json_encode($this->make_request($url,null));
-
 
445
	  	$this->response->type('json');
-
 
446
		$this->layout = 'ajax';
499
		foreach($users AS $user){
447
	    echo($json);die;
-
 
448
	}
-
 
449
 
-
 
450
	public function getdial2verifystatus() { 
-
 
451
 
-
 
452
		$SID=$_REQUEST["SID"];
-
 
453
    
500
			$data = array();
454
	    $json = array();
-
 
455
		$VerificationCall="http://engine.dial2verify.in/Integ/UserLayer/DataFeed_APIV2.dvf?SID=$SID";
-
 
456
 
501
	        $data['UserAnswerProfile']['user_id'] = $user['User']['id'];
457
	   // Make a call to Dial2Verify API & Parse The JSON Response
502
	        $data['UserAnswerProfile']['alias'] = $user['User']['first_name']. ' '.substr($user['User']['last_name'], 0, 1);
458
		// $RequestPayload=json_decode(file_get_contents($VerificationCall),true);
503
	        $this->User->UserAnswerProfile->create();
459
		$RequestPayload = $this->make_request($VerificationCall,null);
504
	        $this->User->UserAnswerProfile->save($data);
460
		// $RequestPayload = json_decode($response,true);
505
 
461
 
506
	        $data['UserStatistic']['user_id'] = $user['User']['id'];
462
		$VerifStatus=$RequestPayload["VerificationStatus"];
-
 
463
	     
-
 
464
		$json["VerificationStatus"]=$VerifStatus;
-
 
465
		
507
	        $this->User->UserStatistic->create();
466
	   	$this->response->type('json');
-
 
467
		$this->layout = 'ajax';
-
 
468
	    echo(json_encode($json));die;
-
 
469
	}
-
 
470
 
-
 
471
	public function skipmobileverification() {
508
	        $this->User->UserStatistic->save($data);
472
		$this->Session->write('skipmobileverification',1);
509
		}
473
	}
-
 
474
 
-
 
475
	public function reauthenticate($userId) {
-
 
476
		$user = $this->User->read(null,$userId);
-
 
477
		$this->Auth->login($user['User']);
-
 
478
		$json = array('success'=>true);
-
 
479
		$this->response->type('json');
-
 
480
		$this->layout = 'ajax';
-
 
481
	    echo(json_encode($json));die;
510
	}*/
482
	}
511
}
483
}
512
484