2014-02-18 12:10:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
App::uses('AppController', 'Controller');
|
|
|
|
|
|
|
|
class UserController extends AppController {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This controller use User Model
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2014-03-02 12:14:02 +01:00
|
|
|
|
2014-03-18 22:48:22 +01:00
|
|
|
public $uses = array('DreamjobListGraducation', 'DreamjobWorker', 'DreamjobCompany', 'DreamjobPageText', 'DreamjobPageImage', 'DreamjobJobOpening', 'DreamjobCvCategory', 'DreamjobListGraducation', 'Mannerofaddress');
|
2014-03-15 01:52:07 +01:00
|
|
|
public $components = array('MiconwareSession','RequestHandler');
|
2014-02-18 12:10:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a view
|
|
|
|
*
|
|
|
|
* @param mixed What page to display
|
|
|
|
* @return void
|
|
|
|
* @throws NotFoundException When the view file could not be found
|
|
|
|
* or MissingViewException in debug mode.
|
|
|
|
*/
|
|
|
|
public function profil() {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
2014-03-15 01:52:07 +01:00
|
|
|
$this->autoRender = true;
|
|
|
|
$this->layout = 'default';
|
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
2014-02-18 12:10:29 +01:00
|
|
|
|
|
|
|
//self check
|
|
|
|
$self_company = false;
|
2014-02-19 00:02:17 +01:00
|
|
|
$self = $this->MiconwareSession->getWorker();
|
2014-02-18 12:10:29 +01:00
|
|
|
if(!is_array($self) or count($self)<= 0){
|
2014-02-19 00:02:17 +01:00
|
|
|
$self = $this->MiconwareSession->getCompany();
|
2014-02-18 12:10:29 +01:00
|
|
|
$self_company = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//get Profil
|
2014-02-19 00:02:17 +01:00
|
|
|
$hard_error = false;
|
|
|
|
|
2014-03-15 01:52:07 +01:00
|
|
|
if(!$this->MiconwareSession->isLoggedin())
|
|
|
|
$hard_error = true;
|
|
|
|
|
2014-02-18 12:10:29 +01:00
|
|
|
$company = false;
|
2014-02-19 00:02:17 +01:00
|
|
|
$page = null;
|
|
|
|
$profil = null;
|
|
|
|
|
2014-02-18 12:10:29 +01:00
|
|
|
if(empty($this->request->params['id'])) {
|
|
|
|
$profil = $self;
|
|
|
|
$company = $self_company;
|
|
|
|
}else{
|
|
|
|
$profil = $this->DreamjobWorker->find('first',array('conditions' => array('AppUser.id' => $this->request->params['id'])));
|
|
|
|
if(!is_array($profil) or count($profil)<= 0){
|
|
|
|
$profil = $this->DreamjobCompany->find('first',array('conditions' => array('AppUser.id' => $this->request->params['id'])));
|
|
|
|
$company = true;
|
|
|
|
}
|
|
|
|
$this->set('id', $this->request->params['id']);
|
|
|
|
}
|
|
|
|
//get Page
|
2014-02-19 00:02:17 +01:00
|
|
|
if(($this->MiconwareSession->isLoggedin()) or ($company) ){
|
|
|
|
if(is_array($profil) or count($profil) > 0){
|
|
|
|
if(!empty($this->request->params['page'])){
|
|
|
|
$page = $this->DreamjobPageText->find('first',
|
|
|
|
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
|
|
|
|
);
|
|
|
|
if(!is_array($page) or count($page)<= 0)
|
|
|
|
$page = $this->DreamjobPageImage->find('first',
|
|
|
|
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
|
|
|
|
);
|
2014-03-12 17:42:02 +01:00
|
|
|
}else{
|
|
|
|
if(isset($profil['DreamjobWorker'])){
|
|
|
|
$cv = $this->DreamjobCvCategory->find('all',array('conditions' => array('worker_id'=> $profil['AppUser']['id'])));
|
2014-03-15 01:52:07 +01:00
|
|
|
if(!$self_company and $profil['AppUser']['id']==$self['AppUser']['id'])
|
|
|
|
$this->request->data = $cv;
|
2014-03-12 17:42:02 +01:00
|
|
|
$this->set("cv",$cv);
|
|
|
|
}
|
2014-02-19 00:02:17 +01:00
|
|
|
}
|
2014-02-18 12:10:29 +01:00
|
|
|
}
|
2014-02-19 00:02:17 +01:00
|
|
|
}else
|
|
|
|
$hard_error = true;
|
2014-02-18 12:10:29 +01:00
|
|
|
//error
|
2014-02-19 00:02:17 +01:00
|
|
|
if(!$company and $profil['AppUser']['id'] != $self['AppUser']['id'] or $hard_error){
|
|
|
|
if(($company == $self_company) and !($this->MiconwareSession->isStaff()) or $hard_error){
|
2014-02-18 12:10:29 +01:00
|
|
|
$hard_error = true;
|
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
|
|
|
|
$this->set('error', 'dreamjob.error.noPermision');
|
|
|
|
$this->render('/Home/error');
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$this->set('edit', true);
|
|
|
|
$this->set('MENU_PROFIL',true);
|
|
|
|
}
|
|
|
|
if(!empty($this->request->params['page']) and (!is_array($page) or count($page)<= 0))
|
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
|
|
|
|
//render
|
|
|
|
$this->set('profil', $profil);
|
|
|
|
$this->set('page',$page);
|
|
|
|
if(!$hard_error)
|
|
|
|
if($company){
|
2014-03-01 12:15:34 +01:00
|
|
|
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => array('DreamjobJobOpening.company_id' => $profil['AppUser']['id'],'DreamjobJobOpening.active'=>1)));
|
2014-02-18 12:10:29 +01:00
|
|
|
$this->set("openings",$openings);
|
|
|
|
$this->render('/User/company');
|
|
|
|
}else
|
|
|
|
$this->render('/User/worker');
|
|
|
|
}
|
2014-03-15 01:52:07 +01:00
|
|
|
public function saveCvJson(){
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->RequestHandler->setContent('json', 'application/json' );
|
|
|
|
|
|
|
|
$this->set("cv",null);
|
|
|
|
$this->set('error', null);
|
|
|
|
|
|
|
|
$self = $this->MiconwareSession->getWorker();
|
|
|
|
if(!empty($self) and count($self)> 0){
|
|
|
|
$cv = $this->DreamjobCvCategory->find('all',array('conditions' => array('worker_id'=> $self['AppUser']['id'])));
|
|
|
|
$this->request->data = $cv;
|
|
|
|
$this->set("cv",$cv);
|
|
|
|
$this->set('error', false);
|
|
|
|
}else{
|
|
|
|
$this->set('error', true);
|
|
|
|
}
|
|
|
|
$this->set('_serialize', array('cv','error'));
|
|
|
|
}
|
2014-02-18 12:10:29 +01:00
|
|
|
|
2014-03-18 09:34:04 +01:00
|
|
|
public function settings_account() {
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->autoRender = true;
|
|
|
|
$this->layout = 'default';
|
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
2014-03-18 09:34:04 +01:00
|
|
|
$company = false;
|
|
|
|
if(empty($profil) or count($profil) <= 0){
|
2014-03-15 13:56:26 +01:00
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
2014-03-18 09:34:04 +01:00
|
|
|
$company= true;
|
|
|
|
}
|
2014-03-15 13:56:26 +01:00
|
|
|
|
|
|
|
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{
|
2014-03-18 09:34:04 +01:00
|
|
|
if ($this->request->is('post')){
|
2014-03-18 22:48:22 +01:00
|
|
|
if($this->request->data['User']['password1'] == $this->request->data['User']['password2']) {
|
2014-03-18 09:34:04 +01:00
|
|
|
|
2014-03-18 22:48:22 +01:00
|
|
|
if($this->request->data['User']['password1']!='')
|
|
|
|
$profil['User']['password'] = $this->MiconwareSession->create_hash($this->request->data['User']['password1']);
|
|
|
|
|
2014-03-18 09:34:04 +01:00
|
|
|
$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'];
|
2014-03-18 22:48:22 +01:00
|
|
|
$profil['AppUser']['first_name'] = $this->request->data['AppUser']['first_name'];
|
|
|
|
$profil['AppUser']['last_name'] = $this->request->data['AppUser']['last_name'];
|
2014-03-18 09:34:04 +01:00
|
|
|
|
|
|
|
$result = false;
|
|
|
|
if($company){
|
2014-03-18 22:48:22 +01:00
|
|
|
$profil['DreamjobCompany']['corporateform'] = $this->request->data['DreamjobCompany']['corporateform'];
|
|
|
|
$profil['DreamjobCompany']['owner'] = $this->request->data['DreamjobCompany']['owner'];
|
|
|
|
$profil['DreamjobCompany']['branch'] = $this->request->data['DreamjobCompany']['branch'];
|
|
|
|
$profil['DreamjobCompany']['headcount'] = $this->request->data['DreamjobCompany']['headcount'];
|
|
|
|
$profil['DreamjobCompany']['bank_details'] = $this->request->data['DreamjobCompany']['bank_details'];
|
|
|
|
$profil['DreamjobCompany']['website'] = $this->request->data['DreamjobCompany']['website'];
|
2014-03-18 09:34:04 +01:00
|
|
|
$result = $this->DreamjobCompany->saveSettings($profil);
|
|
|
|
}else{
|
2014-03-18 22:48:22 +01:00
|
|
|
$profil['AppUser']['mannerofaddress_id'] = $this->request->data['AppUser']['mannerofaddress_id'];
|
2014-03-18 09:34:04 +01:00
|
|
|
$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'];
|
2014-03-18 22:48:22 +01:00
|
|
|
$profil['DreamjobWorker']['searchhidden'] = $this->request->data['DreamjobWorker']['searchhidden'];
|
2014-03-18 09:34:04 +01:00
|
|
|
$result = $this->DreamjobWorker->saveSettings($profil);
|
|
|
|
}
|
2014-03-18 22:48:22 +01:00
|
|
|
|
|
|
|
|
2014-03-18 09:34:04 +01:00
|
|
|
if($result){
|
|
|
|
$this->MiconwareSession->setFlash('dreamjob.settings.save','flash',array('alert'=>'success'));
|
|
|
|
}else{
|
|
|
|
$this->MiconwareSession->setFlash('dreamjob.settings.save.error','flash',array('alert'=>'danger'));
|
|
|
|
}
|
2014-03-18 22:48:22 +01:00
|
|
|
|
|
|
|
}else if($this->request->data['User']['password1']!='' or $this->request->data['User']['password2']!=''){
|
2014-03-18 09:34:04 +01:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.error.password.notEqual'),'flash',array('alert'=>'danger'));
|
|
|
|
}
|
2014-03-18 22:48:22 +01:00
|
|
|
|
2014-03-18 09:34:04 +01:00
|
|
|
}
|
|
|
|
$this->request->data = $profil;
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->set('profil',$profil);
|
2014-03-18 09:34:04 +01:00
|
|
|
$this->set('graducations',$this->DreamjobListGraducation->find('list'));
|
2014-03-18 22:48:22 +01:00
|
|
|
$this->set('mannerofaddresss',$this->Mannerofaddress->find('list'));
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->render('/User/settings_account');
|
|
|
|
}
|
|
|
|
}
|
2014-03-18 09:34:04 +01:00
|
|
|
public function settings_pages() {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->autoRender = true;
|
|
|
|
$this->layout = 'default';
|
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
|
|
|
if(empty($profil) or count($profil) <= 0)
|
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
|
|
|
|
|
|
|
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{
|
|
|
|
$this->request->data = $profil;
|
|
|
|
$this->set('profil',$profil);
|
|
|
|
$this->render('/User/settings_pages');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function settings_isearch() {
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->autoRender = true;
|
|
|
|
$this->layout = 'default';
|
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
|
|
|
|
|
|
|
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{
|
2014-03-18 09:34:04 +01:00
|
|
|
$this->request->data = $profil;
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->set('profil',$profil);
|
|
|
|
$this->render('/User/settings_isearch');
|
|
|
|
}
|
|
|
|
}
|
2014-02-18 12:10:29 +01:00
|
|
|
public function test() {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
// $this->set('data', $this->DreamjobCompany->find('all'));
|
|
|
|
$this->set('data', $this->MiconwareSession->getApplication('DreamjobWorker'));
|
|
|
|
$this->render('/User/test');
|
|
|
|
}
|
|
|
|
}
|