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/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'));
/**
* ...and connect the rest of 'Pages' controller's URLs.

View File

@ -3,14 +3,21 @@ App::uses('Component', 'Controller');
class MiconwareSessionComponent extends Component {
public $components = array('Session');
public $self_worker_obj;
public $self_company_obj;
public function init($controller){
$controller->Security->requireSecure();
$this->User = ClassRegistry::init('User');
$this->refreshCache();
}
public function initWeb($controller){
$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("MEDIA_URL","http://dev.dreamjob.cc/media/");
$controller->set('default',array(
@ -22,13 +29,30 @@ class MiconwareSessionComponent extends Component {
'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(){
return $this->Session->check('user');
}
public function isStaff(){
return true;
return false;
}
public function login($mail,$password){

View File

@ -28,14 +28,19 @@ class UserController extends AppController {
//self check
$self_company = false;
$self = $this->MiconwareSession->getApplication('DreamjobWorker');
$self = $this->MiconwareSession->getWorker();
if(!is_array($self) or count($self)<= 0){
$self = $this->MiconwareSession->getApplication('DreamjobCompany');
$self = $this->MiconwareSession->getCompany();
$self_company = true;
}
//get Profil
$hard_error = false;
$company = false;
$page = null;
$profil = null;
if(empty($this->request->params['id'])) {
$profil = $self;
$company = $self_company;
@ -48,8 +53,7 @@ class UserController extends AppController {
$this->set('id', $this->request->params['id']);
}
//get Page
$page = null;
if(($this->MiconwareSession->isLoggedin()) or ($company) ){
if(is_array($profil) or count($profil) > 0){
if(!empty($this->request->params['page'])){
$page = $this->DreamjobPageText->find('first',
@ -61,11 +65,11 @@ class UserController extends AppController {
);
}
}
}else
$hard_error = true;
//error
$hard_error = false;
if($profil['AppUser']['id'] != $self['AppUser']['id']){
if(($company == $self_company) and !($this->MiconwareSession->isStaff())){
if(!$company and $profil['AppUser']['id'] != $self['AppUser']['id'] or $hard_error){
if(($company == $self_company) and !($this->MiconwareSession->isStaff()) or $hard_error){
$hard_error = true;
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
$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
),
),
'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,6 +123,12 @@ class DreamjobCompany extends AppModel {
'AppUser' => array(
'className' => 'AppUser',
'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(

View File

@ -176,10 +176,15 @@ class DreamjobJobOpening extends AppModel {
public $belongsTo = array(
'DreamjobCompany' => array(
'className' => 'DreamjobCompany',
'foreignKey' => 'company_id',
'conditions' => '',
'fields' => '',
'order' => ''
'foreignKey' => 'company_id'
),
'DreamjobUser' => array(
'className' => 'DreamjobUser',
'foreignKey' => 'company_id'
),
'AppUser' => array(
'className' => 'AppUser',
'foreignKey' => 'company_id'
),
'DreamjobListGraducation' => array(
'className' => 'DreamjobListGraducation',
@ -196,4 +201,12 @@ class DreamjobJobOpening extends AppModel {
'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,14 +123,19 @@ class DreamjobWorker extends AppModel {
);
public $hasAndBelongsToMany = array(
'User' =>
array(
'User' =>array(
'className' => 'User',
'with' => 'AppUser',
//'joinTable' => 'mic_sys_micapp',
'foreignKey' => 'id',
'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(
@ -147,6 +152,12 @@ class DreamjobWorker extends AppModel {
'AppUser' => array(
'className' => 'AppUser',
'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(

View File

@ -21,13 +21,13 @@ if($isLoggedin){
<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>
<c:if test="${COMPANY!=null}">
<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>
</c:if>
<c:if test="${WORKER!=null}">
<?php if(!empty($COMPANY)){ ?>
<li<?php if(isset($MENU_OPENING)){?> class="active"<?php } ?>>
<?=$this->Html->image('bar-job.png',array('url'=>array('controller'=>'job','action'=>'openingList'))); ?></a></li>
<?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_FAVORITY)){?> class="active"<?php } ?>><a href="<c:url value="${URL}favority/"/>"><img src="<c:url value="${STATIC_URL}img/bar-favority.png"/>"/></a></li>
</c:if>
<li<?php if(isset($MENU_FAVORITY)){?> class="active"<?php } ?>><?=$this->Html->image('bar-favority.png',array('url'=>array('controller'=>'job','action'=>'favorite'))); ?></a></li>
<?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>
</ul>
<?php

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,11 @@
echo $this->element('user_worker_header');
?>
</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">
<!-- tab -->
<div class="tabs-below">
@ -47,3 +52,6 @@
?>
<!-- /tab -->
</div>
<?php
}
?>