2014-02-18 12:10:29 +01:00
|
|
|
<?php
|
|
|
|
App::uses('AppModel', 'Model');
|
2014-04-13 13:28:39 +02:00
|
|
|
App::uses('CakeEmail', 'Network/Email');
|
2014-02-18 12:10:29 +01:00
|
|
|
/**
|
|
|
|
* DreamjobWorker Model
|
|
|
|
*
|
|
|
|
* TODO
|
|
|
|
*
|
|
|
|
* @property DjaccountPtr $DjaccountPtr
|
|
|
|
* @property Graducation $Graducation
|
|
|
|
*/
|
|
|
|
class DreamjobWorker extends AppModel {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use database config
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $useDbConfig = 'dreamjobMain';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use table
|
|
|
|
*
|
|
|
|
* @var mixed False or table name
|
|
|
|
*/
|
|
|
|
public $useTable = 'mic_dj_account_wrk';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Primary key field
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $primaryKey = 'djaccount_ptr_id';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display field
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $displayField = 'djaccount_ptr_id';
|
|
|
|
|
2014-04-13 13:28:39 +02:00
|
|
|
|
|
|
|
public static function sendMail($data){
|
|
|
|
$Email = new CakeEmail('dreamjobMain');
|
|
|
|
$Email->to($data['User']['mail']);
|
2014-05-05 16:44:28 +02:00
|
|
|
$Email->subject('Willkommen bei dreamJOB');
|
|
|
|
$Email->template('registration_worker');
|
2014-04-13 13:28:39 +02:00
|
|
|
$key = substr($data['User']['code'],2);
|
|
|
|
$Email->viewVars(array('data'=>$data,'key'=>$key));
|
2014-05-06 11:05:39 +02:00
|
|
|
$Email->attachments(array('dak.jpg' => WWW_ROOT.DS.'mail'.DS.'dak.jpg'));
|
2014-04-13 13:28:39 +02:00
|
|
|
return $Email->send();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-02 20:37:38 +02:00
|
|
|
public function registration($data){
|
|
|
|
$dataSource = $this->getDataSource();
|
2014-04-08 19:28:07 +02:00
|
|
|
|
2014-04-02 20:37:38 +02:00
|
|
|
$dataSource->begin();
|
2014-04-08 19:28:07 +02:00
|
|
|
|
|
|
|
if($data['AppUser']['mannerofaddress_id'])
|
|
|
|
$data['User']['mannerofaddress_id'] = $data['AppUser']['mannerofaddress_id'];
|
|
|
|
else
|
|
|
|
$data['AppUser']['mannerofaddress_id'] = $data['User']['mannerofaddress_id'];
|
|
|
|
|
|
|
|
if($data['AppUser']['first_name'])
|
|
|
|
$data['User']['first_name'] = $data['AppUser']['first_name'];
|
|
|
|
else
|
|
|
|
$data['AppUser']['first_name'] = $data['User']['first_name'];
|
|
|
|
|
|
|
|
if($data['AppUser']['last_name'])
|
|
|
|
$data['User']['last_name'] = $data['AppUser']['last_name'];
|
|
|
|
else
|
|
|
|
$data['AppUser']['last_name'] = $data['User']['last_name'];
|
|
|
|
|
|
|
|
if($data['AppUser']['bday'])
|
|
|
|
$data['User']['bday'] = $data['AppUser']['bday'];
|
|
|
|
else
|
|
|
|
$data['AppUser']['bday'] = $data['User']['bday'];
|
|
|
|
|
|
|
|
|
2014-04-17 00:18:16 +02:00
|
|
|
$data['User']['date_joined'] = date("Y-m-d H:i:s");
|
2014-04-08 19:28:07 +02:00
|
|
|
$this->User->create(array('User'=>$data['User']));
|
|
|
|
$result=$this->User->save();
|
|
|
|
if($result){
|
|
|
|
$data['User']['id']=$this->User->id;
|
|
|
|
$data['AppUser']['user_id']=$this->User->id;
|
|
|
|
$this->AppUser->create(array('AppUser'=>$data['AppUser']));
|
|
|
|
$result=$this->AppUser->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
if($result){
|
|
|
|
$data['AppUser']['id']=$this->AppUser->id;
|
|
|
|
$data['DreamjobUser']['micapplication_ptr_id']=$this->AppUser->id;
|
|
|
|
$this->DreamjobUser->create(array('DreamjobUser'=>$data['DreamjobUser']));
|
|
|
|
$result=$this->DreamjobUser->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
if($result){
|
|
|
|
$data['DreamjobWorker']['djaccount_ptr_id']=$this->AppUser->id;
|
|
|
|
$this->create(array('DreamjobWorker'=>$data['DreamjobWorker']));
|
|
|
|
$result=$this->save();
|
|
|
|
}
|
2014-04-11 17:36:26 +02:00
|
|
|
if($result)
|
2014-04-13 13:28:39 +02:00
|
|
|
$result = self::sendMail($data);
|
2014-04-08 19:28:07 +02:00
|
|
|
|
2014-04-02 20:37:38 +02:00
|
|
|
if ($result) {
|
2014-04-09 19:30:26 +02:00
|
|
|
$dataSource->commit();
|
2014-04-02 20:37:38 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
$dataSource->rollback();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-18 09:34:04 +01:00
|
|
|
public function saveSettings($data){
|
|
|
|
$dataSource = $this->getDataSource();
|
|
|
|
$dataSource->begin();
|
|
|
|
|
|
|
|
$this->id = $data['AppUser']['id'];
|
|
|
|
$this->User->id = $data['User']['id'];
|
|
|
|
$this->AppUser->id = $data['AppUser']['id'];
|
|
|
|
$this->DreamjobUser->id = $data['AppUser']['id'];
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->User->saveField('password',$data['User']['password']);
|
|
|
|
|
|
|
|
if($result)
|
|
|
|
$result = $this->AppUser->saveField('nickname',$data['AppUser']['nickname']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->AppUser->saveField('first_name',$data['AppUser']['first_name']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->AppUser->saveField('last_name',$data['AppUser']['last_name']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->AppUser->saveField('bday',$data['AppUser']['bday']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->AppUser->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->DreamjobUser->saveField('street',$data['DreamjobUser']['street']);
|
|
|
|
if($result)
|
2014-04-22 16:01:00 +02:00
|
|
|
$result = $this->DreamjobUser->saveField('city_id',$data['DreamjobUser']['city_id']);
|
2014-03-18 09:34:04 +01:00
|
|
|
if($result)
|
|
|
|
$result = $this->DreamjobUser->saveField('postcode',$data['DreamjobUser']['postcode']);
|
|
|
|
|
|
|
|
if($result)
|
|
|
|
$result = $this->saveField('iam',$data['DreamjobWorker']['iam']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->saveField('country',$data['DreamjobWorker']['country']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->saveField('leadership_ability',$data['DreamjobWorker']['leadership_ability']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->saveField('searchhidden',$data['DreamjobWorker']['searchhidden']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->saveField('advertising',$data['DreamjobWorker']['advertising']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->saveField('workexperience',$data['DreamjobWorker']['workexperience']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->saveField('graducation_id',$data['DreamjobWorker']['graducation_id']);
|
|
|
|
|
|
|
|
if($result)
|
|
|
|
$result = $this->AppUser->saveField('take_systemwide',$data['AppUser']['take_systemwide']);
|
|
|
|
|
|
|
|
if($result and $data['AppUser']['take_systemwide']){
|
|
|
|
$result = $this->User->saveField('nickname',$data['AppUser']['nickname']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->User->saveField('first_name',$data['AppUser']['first_name']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->User->saveField('last_name',$data['AppUser']['last_name']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->User->saveField('bday',$data['AppUser']['bday']);
|
|
|
|
if($result)
|
|
|
|
$result = $this->User->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
$dataSource->commit();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
$dataSource->rollback();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-02-18 12:10:29 +01:00
|
|
|
/**
|
|
|
|
* Validation rules
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $validate = array(
|
|
|
|
'djaccount_ptr_id' => 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
|
|
|
|
),
|
|
|
|
'multiple' => array(
|
|
|
|
'rule' => array('multiple'),
|
|
|
|
//'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
|
|
|
|
),
|
|
|
|
'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
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'searchhidden' => array(
|
|
|
|
'boolean' => array(
|
|
|
|
'rule' => array('boolean'),
|
|
|
|
//'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
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'advertising' => array(
|
|
|
|
'boolean' => array(
|
|
|
|
'rule' => array('boolean'),
|
|
|
|
//'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
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'leadership_ability' => array(
|
|
|
|
'boolean' => array(
|
|
|
|
'rule' => array('boolean'),
|
|
|
|
//'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
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'country' => 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
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'iam' => 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
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
public $hasAndBelongsToMany = array(
|
2014-02-19 00:02:17 +01:00
|
|
|
'User' =>array(
|
|
|
|
'className' => 'User',
|
|
|
|
'with' => 'AppUser',
|
|
|
|
'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'
|
|
|
|
)
|
2014-02-18 12:10:29 +01:00
|
|
|
);
|
|
|
|
public $belongsTo = array(
|
|
|
|
'DreamjobListGraducation' => array(
|
|
|
|
'className' => 'DreamjobListGraducation',
|
|
|
|
'foreignKey' => 'graducation_id'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
public $hasOne = array(
|
|
|
|
'DreamjobUser' => array(
|
|
|
|
'className' => 'DreamjobUser',
|
|
|
|
'foreignKey' => 'micapplication_ptr_id'
|
|
|
|
),
|
|
|
|
'AppUser' => array(
|
|
|
|
'className' => 'AppUser',
|
|
|
|
'foreignKey' => 'id'
|
2014-02-19 00:02:17 +01:00
|
|
|
),
|
|
|
|
'User' => array(
|
|
|
|
'className' => 'User',
|
|
|
|
'foreignKey' => false,
|
|
|
|
'conditions' => array('DreamjobWorker.djaccount_ptr_id=AppUser.id and User.id = AppUser.user_id'),
|
|
|
|
'limit' => 1
|
2014-04-22 16:01:00 +02:00
|
|
|
),
|
|
|
|
'DreamjobListCity' => array(
|
|
|
|
'className' => 'DreamjobListCity',
|
|
|
|
'foreignKey' => false,
|
|
|
|
'conditions' => array('DreamjobListCity.id=DreamjobUser.city_id'),
|
|
|
|
'limit' => 1
|
2014-04-23 17:18:47 +02:00
|
|
|
),
|
|
|
|
'Mannerofaddress' => array(
|
|
|
|
'className' => 'Mannerofaddress',
|
|
|
|
'foreignKey' => false,
|
|
|
|
'conditions' => array('DreamjobWorker.djaccount_ptr_id=AppUser.id and Mannerofaddress.id=AppUser.mannerofaddress_id'),
|
|
|
|
'limit' => 1
|
|
|
|
),
|
2014-02-18 12:10:29 +01:00
|
|
|
);
|
|
|
|
public $hasMany = array(
|
|
|
|
'DreamjobPageInh' => array(
|
|
|
|
'className' => 'DreamjobPageInh',
|
2014-03-23 10:16:15 +01:00
|
|
|
'foreignKey' => 'user_id',
|
|
|
|
'order' => "DreamjobPageInh.position"
|
2014-03-04 09:07:18 +01:00
|
|
|
),
|
2014-04-23 17:18:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-04 09:07:18 +01:00
|
|
|
'DreamjobJobApplication' => array(
|
|
|
|
'className' => 'DreamjobJobApplication',
|
|
|
|
'foreignKey' => 'worker_id'
|
2014-03-28 16:22:19 +01:00
|
|
|
),
|
|
|
|
'DreamjobISearch' => array(
|
|
|
|
'className' => 'DreamjobISearch',
|
|
|
|
'foreignKey' => 'worker_id'
|
2014-04-01 20:58:36 +02:00
|
|
|
),
|
|
|
|
'DreamjobCvEntry' => array(
|
|
|
|
'className' => 'DreamjobCvEntry',
|
|
|
|
'foreignKey' => 'worker_id',
|
|
|
|
'order'=>'category_id'
|
2014-02-18 12:10:29 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|