upload Image
This commit is contained in:
parent
87ba3e4ebc
commit
b59886c2cf
|
@ -3,7 +3,7 @@
|
||||||
/app/Config/database.php
|
/app/Config/database.php
|
||||||
/app/Config/email.php
|
/app/Config/email.php
|
||||||
/app/webroot/uploads/
|
/app/webroot/uploads/
|
||||||
/app/webroot/avatar/
|
/app/webroot/img/avatar/
|
||||||
/app/webroot/dreamjob/
|
/app/webroot/dreamjob/
|
||||||
/app/tmp
|
/app/tmp
|
||||||
/lib/Cake/Console/Templates/skel/tmp/
|
/lib/Cake/Console/Templates/skel/tmp/
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
Router::connect('/settings/pages/:page', array('controller' => 'user', 'action' => 'settings_pageInh'),array("page" => "[0-9]+"));
|
Router::connect('/settings/pages/:page', array('controller' => 'user', 'action' => 'settings_pageInh'),array("page" => "[0-9]+"));
|
||||||
Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'settings_isearch'));
|
Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'settings_isearch'));
|
||||||
Router::connect('/settings/delete', array('controller' => 'user', 'action' => 'profil_delete'));
|
Router::connect('/settings/delete', array('controller' => 'user', 'action' => 'profil_delete'));
|
||||||
|
Router::connect('/settings/img', array('controller' => 'user', 'action' => 'avatar_upload'));
|
||||||
|
|
||||||
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]+"));
|
||||||
|
|
|
@ -19,7 +19,8 @@ class MiconwareSessionComponent extends Component {
|
||||||
$controller->set("COMPANY",($this->self_company_obj)?$this->self_company_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","/");
|
$controller->set("MEDIA",'/uploads');
|
||||||
|
$controller->set("strip_tags",'<p><a><img><span><div>');
|
||||||
$controller->set('default_sForm',array(
|
$controller->set('default_sForm',array(
|
||||||
'inputDefaults' => array(
|
'inputDefaults' => array(
|
||||||
'div' => array('class' => 'control-group'),
|
'div' => array('class' => 'control-group'),
|
||||||
|
|
|
@ -10,7 +10,7 @@ class UserController extends AppController {
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public $uses = array('DreamjobListGraducation', 'DreamjobWorker', 'DreamjobCompany', 'DreamjobPageText','DreamjobPageInh', 'DreamjobPageImage', 'DreamjobJobOpening', 'DreamjobCvEntry', 'DreamjobListCvCategory', 'DreamjobListGraducation', 'DreamjobListJob','DreamjobListKindofjob','DreamjobListBranch','Mannerofaddress','DreamjobISearch','User');
|
public $uses = array('DreamjobListGraducation', 'DreamjobWorker', 'DreamjobCompany', 'DreamjobPageText','DreamjobPageInh', 'DreamjobPageImage', 'DreamjobJobOpening', 'DreamjobCvEntry', 'DreamjobListCvCategory', 'DreamjobListGraducation', 'DreamjobListJob','DreamjobListKindofjob','DreamjobListBranch','Mannerofaddress','DreamjobISearch','User','AppUser');
|
||||||
public $components = array('MiconwareSession','RequestHandler');
|
public $components = array('MiconwareSession','RequestHandler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -500,6 +500,37 @@ class UserController extends AppController {
|
||||||
$this->render('/User/settings_account_delete');
|
$this->render('/User/settings_account_delete');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function avatar_upload() {
|
||||||
|
$this->MiconwareSession->init($this);
|
||||||
|
$this->layout = 'default';
|
||||||
|
$this->MiconwareSession->initWeb($this);
|
||||||
|
$this->RequestHandler->setContent('html', 'application/html' );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$profil = $this->MiconwareSession->getApplication('AppUser');
|
||||||
|
|
||||||
|
if(empty($profil) or count($profil) <= 0){
|
||||||
|
$this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
|
||||||
|
$this->set('error', 'dreamjob.error.noPermision');
|
||||||
|
$this->render('/Home/error');
|
||||||
|
}else{
|
||||||
|
if($this->request->is('put') or $this->request->is('post')){
|
||||||
|
$data['AppUser']['id'] = $profil['AppUser']['id'];
|
||||||
|
$data['AppUser']['take_systemwide'] = $profil['AppUser']['take_systemwide'];
|
||||||
|
$data['AppUser']['user_id'] = $profil['AppUser']['user_id'];
|
||||||
|
$data['AppUser']['avatar'] = $this->request->data['AppUser']['avatar'];
|
||||||
|
$result = $this->AppUser->imageUpload($data);
|
||||||
|
if($result){
|
||||||
|
$this->MiconwareSession->setFlash('dreamjob.settings.avatar.done','flash',array('alert'=>'success'));
|
||||||
|
}else{
|
||||||
|
$this->MiconwareSession->setFlash('dreamjob.settings.avatar.error','flash',array('alert'=>'danger'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->request->data = $profil;
|
||||||
|
$this->render('/User/settings_imageUpload');
|
||||||
|
}
|
||||||
|
}
|
||||||
public function test() {
|
public function test() {
|
||||||
$this->MiconwareSession->init($this);
|
$this->MiconwareSession->init($this);
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,40 @@ class AppUser extends AppModel {
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $displayField = 'id';
|
public $displayField = 'id';
|
||||||
|
public $uploadDir = 'uploads';
|
||||||
/**
|
/**
|
||||||
* Validation rules
|
* Validation rules
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
public function imageUpload($data){
|
||||||
|
$dataSource = $this->getDataSource();
|
||||||
|
$dataSource->begin();
|
||||||
|
$this->id = $data["AppUser"]['id'];
|
||||||
|
$this->User->id = $data["AppUser"]['user_id'];
|
||||||
|
$filename = $this->id . "_-profil.". pathinfo($data[$this->alias]['avatar']['name'], PATHINFO_EXTENSION);
|
||||||
|
$filename = WWW_ROOT . $this->uploadDir . DS . $filename;
|
||||||
|
if(file_exists($filename)){
|
||||||
|
chmod($filename,0755); //Change the file permissions if allowed
|
||||||
|
unlink($filename); //remove the file
|
||||||
|
}
|
||||||
|
if (!move_uploaded_file($data[$this->alias]['avatar']['tmp_name'], $filename)) {
|
||||||
|
$result = false;
|
||||||
|
} else {
|
||||||
|
$result = $this->saveField('avatar', str_replace(DS, "/", str_replace(WWW_ROOT.$this->uploadDir.DS, "", $filename) ));
|
||||||
|
if($data["AppUser"]['take_systemwide'])
|
||||||
|
$result = $this->User->saveField('avatar', str_replace(DS, "/", str_replace(WWW_ROOT.$this->uploadDir.DS, "", $filename) ));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$dataSource->commit();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$dataSource->rollback();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public $validate = array(
|
public $validate = array(
|
||||||
'id' => array(
|
'id' => array(
|
||||||
'naturalNumber' => array(
|
'naturalNumber' => array(
|
||||||
|
|
|
@ -133,10 +133,15 @@ public function saveAndUpload($data){
|
||||||
$filename = $data["DreamjobPageInh"]['user_id'] . "_-page-_" . $this->id .".". pathinfo($data[$this->alias]['image']['name'], PATHINFO_EXTENSION);
|
$filename = $data["DreamjobPageInh"]['user_id'] . "_-page-_" . $this->id .".". pathinfo($data[$this->alias]['image']['name'], PATHINFO_EXTENSION);
|
||||||
$filename = WWW_ROOT . $this->uploadDir . DS . $filename;
|
$filename = WWW_ROOT . $this->uploadDir . DS . $filename;
|
||||||
|
|
||||||
|
if(file_exists($filename)){
|
||||||
|
chmod($filename,0755); //Change the file permissions if allowed
|
||||||
|
unlink($filename); //remove the file
|
||||||
|
}
|
||||||
|
|
||||||
if (!move_uploaded_file($data[$this->alias]['image']['tmp_name'], $filename)) {
|
if (!move_uploaded_file($data[$this->alias]['image']['tmp_name'], $filename)) {
|
||||||
$result = false;
|
$result = false;
|
||||||
} else {
|
} else {
|
||||||
$this->saveField('image', str_replace(DS, "/", str_replace(WWW_ROOT, "", $filename) ));
|
$result = $this->saveField('image', str_replace(DS, "/", str_replace(WWW_ROOT.$this->uploadDir.DS, "", $filename) ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$avatar = false;
|
$avatar = false;
|
||||||
|
$url = '';
|
||||||
if($opening['AppUser']['take_systemwide']){
|
if($opening['AppUser']['take_systemwide']){
|
||||||
if($opening['User']['avatar'])
|
if($opening['User']['avatar']){
|
||||||
|
$url = $MEDIA.DS.$opening['User']['avatar'];
|
||||||
$avatar = true;
|
$avatar = true;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
if($opening['AppUser']['avatar'])
|
if($opening['AppUser']['avatar']){
|
||||||
|
$url = $MEDIA.DS.$opening['AppUser']['avatar'];
|
||||||
$avatar = true;
|
$avatar = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php if(!empty($opening_MINI) or !($opening_in_app or $opening_in_fav)){ ?>
|
<?php if(!empty($opening_MINI) or !($opening_in_app or $opening_in_fav)){ ?>
|
||||||
|
@ -46,13 +51,7 @@ if($opening['AppUser']['take_systemwide']){
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<span><?=$opening['AppUser']['nickname']." ".$opening['DreamjobCompany']['corporateform'];?></span>
|
<span><?=$opening['AppUser']['nickname']." ".$opening['DreamjobCompany']['corporateform'];?></span>
|
||||||
<div>
|
<div>
|
||||||
<img src="<?php
|
<img src="<?=$url;?>"/>
|
||||||
if($opening['AppUser']['take_systemwide']){
|
|
||||||
echo $MEDIA_URL.$opening['User']['avatar'];
|
|
||||||
}else{
|
|
||||||
echo $MEDIA_URL.$opening['AppUser']['avatar'];
|
|
||||||
}
|
|
||||||
?>"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
if(isset($page['DreamjobPageImage'])){
|
if(isset($page['DreamjobPageImage'])){
|
||||||
?>
|
?>
|
||||||
<center>
|
<center>
|
||||||
<img src="<?=$MEDIA_URL.$page['DreamjobPageImage']['image'];?>"/>
|
<img src="<?=$MEDIA.DS.$page['DreamjobPageImage']['image'];?>"/>
|
||||||
</center>
|
</center>
|
||||||
<?php
|
<?php
|
||||||
}else{
|
}else{
|
||||||
echo $page['DreamjobPageText']['text'];
|
echo strip_tags($page['DreamjobPageText']['text'],$strip_tags);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -4,21 +4,28 @@
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="bar avatar">
|
<div class="bar avatar">
|
||||||
<img src="<?php
|
<?php
|
||||||
if($profil['AppUser']['take_systemwide'])
|
$url='img/icon_user.png';
|
||||||
if($profil['User']['avatar'])
|
if($profil['AppUser']['take_systemwide'])
|
||||||
echo $MEDIA_URL.$profil['User']['avatar'];
|
if($profil['User']['avatar'])
|
||||||
else
|
$url = $MEDIA.DS.$profil['User']['avatar'];
|
||||||
echo $STATIC_URL."img/icon_user.png";
|
|
||||||
else
|
else
|
||||||
if($profil['AppUser']['avatar'])
|
if($profil['AppUser']['avatar'])
|
||||||
echo $MEDIA_URL.$profil['AppUser']['avatar'];
|
$url = $MEDIA.DS.$profil['AppUser']['avatar'];
|
||||||
else
|
|
||||||
echo $STATIC_URL."img/icon_user.png";
|
?>
|
||||||
?>"/>
|
<img src="<?=$url;?>"/>
|
||||||
</div>
|
<?php if($edit): ?>
|
||||||
<div class="bar">
|
<div class="imgsubtitle edit">
|
||||||
|
<?php
|
||||||
|
$link = '<span class="glyphicon glyphicon-picture"></span>'.__('dreamjob.image.edit');
|
||||||
|
echo $this->Html->link($link,array('controller' => 'user', 'action' => 'avatar_upload'),array('data-target'=>'#popup','data-toggle'=>"modal",'title'=>__('dreamjob.image.edit'),"ref"=>"eventOff",'escape'=>false));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<div class="bar">
|
||||||
<h1>
|
<h1>
|
||||||
<?php
|
<?php
|
||||||
if($profil['AppUser']['take_systemwide'])
|
if($profil['AppUser']['take_systemwide'])
|
||||||
|
|
|
@ -24,18 +24,17 @@
|
||||||
?>
|
?>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<img src="<?php
|
<?php
|
||||||
if($profil[$AppUser]['take_systemwide'])
|
$url='img/icon_user.png';
|
||||||
if($profil[$User]['avatar'])
|
if($profil[$AppUser]['take_systemwide'])
|
||||||
echo $MEDIA_URL.$profil[$User]['avatar'];
|
if($profil[$User]['avatar'])
|
||||||
else
|
$url = $MEDIA.DS.$profil[$User]['avatar'];
|
||||||
echo $STATIC_URL."img/icon_user.png";
|
else
|
||||||
else
|
if($profil[$AppUser]['avatar'])
|
||||||
if($profil[$AppUser]['avatar'])
|
$url = $MEDIA.DS.$profil[$AppUser]['avatar'];
|
||||||
echo $MEDIA_URL.$profil[$AppUser]['avatar'];
|
|
||||||
else
|
?>
|
||||||
echo $STATIC_URL."img/icon_user.png";
|
<img src="<?=$url;?>"/>
|
||||||
?>"/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<span><?=__('dreamjob.city').': '.$profil[$DreamjobUser]['city'];?></span>
|
<span><?=__('dreamjob.city').': '.$profil[$DreamjobUser]['city'];?></span>
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
</span>
|
</span>
|
||||||
</legend>
|
</legend>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<?=$msgitem['text']; ?>
|
<?=strip_tags($msgitem['text'],$strip_tags); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
<?=$this->element('job_opening_head_extra');?>
|
<?=$this->element('job_opening_head_extra');?>
|
||||||
<br/>
|
<br/>
|
||||||
<div>
|
<div>
|
||||||
<?=$opening['DreamjobJobOpening']['text'];?>
|
<?=strip_tags($opening['DreamjobJobOpening']['text'],$strip_tags);?>
|
||||||
</div>
|
</div>
|
||||||
<?php if($WORKER){ ?>
|
<?php if(!empty($WORKER)){ ?>
|
||||||
<div class="buttonrow">
|
<div class="buttonrow">
|
||||||
<?php
|
<?php
|
||||||
echo $this->Html->link(__('dreamjob.applicate'),array('controller'=>'job', 'action'=>'applicationSend', 'id'=> $opening['DreamjobJobOpening']['id']),array("class" => "btn btn-primary"));
|
echo $this->Html->link(__('dreamjob.applicate'),array('controller'=>'job', 'action'=>'applicationSend', 'id'=> $opening['DreamjobJobOpening']['id']),array("class" => "btn btn-primary"));
|
||||||
|
|
|
@ -12,7 +12,7 @@ if($profil['AppUser']['take_systemwide']){
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="box-extra">
|
<div class="box-extra">
|
||||||
<?php if($avatar){ ?>
|
<?php if($avatar or $edit){ ?>
|
||||||
<div class="box-extra-left infofield">
|
<div class="box-extra-left infofield">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<img src="<?php
|
<img src="<?php
|
||||||
|
@ -22,6 +22,14 @@ if($profil['AppUser']['take_systemwide']){
|
||||||
echo $MEDIA_URL.$profil['AppUser']['avatar'];
|
echo $MEDIA_URL.$profil['AppUser']['avatar'];
|
||||||
}
|
}
|
||||||
?>"/>
|
?>"/>
|
||||||
|
<?php if($edit):?>
|
||||||
|
<div class="imgsubtitle edit">
|
||||||
|
<?php
|
||||||
|
$link = '<span class="glyphicon glyphicon-picture"></span>'.__('dreamjob.image.edit');
|
||||||
|
echo $this->Html->link($link,array('controller' => 'user', 'action' => 'avatar_upload'),array('data-target'=>'#popup','data-toggle'=>"modal",'title'=>__('dreamjob.image.edit'),"ref"=>"eventOff",'escape'=>false));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if(!empty($profil['DreamjobCompany']['website'])){?>
|
<?php if(!empty($profil['DreamjobCompany']['website'])){?>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
?>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="tabs-below">
|
<div class="tabs-below">
|
||||||
<ul class="nav nav-tabs pull-right">
|
<ul class="nav nav-tabs pull-right">
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<div class="box">
|
||||||
|
<h1><?=__('dreamjob.image.edit');?></h1>
|
||||||
|
<?php
|
||||||
|
$default_Form['type']='file';
|
||||||
|
echo $this->Form->create('AppUser',$default_Form);
|
||||||
|
echo $this->Form->input('AppUser.avatar',array('type'=>'file'));
|
||||||
|
?>
|
||||||
|
<div class="buttonrow">
|
||||||
|
<?=$this->Form->button('<span class="glyphicon glyphicon-floppy-disk"></span> '.__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
echo $this->Form->end();
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
|
@ -419,3 +419,15 @@ body.loading #container{
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.imgsubtitle.edit{
|
||||||
|
background:rgba(0,0,0,0.8);
|
||||||
|
color:white;
|
||||||
|
width:200px;
|
||||||
|
float:none;
|
||||||
|
height:20px;
|
||||||
|
margin-top:-20px;
|
||||||
|
position:absolute;
|
||||||
|
}
|
||||||
|
.imgsubtitle.edit a{
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue