dreamjob/app/Controller/HomeController.php

125 lines
4.2 KiB
PHP
Raw Normal View History

2015-03-31 14:49:03 +02:00
<?php
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
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 static $opening_limit = 5;
function beforeFilter(){
$this->Security->unlockedActions[]="login";
parent::beforeFilter();
}
public function home() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$c = $this->MiconwareSession->getCompany();
if (!empty($c))
return $this->redirect(array('controller'=>'home','action' => 'company'));
$openings = $this->DreamjobJobOpening->find('all',array('conditions'=>$this->MiconwareSession->getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> self::$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.success'),'flash',array('alert'=>'success'));
}else{
$this->MiconwareSession->setFlash(__('dreamjob.loggedin.error'),'flash',array('alert'=>'danger'));
}
}else{
if(isset($this->params['url']['mail']) && isset($this->params['url']['password'])){
$this->request->data['User']['mail'] = $this->params['url']['mail'];
$this->request->data['User']['password'] = $this->params['url']['password'];
}
}
$this->MiconwareSession->initWeb($this);
$this->render('/Home/login');
}
public function logout(){
$this->MiconwareSession->init($this);
if($this->MiconwareSession->logout())
$this->MiconwareSession->setFlash(__('dreamjob.loggingout.success'),'flash',array('alert'=>'success'));
else
$this->MiconwareSession->setFlash(__('dreamjob.loggingout.error'),'flash',array('alert'=>'danger'));
$this->MiconwareSession->initWeb($this);
$openings = $this->DreamjobJobOpening->find('all',array('conditions'=>$this->MiconwareSession->getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> self::$opening_limit));
$this->set('openings',$openings);
$this->set('title', __('dreamjob.startpage'));
$this->set('MENU_START', true);
$this->render('/Home/home');
}
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');
}
public function company() {
if($this->request->is('post')){
$Email = new CakeEmail('dreamjobMain');
$Email->to('service@dream-job.eu');
$Email->from(array($this->request->data['mail']['adresse'] => $this->request->data['mail']['first_name'].' '.$this->request->data['mail']['last_name']));
$Email->subject('[Dreamjob-Kontakt-Firma]'.$this->request->data['mail']['subject']);
$Email->template('contact');
$Email->viewVars(array('text'=>$this->request->data,'strip_tags'=>$this->MiconwareSession->strip_tags));
if($Email->send())
$this->MiconwareSession->setFlash(__('dreamjob.contactSend.success'),'flash',array('alert'=>'success'));
else
$this->MiconwareSession->setFlash(__('dreamjob.contactSend.error'),'flash',array('alert'=>'danger'));
}
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$this->set('MENU_START_company', true);
$this->set('title', __('dreamjob.company'));
$this->render('/Home/company');
}
}