favoriten

This commit is contained in:
Martin Müller 2014-02-19 00:02:17 +01:00
parent 2d72ae7982
commit 27e5c04e28
12 changed files with 185 additions and 97 deletions

View File

@ -35,6 +35,13 @@
Router::connect('/user/:id', array('controller' => 'user', 'action' => 'profil'),array("id" => "[0-9]+")); Router::connect('/user/:id', array('controller' => 'user', 'action' => 'profil'),array("id" => "[0-9]+"));
Router::connect('/user/:id/page/:page', array('controller' => 'user', 'action' => 'profil'),array("id" => "[0-9]+","page" => "[0-9]+")); Router::connect('/user/:id/page/:page', array('controller' => 'user', 'action' => 'profil'),array("id" => "[0-9]+","page" => "[0-9]+"));
Router::connect('/opening', array('controller' => 'job', 'action' => 'openingList'));
Router::connect('/opening/add', array('controller' => 'job', 'action' => 'openingAdd'));
Router::connect('/opening/:id', array('controller' => 'job', 'action' => 'openingGet'),array("id" => "[0-9]+"));
Router::connect('/opening/:id/:favorite', array('controller' => 'job', 'action' => 'openingGet'), array("id" => "[0-9]+",'favorite' => '(?i:favorite)'));
Router::connect('/favorite', array('controller' => 'job', 'action' => 'favorite'));
Router::connect('/test/', array('controller' => 'user', 'action' => 'test')); Router::connect('/test/', array('controller' => 'user', 'action' => 'test'));
/** /**
* ...and connect the rest of 'Pages' controller's URLs. * ...and connect the rest of 'Pages' controller's URLs.

View File

@ -3,14 +3,21 @@ App::uses('Component', 'Controller');
class MiconwareSessionComponent extends Component { class MiconwareSessionComponent extends Component {
public $components = array('Session'); public $components = array('Session');
public $self_worker_obj;
public $self_company_obj;
public function init($controller){ public function init($controller){
$controller->Security->requireSecure(); $controller->Security->requireSecure();
$this->User = ClassRegistry::init('User'); $this->User = ClassRegistry::init('User');
$this->refreshCache();
} }
public function initWeb($controller){ public function initWeb($controller){
$controller->set("isLoggedin",$this->isLoggedin()); $controller->set("isLoggedin",$this->isLoggedin());
if($this->isLoggedin()){
$controller->set("WORKER",($this->self_worker_obj)?$this->self_worker_obj:false);
$controller->set("COMPANY",($this->self_company_obj)?$this->self_company_obj:false);
}
$controller->set("isStaff",$this->isStaff()); $controller->set("isStaff",$this->isStaff());
$controller->set("MEDIA_URL","http://dev.dreamjob.cc/media/"); $controller->set("MEDIA_URL","http://dev.dreamjob.cc/media/");
$controller->set('default',array( $controller->set('default',array(
@ -22,13 +29,30 @@ class MiconwareSessionComponent extends Component {
'class' => '')) 'class' => ''))
); );
} }
public function refreshCache(){
if($this->isLoggedin()){
$self_company = false;
$this->self_worker_obj = $this->getApplication('DreamjobWorker');
if(!is_array($this->self_worker_obj) or count($this->self_worker_obj)<= 0){
$this->self_company_obj = $this->getApplication('DreamjobCompany');
$self_company = true;
}
}
}
public function getCompany(){
return $this->self_company_obj;
}
public function getWorker(){
return $this->self_worker_obj;
}
public function isLoggedin(){ public function isLoggedin(){
return $this->Session->check('user'); return $this->Session->check('user');
} }
public function isStaff(){ public function isStaff(){
return true; return false;
} }
public function login($mail,$password){ public function login($mail,$password){

View File

@ -28,14 +28,19 @@ class UserController extends AppController {
//self check //self check
$self_company = false; $self_company = false;
$self = $this->MiconwareSession->getApplication('DreamjobWorker'); $self = $this->MiconwareSession->getWorker();
if(!is_array($self) or count($self)<= 0){ if(!is_array($self) or count($self)<= 0){
$self = $this->MiconwareSession->getApplication('DreamjobCompany'); $self = $this->MiconwareSession->getCompany();
$self_company = true; $self_company = true;
} }
//get Profil //get Profil
$hard_error = false;
$company = false; $company = false;
$page = null;
$profil = null;
if(empty($this->request->params['id'])) { if(empty($this->request->params['id'])) {
$profil = $self; $profil = $self;
$company = $self_company; $company = $self_company;
@ -48,24 +53,23 @@ class UserController extends AppController {
$this->set('id', $this->request->params['id']); $this->set('id', $this->request->params['id']);
} }
//get Page //get Page
if(($this->MiconwareSession->isLoggedin()) or ($company) ){
$page = null; if(is_array($profil) or count($profil) > 0){
if(is_array($profil) or count($profil) > 0){ if(!empty($this->request->params['page'])){
if(!empty($this->request->params['page'])){ $page = $this->DreamjobPageText->find('first',
$page = $this->DreamjobPageText->find('first', array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id'])) );
); if(!is_array($page) or count($page)<= 0)
if(!is_array($page) or count($page)<= 0) $page = $this->DreamjobPageImage->find('first',
$page = $this->DreamjobPageImage->find('first', array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id'])) );
); }
} }
} }else
$hard_error = true;
//error //error
$hard_error = false; if(!$company and $profil['AppUser']['id'] != $self['AppUser']['id'] or $hard_error){
if($profil['AppUser']['id'] != $self['AppUser']['id']){ if(($company == $self_company) and !($this->MiconwareSession->isStaff()) or $hard_error){
if(($company == $self_company) and !($this->MiconwareSession->isStaff())){
$hard_error = true; $hard_error = true;
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
$this->set('error', 'dreamjob.error.noPermision'); $this->set('error', 'dreamjob.error.noPermision');

View File

@ -91,6 +91,16 @@ class DreamjobCompany extends AppModel {
//'on' => 'create', // Limit validation to 'create' or 'update' operations //'on' => 'create', // Limit validation to 'create' or 'update' operations
), ),
), ),
'pro_user' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
); );
@ -113,8 +123,14 @@ class DreamjobCompany extends AppModel {
'AppUser' => array( 'AppUser' => array(
'className' => 'AppUser', 'className' => 'AppUser',
'foreignKey' => 'id' 'foreignKey' => 'id'
) ),
); 'User' => array(
'className' => 'User',
'foreignKey' => false,
'conditions' => array('DreamjobCompany.djaccount_ptr_id=AppUser.id and User.id = AppUser.user_id'),
'limit' => 1
)
);
public $hasMany = array( public $hasMany = array(
'DreamjobPageInh' => array( 'DreamjobPageInh' => array(
'className' => 'DreamjobPageInh', 'className' => 'DreamjobPageInh',

View File

@ -176,10 +176,15 @@ class DreamjobJobOpening extends AppModel {
public $belongsTo = array( public $belongsTo = array(
'DreamjobCompany' => array( 'DreamjobCompany' => array(
'className' => 'DreamjobCompany', 'className' => 'DreamjobCompany',
'foreignKey' => 'company_id', 'foreignKey' => 'company_id'
'conditions' => '', ),
'fields' => '', 'DreamjobUser' => array(
'order' => '' 'className' => 'DreamjobUser',
'foreignKey' => 'company_id'
),
'AppUser' => array(
'className' => 'AppUser',
'foreignKey' => 'company_id'
), ),
'DreamjobListGraducation' => array( 'DreamjobListGraducation' => array(
'className' => 'DreamjobListGraducation', 'className' => 'DreamjobListGraducation',
@ -196,4 +201,12 @@ class DreamjobJobOpening extends AppModel {
'order' => '' 'order' => ''
) )
); );
public $hasOne = array(
'User' => array(
'className' => 'User',
'foreignKey' => false,
'conditions' => array('DreamjobJobOpening.company_id = AppUser.id and User.id = AppUser.user_id'),
'limit' => 1
)
);
} }

View File

@ -123,15 +123,20 @@ class DreamjobWorker extends AppModel {
); );
public $hasAndBelongsToMany = array( public $hasAndBelongsToMany = array(
'User' => 'User' =>array(
array( 'className' => 'User',
'className' => 'User', 'with' => 'AppUser',
'with' => 'AppUser', 'foreignKey' => 'id',
//'joinTable' => 'mic_sys_micapp', 'associationForeignKey' => 'user_id',
'foreignKey' => 'id', 'limit' => 1
'associationForeignKey' => 'user_id', ),
'limit' => 1 'Favority' => array(
) 'className' => 'DreamjobJobOpening',
'with' => 'DreamjobJobFavority',
//'joinTable' => 'mic_dj_job_opening_worker',
'foreignKey' => 'worker_id',
'associationForeignKey' => 'opening_id'
)
); );
public $belongsTo = array( public $belongsTo = array(
'DreamjobListGraducation' => array( 'DreamjobListGraducation' => array(
@ -147,6 +152,12 @@ class DreamjobWorker extends AppModel {
'AppUser' => array( 'AppUser' => array(
'className' => 'AppUser', 'className' => 'AppUser',
'foreignKey' => 'id' 'foreignKey' => 'id'
),
'User' => array(
'className' => 'User',
'foreignKey' => false,
'conditions' => array('DreamjobWorker.djaccount_ptr_id=AppUser.id and User.id = AppUser.user_id'),
'limit' => 1
) )
); );
public $hasMany = array( public $hasMany = array(

View File

@ -21,13 +21,13 @@ if($isLoggedin){
<ul class="list-unstyled"> <ul class="list-unstyled">
<li<?php if(isset($MENU_PROFIL)){?> class="active"<?php } ?>><?=$this->Html->image('bar-profil.png',array('url'=>array('controller'=>'user','action'=>'profil'))); ?></li> <li<?php if(isset($MENU_PROFIL)){?> class="active"<?php } ?>><?=$this->Html->image('bar-profil.png',array('url'=>array('controller'=>'user','action'=>'profil'))); ?></li>
<c:if test="${COMPANY!=null}"> <?php if(!empty($COMPANY)){ ?>
<li<?php if(isset($MENU_OPENING)){?> class="active"<?php } ?>><a href="<c:url value="${URL}opening/"/>"><img src="<c:url value="${STATIC_URL}img/bar-job.png"/>"/></a></li> <li<?php if(isset($MENU_OPENING)){?> class="active"<?php } ?>>
</c:if> <?=$this->Html->image('bar-job.png',array('url'=>array('controller'=>'job','action'=>'openingList'))); ?></a></li>
<c:if test="${WORKER!=null}"> <?php }elseif(!empty($WORKER)){ ?>
<li<?php if(isset($MENU_APPLICATION)){?> class="active"<?php } ?>><a href="<c:url value="${URL}application/"/>"><img src="<c:url value="${STATIC_URL}img/bar-job.png"/>"/></a></li> <li<?php if(isset($MENU_APPLICATION)){?> class="active"<?php } ?>><a href="<c:url value="${URL}application/"/>"><img src="<c:url value="${STATIC_URL}img/bar-job.png"/>"/></a></li>
<li<?php if(isset($MENU_FAVORITY)){?> class="active"<?php } ?>><a href="<c:url value="${URL}favority/"/>"><img src="<c:url value="${STATIC_URL}img/bar-favority.png"/>"/></a></li> <li<?php if(isset($MENU_FAVORITY)){?> class="active"<?php } ?>><?=$this->Html->image('bar-favority.png',array('url'=>array('controller'=>'job','action'=>'favorite'))); ?></a></li>
</c:if> <?php } ?>
<li<?php if(isset($MENU_SETTINGS)){?> class="active"<?php } ?>><a href=""><img src="<c:url value="${STATIC_URL}img/bar-settings.png"/>"/></a></li> <li<?php if(isset($MENU_SETTINGS)){?> class="active"<?php } ?>><a href=""><img src="<c:url value="${STATIC_URL}img/bar-settings.png"/>"/></a></li>
</ul> </ul>
<?php <?php

View File

@ -2,50 +2,61 @@
/* /*
* *
*/ */
$opening_in_fav = false;
$opening_in_app = false; $opening_in_app = false;
$opening_in_fav=false;
if(is_array($WORKER) and count($WORKER)>0){
foreach($WORKER['Favority'] as $val){
if($val['id'] == $opening['DreamjobJobOpening']['id'])
$opening_in_fav=true;
}
}
$avatar = false;
if($opening['AppUser']['take_systemwide']){
if($opening['User']['avatar'])
$avatar = true;
}else{
if($opening['AppUser']['avatar'])
$avatar = true;
}
?> ?>
<c:if test="${WORKER!=null}">
<c:forEach var="item" items="${WORKER.applications}">
<c:if test="${item.opening.id eq opening.id}">
<c:set var="opening_in_app" value="true" />
<c:set var="opening_app" value="${item}" />
</c:if>
</c:forEach>
<c:forEach var="item" items="${WORKER.favority}">
<c:if test="${item.id eq opening.id}">
<c:set var="opening_in_fav" value="true" />
</c:if>
</c:forEach>
</c:if>
<c:if test="${empty opening_MINI || not (opening_in_app || opening_in_fav)}"> <c:if test="${empty opening_MINI || not (opening_in_app || opening_in_fav)}">
<div class="openingitem"> <div class="openingitem">
<h3><?=$opening['DreamjobJobOpening']['title'];?></h3> <h3><?=$opening['DreamjobJobOpening']['title'];?></h3>
<c:if test="${WORKER!=null}"> <c:if test="${WORKER!=null}">
<c:if test="${not opening_in_app}"> <c:if test="${not opening_in_app}">
<span style="float: right;"> <span style="float: right;">
<a href="<c:url value="${URL}favority/toggle/${opening.id}/"/>"><c:choose> <?php
<c:when test="${opening_in_fav}"><img src="<c:url value="${STATIC_URL}img/favority_on.png"/>"/></c:when><c:otherwise><img src="<c:url value="${STATIC_URL}img/favority_off.png"/>"/></c:otherwise></c:choose></a> $image='favority_off.png';
if($opening_in_fav)
$image='favority_on.png';
echo $this->Html->image($image,array('url' => array('controller'=>'job','action'=>'openingGet','id'=>$opening['DreamjobJobOpening']['id'],'favorite'=>'favorite')));
?>
</span> </span>
</c:if> </c:if>
</c:if> </c:if>
<div> <div>
<c:choose> <?php if($avatar){ ?>
<c:when test="${opening.company.avatar != null}"> <div class="icon">
<div class="icon"> <span><?=$opening['AppUser']['nickname']." ".$opening['DreamjobCompany']['corporateform'];?></span>
<span><c:out value="${opening.company.nickname}${opening.company.corporateform}"/></span> <div>
<div> <img src="<?php
<img src="<c:url value="${MEDIA_URL}${profil.avatar}"/>"/> if($opening['AppUser']['take_systemwide']){
</div> echo $MEDIA_URL.$opening['User']['avatar'];
}else{
echo $MEDIA_URL.$opening['AppUser']['avatar'];
}
?>"/>
</div> </div>
</c:when> </div>
<c:otherwise> <?php
<div class="noicon-title"> }else{
<span><c:out value="${opening.company.nickname}${opening.company.corporateform}"/></span> ?>
</div> <div class="noicon-title">
</c:otherwise> <span><?=$opening['AppUser']['nickname']." ".$opening['DreamjobCompany']['corporateform'];?></span>
</c:choose> </div>
<?php } ?>
<div class="left"> <div class="left">
<span><?=__("dreamjob.graducation.company");?>: <?=$opening['DreamjobListGraducation']['name'];?></span> <span><?=__("dreamjob.graducation.company");?>: <?=$opening['DreamjobListGraducation']['name'];?></span>
<span><?=__("dreamjob.branch");?>: <?=$opening['DreamjobJobOpening']['branch'];?></span> <span><?=__("dreamjob.branch");?>: <?=$opening['DreamjobJobOpening']['branch'];?></span>
@ -55,15 +66,12 @@
</div> </div>
<div class="right"> <div class="right">
<div class="btn-group-vertical"> <div class="btn-group-vertical">
<a class="btn btn-default" href="<c:url value="${URL}opening/${opening.id}/"/>"> <?=$this->Html->link(__('dreamjob.opening.detail'),array('controller'=>'job', 'action'=>'openingGet', 'id'=> $opening['DreamjobJobOpening']['id']),array("class" => "btn btn-default"));?>
<spring:message code="dreamjob.opening.detail"/> <?php if($COMPANY['AppUser']['id'] == $opening['DreamjobJobOpening']['company_id']){ ?>
</a>
<c:choose>
<c:when test="${COMPANY.id==opening.company.id}">
<a class="btn btn-default" href="<c:url value="${URL}opening/edit/${opening.id}/"/>"> <a class="btn btn-default" href="<c:url value="${URL}opening/edit/${opening.id}/"/>">
<spring:message code="dreamjob.edit"/> <?=__("dreamjob.edit");?>
</a> </a>
</c:when> <?php }elseif(false){ ?>
<c:when test="${opening_in_app}"> <c:when test="${opening_in_app}">
<c:set var="count" value="0"/> <c:set var="count" value="0"/>
<c:set var="newcount" value="0"/> <c:set var="newcount" value="0"/>
@ -79,15 +87,13 @@
<c:if test="${newcount eq count}">${newcount}/</c:if> <c:if test="${newcount eq count}">${newcount}/</c:if>
${count}</span> ${count}</span>
</a> </a>
</c:when> <?php }else{ ?>
<c:otherwise>
<a class="btn btn-default <a class="btn btn-default
<c:if test="${WORKER ==null}">disabled</c:if>" <?php if(!is_array($WORKER) and count($WORKER) <= 0){ ?>disabled<?php } ?>"
href="{% url de.miconware.dreamjob.jobs.views.application_send opening.pk %}"> href="{% url de.miconware.dreamjob.jobs.views.application_send opening.pk %}">
<spring:message code="dreamjob.applicate"/> <?=__("dreamjob.applicate");?>
</a> </a>
</c:otherwise> <?php } ?>
</c:choose>
</div> </div>
</div> </div>
</div> </div>

View File

@ -7,8 +7,8 @@
<div class="bar avatar"> <div class="bar avatar">
<img src="<?php <img src="<?php
if($profil['AppUser']['take_systemwide']) if($profil['AppUser']['take_systemwide'])
if($profil['User'][0]['avatar']) if($profil['User']['avatar'])
echo $MEDIA_URL.$profil['User'][0]['avatar']; echo $MEDIA_URL.$profil['User']['avatar'];
else else
echo $STATIC_URL."img/icon_user.png"; echo $STATIC_URL."img/icon_user.png";
else else
@ -22,7 +22,7 @@
<h1> <h1>
<?php <?php
if($profil['AppUser']['take_systemwide']) if($profil['AppUser']['take_systemwide'])
echo $profil['User'][0]['first_name'].' '.$profil['User'][0]['last_name']; echo $profil['User']['first_name'].' '.$profil['User']['last_name'];
else else
echo $profil['AppUser']['first_name'].' '.$profil['AppUser']['last_name']; echo $profil['AppUser']['first_name'].' '.$profil['AppUser']['last_name'];
?> ?>
@ -34,8 +34,8 @@
<c:out value="${profil.iam}"/> <c:out value="${profil.iam}"/>
</p> </p>
<h3><?=__("dreamjob.mail");?></h3> <h3><?=__("dreamjob.mail");?></h3>
<a href="mailto:<?=$profil['User'][0]['mail'];?>"> <a href="mailto:<?=$profil['User']['mail'];?>">
<?=$profil['User'][0]['mail'];?> <?=$profil['User']['mail'];?>
</a> </a>
</div> </div>
<div class="bar"> <div class="bar">
@ -43,7 +43,7 @@
<?=__("dreamjob.bday");?>:<br/> <?=__("dreamjob.bday");?>:<br/>
<?php <?php
if($profil['AppUser']['take_systemwide']) if($profil['AppUser']['take_systemwide'])
echo $this->Time->format('d.m.Y', $profil['User'][0]['bday']); echo $this->Time->format('d.m.Y', $profil['User']['bday']);
else else
echo $this->Time->format('d.m.Y', $profil['AppUser']['bday']); echo $this->Time->format('d.m.Y', $profil['AppUser']['bday']);
?> ?>

View File

@ -112,7 +112,6 @@
<!-- java script --> <!-- java script -->
<?php <?php
echo $this->Html->script(array('jquery.min','bootstrap.min','dreamjob')); echo $this->Html->script(array('jquery.min','bootstrap.min','dreamjob'));
//echo $this->element('sql_dump');
?> ?>
</body> </body>
</html> </html>

View File

@ -4,7 +4,7 @@
*/ */
$avatar = false; $avatar = false;
if($profil['AppUser']['take_systemwide']){ if($profil['AppUser']['take_systemwide']){
if($profil['User'][0]['avatar']) if($profil['User']['avatar'])
$avatar = true; $avatar = true;
}else{ }else{
if($profil['AppUser']['avatar']) if($profil['AppUser']['avatar'])
@ -17,7 +17,7 @@ if($profil['AppUser']['take_systemwide']){
<div class="box"> <div class="box">
<img src="<?php <img src="<?php
if($profil['AppUser']['take_systemwide']){ if($profil['AppUser']['take_systemwide']){
echo $MEDIA_URL.$profil['User'][0]['avatar']; echo $MEDIA_URL.$profil['User']['avatar'];
}else{ }else{
echo $MEDIA_URL.$profil['AppUser']['avatar']; echo $MEDIA_URL.$profil['AppUser']['avatar'];
} }
@ -33,8 +33,8 @@ if($profil['AppUser']['take_systemwide']){
<?php } ?> <?php } ?>
<p> <p>
<?=__("dreamjob.mail");?><br/> <?=__("dreamjob.mail");?><br/>
<a href="mailto:<?=$profil['User'][0]['mail'];?>"> <a href="mailto:<?=$profil['User']['mail'];?>">
<?=$profil['User'][0]['mail'];?> <?=$profil['User']['mail'];?>
</a> </a>
</p> </p>
<br/> <br/>
@ -56,8 +56,8 @@ if($profil['AppUser']['take_systemwide']){
<?php } ?> <?php } ?>
<p> <p>
<?=__("dreamjob.mail");?><br/> <?=__("dreamjob.mail");?><br/>
<a href="mailto:<?=$profil['User'][0]['mail'];?>"> <a href="mailto:<?=$profil['User']['mail'];?>">
<?=$profil['User'][0]['mail'];?> <?=$profil['User']['mail'];?>
</a> </a>
</p> </p>
</div> </div>

View File

@ -8,6 +8,11 @@
echo $this->element('user_worker_header'); echo $this->element('user_worker_header');
?> ?>
</div> </div>
<?php
if(( !empty($COMPANY) and is_array($COMPANY) and count($COMPANY) > 0 and ($COMPANY['DreamjobCompany']['pro_user']>0) )
or ( !empty($WORKER) and is_array($WORKER) and count($WORKER) > 0 )
){
?>
<div id="tab" class="box"> <div id="tab" class="box">
<!-- tab --> <!-- tab -->
<div class="tabs-below"> <div class="tabs-below">
@ -47,3 +52,6 @@
?> ?>
<!-- /tab --> <!-- /tab -->
</div> </div>
<?php
}
?>