delete Account option

This commit is contained in:
Martin Müller 2014-04-13 21:11:21 +02:00
parent 6375ea62c9
commit dc941eb8a9
7 changed files with 98 additions and 2 deletions

View File

@ -43,6 +43,7 @@
Router::connect('/settings/pages', array('controller' => 'user', 'action' => 'settings_pageInh')); 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/pages/:page', array('controller' => 'user', 'action' => 'settings_pageInh'),array("page" => "[0-9]+"));
Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'settings_isearch')); Router::connect('/settings/isearch', array('controller' => 'user', 'action' => 'settings_isearch'));
Router::connect('/settings/delete', array('controller' => 'user', 'action' => 'profil_delete'));
Router::connect('/user/:id', array('controller' => 'user', 'action' => 'profil'),array("id" => "[0-9]+")); Router::connect('/user/:id', array('controller' => 'user', 'action' => 'profil'),array("id" => "[0-9]+"));

View File

@ -10,7 +10,7 @@ class UserController extends AppController {
* @var array * @var array
*/ */
public $uses = array('DreamjobListGraducation', 'DreamjobWorker', 'DreamjobCompany', 'DreamjobPageText','DreamjobPageInh', 'DreamjobPageImage', 'DreamjobJobOpening', 'DreamjobCvEntry', 'DreamjobListCvCategory', 'DreamjobListGraducation', 'DreamjobListJob','DreamjobListKindofjob','DreamjobListBranch','Mannerofaddress','DreamjobISearch'); public $uses = array('DreamjobListGraducation', 'DreamjobWorker', 'DreamjobCompany', 'DreamjobPageText','DreamjobPageInh', 'DreamjobPageImage', 'DreamjobJobOpening', 'DreamjobCvEntry', 'DreamjobListCvCategory', 'DreamjobListGraducation', 'DreamjobListJob','DreamjobListKindofjob','DreamjobListBranch','Mannerofaddress','DreamjobISearch','User');
public $components = array('MiconwareSession','RequestHandler'); public $components = array('MiconwareSession','RequestHandler');
/** /**
@ -464,6 +464,42 @@ class UserController extends AppController {
$this->render('/User/settings_isearch'); $this->render('/User/settings_isearch');
} }
} }
public function profil_delete() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$this->autoRender = true;
$this->layout = 'default';
$this->RequestHandler->setContent('html', 'application/html' );
$profil = $this->MiconwareSession->getWorker();
$company = false;
if(empty($profil) or count($profil) <= 0){
$profil = $this->MiconwareSession->getCompany();
$company= true;
}
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('post')){
$key = $this->MiconwareSession->generateKey();
$profil['User']['code'] = "d:".$key;
$result = $this->User->sendDelete($profil);
if($result){
$this->MiconwareSession->setFlash('dreamjob.settings.delete.agree','flash',array('alert'=>'success'));
}else{
$this->MiconwareSession->setFlash('dreamjob.settings.delete.error','flash',array('alert'=>'danger'));
}
}
$this->render('/User/settings_account_delete');
}
}
public function test() { public function test() {
$this->MiconwareSession->init($this); $this->MiconwareSession->init($this);

View File

@ -33,13 +33,38 @@ class User extends AppModel {
* *
* @var array * @var array
*/ */
public static function sendDeleteMail($data){
$Email = new CakeEmail('dreamjobMain');
$Email->to($data['User']['mail']);
$Email->subject('Welcome to our really cool thing');
$Email->template('delete_order');
$key = substr($data['User']['code'],2);
$Email->viewVars(array('data'=>$data,'key'=>$key));
return $Email->send();
}
public function sendDelete($data){
$dataSource = $this->getDataSource();
$dataSource->begin();
$this->id = $data['User']['id'];
$result = $this->saveField('code',$data['User']['code']);
if($result)
$result=self::sendDeleteMail($data);
if($result) {
$dataSource->commit();
return true;
} else {
$dataSource->rollback();
}
return false;
}
public function activeLinkUser($mail,$key){ public function activeLinkUser($mail,$key){
$dataSource = $this->getDataSource(); $dataSource = $this->getDataSource();
$dataSource->begin(); $dataSource->begin();
$data = $this->find('first',array('conditions' => array( $data = $this->find('first',array('conditions' => array(
'mail' => $mail, 'mail' => $mail,
'code'=> 'a:'.$key 'code'=> array('a:'.$key,'d:'.$key)
))); )));
$result = false; $result = false;
if(!empty($data) and count($data)>0){ if(!empty($data) and count($data)>0){

View File

@ -0,0 +1,4 @@
<?php
echo $this->Html->link(__('dreamjob.regisration.active.link'),array('controller' => 'registration', 'action' => 'active','code'=>$key,
'?'=>array('mail'=>$data['User']['mail']),'full_base' => true) );
?>

View File

@ -0,0 +1,4 @@
<?php
echo $this->Html->url(array('controller'=>'registration','action'=>'active','code'=>$key,
'?'=>array('mail'=>$data['User']['mail'])),true);
?>

View File

@ -79,6 +79,7 @@ if($profil['AppUser']['take_systemwide']){
echo $this->Form->input('DreamjobWorker.country',array('label'=>array('text'=>__("dreamjob.country"),"class"=>$default_Form['inputDefaults']['label']['class']))); echo $this->Form->input('DreamjobWorker.country',array('label'=>array('text'=>__("dreamjob.country"),"class"=>$default_Form['inputDefaults']['label']['class'])));
?> ?>
<div class="buttonrow"> <div class="buttonrow">
<?=$this->Html->link(__('dreamjob.settings.delete'),array('controller'=>'user', 'action'=>'profil_delete'),array("class" => "btn btn-default"));?>
<?=$this->Form->button(__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?> <?=$this->Form->button(__('dreamjob.settings.save'),array('div' => false,'class'=>"btn btn-primary ",'type' => 'submit'));?>
</div> </div>
</fieldset> </fieldset>

View File

@ -0,0 +1,25 @@
<div class="box">
<div class="tabs-below">
<ul class="nav nav-tabs pull-right">
<li><?=$this->Html->link(__("dreamjob.settings"),array('controller'=>'user','action'=>'settings_account'));?></li>
<li><?=$this->Html->link(__("dreamjob.settings.pages"),array('controller'=>'user','action'=>'settings_pageInh'));?></li>
<?php
if(!empty($WORKER) and count($WORKER)>0){
?>
<li><?=$this->Html->link(__("dreamjob.settings.isearch"),array('controller'=>'user','action'=>'settings_isearch'));?></li>
<?php
}
?>
</ul>
</div>
<h1><?=__("dreamjob.settings.delete.title");?></h1>
<?php
echo $this->Form->create(false,$default_Form);
echo __("dreamjob.settings.delete.text");
?>
<div class="buttonrow">
<?=$this->Html->link(__('dreamjob.settings.to'),array('controller'=>'user', 'action'=>'settings_account'),array("class" => "btn btn-success"));;?>
<?=$this->Form->button(__('dreamjob.settings.delete'),array('div' => false,'class'=>"btn btn-danger ",'type' => 'submit'));?>
</div>
<?php echo $this->Form->end(); ?>
</div>