mail bugfix

This commit is contained in:
Martin Müller 2014-04-13 13:28:39 +02:00
parent ca42efc55f
commit bba96e8c84
6 changed files with 50 additions and 32 deletions

View File

@ -22,23 +22,7 @@ class JobController extends AppController {
*/ */
public static function sendApplicationMail($mail,$id){
$Email = new CakeEmail('dreamjobMain');
$Email->to($mail);
$Email->subject('Welcome to our really cool thing');
$Email->template('job_application');
$Email->viewVars(array('app_id'=>$id));
return $Email->send();
}
public static function sendMsgMail($mail,$id){
$Email = new CakeEmail('dreamjobMain');
$Email->to($mail);
$Email->subject('Welcome to our really cool thing');
$Email->template('job_application_msg');
$Email->viewVars(array('app_id'=>$id));
return $Email->send();
}
public function openingList() { public function openingList() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);

View File

@ -10,18 +10,9 @@ class RegistrationController extends AppController {
* *
* @var array * @var array
*/ */
public $componens = array('Email','MiconwareSession'); public $componens = array('MiconwareSession');
public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch','DreamjobWorker','DreamjobCompany','User'); public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch','DreamjobWorker','DreamjobCompany','User');
public static function registrationMail($data){
$Email = new CakeEmail('dreamjobMain');
$Email->to($data['User']['mail']);
$Email->subject('Welcome to our really cool thing');
$Email->template('registration');
$key = substr($data['User']['code'],2);
$Email->viewVars(array('data'=>$data,'key'=>$key));
return $Email->send();
}
public function main() { public function main() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);

View File

@ -1,5 +1,6 @@
<?php <?php
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
App::uses('CakeEmail', 'Network/Email');
/** /**
* DreamjobCompany Model * DreamjobCompany Model
* *
@ -38,6 +39,16 @@ class DreamjobCompany extends AppModel {
public $displayField = 'djaccount_ptr_id'; public $displayField = 'djaccount_ptr_id';
public static function sendMail($data){
$Email = new CakeEmail('dreamjobMain');
$Email->to($data['User']['mail']);
$Email->subject('Welcome to our really cool thing');
$Email->template('registration');
$key = substr($data['User']['code'],2);
$Email->viewVars(array('data'=>$data,'key'=>$key));
return $Email->send();
}
public function registration($data){ public function registration($data){
$dataSource = $this->getDataSource(); $dataSource = $this->getDataSource();
@ -73,7 +84,7 @@ class DreamjobCompany extends AppModel {
$result=$this->save(); $result=$this->save();
} }
if($result) if($result)
$result = RegistrationController::registrationMail($data); $result = self::sendMail($data);
if ($result) { if ($result) {
$dataSource->commit(); $dataSource->commit();
return true; return true;

View File

@ -1,5 +1,6 @@
<?php <?php
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
App::uses('CakeEmail', 'Network/Email');
/** /**
* MicDjJobsApplication Model * MicDjJobsApplication Model
* *
@ -34,6 +35,15 @@ class DreamjobJobApplication extends AppModel {
* *
* @var array * @var array
*/ */
public static function sendMail($mail,$id){
$Email = new CakeEmail('dreamjobMain');
$Email->to($mail);
$Email->subject('Welcome to our really cool thing');
$Email->template('job_application');
$Email->viewVars(array('app_id'=>$id));
return $Email->send();
}
public function sendApplication($data){ public function sendApplication($data){
$dataSource = $this->getDataSource(); $dataSource = $this->getDataSource();
$dataSource->begin(); $dataSource->begin();
@ -41,7 +51,7 @@ class DreamjobJobApplication extends AppModel {
if($result){ if($result){
$open = $this->DreamjobJobOpening->find('first', array('conditions' => array('DreamjobJobOpening.id' => $data['DreamjobJobApplication']['opening_id']))); $open = $this->DreamjobJobOpening->find('first', array('conditions' => array('DreamjobJobOpening.id' => $data['DreamjobJobApplication']['opening_id'])));
$result = JobController::sendApplicationMail($open['User']['mail']l,$this->id); $result = self::sendMail($open['User']['mail']l,$this->id);
} }
if ($result) { if ($result) {

View File

@ -1,5 +1,6 @@
<?php <?php
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
App::uses('CakeEmail', 'Network/Email');
/** /**
* MicDjJobsMsg Model * MicDjJobsMsg Model
* *
@ -33,6 +34,14 @@ class DreamjobJobMsg extends AppModel {
* *
* @var array * @var array
*/ */
public static function sendMail($mail,$id){
$Email = new CakeEmail('dreamjobMain');
$Email->to($mail);
$Email->subject('Welcome to our really cool thing');
$Email->template('job_application_msg');
$Email->viewVars(array('app_id'=>$id));
return $Email->send();
}
public function sendMessage(){ public function sendMessage(){
$dataSource = $this->getDataSource(); $dataSource = $this->getDataSource();
$dataSource->begin(); $dataSource->begin();
@ -40,9 +49,9 @@ class DreamjobJobMsg extends AppModel {
if($result){ if($result){
$app = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobApplication.id' => $this->application_id))); $app = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobApplication.id' => $this->application_id)));
if($this->fromcompany) if($this->fromcompany)
$result = JobController::sendMsgMail($app['User']['mail'],$this->application_id); $result = self::sendMail($app['User']['mail'],$this->application_id);
else else
$result = JobController::sendMsgMail($app['WorkerUser']['mail'],$this->application_id); $result = sel::sendMail($app['WorkerUser']['mail'],$this->application_id);
} }
if ($result) { if ($result) {
$dataSource->commit(); $dataSource->commit();

View File

@ -1,5 +1,6 @@
<?php <?php
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
App::uses('CakeEmail', 'Network/Email');
/** /**
* DreamjobWorker Model * DreamjobWorker Model
* *
@ -38,6 +39,18 @@ class DreamjobWorker extends AppModel {
*/ */
public $displayField = 'djaccount_ptr_id'; public $displayField = 'djaccount_ptr_id';
public static function sendMail($data){
$Email = new CakeEmail('dreamjobMain');
$Email->to($data['User']['mail']);
$Email->subject('Welcome to our really cool thing');
$Email->template('registration');
$key = substr($data['User']['code'],2);
$Email->viewVars(array('data'=>$data,'key'=>$key));
return $Email->send();
}
public function registration($data){ public function registration($data){
$dataSource = $this->getDataSource(); $dataSource = $this->getDataSource();
@ -87,7 +100,7 @@ class DreamjobWorker extends AppModel {
$result=$this->save(); $result=$this->save();
} }
if($result) if($result)
$result = RegistrationController::registrationMail($data); $result = self::sendMail($data);
if ($result) { if ($result) {
$dataSource->commit(); $dataSource->commit();