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-04-22 16:01:00 +02:00
|
|
|
public $uses = array('DreamjobListGraducation', 'DreamjobWorker', 'DreamjobCompany', 'DreamjobPageText','DreamjobPageInh', 'DreamjobPageImage', 'DreamjobJobOpening', 'DreamjobCvEntry', 'DreamjobListCvCategory', 'DreamjobListGraducation', 'DreamjobListJob','DreamjobListKindofjob','DreamjobListBranch','Mannerofaddress','DreamjobISearch','User','AppUser','DreamjobListCity');
|
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.
|
|
|
|
*/
|
2014-03-29 21:09:17 +01:00
|
|
|
function beforeFilter(){
|
|
|
|
$this->Security->unlockedActions[]="settings_isearch";
|
2014-04-01 20:58:36 +02:00
|
|
|
$this->Security->unlockedActions[]="profil_edit";
|
|
|
|
if($this->request->action=="settings_isearch")
|
|
|
|
unset($this->request->data['_Token']['key']);
|
2014-03-29 21:09:17 +01:00
|
|
|
parent::beforeFilter();
|
|
|
|
}
|
|
|
|
|
2014-03-26 09:15:43 +01:00
|
|
|
|
2014-02-18 12:10:29 +01:00
|
|
|
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
|
|
|
|
2014-02-18 12:10:29 +01:00
|
|
|
$company = false;
|
2014-02-19 00:02:17 +01:00
|
|
|
$page = null;
|
|
|
|
$profil = null;
|
|
|
|
|
2014-04-01 20:58:36 +02:00
|
|
|
if(empty($this->request->params['id'])){
|
2014-02-18 12:10:29 +01:00
|
|
|
$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'])){
|
2014-04-01 20:58:36 +02:00
|
|
|
$cv = $this->DreamjobCvEntry->find('all',array('conditions' => array('worker_id'=> $profil['AppUser']['id'])));
|
2014-04-13 20:39:12 +02:00
|
|
|
if(!$self_company and $profil['AppUser']['id']==$self['AppUser']['id']){
|
|
|
|
$cvp0 = $this->DreamjobListCvCategory->find('first',array('conditions' => array('DreamjobListCvCategory.position' => 0)));
|
|
|
|
$this->set('cvp0', $cvp0);
|
|
|
|
$this->set("cv",$cv);
|
|
|
|
}
|
2014-03-12 17:42:02 +01:00
|
|
|
}
|
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-04-16 18:24:34 +02:00
|
|
|
$this->set('edit', false);
|
2014-04-23 16:13:39 +02:00
|
|
|
if(!isset( $profil['AppUser']['id']))
|
|
|
|
$hard_error = true;
|
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'));
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-02-18 12:10:29 +01:00
|
|
|
$this->render('/Home/error');
|
|
|
|
}
|
2014-04-15 21:43:23 +02:00
|
|
|
}elseif($profil['AppUser']['id'] == $self['AppUser']['id']){
|
2014-02-18 12:10:29 +01:00
|
|
|
$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-28 16:22:19 +01:00
|
|
|
$con = $this->MiconwareSession->getOpeningCondition();
|
2014-03-26 19:49:36 +01:00
|
|
|
$con['DreamjobJobOpening.company_id'] = $profil['AppUser']['id'];
|
|
|
|
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con));
|
2014-02-18 12:10:29 +01:00
|
|
|
$this->set("openings",$openings);
|
|
|
|
$this->render('/User/company');
|
|
|
|
}else
|
|
|
|
$this->render('/User/worker');
|
|
|
|
}
|
2014-04-01 20:58:36 +02:00
|
|
|
public function profil_edit(){
|
2014-03-15 01:52:07 +01:00
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
2014-04-01 20:58:36 +02:00
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
|
|
|
$this->layout = 'default';
|
2014-03-15 01:52:07 +01:00
|
|
|
|
|
|
|
$self = $this->MiconwareSession->getWorker();
|
|
|
|
if(!empty($self) and count($self)> 0){
|
2014-04-01 20:58:36 +02:00
|
|
|
if($this->request->is('post')){
|
|
|
|
$tosave = array();
|
|
|
|
if(isset($this->request->data['DreamjobCvEntry'])){
|
|
|
|
$tosave = $this->request->data['DreamjobCvEntry'];
|
|
|
|
foreach($tosave as $i => $a)
|
|
|
|
$tosave[$i]['worker_id']=$self['AppUser']['id'];
|
|
|
|
}
|
|
|
|
$result = $this->DreamjobCvEntry->saveAndDelete($tosave,$self['DreamjobCvEntry']);
|
|
|
|
if($result){
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.save.success'),'flash',array('alert'=>'success'));
|
2014-04-01 20:58:36 +02:00
|
|
|
}else{
|
2014-04-29 20:49:20 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.save.error'),'flash',array('alert'=>'danger'));
|
2014-04-01 20:58:36 +02:00
|
|
|
}
|
|
|
|
}
|
2014-04-13 20:06:35 +02:00
|
|
|
$cvc = $this->DreamjobListCvCategory->find('all');
|
2014-04-01 20:58:36 +02:00
|
|
|
$cve = $this->DreamjobCvEntry->find('all',array('conditions' => array('worker_id'=> $self['AppUser']['id'])));
|
|
|
|
$cve2 = array('DreamjobCvEntry'=>null);
|
|
|
|
foreach($cve as $i => $data)
|
|
|
|
$cve2['DreamjobCvEntry'][$i] = $data['DreamjobCvEntry'];
|
|
|
|
$this->request->data = $cve2;
|
|
|
|
$this->set('cvc',$cvc);
|
|
|
|
$this->set('cve',$cve);
|
|
|
|
$this->set('profil',$self);
|
|
|
|
$this->set('edit_show',true);
|
|
|
|
$this->render('/User/worker');
|
2014-03-15 01:52:07 +01:00
|
|
|
}else{
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-04-01 20:58:36 +02:00
|
|
|
$this->render('/Home/error');
|
2014-03-15 01:52:07 +01:00
|
|
|
}
|
|
|
|
}
|
2014-04-16 15:34:02 +02:00
|
|
|
/*
|
2014-03-23 10:16:15 +01:00
|
|
|
public function savePageDeleteJson(){
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->RequestHandler->setContent('json', 'application/json' );
|
|
|
|
|
|
|
|
$this->set('error', null);
|
|
|
|
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
|
|
|
$company = false;
|
|
|
|
if(empty($profil) or count($profil) <= 0){
|
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
|
|
|
$company= true;
|
|
|
|
}
|
|
|
|
if(!empty($profil) and count($profil)> 0 and !empty($this->request->query['id'])){
|
|
|
|
$data2 = array('DreamjobPageInh.id' => $this->request->query['id'],'DreamjobPageInh.user_id'=>$profil['AppUser']['id']);
|
|
|
|
//$this->set('error', !$this->DreamjobPageInh->deleteAll($data2,false));
|
|
|
|
$this->set('error', false);
|
|
|
|
}else{
|
|
|
|
$this->set('error', true);
|
|
|
|
}
|
|
|
|
$this->set('_serialize', array('error'));
|
2014-04-16 15:34:02 +02:00
|
|
|
}*/
|
2014-03-23 10:16:15 +01:00
|
|
|
public function savePageOrder(){
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->autoRender = true;
|
|
|
|
$this->layout = 'default';
|
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
|
|
|
|
|
|
|
$this->set('error', null);
|
|
|
|
|
|
|
|
$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'));
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-03-23 10:16:15 +01:00
|
|
|
$this->render('/Home/error');
|
|
|
|
}else{
|
|
|
|
if(isset($this->request->query['list']) and is_array($this->request->query['list'])){
|
|
|
|
$i=10;
|
|
|
|
$try = true;
|
|
|
|
foreach($this->request->query['list'] as $pageid){
|
|
|
|
if($try)
|
|
|
|
$try=$this->DreamjobPageInh->updateAll(array('DreamjobPageInh.position'=>$i),array('DreamjobPageInh.id'=>$pageid,'DreamjobPageInh.user_id'=>$profil['AppUser']['id']));
|
|
|
|
$i+=10;
|
|
|
|
}
|
|
|
|
if($try){
|
|
|
|
$this->MiconwareSession->refreshCache();
|
|
|
|
if($company)
|
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
|
|
|
else
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.page.order.save.success'),'flash',array('alert'=>'success'));
|
2014-03-23 10:16:15 +01:00
|
|
|
}
|
|
|
|
else
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.page.order.save.error'),'flash',array('alert'=>'danger'));
|
2014-03-23 10:16:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->set('profil',$profil);
|
|
|
|
$this->render('/User/settings_pages');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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'));
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-03-15 13:56:26 +01:00
|
|
|
$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-04-22 16:01:00 +02:00
|
|
|
$profil['DreamjobUser']['city_id'] = $this->request->data['DreamjobUser']['city_id'];
|
2014-03-18 09:34:04 +01:00
|
|
|
$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-05-01 12:42:51 +02:00
|
|
|
$profil['AppUser']['nickname'] = $this->request->data['AppUser']['nickname'];
|
2014-03-18 22:48:22 +01:00
|
|
|
$profil['DreamjobCompany']['corporateform'] = $this->request->data['DreamjobCompany']['corporateform'];
|
|
|
|
$profil['DreamjobCompany']['owner'] = $this->request->data['DreamjobCompany']['owner'];
|
2014-03-28 16:22:19 +01:00
|
|
|
$profil['DreamjobCompany']['branch_id'] = $this->request->data['DreamjobCompany']['branch_id'];
|
2014-03-18 22:48:22 +01:00
|
|
|
$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-26 19:49:36 +01:00
|
|
|
$profil['DreamjobWorker']['workexperience'] = $this->request->data['DreamjobWorker']['workexperience'];
|
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){
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.save.success'),'flash',array('alert'=>'success'));
|
2014-03-18 09:34:04 +01:00
|
|
|
}else{
|
2014-04-29 20:49:20 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.save.error'),'flash',array('alert'=>'danger'));
|
2014-03-18 09:34:04 +01:00
|
|
|
}
|
2014-03-18 22:48:22 +01:00
|
|
|
|
|
|
|
}else if($this->request->data['User']['password1']!='' or $this->request->data['User']['password2']!=''){
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.password.error.notEqual'),'flash',array('alert'=>'danger'));
|
2014-03-18 09:34:04 +01:00
|
|
|
}
|
2014-03-18 22:48:22 +01:00
|
|
|
|
2014-03-18 09:34:04 +01:00
|
|
|
}
|
2014-05-06 17:59:42 +02:00
|
|
|
if(empty($profil['DreamjobCompany']['website']))
|
|
|
|
$profil['DreamjobCompany']['website'] = 'http://';
|
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-28 16:22:19 +01:00
|
|
|
$this->set('branches',$this->DreamjobListBranch->find('list'));
|
2014-03-26 19:49:36 +01:00
|
|
|
$this->set('mannerofaddresses',$this->Mannerofaddress->find('list'));
|
2014-04-22 16:01:00 +02:00
|
|
|
$this->set('cities',$this->DreamjobListCity->find('list'));
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->render('/User/settings_account');
|
|
|
|
}
|
|
|
|
}
|
2014-03-26 09:15:43 +01:00
|
|
|
public function settings_pageInh() {
|
|
|
|
|
2014-03-18 09:34:04 +01:00
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->autoRender = true;
|
|
|
|
$this->layout = 'default';
|
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
|
|
|
|
2014-03-26 09:15:43 +01:00
|
|
|
$result = false;
|
2014-03-18 09:34:04 +01:00
|
|
|
|
|
|
|
$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'));
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-03-18 09:34:04 +01:00
|
|
|
$this->render('/Home/error');
|
|
|
|
}else{
|
2014-03-26 19:49:36 +01:00
|
|
|
//PAGE BEARBEITEN
|
2014-03-23 10:16:15 +01:00
|
|
|
if(!empty($this->request->params['page'])){
|
2014-03-26 09:15:43 +01:00
|
|
|
$image = false;
|
2014-03-23 10:16:15 +01:00
|
|
|
$page = $this->DreamjobPageText->find('first',
|
|
|
|
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
|
|
|
|
);
|
2014-03-26 09:15:43 +01:00
|
|
|
if(!is_array($page) or count($page)<= 0){
|
2014-03-23 10:16:15 +01:00
|
|
|
$page = $this->DreamjobPageImage->find('first',
|
|
|
|
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
|
|
|
|
);
|
2014-03-26 09:15:43 +01:00
|
|
|
$image = true;
|
2014-03-23 10:16:15 +01:00
|
|
|
}
|
2014-03-26 09:15:43 +01:00
|
|
|
if(!empty($page) and count($page)> 0){
|
|
|
|
if($this->request->is('post')){
|
2014-04-23 22:08:43 +02:00
|
|
|
var_dump($this->request);
|
2014-03-26 09:15:43 +01:00
|
|
|
$this->request->data['DreamjobPageInh']['user_id']=$profil['AppUser']['id'];
|
|
|
|
if($image){
|
|
|
|
$this->request->data['DreamjobPageInh']['id']=$page['DreamjobPageInh']['id'];
|
|
|
|
$this->request->data['DreamjobPageImage']['page_ptr_id']=$page['DreamjobPageInh']['id'];
|
|
|
|
$result = $this->DreamjobPageImage->saveAndUpload($this->request->data);
|
|
|
|
}else{
|
|
|
|
$this->request->data['DreamjobPageInh']['id']=$page['DreamjobPageInh']['id'];
|
|
|
|
$this->request->data['DreamjobPageText']['page_ptr_id']=$page['DreamjobPageInh']['id'];
|
|
|
|
$result = $this->DreamjobPageText->saveAssociated($this->request->data);
|
|
|
|
}
|
|
|
|
if(!$result)
|
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.page.save.error'),'flash',array('alert'=>'danger'));
|
|
|
|
}else
|
|
|
|
$this->request->data=$page;
|
|
|
|
$this->set('page',$page);
|
|
|
|
}else
|
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
|
2014-03-23 10:16:15 +01:00
|
|
|
}else{
|
2014-03-26 19:49:36 +01:00
|
|
|
// PAGE LOESCHEN
|
|
|
|
if(!empty($this->request->query['del'])){
|
|
|
|
$image = false;
|
|
|
|
$page = $this->DreamjobPageText->find('first',
|
|
|
|
array('conditions' => array("DreamjobPageInh.id" => $this->request->query['del'],'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->query['del'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
|
|
|
|
);
|
|
|
|
$image = true;
|
|
|
|
}
|
|
|
|
$result = false;
|
|
|
|
if(!empty($page) and count($page)> 0){
|
|
|
|
$path = null;
|
|
|
|
if($image){
|
2014-04-16 15:34:02 +02:00
|
|
|
$result = $this->DreamjobPageImage->delete($page,false);
|
2014-03-26 19:49:36 +01:00
|
|
|
}else
|
|
|
|
$result = $this->DreamjobPageText->delete($page['DreamjobPageInh']['id'],false);
|
2014-04-16 15:41:56 +02:00
|
|
|
|
2014-03-26 19:49:36 +01:00
|
|
|
if($result){
|
|
|
|
$this->MiconwareSession->refreshCache();
|
2014-05-01 12:27:07 +02:00
|
|
|
|
|
|
|
if(isset($profil['DreamjobWorker']))
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
|
|
|
else
|
2014-03-26 19:49:36 +01:00
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.pages.delete.success'),'flash',array('alert'=>'success'));
|
2014-03-26 19:49:36 +01:00
|
|
|
}else{
|
2014-04-29 20:49:20 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.pages.delete.error'),'flash',array('alert'=>'danger'));
|
2014-03-26 19:49:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
// NEW PAGE
|
2014-03-23 10:16:15 +01:00
|
|
|
if($this->request->is('post')){
|
2014-03-26 09:15:43 +01:00
|
|
|
if(!empty($this->request->data['DreamjobPageText']['text']) and $this->request->data['DreamjobPageImage']['image']['error']==0){
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.page.oneType.error'),'flash',array('alert'=>'danger'));
|
2014-03-26 09:15:43 +01:00
|
|
|
}else{
|
|
|
|
$this->request->data['DreamjobPageInh']['user_id']=$profil['AppUser']['id'];
|
|
|
|
if($this->request->data['DreamjobPageImage']['image']['error']==0){
|
|
|
|
unset($this->request->data['DreamjobPageText']);
|
|
|
|
$this->DreamjobPageImage->create();
|
|
|
|
$result = $this->DreamjobPageImage->saveAndUpload($this->request->data);
|
|
|
|
}else{
|
|
|
|
unset($this->request->data['DreamjobPageImage']);
|
|
|
|
$this->DreamjobPageText->create();
|
|
|
|
$result = $this->DreamjobPageText->saveAssociated($this->request->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$result)
|
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.page.save.error'),'flash',array('alert'=>'danger'));
|
|
|
|
}
|
2014-03-23 10:16:15 +01:00
|
|
|
}
|
|
|
|
}
|
2014-03-26 09:15:43 +01:00
|
|
|
if($result){
|
|
|
|
$this->MiconwareSession->refreshCache();
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.page.save.success'),'flash',array('alert'=>'success'));
|
2014-03-26 09:15:43 +01:00
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
|
|
|
if(empty($profil) or count($profil) <= 0)
|
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
|
|
|
}
|
2014-03-18 09:34:04 +01:00
|
|
|
$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'));
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->render('/Home/error');
|
|
|
|
}else{
|
2014-03-28 16:22:19 +01:00
|
|
|
if($this->request->is('post')){
|
2014-04-01 20:58:36 +02:00
|
|
|
$tosave = array();
|
|
|
|
if(isset($this->request->data['DreamjobISearch'])){
|
2014-03-29 21:09:17 +01:00
|
|
|
$tosave = $this->request->data['DreamjobISearch'];
|
|
|
|
foreach($tosave as $i => $a)
|
|
|
|
$tosave[$i]['worker_id']=$profil['AppUser']['id'];
|
2014-04-01 20:58:36 +02:00
|
|
|
}
|
2014-03-29 21:09:17 +01:00
|
|
|
$result = $this->DreamjobISearch->saveAndDelete($tosave,$profil['DreamjobISearch']);
|
2014-03-28 16:22:19 +01:00
|
|
|
if($result){
|
2014-03-29 21:09:17 +01:00
|
|
|
$this->MiconwareSession->refreshCache();
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.save.success'),'flash',array('alert'=>'success'));
|
2014-03-28 16:22:19 +01:00
|
|
|
}else{
|
2014-04-29 20:49:20 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.save.error'),'flash',array('alert'=>'danger'));
|
2014-03-28 16:22:19 +01:00
|
|
|
}
|
|
|
|
}
|
2014-03-18 09:34:04 +01:00
|
|
|
$this->request->data = $profil;
|
2014-03-28 16:22:19 +01:00
|
|
|
$this->set('kindofjobs',$this->DreamjobListKindofjob->find('list'));
|
|
|
|
$this->set('jobs',$this->DreamjobListJob->find('list'));
|
|
|
|
$this->set('branches',$this->DreamjobListBranch->find('list'));
|
2014-03-15 13:56:26 +01:00
|
|
|
$this->set('profil',$profil);
|
|
|
|
$this->render('/User/settings_isearch');
|
|
|
|
}
|
|
|
|
}
|
2014-04-13 21:11:21 +02:00
|
|
|
public function profil_delete() {
|
|
|
|
$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'));
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-04-13 21:11:21 +02:00
|
|
|
$this->render('/Home/error');
|
|
|
|
}else{
|
|
|
|
if ($this->request->is('post')){
|
|
|
|
$key = $this->MiconwareSession->generateKey();
|
|
|
|
$profil['User']['code'] = "d:".$key;
|
|
|
|
$result = $this->User->sendDelete($profil);
|
|
|
|
|
|
|
|
if($result){
|
2014-04-29 20:49:20 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.delete.agree'),'flash',array('alert'=>'success'));
|
2014-04-13 21:11:21 +02:00
|
|
|
}else{
|
2014-04-29 20:49:20 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.delete.error'),'flash',array('alert'=>'danger'));
|
2014-04-13 21:11:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->render('/User/settings_account_delete');
|
|
|
|
}
|
|
|
|
}
|
2014-04-15 19:47:57 +02:00
|
|
|
public function avatar_upload() {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
$this->layout = 'default';
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$this->RequestHandler->setContent('html', 'application/html' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$profil = $this->MiconwareSession->getApplication('AppUser');
|
|
|
|
|
|
|
|
if(empty($profil) or count($profil) <= 0){
|
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
|
2014-04-15 19:47:57 +02:00
|
|
|
$this->render('/Home/error');
|
|
|
|
}else{
|
|
|
|
if($this->request->is('put') or $this->request->is('post')){
|
|
|
|
$data['AppUser']['id'] = $profil['AppUser']['id'];
|
|
|
|
$data['AppUser']['take_systemwide'] = $profil['AppUser']['take_systemwide'];
|
|
|
|
$data['AppUser']['user_id'] = $profil['AppUser']['user_id'];
|
|
|
|
$data['AppUser']['avatar'] = $this->request->data['AppUser']['avatar'];
|
|
|
|
$result = $this->AppUser->imageUpload($data);
|
|
|
|
if($result){
|
2014-06-10 18:37:45 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.avatar.success'),'flash',array('alert'=>'success'));
|
2014-04-15 19:47:57 +02:00
|
|
|
}else{
|
2014-04-29 20:49:20 +02:00
|
|
|
$this->MiconwareSession->setFlash(__('dreamjob.settings.avatar.error'),'flash',array('alert'=>'danger'));
|
2014-04-15 19:47:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->request->data = $profil;
|
|
|
|
$this->render('/User/settings_imageUpload');
|
|
|
|
}
|
|
|
|
}
|
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'));
|
2014-04-11 19:43:26 +02:00
|
|
|
$this->set('data', $this->DreamjobJobMsg->find('first'));
|
2014-02-18 12:10:29 +01:00
|
|
|
$this->render('/User/test');
|
|
|
|
}
|
|
|
|
}
|