diff --git a/app/Config/core.php b/app/Config/core.php index 28157d1..7d1e8e7 100755 --- a/app/Config/core.php +++ b/app/Config/core.php @@ -384,3 +384,10 @@ Cache::config('_cake_model_', array( 'serialize' => ($engine === 'File'), 'duration' => $duration )); + + +Configure::write('Session', array( + 'defaults' => 'php', + 'cookie' => 'DreamJOBSession' + ) +); diff --git a/app/Config/routes.php b/app/Config/routes.php index ca95232..2ad7f9c 100755 --- a/app/Config/routes.php +++ b/app/Config/routes.php @@ -32,8 +32,9 @@ Router::connect('/profil', array('controller' => 'user', 'action' => 'profil')); Router::connect('/profil/page/:page', array('controller' => 'user', 'action' => 'profil'),array("page" => "[0-9]+")); - Router::connect('/settings', array('controller' => 'user', 'action' => 'settings')); - Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'isearch')); + Router::connect('/settings', array('controller' => 'user', 'action' => 'settings_account')); + Router::connect('/settings/pages', array('controller' => 'user', 'action' => 'settings_pages')); + Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'settings_isearch')); Router::connect('/user/:id', array('controller' => 'user', 'action' => 'profil'),array("id" => "[0-9]+")); diff --git a/app/Controller/Component/MiconwareSessionComponent.php b/app/Controller/Component/MiconwareSessionComponent.php index 4e644bd..e065d18 100755 --- a/app/Controller/Component/MiconwareSessionComponent.php +++ b/app/Controller/Component/MiconwareSessionComponent.php @@ -111,7 +111,7 @@ class MiconwareSessionComponent extends Component { /** * PasswordHasg */ - private function create_hash($password) + public function create_hash($password) { $salt = base64_encode(mcrypt_create_iv(8, MCRYPT_DEV_URANDOM)); return "pbkdf2_sha1$10000$" . $salt . "$" .base64_encode($this->pbkdf2("sha1",$password,$salt,10000,20,true)); diff --git a/app/Controller/JobController.php b/app/Controller/JobController.php index bbd0a5c..63d867d 100644 --- a/app/Controller/JobController.php +++ b/app/Controller/JobController.php @@ -85,7 +85,6 @@ class JobController extends AppController { $this->DreamjobJobOpening->create($this->request->data); $this->DreamjobJobOpening->data['DreamjobJobOpening']['id'] = $this->request->params['id']; $this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $cid; - echo var_dump($this->DreamjobJobOpening); if ($this->DreamjobJobOpening->save($this->DreamjobJobOpening->data)) { $this->MiconwareSession->setFlash('dreamjob.opening.save','flash',array('alert'=>'success')); @@ -327,7 +326,6 @@ class JobController extends AppController { unset($this->request->data['DreamjobJobApplicationPage']['page_id']); foreach($pages as $id) $this->request->data['DreamjobJobApplicationPage'][]=array('page_id'=> $id); - echo var_dump($this->request->data); $result = $this->DreamjobJobApplication->saveAssociated($this->request->data); if ($result) { $this->MiconwareSession->setFlash('dreamjob.opening.save.add','flash',array('alert'=>'success')); diff --git a/app/Controller/UserController.php b/app/Controller/UserController.php index f92bc99..7dc82cc 100755 --- a/app/Controller/UserController.php +++ b/app/Controller/UserController.php @@ -10,7 +10,7 @@ class UserController extends AppController { * @var array */ - public $uses = array('DreamjobListGraducation','DreamjobWorker','DreamjobCompany','DreamjobPageText','DreamjobPageImage','DreamjobJobOpening','DreamjobCvCategory'); + public $uses = array('DreamjobListGraducation','DreamjobWorker','DreamjobCompany','DreamjobPageText','DreamjobPageImage','DreamjobJobOpening','DreamjobCvCategory','DreamjobListGraducation'); public $components = array('MiconwareSession','RequestHandler'); /** @@ -126,7 +126,65 @@ class UserController extends AppController { $this->set('_serialize', array('cv','error')); } - public function settings() { + public function settings_account() { + $this->MiconwareSession->init($this); + + $this->MiconwareSession->initWeb($this); + $this->autoRender = true; + $this->layout = 'default'; + $this->RequestHandler->setContent('html', 'application/html' ); + + + + $profil = $this->MiconwareSession->getWorker(); + $company = false; + if(empty($profil) or count($profil) <= 0){ + $profil = $this->MiconwareSession->getCompany(); + $company= true; + } + + if(empty($profil) or count($profil) <= 0){ + $this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger')); + $this->set('error', 'dreamjob.error.noPermision'); + $this->render('/Home/error'); + }else{ + if ($this->request->is('post')){ + if($this->request->data['User']['password'] == $this->request->data['User']['password2']) { + + $profil['User']['password'] = $this->MiconwareSession->create_hash($this->request->data['User']['password']); + $profil['DreamjobUser']['city'] = $this->request->data['DreamjobUser']['city']; + $profil['DreamjobUser']['street'] = $this->request->data['DreamjobUser']['street']; + $profil['DreamjobUser']['postcode'] = $this->request->data['DreamjobUser']['postcode']; + $profil['AppUser']['bday'] = $this->request->data['AppUser']['bday']; + + $result = false; + if($company){ + $result = $this->DreamjobCompany->saveSettings($profil); + }else{ + $profil['DreamjobWorker']['country'] = $this->request->data['DreamjobWorker']['country']; + $profil['DreamjobWorker']['iam'] = $this->request->data['DreamjobWorker']['iam']; + $profil['DreamjobWorker']['graducation_id'] = $this->request->data['DreamjobWorker']['graducation_id']; + $result = $this->DreamjobWorker->saveSettings($profil); + } + + + if($result){ + $this->MiconwareSession->setFlash('dreamjob.settings.save','flash',array('alert'=>'success')); + }else{ + $this->MiconwareSession->setFlash('dreamjob.settings.save.error','flash',array('alert'=>'danger')); + } + }else{ + $this->MiconwareSession->setFlash(__('dreamjob.error.password.notEqual'),'flash',array('alert'=>'danger')); + } + } + $profil['User']['password']=''; + $this->request->data = $profil; + $this->set('profil',$profil); + $this->set('graducations',$this->DreamjobListGraducation->find('list')); + $this->render('/User/settings_account'); + } + } + public function settings_pages() { $this->MiconwareSession->init($this); $this->MiconwareSession->initWeb($this); @@ -145,11 +203,12 @@ class UserController extends AppController { $this->set('error', 'dreamjob.error.noPermision'); $this->render('/Home/error'); }else{ + $this->request->data = $profil; $this->set('profil',$profil); - $this->render('/User/settings_account'); + $this->render('/User/settings_pages'); } } - public function iSearch() { + public function settings_isearch() { $this->MiconwareSession->init($this); $this->MiconwareSession->initWeb($this); @@ -166,6 +225,7 @@ class UserController extends AppController { $this->set('error', 'dreamjob.error.noPermision'); $this->render('/Home/error'); }else{ + $this->request->data = $profil; $this->set('profil',$profil); $this->render('/User/settings_isearch'); } diff --git a/app/Model/DreamjobCompany.php b/app/Model/DreamjobCompany.php index 59af77b..0c41a56 100755 --- a/app/Model/DreamjobCompany.php +++ b/app/Model/DreamjobCompany.php @@ -37,6 +37,74 @@ class DreamjobCompany extends AppModel { */ public $displayField = 'djaccount_ptr_id'; + + public function saveSettings($data){ + $dataSource = $this->getDataSource(); + $dataSource->begin(); + + $this->id = $data['AppUser']['id']; + $this->User->id = $data['User']['id']; + $this->AppUser->id = $data['AppUser']['id']; + $this->DreamjobUser->id = $data['AppUser']['id']; + + + $result = $this->User->saveField('password',$data['User']['password']); + + if($result) + $result = $this->AppUser->saveField('nickname',$data['AppUser']['nickname']); + if($result) + $result = $this->AppUser->saveField('first_name',$data['AppUser']['first_name']); + if($result) + $result = $this->AppUser->saveField('last_name',$data['AppUser']['last_name']); + if($result) + $result = $this->AppUser->saveField('bday',$data['AppUser']['bday']); + if($result) + $result = $this->AppUser->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']); + if($result) + $result = $this->DreamjobUser->saveField('street',$data['DreamjobUser']['street']); + if($result) + $result = $this->DreamjobUser->saveField('city',$data['DreamjobUser']['city']); + if($result) + $result = $this->DreamjobUser->saveField('postcode',$data['DreamjobUser']['postcode']); + + if($result) + $result = $this->saveField('corporateform',$data['DreamjobCompany']['corporateform']); + if($result) + $result = $this->saveField('owner',$data['DreamjobCompany']['owner']); + if($result) + $result = $this->saveField('branch',$data['DreamjobCompany']['branch']); + if($result) + $result = $this->saveField('headcount',$data['DreamjobCompany']['headcount']); + if($result) + $result = $this->saveField('bank_details',$data['DreamjobCompany']['bank_details']); + if($result) + $result = $this->saveField('website',$data['DreamjobCompany']['website']); + + if($result) + $result = $this->AppUser->saveField('take_systemwide',$data['AppUser']['take_systemwide']); + + if($result and $data['AppUser']['take_systemwide']){ + $result = $this->User->saveField('nickname',$data['AppUser']['nickname']); + if($result) + $result = $this->User->saveField('first_name',$data['AppUser']['first_name']); + if($result) + $result = $this->User->saveField('last_name',$data['AppUser']['last_name']); + if($result) + $result = $this->User->saveField('bday',$data['AppUser']['bday']); + if($result) + $result = $this->User->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']); + } + + + + if ($result) { + $dataSource->commit(); + return true; + } else { + $dataSource->rollback(); + } + return false; + } /** * Validation rules * diff --git a/app/Model/DreamjobWorker.php b/app/Model/DreamjobWorker.php index be1e053..ba65736 100755 --- a/app/Model/DreamjobWorker.php +++ b/app/Model/DreamjobWorker.php @@ -38,6 +38,76 @@ class DreamjobWorker extends AppModel { */ public $displayField = 'djaccount_ptr_id'; + + public function saveSettings($data){ + $dataSource = $this->getDataSource(); + $dataSource->begin(); + + $this->id = $data['AppUser']['id']; + $this->User->id = $data['User']['id']; + $this->AppUser->id = $data['AppUser']['id']; + $this->DreamjobUser->id = $data['AppUser']['id']; + + + $result = $this->User->saveField('password',$data['User']['password']); + + if($result) + $result = $this->AppUser->saveField('nickname',$data['AppUser']['nickname']); + if($result) + $result = $this->AppUser->saveField('first_name',$data['AppUser']['first_name']); + if($result) + $result = $this->AppUser->saveField('last_name',$data['AppUser']['last_name']); + if($result) + $result = $this->AppUser->saveField('bday',$data['AppUser']['bday']); + if($result) + $result = $this->AppUser->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']); + if($result) + $result = $this->DreamjobUser->saveField('street',$data['DreamjobUser']['street']); + if($result) + $result = $this->DreamjobUser->saveField('city',$data['DreamjobUser']['city']); + if($result) + $result = $this->DreamjobUser->saveField('postcode',$data['DreamjobUser']['postcode']); + + if($result) + $result = $this->saveField('iam',$data['DreamjobWorker']['iam']); + if($result) + $result = $this->saveField('country',$data['DreamjobWorker']['country']); + if($result) + $result = $this->saveField('leadership_ability',$data['DreamjobWorker']['leadership_ability']); + if($result) + $result = $this->saveField('searchhidden',$data['DreamjobWorker']['searchhidden']); + if($result) + $result = $this->saveField('advertising',$data['DreamjobWorker']['advertising']); + if($result) + $result = $this->saveField('workexperience',$data['DreamjobWorker']['workexperience']); + if($result) + $result = $this->saveField('graducation_id',$data['DreamjobWorker']['graducation_id']); + + if($result) + $result = $this->AppUser->saveField('take_systemwide',$data['AppUser']['take_systemwide']); + + if($result and $data['AppUser']['take_systemwide']){ + $result = $this->User->saveField('nickname',$data['AppUser']['nickname']); + if($result) + $result = $this->User->saveField('first_name',$data['AppUser']['first_name']); + if($result) + $result = $this->User->saveField('last_name',$data['AppUser']['last_name']); + if($result) + $result = $this->User->saveField('bday',$data['AppUser']['bday']); + if($result) + $result = $this->User->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']); + } + + + + if ($result) { + $dataSource->commit(); + return true; + } else { + $dataSource->rollback(); + } + return false; + } /** * Validation rules * diff --git a/app/View/Elements/barleft.ctp b/app/View/Elements/barleft.ctp index 2896639..b9f302c 100755 --- a/app/View/Elements/barleft.ctp +++ b/app/View/Elements/barleft.ctp @@ -28,7 +28,7 @@ if($isLoggedin){