Commit 078e4d9f authored by Oliver Eglseder's avatar Oliver Eglseder
Browse files

[TASK] Detect plugin and fix test send

parent 38376929
......@@ -13,6 +13,8 @@ namespace TYPO3\Election\Controller;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\Election\Domain\Model\ElectionCircular;
use TYPO3\Election\Domain\Model\Elector;
use TYPO3\Election\Utility\MailUtility;
......@@ -123,6 +125,12 @@ class BeElectionCircularController extends AbstractProtectedBeController
$elector,
$this->configuration
);
$this->redirect(
self::ACTION_PREVIEW,
self::CONTROLLER_NAME,
'election',
['electionCircular' => $electionCircular]
);
}
/**
......@@ -130,8 +138,13 @@ class BeElectionCircularController extends AbstractProtectedBeController
*/
protected function isPluginInstalled()
{
// TODO: actually search for an active plugin in the database where pid=configuration.pluginPid
return false;
$extendedDeleteClause = BackendUtility::BEenableFields('tt_content');
$count = $this->getDatabaseConnection()->exec_SELECTcountRows(
'uid',
'tt_content',
'CType LIKE "list" AND list_type LIKE "election_pi1" AND hidden=0 ' . $extendedDeleteClause
);
return $count > 0;
}
/**
......@@ -161,4 +174,12 @@ class BeElectionCircularController extends AbstractProtectedBeController
{
return $this->configuration->getElectionManagerGroup();
}
/**
* @return DatabaseConnection
*/
protected function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
}
<?php
namespace TYPO3\Election\Domain\Model;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class ElectionInvitation
*/
class ElectionInvitation extends AbstractEntity
{
/**
* @var string
*/
protected $secret = '';
/**
* @var \TYPO3\Election\Domain\Model\Election
*/
protected $election = null;
/**
* @var \TYPO3\Election\Domain\Model\Elector
*/
protected $elector = null;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\Election\Domain\Model\ElectionToken>
*/
protected $electionTokens = [];
/**
* @return string
*/
public function getSecret()
{
return $this->secret;
}
/**
* @param string $secret
*/
public function setSecret($secret)
{
$this->secret = $secret;
}
/**
* @return Election
*/
public function getElection()
{
return $this->election;
}
/**
* @param Election $election
*/
public function setElection($election)
{
$this->election = $election;
}
/**
* @return Elector
*/
public function getElector()
{
return $this->elector;
}
/**
* @param Elector $elector
*/
public function setElector($elector)
{
$this->elector = $elector;
}
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getElectionTokens()
{
return $this->electionTokens;
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $electionTokens
*/
public function setElectionTokens($electionTokens)
{
$this->electionTokens = $electionTokens;
}
}
<?php
namespace TYPO3\Election\Domain\Model;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
......
......@@ -35,13 +35,11 @@ class MailUtility
Elector $elector,
Configuration $configuration
) {
if (GeneralUtility::makeInstance(MailMessage::class)
GeneralUtility::makeInstance(MailMessage::class)
->setSubject($electionCircular->getSubject())
->setFrom(array($configuration->getFromEmail() => $configuration->getFromName()))
->setTo(array($elector->getEmail() => $elector->getFullName()))
->setBody($electionCircular->getRenderedBody($elector))
->send() === 1) {
$elector->getElectionTokensForElection($electionCircular->getElection())->setEmailSent(true);
}
->send();
}
}
......@@ -348,6 +348,9 @@
<trans-unit id="view.be.election_circular.preview.send_to_test_email">
<source>Send test</source>
</trans-unit>
<trans-unit id="view.be.election_circular.preview.send_invitations">
<source>Send invitations</source>
</trans-unit>
<!-- MODEL ELECTION CIRCULARS -->
......
......@@ -7,6 +7,21 @@
arguments="{electionCircular:electionCircular}">
<core:icon identifier="actions-edit-rename"/>
</f:link.action>
<f:if condition="{isPluginInstalled}">
<f:then>
<f:link.action class="btn btn-default" action="send" controller="BeElectionCircular"
arguments="{electionCircular:electionCircular}">
<core:icon identifier="actions-system-list-open"/>
<f:translate key="view.be.election_circular.preview.send_invitations">Send invitations</f:translate>
</f:link.action>
</f:then>
<f:else>
<a disabled="disabled" class="btn btn-default">
<core:icon identifier="actions-system-list-open" state="disabled"/>
<f:translate key="view.be.election_circular.preview.send_invitations">Send invitations</f:translate>
</a>
</f:else>
</f:if>
</f:section>
<f:section name="RightToolBar">
......
......@@ -7,3 +7,13 @@ if (!defined('TYPO3_MODE')) {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter(
\TYPO3\Election\Property\TypeConverter\UploadedFileReferenceConverter::class
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.election',
'pi1',
array(
'FeDashboard' => 'index',
),
array(
'FeDashboard' => 'index',
)
);
......@@ -37,6 +37,7 @@ call_user_func(
'labels' => 'LLL:EXT:election/Resources/Private/Language/locallang.xlf',
)
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('Election', 'pi1', 'TYPO3 Election tool plugin');
},
'TYPO3',
$_EXTKEY
......
......@@ -135,6 +135,23 @@ CREATE TABLE tx_election_domain_model_electioncircular (
KEY parent (pid)
);
#
# Table structure for table 'tx_election_domain_model_electioninvitation'
#
CREATE TABLE tx_election_domain_model_electioninvitation (
uid INT(11) unsigned NOT NULL auto_increment,
pid INT(11) unsigned DEFAULT '0' NOT NULL,
creation_date INT(11) unsigned DEFAULT '0' NOT NULL,
creation_user INT(11) unsigned DEFAULT '0' NOT NULL,
secret VARCHAR(255) DEFAULT '' NOT NULL,
election INT(11) unsigned DEFAULT '0' NOT NULL,
elector INT(11) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
#
# Table structure for table 'tx_election_domain_model_electorate_elector_mm'
#
......
......@@ -147,4 +147,28 @@ config.tx_extbase.persistence.classes {
}
}
}
TYPO3\Election\Domain\Model\ElectionInvitation < temp.abstractEntity
TYPO3\Election\Domain\Model\ElectionInvitation {
mapping {
tableName = tx_election_domain_model_electioninvitation
columns {
secret.mapOnProperty = secret
election {
mapOnProperty = election
config {
type = select
foreign_table = tx_election_domain_model_election
}
}
elector {
mapOnProperty = elector
config {
type = select
foreign_table = tx_election_domain_model_elector
}
}
}
}
}
}
Supports Markdown
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