dreamjob/app/Controller/HomeController.php

106 lines
3.2 KiB
PHP
Executable File

<?php
App::uses('AppController', 'Controller');
class HomeController extends AppController {
/**
* This controller use User Model
*
* @var array
*/
public $uses = array("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.
*/
private $opening_limit = 3;
public function home() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$openings = $this->DreamjobJobOpening->find('all',array('conditions'=>$this->MiconwareSession->getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> $this->opening_limit));
$this->set('openings',$openings);
$this->set('title', 'dreamjob.startpage');
$this->set('MENU_START', true);
$this->render('/Home/home');
}
public function login(){
$this->MiconwareSession->init($this);
if($this->request->is('post') and isset($this->request->data['User']['mail']) and isset($this->request->data['User']['password'])){
if($this->MiconwareSession->login(
$this->request->data['User']['mail'],
$this->request->data['User']['password'])
){
$this->MiconwareSession->refreshCache();
$this->MiconwareSession->setFlash(__('dreamjob.loggedin'),'flash',array('alert'=>'success'));
}else{
$this->MiconwareSession->setFlash(__('dreamjob.loggedinError'),'flash',array('alert'=>'danger'));
}
}else{
$this->MiconwareSession->setFlash(__('dreamjob.loggedinError'),'flash',array('alert'=>'danger'));
}
$this->MiconwareSession->initWeb($this);
$openings = $this->DreamjobJobOpening->find('all',array('conditions'=>$this->MiconwareSession->getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> $this->opening_limit));
$this->set('openings',$openings);
$this->set('title', 'dreamjob.startpage');
$this->set('MENU_START', true);
$this->render('/Home/home');
}
public function logout(){
$this->MiconwareSession->init($this);
if($this->MiconwareSession->logout())
$this->MiconwareSession->setFlash(__('dreamjob.loggingoutSucess'),'flash',array('alert'=>'success'));
else
$this->MiconwareSession->setFlash(__('dreamjob.loggingoutError'),'flash',array('alert'=>'danger'));
$this->MiconwareSession->initWeb($this);
$openings = $this->DreamjobJobOpening->find('all',array('conditions'=>$this->MiconwareSession->getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> $this->opening_limit));
$this->set('openings',$openings);
$this->set('title', 'dreamjob.startpage');
$this->set('MENU_START', true);
$this->render('/Home/home');
}
public function contact() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$this->set('title', 'dreamjob.contact');
$this->render('/Home/contact');
}
public function impressum() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$this->set('title', 'dreamjob.impressum');
$this->render('/Home/impressum');
}
public function agb() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$this->set('title', 'dreamjob.agb');
$this->render('/Home/agb');
}
}