');
$controller->set('default_sForm',array(
'inputDefaults' => array(
'div' => array('class' => 'control-group'),
diff --git a/app/Controller/UserController.php b/app/Controller/UserController.php
index b572eb9..5840fa9 100755
--- a/app/Controller/UserController.php
+++ b/app/Controller/UserController.php
@@ -10,7 +10,7 @@ class UserController extends AppController {
* @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');
/**
@@ -500,6 +500,37 @@ class UserController extends AppController {
$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() {
$this->MiconwareSession->init($this);
diff --git a/app/Model/AppUser.php b/app/Model/AppUser.php
index b5a79ca..ccdc641 100755
--- a/app/Model/AppUser.php
+++ b/app/Model/AppUser.php
@@ -28,12 +28,40 @@ class AppUser extends AppModel {
* @var string
*/
public $displayField = 'id';
-
+ public $uploadDir = 'uploads';
/**
* Validation rules
*
* @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(
'id' => array(
'naturalNumber' => array(
diff --git a/app/Model/DreamjobPageImage.php b/app/Model/DreamjobPageImage.php
index a52a385..5e28520 100644
--- a/app/Model/DreamjobPageImage.php
+++ b/app/Model/DreamjobPageImage.php
@@ -132,11 +132,16 @@ public function saveAndUpload($data){
if($result){
$filename = $data["DreamjobPageInh"]['user_id'] . "_-page-_" . $this->id .".". pathinfo($data[$this->alias]['image']['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]['image']['tmp_name'], $filename)) {
$result = false;
} 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) ));
}
}
diff --git a/app/View/Elements/job_opening_item.ctp b/app/View/Elements/job_opening_item.ctp
index ca44f17..a214ee5 100644
--- a/app/View/Elements/job_opening_item.ctp
+++ b/app/View/Elements/job_opening_item.ctp
@@ -18,12 +18,17 @@
}
$avatar = false;
+$url = '';
if($opening['AppUser']['take_systemwide']){
- if($opening['User']['avatar'])
+ if($opening['User']['avatar']){
+ $url = $MEDIA.DS.$opening['User']['avatar'];
$avatar = true;
+ }
}else{
- if($opening['AppUser']['avatar'])
+ if($opening['AppUser']['avatar']){
+ $url = $MEDIA.DS.$opening['AppUser']['avatar'];
$avatar = true;
+ }
}
?>
@@ -46,13 +51,7 @@ if($opening['AppUser']['take_systemwide']){
=$opening['AppUser']['nickname']." ".$opening['DreamjobCompany']['corporateform'];?>
-
+
-
+
diff --git a/app/View/Elements/user_worker_header.ctp b/app/View/Elements/user_worker_header.ctp
index 54285bb..a9af000 100644
--- a/app/View/Elements/user_worker_header.ctp
+++ b/app/View/Elements/user_worker_header.ctp
@@ -4,21 +4,28 @@
*/
?>
-
-
+ "/>
-
-
+ if($profil['AppUser']['avatar'])
+ $url = $MEDIA.DS.$profil['AppUser']['avatar'];
+
+ ?>
+
+
+
+ '.__('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));
+ ?>
+
+
+
+
-
"/>
+
+
=__('dreamjob.city').': '.$profil[$DreamjobUser]['city'];?>
diff --git a/app/View/Job/application.ctp b/app/View/Job/application.ctp
index 16c7aac..2bc881d 100644
--- a/app/View/Job/application.ctp
+++ b/app/View/Job/application.ctp
@@ -92,7 +92,7 @@
- =$msgitem['text']; ?>
+ =strip_tags($msgitem['text'],$strip_tags); ?>
diff --git a/app/View/Job/opening.ctp b/app/View/Job/opening.ctp
index 5229142..eb56cbf 100644
--- a/app/View/Job/opening.ctp
+++ b/app/View/Job/opening.ctp
@@ -42,9 +42,9 @@
=$this->element('job_opening_head_extra');?>
- =$opening['DreamjobJobOpening']['text'];?>
+ =strip_tags($opening['DreamjobJobOpening']['text'],$strip_tags);?>
-
+
Html->link(__('dreamjob.applicate'),array('controller'=>'job', 'action'=>'applicationSend', 'id'=> $opening['DreamjobJobOpening']['id']),array("class" => "btn btn-primary"));
diff --git a/app/View/User/company.ctp b/app/View/User/company.ctp
index a281eef..4f34e97 100644
--- a/app/View/User/company.ctp
+++ b/app/View/User/company.ctp
@@ -12,7 +12,7 @@ if($profil['AppUser']['take_systemwide']){
}
?>