101 lines
3.3 KiB
PHP
Executable File
101 lines
3.3 KiB
PHP
Executable File
<?php
|
|
|
|
App::uses('AppController', 'Controller');
|
|
|
|
class UserController extends AppController {
|
|
|
|
/**
|
|
* This controller use User Model
|
|
*
|
|
* @var array
|
|
*/
|
|
public $uses = array('DreamjobListGraducation','DreamjobWorker','DreamjobCompany','DreamjobPageText','DreamjobPageImage','DreamjobJobOpening');
|
|
|
|
/**
|
|
* 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);
|
|
|
|
|
|
|
|
//self check
|
|
$self_company = false;
|
|
$self = $this->MiconwareSession->getApplication('DreamjobWorker');
|
|
if(!is_array($self) or count($self)<= 0){
|
|
$self = $this->MiconwareSession->getApplication('DreamjobCompany');
|
|
$self_company = true;
|
|
}
|
|
|
|
//get Profil
|
|
$company = false;
|
|
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
|
|
|
|
$page = null;
|
|
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']))
|
|
);
|
|
}
|
|
}
|
|
|
|
//error
|
|
$hard_error = false;
|
|
if($profil['AppUser']['id'] != $self['AppUser']['id']){
|
|
if(($company == $self_company) and !($this->MiconwareSession->isStaff())){
|
|
$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){
|
|
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => array('DreamjobJobOpening.company_id' => $profil['AppUser']['id'])));
|
|
$this->set("openings",$openings);
|
|
$this->render('/User/company');
|
|
}else
|
|
$this->render('/User/worker');
|
|
}
|
|
|
|
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');
|
|
}
|
|
}
|