erste Mailversuche + registration sollte fertig sein + auser aktivierung

This commit is contained in:
Martin Müller 2014-04-08 19:28:07 +02:00
parent 4b0a3942f9
commit 34f07e3120
9 changed files with 286 additions and 25 deletions

103
app/Config/email.php Executable file
View File

@ -0,0 +1,103 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 2.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* This is email configuration file.
*
* Use it to configure email transports of CakePHP.
*
* Email configuration class.
* You can specify multiple configurations for production, development and testing.
*
* transport => The name of a supported transport; valid options are as follows:
* Mail - Send using PHP mail function
* Smtp - Send using SMTP
* Debug - Do not send the email, just return the result
*
* You can add custom transports (or override existing transports) by adding the
* appropriate file to app/Network/Email. Transports should be named 'YourTransport.php',
* where 'Your' is the name of the transport.
*
* from =>
* The origin email. See CakeEmail::from() about the valid values
*
*/
class EmailConfig {
public $default = array(
'transport' => 'Mail',
'from' => 'you@localhost',
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
public $dreamjobMain = array(
'transport' => 'Mail',
'from' => array('noreply@dreamjob.cc'=>'Dreamjob-Site'),
'replyTo' => array('service@dreamjob.cc'=>'[Dreamjob] Service'),
'emailFormat'=>'both',
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
public $smtp = array(
'transport' => 'Smtp',
'from' => array('site@localhost' => 'My Site'),
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'username' => 'user',
'password' => 'secret',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
public $fast = array(
'from' => 'you@localhost',
'sender' => null,
'to' => null,
'cc' => null,
'bcc' => null,
'replyTo' => null,
'readReceipt' => null,
'returnPath' => null,
'messageId' => true,
'subject' => null,
'message' => null,
'headers' => null,
'viewRender' => null,
'template' => false,
'layout' => false,
'viewVars' => null,
'attachments' => null,
'emailFormat' => null,
'transport' => 'Smtp',
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'username' => 'user',
'password' => 'secret',
'client' => null,
'log' => true,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}

View File

@ -117,8 +117,9 @@ class MiconwareSessionComponent extends Component {
)); ));
} }
public static function generateKey($length=8){
return base64_encode(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
}
/** /**
* PasswordHasg * PasswordHasg

View File

@ -1,6 +1,7 @@
<?php <?php
App::uses('AppController', 'Controller'); App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
class RegistrationController extends AppController { class RegistrationController extends AppController {
@ -9,8 +10,17 @@ class RegistrationController extends AppController {
* *
* @var array * @var array
*/ */
public $componens = array('Email','MiconwareSession');
public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch','DreamjobWorker','DreamjobCompany');
public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch'); private function registrationMail($data){
$Email = new CakeEmail('dreamjobMain');
$Email->to($data['User']['mail']);
$Email->subject('Welcome to our really cool thing');
$Email->template('simple_message');
$Email->viewVars(array('data'=>$data));
return $Email->send();
}
public function main() { public function main() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);
@ -30,12 +40,39 @@ class RegistrationController extends AppController {
if ($this->request->is('post')){ if ($this->request->is('post')){
if($this->request->data['DreamjobCompany']['agb']) { if($this->request->data['DreamjobCompany']['agb']) {
unset($this->request->data['DreamjobCompany']['agb']); unset($this->request->data['DreamjobCompany']['agb']);
$result = $this->DreamjobCompany->registration($this->request->data); if($this->request->data['User']['password1'] == $this->request->data['User']['password2']) {
$data = array();
$data['User']['password'] = $this->MiconwareSession->create_hash($this->request->data['User']['password1']);
$data['User']['mail'] = $this->request->data['User']['mail'];
$data['DreamjobUser']['city'] = $this->request->data['DreamjobUser']['city'];
$data['DreamjobUser']['street'] = $this->request->data['DreamjobUser']['street'];
$data['DreamjobUser']['postcode'] = $this->request->data['DreamjobUser']['postcode'];
$data['AppUser']['nickname'] = $this->request->data['AppUser']['nickname'];
$data['DreamjobCompany']['corporateform'] = $this->request->data['DreamjobCompany']['corporateform'];
$data['DreamjobCompany']['owner'] = $this->request->data['DreamjobCompany']['owner'];
$data['DreamjobCompany']['branch_id'] = $this->request->data['DreamjobCompany']['branch_id'];
$data['DreamjobCompany']['headcount'] = $this->request->data['DreamjobCompany']['headcount'];
$data['DreamjobCompany']['bank_details'] = '';
//$data['DreamjobCompany']['bank_details'] = $this->request->data['DreamjobCompany']['bank_details'];
$data['DreamjobCompany']['website'] = $this->request->data['DreamjobCompany']['website'];
$data['User']['code'] = "a:".$this->MiconwareSession->generateKey();
$result = $this->DreamjobCompany->registration($data);
if($result){
$result = $this->registrationMail($data);
if($result){
$this->log("Registratrion Mail:"+$data['User']['mail']);
}
}
if ($result) { if ($result) {
$this->MiconwareSession->setFlash('dreamjob.registration.done','flash',array('alert'=>'success')); $this->MiconwareSession->setFlash('dreamjob.registration.done','flash',array('alert'=>'success'));
}else{ }else{
$this->MiconwareSession->setFlash('dreamjob.registration.error','flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash('dreamjob.registration.error','flash',array('alert'=>'danger'));
} }
}else if($this->request->data['User']['password1']!='' or $this->request->data['User']['password2']!=''){
$this->MiconwareSession->setFlash(__('dreamjob.error.password.notEqual'),'flash',array('alert'=>'danger'));
}
}else{ }else{
$this->MiconwareSession->setFlash('dreamjob.agb.error.notAccept','flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash('dreamjob.agb.error.notAccept','flash',array('alert'=>'danger'));
} }
@ -55,12 +92,42 @@ class RegistrationController extends AppController {
if ($this->request->is('post')){ if ($this->request->is('post')){
if($this->request->data['DreamjobWorker']['agb']) { if($this->request->data['DreamjobWorker']['agb']) {
unset($this->request->data['DreamjobWorker']['agb']); unset($this->request->data['DreamjobWorker']['agb']);
$result = $this->DreamjobWorker->registration($this->request->data); if($this->request->data['User']['password1'] == $this->request->data['User']['password2']) {
$data = array();
$data['User']['password'] = $this->MiconwareSession->create_hash($this->request->data['User']['password1']);
$data['User']['mail'] = $this->request->data['User']['mail'];
$data['DreamjobUser']['city'] = $this->request->data['DreamjobUser']['city'];
$data['DreamjobUser']['street'] = $this->request->data['DreamjobUser']['street'];
$data['DreamjobUser']['postcode'] = $this->request->data['DreamjobUser']['postcode'];
$data['AppUser']['bday'] = $this->request->data['AppUser']['bday'];
$data['AppUser']['first_name'] = $this->request->data['AppUser']['first_name'];
$data['AppUser']['last_name'] = $this->request->data['AppUser']['last_name'];
//WORKER
$data['AppUser']['mannerofaddress_id'] = $this->request->data['AppUser']['mannerofaddress_id'];
$data['DreamjobWorker']['country'] = $this->request->data['DreamjobWorker']['country'];
$data['DreamjobWorker']['iam'] = $this->request->data['DreamjobWorker']['iam'];
$data['DreamjobWorker']['graducation_id'] = $this->request->data['DreamjobWorker']['graducation_id'];
$data['DreamjobWorker']['searchhidden'] = true;
$data['DreamjobWorker']['workexperience'] = $this->request->data['DreamjobWorker']['workexperience'];
$data['User']['code'] = "a:".$this->MiconwareSession->generateKey();
$result = $this->DreamjobWorker->registration($data);
if($result){
$result = $this->registrationMail($data);
if($result){
$this->log("Registratrion Mail:"+$data['User']['mail']);
}
}
if ($result) { if ($result) {
$this->MiconwareSession->setFlash('dreamjob.registration.done','flash',array('alert'=>'success')); $this->MiconwareSession->setFlash('dreamjob.registration.done','flash',array('alert'=>'success'));
}else{ }else{
$this->MiconwareSession->setFlash('dreamjob.registration.error','flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash('dreamjob.registration.error','flash',array('alert'=>'danger'));
} }
}else if($this->request->data['User']['password1']!='' or $this->request->data['User']['password2']!=''){
$this->MiconwareSession->setFlash(__('dreamjob.error.password.notEqual'),'flash',array('alert'=>'danger'));
}
}else{ }else{
$this->MiconwareSession->setFlash('dreamjob.agb.error.notAccept','flash',array('alert'=>'danger')); $this->MiconwareSession->setFlash('dreamjob.agb.error.notAccept','flash',array('alert'=>'danger'));
} }

View File

@ -40,9 +40,41 @@ class DreamjobCompany extends AppModel {
public function registration($data){ public function registration($data){
$dataSource = $this->getDataSource(); $dataSource = $this->getDataSource();
$dataSource->begin(); $dataSource->begin();
if($data['AppUser']['nickname'])
$data['User']['nickname'] = $data['AppUser']['nickname'];
else
$data['AppUser']['nickname'] = $data['User']['nickname'];
$this->User->create(array('User'=>$data['User']));
$result=$this->User->save();
if($result){ if($result){
$dataSource->commit(); $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['DreamjobCompany']['djaccount_ptr_id']=$this->AppUser->id;
$this->create(array('DreamjobCompany'=>$data['DreamjobCompany']));
$result=$this->save();
}
if ($result) {
$dataSource->rollback();
return true; return true;
} else { } else {
$dataSource->rollback(); $dataSource->rollback();

View File

@ -40,9 +40,55 @@ class DreamjobWorker extends AppModel {
public function registration($data){ public function registration($data){
$dataSource = $this->getDataSource(); $dataSource = $this->getDataSource();
$dataSource->begin(); $dataSource->begin();
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'];
$this->User->create(array('User'=>$data['User']));
$result=$this->User->save();
if($result){ if($result){
$dataSource->commit(); $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();
}
if ($result) {
$dataSource->rollback();
return true; return true;
} else { } else {
$dataSource->rollback(); $dataSource->rollback();

View File

@ -0,0 +1,6 @@
<?php
/*
*
*/
echo var_dump($data);
?>

View File

@ -0,0 +1,6 @@
<?php
/*
*
*/
echo var_dump($data);
?>

View File

@ -30,7 +30,7 @@
<div class="buttonrow"> <div class="buttonrow">
<div class="checkbox" style="width:20%;display:inline-block;"> <div class="checkbox" style="width:20%;display:inline-block;">
<?=$this->Form->checkbox('agb');?> <?=$this->Form->checkbox('agb');?>
<?=$this->Html->link(__("dreamjob.agb.accept"),array('controller'=>'home','action'=>'agb'),array('ref'=>'external'));?></span> <?=$this->Html->link(__("dreamjob.agb.accept"),array('controller'=>'home','action'=>'agb'),array('data-target'=>'#popup','data-toggle'=>"modal",'title'=>__('dreamjob.agb'),"ref"=>"eventOff"));?>
</div> </div>
<br/> <br/>
<?=$this->Form->button(__('dreamjob.application.send'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?> <?=$this->Form->button(__('dreamjob.application.send'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?>

View File

@ -10,8 +10,6 @@
ajaxStart: function() { $body.addClass("loading"); }, ajaxStart: function() { $body.addClass("loading"); },
ajaxStop: function() { $body.removeClass("loading"); } ajaxStop: function() { $body.removeClass("loading"); }
}); });
function event(where){
$("#alert .alert").alert();
$("#popup").modal({'remote':false,'show':false}); $("#popup").modal({'remote':false,'show':false});
$("#popup").on('show.bs.modal',function(e){ $("#popup").on('show.bs.modal',function(e){
$.ajax({url:$(e.relatedTarget).attr("href"),success:function(data){ $.ajax({url:$(e.relatedTarget).attr("href"),success:function(data){
@ -19,6 +17,8 @@
$("#popup .modal-body").html($("#container div.box",data).html()); $("#popup .modal-body").html($("#container div.box",data).html());
} ,error:function(data){}}); } ,error:function(data){}});
}); });
function event(where){
$("#alert .alert").alert();
$(where+'.dropdown-toggle').dropdown(); $(where+'.dropdown-toggle').dropdown();