settings account (worker) - nahezu fertig

This commit is contained in:
Martin Müller 2014-03-18 09:34:04 +01:00
parent c9b2b458b9
commit 9d7e1bcd4b
11 changed files with 252 additions and 22 deletions

View File

@ -384,3 +384,10 @@ Cache::config('_cake_model_', array(
'serialize' => ($engine === 'File'),
'duration' => $duration
));
Configure::write('Session', array(
'defaults' => 'php',
'cookie' => 'DreamJOBSession'
)
);

View File

@ -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]+"));

View File

@ -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));

View File

@ -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'));

View File

@ -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');
}

View File

@ -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
*

View File

@ -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
*

View File

@ -28,7 +28,7 @@ if($isLoggedin){
<li<?php if(isset($MENU_APPLICATION)){?> class="active"<?php } ?>><?=$this->Html->image('bar-job.png',array('url'=>array('controller'=>'job','action'=>'applicationList'))); ?></li>
<li<?php if(isset($MENU_FAVORITY)){?> class="active"<?php } ?>><?=$this->Html->image('bar-favority.png',array('url'=>array('controller'=>'job','action'=>'favorite'))); ?></li>
<?php } ?>
<li<?php if(isset($MENU_SETTINGS)){?> class="active"<?php } ?>><?=$this->Html->image('bar-settings.png',array('url'=>array('controller'=>'user','action'=>'settings'))); ?></li>
<li<?php if(isset($MENU_SETTINGS)){?> class="active"<?php } ?>><?=$this->Html->image('bar-settings.png',array('url'=>array('controller'=>'user','action'=>'settings_account'))); ?></li>
</ul>
<?php
}elseif(!empty($MENU_START)){

View File

@ -12,28 +12,51 @@ if($profil['AppUser']['take_systemwide']){
}
?>
<div class="box">
<div class="tabs-below">
<ul class="nav nav-tabs pull-right">
<li class="active"><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li>
<li><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pages'));?></li>
<?php
if(!empty($WORKER) and count($WORKER)>0){
?>
<div class="tabs-below">
<ul class="nav nav-tabs pull-right">
<li class="active"><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings'));?></li>
<li><?=$this->Html->link(__("dreamjob.settings.isearch"),array('controller'=>'user','action'=>'isearch'));?></li>
</ul>
</div>
<li><?=$this->Html->link(__("dreamjob.settings.isearch"),array('controller'=>'user','action'=>'settings_isearch'));?></li>
<?php
}
?>
</ul>
</div>
<h1><?=__("dreamjob.settings");?></h1>
<?php
echo $this->Form->create('DreamjobJobApplication',$default_Form);
?>
<h1><?=__("dreamjob.settings");?></h1>
<fieldset>
<legend><?=__("dreamjob.account");?></legend>
<?php
echo $this->Form->input('User.mail',array('label'=>array('text'=>__("dreamjob.title"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('User.mail',array('label'=>array('text'=>__("dreamjob.mail"),"class"=>$default_Form['inputDefaults']['label']['class']),'disabled'));
echo $this->Form->input('User.password',array('label'=>array('text'=>__("dreamjob.password"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('User.password2',array('label'=>array('text'=>__("dreamjob.password2"),"class"=>$default_Form['inputDefaults']['label']['class']),'type'=>'password'));
if($WORKER){
?>
<legend><?=__("dreamjob.worker");?></legend>
<?php
echo $this->Form->input('AppUser.bday',array('label'=>array('text'=>__("dreamjob.bday"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('DreamjobWorker.iam',array('label'=>array('text'=>__("dreamjob.iam"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('DreamjobWorker.graducation_id',array('label'=>array('text'=>__("dreamjob.graducation"),"class"=>$default_Form['inputDefaults']['label']['class'])));
}
?>
<legend><?=__("dreamjob.addresse");?></legend>
<?php
echo $this->Form->input('DreamjobUser.street',array('label'=>array('text'=>__("dreamjob.street"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('DreamjobUser.city',array('label'=>array('text'=>__("dreamjob.city"),"class"=>$default_Form['inputDefaults']['label']['class'])));
echo $this->Form->input('DreamjobUser.postcode',array('label'=>array('text'=>__("dreamjob.postcode"),"class"=>$default_Form['inputDefaults']['label']['class'])));
if($WORKER)
echo $this->Form->input('DreamjobWorker.country',array('label'=>array('text'=>__("dreamjob.country"),"class"=>$default_Form['inputDefaults']['label']['class'])));
?>
<div class="buttonrow">
<?=$this->Form->button(__('dreamjob.application.send'),array('div' => false,'class'=>"btn btn-default ",'type' => 'submit'));?>
<?=$this->Form->button(__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-default ",'type' => 'submit'));?>
</div>
</fieldset>
<?php echo $this->Form->end(); ?>

View File

@ -14,8 +14,10 @@ if($profil['AppUser']['take_systemwide']){
<div class="box">
<div class="tabs-below">
<ul class="nav nav-tabs pull-right">
<li><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings'));?></li>
<li class="active"><?=$this->Html->link(__("dreamjob.settings.isearch"),array('controller'=>'user','action'=>'isearch'));?></li>
<li><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li>
<li><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pages'));?></li>
<li class="active"><?=$this->Html->link(__("dreamjob.settings.isearch"),array('controller'=>'user','action'=>'settings_isearch'));?></li>
</ul>
</div>
<h1><?=__("dreamjob.settings.isearch");?></h1>
</div>

View File

@ -248,6 +248,7 @@ body.loading #container{
.buttonrow{
text-align:right;
margin-top:25px;
padding:0px 15px;
}
/*
* Opening