diff --git a/.gitignore b/.gitignore
index 03e7241..e48481d 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,9 @@
# User specific & automatically generated files #
#################################################
/app/Config/database.php
+/app/webroot/uploads/
+/app/webroot/avatar/
+/app/webroot/dreamjob/
/app/tmp
/lib/Cake/Console/Templates/skel/tmp/
/plugins
diff --git a/app/Config/core.php b/app/Config/core.php
index 7d1e8e7..3613637 100755
--- a/app/Config/core.php
+++ b/app/Config/core.php
@@ -216,10 +216,11 @@ Configure::write('Routing.prefixes', array('admin'));
* the cake shell command: cake schema create Sessions
*
*/
- Configure::write('Session', array(
- 'defaults' => 'php'
- ));
-
+Configure::write('Session', array(
+ 'defaults' => 'php',
+ 'cookie' => 'PHPSESSID'
+ )
+);
/**
* A random string used in security hashing methods.
*/
@@ -384,10 +385,3 @@ Cache::config('_cake_model_', array(
'serialize' => ($engine === 'File'),
'duration' => $duration
));
-
-
-Configure::write('Session', array(
- 'defaults' => 'php',
- 'cookie' => 'DreamJOBSession'
- )
-);
diff --git a/app/Config/routes.php b/app/Config/routes.php
index 8e91965..89d5adf 100755
--- a/app/Config/routes.php
+++ b/app/Config/routes.php
@@ -34,8 +34,8 @@
Router::connect('/profil', array('controller' => 'user', 'action' => 'profil'));
Router::connect('/profil/page/:page', array('controller' => 'user', 'action' => 'profil'),array("page" => "[0-9]+"));
Router::connect('/settings', array('controller' => 'user', 'action' => 'settings_account'));
- Router::connect('/settings/pages', array('controller' => 'user', 'action' => 'settings_pages'));
- Router::connect('/settings/pages/:page', array('controller' => 'user', 'action' => 'settings_pages'),array("page" => "[0-9]+"));
+ Router::connect('/settings/pages', array('controller' => 'user', 'action' => 'settings_pageInh'));
+ 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'));
diff --git a/app/Controller/Component/MiconwareSessionComponent.php b/app/Controller/Component/MiconwareSessionComponent.php
index e065d18..cbbdb76 100755
--- a/app/Controller/Component/MiconwareSessionComponent.php
+++ b/app/Controller/Component/MiconwareSessionComponent.php
@@ -19,7 +19,7 @@ class MiconwareSessionComponent extends Component {
$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("MEDIA_URL","/");
$controller->set('default_sForm',array(
'inputDefaults' => array(
'div' => array('class' => 'control-group'),
diff --git a/app/Controller/HomeController.php b/app/Controller/HomeController.php
index 4b365af..1dc42ee 100755
--- a/app/Controller/HomeController.php
+++ b/app/Controller/HomeController.php
@@ -91,7 +91,7 @@ class HomeController extends AppController {
}
- public function iagb() {
+ public function agb() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$this->set('title', 'dreamjob.agb');
diff --git a/app/Controller/UserController.php b/app/Controller/UserController.php
index 9cdd803..8f9053f 100755
--- a/app/Controller/UserController.php
+++ b/app/Controller/UserController.php
@@ -21,6 +21,7 @@ class UserController extends AppController {
* @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode.
*/
+
public function profil() {
$this->MiconwareSession->init($this);
@@ -267,7 +268,8 @@ class UserController extends AppController {
$this->render('/User/settings_account');
}
}
- public function settings_pages() {
+ public function settings_pageInh() {
+
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
@@ -275,7 +277,7 @@ class UserController extends AppController {
$this->layout = 'default';
$this->RequestHandler->setContent('html', 'application/html' );
-
+ $result = false;
$profil = $this->MiconwareSession->getWorker();
if(empty($profil) or count($profil) <= 0)
@@ -286,25 +288,64 @@ class UserController extends AppController {
$this->set('error', 'dreamjob.error.noPermision');
$this->render('/Home/error');
}else{
- var_dump($this->request->data);
if(!empty($this->request->params['page'])){
+ $image = false;
$page = $this->DreamjobPageText->find('first',
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',
array('conditions' => array("DreamjobPageInh.id" => $this->request->params['page'],'DreamjobPageInh.user_id' => $profil['AppUser']['id']))
);
- if($this->request->is('post')){
- $this->MiconwareSession->setFlash(__('dreamjob.page.save'),'flash',array('alert'=>'success'));
+ $image = true;
}
- $this->request->data=$page;
- $this->set('page',$page);
+ if(!empty($page) and count($page)> 0){
+ if($this->request->is('post')){
+ $this->request->data['DreamjobPageInh']['user_id']=$profil['AppUser']['id'];
+ if($image){
+ $this->request->data['DreamjobPageInh']['id']=$page['DreamjobPageInh']['id'];
+ $this->request->data['DreamjobPageImage']['page_ptr_id']=$page['DreamjobPageInh']['id'];
+ $result = $this->DreamjobPageImage->saveAndUpload($this->request->data);
+ }else{
+ $this->request->data['DreamjobPageInh']['id']=$page['DreamjobPageInh']['id'];
+ $this->request->data['DreamjobPageText']['page_ptr_id']=$page['DreamjobPageInh']['id'];
+ $result = $this->DreamjobPageText->saveAssociated($this->request->data);
+ }
+ if(!$result)
+ $this->MiconwareSession->setFlash(__('dreamjob.page.save.error'),'flash',array('alert'=>'danger'));
+ }else
+ $this->request->data=$page;
+ $this->set('page',$page);
+ }else
+ $this->MiconwareSession->setFlash(__('dreamjob.error.page.notFound'),'flash',array('alert'=>'danger'));
}else{
if($this->request->is('post')){
- $this->MiconwareSession->setFlash(__('dreamjob.page.save'),'flash',array('alert'=>'success'));
+ 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'));
+ }else{
+ $this->request->data['DreamjobPageInh']['user_id']=$profil['AppUser']['id'];
+ if($this->request->data['DreamjobPageImage']['image']['error']==0){
+ unset($this->request->data['DreamjobPageText']);
+ $this->DreamjobPageImage->create();
+ $result = $this->DreamjobPageImage->saveAndUpload($this->request->data);
+ }else{
+ unset($this->request->data['DreamjobPageImage']);
+ $this->DreamjobPageText->create();
+ $result = $this->DreamjobPageText->saveAssociated($this->request->data);
+ }
+
+ if(!$result)
+ $this->MiconwareSession->setFlash(__('dreamjob.page.save.error'),'flash',array('alert'=>'danger'));
+ }
}
}
+ if($result){
+ $this->MiconwareSession->refreshCache();
+ $this->MiconwareSession->setFlash(__('dreamjob.page.save'),'flash',array('alert'=>'success'));
+ $profil = $this->MiconwareSession->getWorker();
+ if(empty($profil) or count($profil) <= 0)
+ $profil = $this->MiconwareSession->getCompany();
+ }
$this->set('profil',$profil);
$this->render('/User/settings_pages');
}
diff --git a/app/Model/DreamjobJobFavority.php b/app/Model/DreamjobJobFavority.php
index 8d4054d..afd0d34 100644
--- a/app/Model/DreamjobJobFavority.php
+++ b/app/Model/DreamjobJobFavority.php
@@ -10,7 +10,7 @@ class DreamjobJobFavority extends AppModel {
public $useDbConfig = 'dreamjobMain';
- public $useTable = 'mic_dj_job_opening_worker';
+ public $useTable = 'mic_dj_jobs_opening_worker';
public $validate = array(
'worker_id' => array(
diff --git a/app/Model/DreamjobPageImage.php b/app/Model/DreamjobPageImage.php
index 8cf45e7..f6d27b0 100644
--- a/app/Model/DreamjobPageImage.php
+++ b/app/Model/DreamjobPageImage.php
@@ -34,6 +34,8 @@ class DreamjobPageImage extends AppModel {
* @var string
*/
public $displayField = 'page_ptr_id';
+
+
/**
* Validation rules
@@ -59,28 +61,93 @@ class DreamjobPageImage extends AppModel {
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
-/* 'image' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
- //'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
- ),
- 'alphaNumeric' => array(
- 'rule' => array('alphaNumeric'),
- //'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
- ),
- ),*/
+ 'image' => array(
+ // http://book.cakephp.org/2.0/en/models/data-validation.html#Validation::uploadError
+ 'uploadError' => array(
+ 'rule' => 'uploadError',
+ 'message' => 'Something went wrong with the file upload',
+ 'required' => FALSE,
+ 'allowEmpty' => TRUE,
+ ),
+ // http://book.cakephp.org/2.0/en/models/data-validation.html#Validation::mimeType
+ 'mimeType' => array(
+ 'rule' => array('mimeType', array('image/gif','image/png','image/jpg','image/jpeg')),
+ 'message' => 'Invalid file, only images allowed',
+ 'required' => FALSE,
+ 'allowEmpty' => TRUE,
+ ),
+ 'processUpload' => array(
+ 'rule' => 'processUpload',
+ 'message' => 'Something went wrong with the file upload',
+ 'required' => FALSE,
+ 'allowEmpty' => TRUE,
+ 'last' => TRUE,
+ )
+ )
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
+ /**
+* Upload Directory relative to WWW_ROOT
+* @param string
+*/
+public $uploadDir = 'uploads';
+/**
+* Before Validation Callback
+* @param array $options
+* @return boolean
+*/
+public function beforeValidate($options = array()) {
+ // ignore empty file - causes issues with form validation when file is empty and optional
+ if (!empty($this->data[$this->alias]['image']['error']) && $this->data[$this->alias]['image']['error']==4 && $this->data[$this->alias]['image']['size']==0) {
+ unset($this->data[$this->alias]['image']);
+ }
+ return parent::beforeValidate($options);
+}
+
+/**
+ * Process the Upload
+ * @param array $check
+ * @return boolean
+ */
+public function processUpload($check=array()) {
+ // deal with uploaded file
+ if (!empty($check['image']['tmp_name'])) {
+
+ // check file is uploaded
+ if (!is_uploaded_file($check['image']['tmp_name'])) {
+ return FALSE;
+ }
+ $this->data[$this->alias]['image'] = "onUpload";
+ }
+ return TRUE;
+}
+
+
+public function saveAndUpload($data){
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+ $result = $this->saveAssociated($data);
+ if($result){
+ $filename = $data["DreamjobPageInh"]['user_id'] . "_-_p" . $this->id .".". pathinfo($data[$this->alias]['image']['name'], PATHINFO_EXTENSION);
+ $filename = WWW_ROOT . $this->uploadDir . DS . $filename;
+
+ 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) ));
+ }
+ }
+
+ if ($result) {
+ $dataSource->commit();
+ return true;
+ } else {
+ $dataSource->rollback();
+ }
+ return false;
+}
/**
* belongsTo associations
*
diff --git a/app/View/Job/application_send.ctp b/app/View/Job/application_send.ctp
index ff28655..db14e4b 100644
--- a/app/View/Job/application_send.ctp
+++ b/app/View/Job/application_send.ctp
@@ -32,7 +32,7 @@
=$this->Form->checkbox('agb').__("dreamjob.agb.accept");?>
- =$this->Form->button(__('dreamjob.application.send'),array('div' => false,'class'=>"btn btn-default ",'type' => 'submit'));?>
+ =$this->Form->button(__('dreamjob.application.send'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?>
Form->end(); ?>
diff --git a/app/View/Job/opening_edit.ctp b/app/View/Job/opening_edit.ctp
index 395abfa..b1e160b 100644
--- a/app/View/Job/opening_edit.ctp
+++ b/app/View/Job/opening_edit.ctp
@@ -46,7 +46,7 @@ echo $this->Form->create('DreamjobJobOpening',$default_Form);
Form->textarea('DreamjobJobOpening.text',array("class"=>'form-control',"rows"=>10)); ?>