delete pages

This commit is contained in:
Martin Müller 2014-03-26 19:49:36 +01:00
parent 8d4e2bdda8
commit 0ff21cece8
6 changed files with 77 additions and 23 deletions

View File

@ -20,11 +20,20 @@ class HomeController extends AppController {
* @throws NotFoundException When the view file could not be found * @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode. * or MissingViewException in debug mode.
*/ */
private $home_opening_condition = array('contitions'=>array('active'=>true),'order'=>'DreamjobJobOpening.id DESC','limit'=>3); public static function getOpeningCondition(){
return array('and'=>array(
'DreamjobJobOpening.active'=>true,
'DreamjobJobOpening.startdate <='=> date("Y-m-d"),
'DreamjobJobOpening.enddate >='=> date("Y-m-d", strtotime("+1 day"))
));
}
private $opening_limit = 3;
public function home() { public function home() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this); $this->MiconwareSession->initWeb($this);
$openings = $this->DreamjobJobOpening->find('all',$this->home_opening_condition); $openings = $this->DreamjobJobOpening->find('all',array('conditions'=>HomeController::getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> $this->opening_limit));
$this->set('openings',$openings); $this->set('openings',$openings);
$this->set('title', 'dreamjob.startpage'); $this->set('title', 'dreamjob.startpage');
$this->set('MENU_START', true); $this->set('MENU_START', true);
@ -51,7 +60,8 @@ class HomeController extends AppController {
$this->MiconwareSession->initWeb($this); $this->MiconwareSession->initWeb($this);
$openings = $this->DreamjobJobOpening->find('all',$this->home_opening_condition); $openings = $this->DreamjobJobOpening->find('all',array('conditions'=>HomeController::getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> $this->opening_limit));
$this->set('openings',$openings); $this->set('openings',$openings);
$this->set('title', 'dreamjob.startpage'); $this->set('title', 'dreamjob.startpage');
$this->set('MENU_START', true); $this->set('MENU_START', true);
@ -67,7 +77,8 @@ class HomeController extends AppController {
$this->MiconwareSession->setFlash('dreamjob.loggingoutError','flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash('dreamjob.loggingoutError','flash',array('alert'=>'danger'));
$this->MiconwareSession->initWeb($this); $this->MiconwareSession->initWeb($this);
$openings = $this->DreamjobJobOpening->find('all',$this->home_opening_condition); $openings = $this->DreamjobJobOpening->find('all',array('conditions'=>HomeController::getOpeningCondition(),
'order'=>'DreamjobJobOpening.id DESC','limit'=> $this->opening_limit));
$this->set('openings',$openings); $this->set('openings',$openings);
$this->set('title', 'dreamjob.startpage'); $this->set('title', 'dreamjob.startpage');
$this->set('MENU_START', true); $this->set('MENU_START', true);

View File

@ -133,7 +133,9 @@ class JobController extends AppController {
$this->MiconwareSession->setFlash('dreamjob.opening.fav.add','flash',array('alert'=>'success')); $this->MiconwareSession->setFlash('dreamjob.opening.fav.add','flash',array('alert'=>'success'));
} }
} }
$opening = $this->DreamjobJobOpening->find('first',array('conditions' => array('DreamjobJobOpening.id' => $this->request->params['id']))); $con = HomeController::getOpeningCondition();
$con['DreamjobJobOpening.id'] = $this->request->params['id'];
$opening = $this->DreamjobJobOpening->find('first',array('conditions' => $con));
} }
@ -161,7 +163,9 @@ class JobController extends AppController {
$fav_id = array(); $fav_id = array();
foreach($self['Favority'] as $fav) foreach($self['Favority'] as $fav)
$fav_id[]=$fav['id']; $fav_id[]=$fav['id'];
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => array('DreamjobJobOpening.id' =>$fav_id))); $con = HomeController::getOpeningCondition();
$con['DreamjobJobOpening.id'] =$fav_id;
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con));
$this->set('openings',$openings); $this->set('openings',$openings);
$this->set('opening_MINI',true); $this->set('opening_MINI',true);
$this->render('/Job/favorite'); $this->render('/Job/favorite');
@ -310,7 +314,9 @@ class JobController extends AppController {
if(!empty($w)){ if(!empty($w)){
$opening = null; $opening = null;
if(!empty($this->request->params['id'])){ if(!empty($this->request->params['id'])){
$opening = $this->DreamjobJobOpening->find('first',array('conditions' => array('DreamjobJobOpening.id' => $this->request->params['id']))); $con = HomeController::getOpeningCondition();
$con['DreamjobJobOpening.id'] = $this->request->params['id'];
$opening = $this->DreamjobJobOpening->find('first',array('conditions' => $con));
} }
if(!is_array($opening) or count($opening) <= 0 ){ if(!is_array($opening) or count($opening) <= 0 ){
$this->set('error', 'dreamjob.error.opening.notFound'); $this->set('error', 'dreamjob.error.opening.notFound');

View File

@ -100,7 +100,9 @@ class UserController extends AppController {
$this->set('page',$page); $this->set('page',$page);
if(!$hard_error) if(!$hard_error)
if($company){ if($company){
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => array('DreamjobJobOpening.company_id' => $profil['AppUser']['id'],'DreamjobJobOpening.active'=>1))); $con = HomeController::getOpeningCondition();
$con['DreamjobJobOpening.company_id'] = $profil['AppUser']['id'];
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con));
$this->set("openings",$openings); $this->set("openings",$openings);
$this->render('/User/company'); $this->render('/User/company');
}else }else
@ -246,6 +248,7 @@ class UserController extends AppController {
$profil['DreamjobWorker']['iam'] = $this->request->data['DreamjobWorker']['iam']; $profil['DreamjobWorker']['iam'] = $this->request->data['DreamjobWorker']['iam'];
$profil['DreamjobWorker']['graducation_id'] = $this->request->data['DreamjobWorker']['graducation_id']; $profil['DreamjobWorker']['graducation_id'] = $this->request->data['DreamjobWorker']['graducation_id'];
$profil['DreamjobWorker']['searchhidden'] = $this->request->data['DreamjobWorker']['searchhidden']; $profil['DreamjobWorker']['searchhidden'] = $this->request->data['DreamjobWorker']['searchhidden'];
$profil['DreamjobWorker']['workexperience'] = $this->request->data['DreamjobWorker']['workexperience'];
$result = $this->DreamjobWorker->saveSettings($profil); $result = $this->DreamjobWorker->saveSettings($profil);
} }
@ -264,7 +267,7 @@ class UserController extends AppController {
$this->request->data = $profil; $this->request->data = $profil;
$this->set('profil',$profil); $this->set('profil',$profil);
$this->set('graducations',$this->DreamjobListGraducation->find('list')); $this->set('graducations',$this->DreamjobListGraducation->find('list'));
$this->set('mannerofaddresss',$this->Mannerofaddress->find('list')); $this->set('mannerofaddresses',$this->Mannerofaddress->find('list'));
$this->render('/User/settings_account'); $this->render('/User/settings_account');
} }
} }
@ -288,6 +291,7 @@ class UserController extends AppController {
$this->set('error', 'dreamjob.error.noPermision'); $this->set('error', 'dreamjob.error.noPermision');
$this->render('/Home/error'); $this->render('/Home/error');
}else{ }else{
//PAGE BEARBEITEN
if(!empty($this->request->params['page'])){ if(!empty($this->request->params['page'])){
$image = false; $image = false;
$page = $this->DreamjobPageText->find('first', $page = $this->DreamjobPageText->find('first',
@ -319,6 +323,45 @@ class UserController extends AppController {
}else }else
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
}else{ }else{
// 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){
$path = WWW_ROOT.$page['DreamjobPageImage']['image'];
$result = $this->DreamjobPageImage->delete($page['DreamjobPageInh']['id'],false);
}else
$result = $this->DreamjobPageText->delete($page['DreamjobPageInh']['id'],false);
if($result){
$result = $this->DreamjobPageInh->delete($page['DreamjobPageInh']['id'],false);
}
if($path!=null and $result){
$result = unlink($path);
}
if($result){
$this->MiconwareSession->refreshCache();
$profil = $this->MiconwareSession->getWorker();
if(empty($profil) or count($profil) <= 0)
$profil = $this->MiconwareSession->getCompany();
$this->MiconwareSession->setFlash('dreamjob.pages.delete','flash',array('alert'=>'success'));
}else{
$this->MiconwareSession->setFlash('dreamjob.pages.delete.error','flash',array('alert'=>'danger'));
}
}
$result = false;
}
// NEW PAGE
if($this->request->is('post')){ if($this->request->is('post')){
if(!empty($this->request->data['DreamjobPageText']['text']) and $this->request->data['DreamjobPageImage']['image']['error']==0){ if(!empty($this->request->data['DreamjobPageText']['text']) and $this->request->data['DreamjobPageImage']['image']['error']==0){
$this->MiconwareSession->setFlash(__('dreamjob.page.oneType'),'flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash(__('dreamjob.page.oneType'),'flash',array('alert'=>'danger'));

View File

@ -111,11 +111,6 @@ if($profil['AppUser']['take_systemwide']){
</ul> </ul>
</div> </div>
<?php <?php
if(!empty($edit)){
?>
Bearbeiten.
<?php
}
if(!empty($page)){ if(!empty($page)){
echo $this->element('user_page'); echo $this->element('user_page');
}else{ }else{

View File

@ -204,14 +204,12 @@ body.loading #container{
.box-extra-left{ .box-extra-left{
display:table-cell; display:table-cell;
width:240px; width:240px;
height: 220px; min-height: 220px;
float:left; float:left;
} }
.box-extra-left > .box{ .box-extra-left > .box{
width:200px; width:200px;
height: 200px; height: 200px;
margin:0px;
margin-right: 20px;
padding: 10px; padding: 10px;
vertical-align: middle; vertical-align: middle;
display:table-cell; display:table-cell;
@ -233,6 +231,7 @@ body.loading #container{
margin-top:6px; margin-top:6px;
margin-bottom: 24px; margin-bottom: 24px;
display:table; display:table;
width:100%;
} }
.box-title h1{ .box-title h1{
text-align: center; text-align: center;

View File

@ -10,14 +10,14 @@
CREATE TABLE IF NOT EXISTS `mic_dj_job_opening_worker` ( CREATE TABLE IF NOT EXISTS `mic_dj_jobs_opening_worker` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`opening_id` int(11) NOT NULL, `opening_id` int(11) NOT NULL,
`worker_id` int(11) NOT NULL, `worker_id` int(11) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `opening_id` (`opening_id`,`worker_id`), UNIQUE KEY `opening_id` (`opening_id`,`worker_id`),
KEY `mic_dj_job_opening_worker_favOpening` (`opening_id`), KEY `mic_dj_jobs_opening_worker_favOpening` (`opening_id`),
KEY `mic_dj_job_opening_worker_favWorker` (`worker_id`) KEY `mic_dj_jobs_opening_worker_favWorker` (`worker_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
@ -36,6 +36,6 @@ ALTER TABLE `mic_dj_account_cmpy` ADD `pro_user` INT NOT NULL ;
-- --
-- Constraints der Tabelle `mic_dj_job_opening_worker` -- Constraints der Tabelle `mic_dj_job_opening_worker`
-- --
ALTER TABLE `mic_dj_job_opening_worker` ALTER TABLE `mic_dj_jobs_opening_worker`
ADD CONSTRAINT `mic_dj_job_opening_worker_favOpening` FOREIGN KEY (`opening_id`) REFERENCES `mic_dj_jobs_opening` (`id`), ADD CONSTRAINT `mic_dj_jobs_opening_worker_favOpening` FOREIGN KEY (`opening_id`) REFERENCES `mic_dj_jobs_opening` (`id`),
ADD CONSTRAINT `mic_dj_job_opening_worker_favWorker` FOREIGN KEY (`worker_id`) REFERENCES `mic_dj_account_wrk` (`djaccount_ptr_id`); ADD CONSTRAINT `mic_dj_jobs_opening_worker_favWorker` FOREIGN KEY (`worker_id`) REFERENCES `mic_dj_account_wrk` (`djaccount_ptr_id`);