Subversion Repositories SmartDukaan

Rev

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

Rev 17232 Rev 17345
Line 1... Line 1...
1
<?php
1
<?php
2
App::uses('AppController', 'Controller');
2
App::uses('AppController', 'Controller');
-
 
3
App::uses('ConnectionManager', 'Model');
3
/**
4
/**
4
 * Users Controller
5
 * Users Controller
5
 *
6
 *
6
 * @property User $User
7
 * @property User $User
7
 */
8
 */
Line 672... Line 673...
672
				$options['conditions'] = array($type.' LIKE '=>"%$search%");			
673
				$options['conditions'] = array($type.' LIKE '=>"%$search%");			
673
			}
674
			}
674
		}else{
675
		}else{
675
			$options['conditions'] = array('date(User.created)'=>date('Y-m-d',time()));			
676
			$options['conditions'] = array('date(User.created)'=>date('Y-m-d',time()));			
676
		}	
677
		}	
-
 
678
		// $db = ConnectionManager::getDataSource("default"); // name of your database connection
-
 
679
		// $last_act = $db->fetchAll("SELECT * from (SELECT * from daily_visitors order by visited desc) as x group by x.user_id ");
-
 
680
		$sql = "SELECT * from (SELECT * from daily_visitors order by visited desc) as x group by x.user_id ";
-
 
681
		$last_act = $this->User->query($sql);
-
 
682
		// debug($last_act);
-
 
683
		$last_act_user_id = array();
-
 
684
		$last_activated = array();
-
 
685
		foreach ($last_act as $key => $row) {
-
 
686
			// echo $key;
-
 
687
			foreach ($row as $key => $value) {
-
 
688
				$last_activated['visited'] = $value['visited'];
-
 
689
				$last_act_user_id[$value['user_id']] = $last_activated['visited'];
-
 
690
			}
-
 
691
		}
-
 
692
		// debug($last_act_user_id);
-
 
693
		$this->set(compact('last_act_user_id'));
677
		$options['fields'] = array('id','email','first_name','referrer','utm_source','utm_medium','utm_term','utm_campaign','mobile_number','activated','Useractive.last_active','User.created','Appacl.access');
694
		$options['fields'] = array('id','email','first_name','referrer','utm_source','utm_medium','utm_term','utm_campaign','mobile_number','activated','User.created','Appacl.access');
678
		$options['joins'] = array(
695
		$options['joins'] = array(
679
		    array('table' => 'useractive',
696
		    /*array('table' => 'useractive',
680
		        'alias' => 'Useractive',
697
		        'alias' => 'Useractive',
681
		        'type' => 'LEFT',
698
		        'type' => 'LEFT',
682
		        'conditions' => array(
699
		        'conditions' => array(
683
		            'Useractive.user_id = User.id',
700
		            'Useractive.user_id = User.id',
684
		        )
701
		        )
685
		    ),
702
		    ),*/
686
		    array('table' => 'appacls',
703
		    array('table' => 'appacls',
687
		        'alias' => 'Appacl',
704
		        'alias' => 'Appacl',
688
		        'type' => 'LEFT',
705
		        'type' => 'LEFT',
689
		        'conditions' => array(
706
		        'conditions' => array(
690
		            'Appacl.user_id = User.id',
707
		            'Appacl.user_id = User.id',
Line 747... Line 764...
747
		$this->set('title_for_layout','Reset your copublish.in password');
764
		$this->set('title_for_layout','Reset your copublish.in password');
748
		$this->SignMeUp->forgottenPassword();
765
		$this->SignMeUp->forgottenPassword();
749
	}	
766
	}	
750
 
767
 
751
	public function login() {
768
	public function login() {
-
 
769
		// $db = ConnectionManager::getDataSource("default"); // name of your database connection
-
 
770
		// $rest = $db->fetchAll("SELECT * from (SELECT * from daily_visitors order by visited desc) as x where x.user_id in (33, 47,2) group by x.user_id ");
-
 
771
		// debug($rest);
-
 
772
 
752
		$this->layout = 'auth';
773
		$this->layout = 'auth';
753
		if (!empty($this->data['User']['next'])) {
774
		if (!empty($this->data['User']['next'])) {
754
		    $next = $this->data['User']['next'];
775
		    $next = $this->data['User']['next'];
755
		    $this->Session->write('next', $next);
776
		    $this->Session->write('next', $next);
756
		} elseif (!empty($this->params['url']['next'])) {
777
		} elseif (!empty($this->params['url']['next'])) {
757
		    $next = $this->params['url']['next'];
778
		    $next = $this->params['url']['next'];
758
		    $this->Session->write('next', $next);
779
		    $this->Session->write('next', $next);
759
		}
780
		}
760
		if ($this->Auth->login()) {
781
		if ($this->Auth->login()) {
-
 
782
			
761
		    $next = $this->Session->read('next');
783
		    $next = $this->Session->read('next');
762
		    if (!empty($next)) {
784
		    if (!empty($next)) {
763
				header('location:' . $next);
785
				header('location:' . $next);
764
				exit();
786
				exit();
765
		    }
787
		    }
766
		    $user = $this->User->read(null, $this->Auth->User('id'));		 		    
788
		    $user = $this->User->read(null, $this->Auth->User('id'));		
-
 
789
		    // debug($user['User']['group_id']);
-
 
790
		 //    session_start();
-
 
791
		 //    $_SESSION["group_id"] = $user['User']['group_id'];
-
 
792
 
-
 
793
		 //    $this->loadModel('Acl');
-
 
794
			// $resul = $this->Acl->find('all', array('conditions' => array('group_id' => $_SESSION["group_id"]),'fields'=>('action')));
-
 
795
			// $_SESSION["permitted_action"] = $resul;
-
 
796
 
-
 
797
			// debug($_SESSION["permitted_action"]);
-
 
798
		    // echo $_SESSION["group_id"];
767
			if ($user['User']['group_id'] == 1) {
799
			if ($user['User']['group_id'] == 1) {
768
				$this->redirect(array('controller' => 'deals', 'action' => 'mine?user_id='.$user['User']['id']));
800
				$this->redirect(array('controller' => 'deals', 'action' => 'mine?user_id='.$user['User']['id']));
769
				exit();
801
				exit();
770
			}
802
			}
771
			else if ($user['User']['group_id'] >= 2) {
803
			else if ($user['User']['group_id'] >= 2) {
Line 779... Line 811...
779
		}
811
		}
780
		$this->set('title_for_layout', "Login to letushaggle.com");
812
		$this->set('title_for_layout', "Login to letushaggle.com");
781
	}
813
	}
782
 
814
 
783
	public function logout() {
815
	public function logout() {
-
 
816
		// session_unset("group_id"); 
-
 
817
		// session_unset("permitted_action");
-
 
818
		// session_destroy("");
-
 
819
		// echo "Group Id" , $_SESSION["group_id"];
784
		$this->Session->setFlash(__('You have been logged out now'),'success_message');
820
		$this->Session->setFlash(__('You have been logged out now'),'success_message');
785
		$this->redirect($this->Auth->logout());
821
		$this->redirect($this->Auth->logout());
786
	}
822
	}
787
 
823
 
788
	public function updatetimezone() {
824
	public function updatetimezone() {