diff --git a/app/Config/routes.php b/app/Config/routes.php index 00067ad..3345851 100755 --- a/app/Config/routes.php +++ b/app/Config/routes.php @@ -34,7 +34,7 @@ Router::connect('/registration', array('controller' => 'registration', 'action' => 'main')); Router::connect('/registration/user', array('controller' => 'registration', 'action' => 'worker')); Router::connect('/registration/company', array('controller' => 'registration', 'action' => 'company')); - Router::connect('/registration/active/:code', array('controller' => 'registration', 'action' => 'active'),array("code" => "(?i:code)")); + Router::connect('/registration/active/:code', array('controller' => 'registration', 'action' => 'active'),array("code" => ".+")); Router::connect('/profil', array('controller' => 'user', 'action' => 'profil')); Router::connect('/profil/page/:page', array('controller' => 'user', 'action' => 'profil'),array("page" => "[0-9]+")); diff --git a/app/Controller/RegistrationController.php b/app/Controller/RegistrationController.php index 7cc4c58..9e974c6 100644 --- a/app/Controller/RegistrationController.php +++ b/app/Controller/RegistrationController.php @@ -11,7 +11,7 @@ class RegistrationController extends AppController { * @var array */ public $componens = array('Email','MiconwareSession'); - public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch','DreamjobWorker','DreamjobCompany'); + public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch','DreamjobWorker','DreamjobCompany','User'); private function registrationMail($data,$key){ $Email = new CakeEmail('dreamjobMain'); @@ -145,8 +145,16 @@ class RegistrationController extends AppController { } } public function active(){ - $this->set('error', 'dreamjob.error.loggedin'); - $this->render('/Home/error'); + $this->MiconwareSession->init($this); + $this->MiconwareSession->initWeb($this); + if(!$this->MiconwareSession->isLoggedin() and !empty($this->request->params['code']) and !empty($this->request->query['mail']) ){ + $result = $this->User->activeLinkUser($this->request->query['mail'],$this->request->params['code']); + $this->set("result",$result); + $this->render('/Registration/active'); + }else{ + $this->set('error', 'dreamjob.error.loggedin'); + $this->render('/Home/error'); + } } } diff --git a/app/Model/DreamjobCompany.php b/app/Model/DreamjobCompany.php index 165347f..df2db92 100755 --- a/app/Model/DreamjobCompany.php +++ b/app/Model/DreamjobCompany.php @@ -74,7 +74,7 @@ class DreamjobCompany extends AppModel { } if ($result) { - $dataSource->rollback(); + $dataSource->commit(); return true; } else { $dataSource->rollback(); diff --git a/app/Model/DreamjobWorker.php b/app/Model/DreamjobWorker.php index c700b6a..aad831c 100755 --- a/app/Model/DreamjobWorker.php +++ b/app/Model/DreamjobWorker.php @@ -88,7 +88,7 @@ class DreamjobWorker extends AppModel { } if ($result) { - $dataSource->rollback(); + $dataSource->commit(); return true; } else { $dataSource->rollback(); diff --git a/app/Model/User.php b/app/Model/User.php index 906adb4..ed58189 100755 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -33,6 +33,29 @@ class User extends AppModel { * * @var array */ + public function activeLinkUser($mail,$key){ + $dataSource = $this->getDataSource(); + + $dataSource->begin(); + $data = $this->find('first',array('conditions' => array( + 'mail' => $mail, + 'code'=> 'a:'.$key + ))); + $result = false; + if(!empty($data) and count($data)>0){ + $this->id = $data['User']['id']; + $result = $this->saveField('code',''); + if($result) + $result = $this->saveField('is_active',true); + } + if($result) { + $dataSource->commit(); + return true; + } else { + $dataSource->rollback(); + } + return false; + } public $validate = array( 'id' => array( 'multiple' => array( diff --git a/app/View/Emails/html/registration.ctp b/app/View/Emails/html/registration.ctp index 95459d2..ddaab86 100644 --- a/app/View/Emails/html/registration.ctp +++ b/app/View/Emails/html/registration.ctp @@ -1,3 +1,4 @@ Html->link(__('dreamjob.regisration.active.link'),array('controller'=>'registration','action'=>'active','code'=>$key)); + echo $this->Html->link(__('dreamjob.regisration.active.link'),array('controller' => 'registration', 'action' => 'active','code'=>$key, + '?'=>array('mail'=>$data['User']['mail']))); ?> diff --git a/app/View/Emails/text/registration.ctp b/app/View/Emails/text/registration.ctp index 8715d39..6fe0d3a 100644 --- a/app/View/Emails/text/registration.ctp +++ b/app/View/Emails/text/registration.ctp @@ -1,3 +1,4 @@ Html->url(array('controller'=>'registration','action'=>'active','code'=>$key)); + echo $this->Html->url(array('controller'=>'registration','action'=>'active','code'=>$key + '?'=>array('mail'=>$data['User']['mail']))); ?> diff --git a/app/View/Registration/active.ctp b/app/View/Registration/active.ctp new file mode 100644 index 0000000..b1d6523 --- /dev/null +++ b/app/View/Registration/active.ctp @@ -0,0 +1,12 @@ + +