Commit 73767bd7 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

[WIP] add mail message dummy methods

parent 592635dc
Pipeline #8142 failed with stages
in 22 seconds
<?php
declare(strict_types = 1);
declare(strict_types=1);
namespace T3o\T3oLdap\Controller;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
......@@ -18,11 +21,15 @@ class GdprController extends ActionController
{
parent::initializeAction();
if (!$GLOBALS['BE_USER']) {
$this->addFlashMessage('no access to this function','Access denied',AbstractMessage::ERROR);
$this->addFlashMessage('no access to this function', 'Access denied', AbstractMessage::ERROR);
$this->forward('message');
}
if ($GLOBALS['BE_USER']->isAdmin() === false) {
$this->addFlashMessage('You need Admin rights, to use this function.','Access denied',AbstractMessage::ERROR);
$this->addFlashMessage(
'You need Admin rights, to use this function.',
'Access denied',
AbstractMessage::ERROR
);
$this->forward('message');
}
}
......@@ -44,7 +51,7 @@ class GdprController extends ActionController
public function step2Action()
{
if ($this->request->getArgument('username')) {
if ($this->request->hasArgument('username')) {
$userName = $this->request->getArgument('username');
} else {
$this->addFlashMessage('No user given', 'Error', AbstractMessage::ERROR);
......@@ -70,10 +77,12 @@ class GdprController extends ActionController
public function confirmAction()
{
if (!$this->request->getArgument('user')) {
if (!$this->request->hasArgument('user')) {
$this->addFlashMessage('No user found', 'Error', AbstractMessage::ERROR);
$this->forward('step1');
}
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$this->view->assignMultiple(
......@@ -88,15 +97,30 @@ class GdprController extends ActionController
);
}
public function deleteAction() {
public function deleteAction()
{
if (!$this->request->hasArgument('user')) {
$this->addFlashMessage('No user found', 'Error', AbstractMessage::ERROR);
$this->forward('step1');
}
$user = $this->request->getArgument('user');
$data['username'] = $user;
$data['email'] = $user;
$data['deleted_by'] = $GLOBALS['BE_USER']->id;
$data['delete_date'] = mktime();
$data['otrs_ticket'] = $this->request->getArgument('otrs');
$data['gitlab_ticket'] = $this->request->getArgument('gitlab');
$data['comment'] = $this->request->getArgument('comment');
$this->sendORTSMail();
$this->sendORTSMail($data);
$this->createORTSTicket();
$this->createORTSTicket($data);
$this->deleteUser();
$this->deleteUser($data);
$this->createOldUser();
$this->createOldUser($data);
$this->addFlashMessage('The user was deleted successfully', 'LDAP deletion', AbstractMessage::OK);
}
/**
......@@ -137,19 +161,37 @@ class GdprController extends ActionController
return $ldap->getUser($userName);
}
protected function createOldUser(){
protected function createOldUser(array $data)
{
$dbConnection = GeneralUtility::makeInstance(ConnectionPool::class);
$dbConnection->getConnectionForTable('old_users')->insert('old_users', $data);
}
protected function sendORTSMail(){
protected function sendORTSMail(array $data)
{
$mail = GeneralUtility::makeInstance(MailMessage::class);
$mail->from(new \Symfony\Component\Mime\Address('jconfirm-t3o-account@typo3.org', 'typo3.org administration'));
$mail->setSubject('User delection process');
$mail->setFrom(array('confirm-t3o-account@typo3.org' => 'typo3.org administration'));
$mail->setTo(array('admin@typo3.org', 'admin@typo3.org' => 'TYPO3 Serverteam'));
$mail->setBody('Here is the message itself');
$mail->send();
}
protected function createORTSTicket(){
protected function createORTSTicket(array $data)
{
$mail = GeneralUtility::makeInstance(MailMessage::class);
$mail->from(new \Symfony\Component\Mime\Address('jconfirm-t3o-account@typo3.org', 'typo3.org administration'));
$mail->setSubject('User delection process');
$mail->setFrom(array('confirm-t3o-account@typo3.org' => 'typo3.org administration'));
$mail->setTo(array('admin@typo3.org', 'admin@typo3.org' => 'TYPO3 Serverteam'));
$mail->setBody('Here is the message itself');
$mail->send();
}
protected function deleteUser(){
protected function deleteUser(array $data)
{
// delete my.typo3.org user
// delete ldap user
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment