...
  View open merge request
Commits (5)
......@@ -3,6 +3,7 @@
namespace T3o\Karma\Controller;
use T3o\Karma\Utility\UserProfileChangeKarmaIssuerUtility;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
......@@ -31,6 +32,8 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
class ManagerController extends AbstractController
{
protected const ISSUER_CODE = 'manualIssuance';
/**
* The test action
*/
......@@ -45,4 +48,83 @@ class ManagerController extends AbstractController
$testUserProfileChangeKarmaIssuerSlot->newUserWasCreated($frontendUser);
}
/**
* Displays textfield for listing usernames and a drop-down menu to select the action
*
* @param string $usernames separated by comma or line breaks
* @param string $issuerAction the issuer action code
* @param string $note for specifying the reason e.g. "T3CON19"
*/
public function manualKarmaIssuanceFormAction(string $usernames='', string $issuerAction='', string $note='')
{
$issuerActions = [];
foreach ($this->settings['issuers'][self::ISSUER_CODE] as $issuerAction=>$issuerActionData) {
$issuerActions[$issuerAction] = $issuerActionData['label'];
}
$this->view->assignMultiple([
'issuerAction' => $issuerAction,
'issuerActions' => $issuerActions,
'usernames' => $usernames,
'note' => $note
]);
}
/**
* Displays a list of real users, as well as usernames that were not found.
*
* @param string $usernames separated by comma or line breaks
* @param string $issuerAction the issuer action code
* @param string $note for specifying the reason e.g. "T3CON19"
*/
public function manualKarmaIssuanceReviewFormAction(string $usernames, string $issuerAction, string $note)
{
if($issuerAction === '') {
$this->addFlashMessage(
'Please choose a karma-earning action.',
'No Action Selected',
AbstractMessage::ERROR
);
$this->forward(
'manualKarmaIssuanceForm',
null,
null,
[
'usernames' => $usernames,
'issuerAction' => $issuerAction,
'note' => $note
]
);
}
$usernamesArray = preg_split('#\s*[\\n,]+\s*#', $usernames, -1, PREG_SPLIT_NO_EMPTY);
$frontendUsers = [];
$usernamesWithoutFrontendUser = [];
foreach($usernamesArray as $username) {
$frontendUser = $this->frontendUserRepository->findOneByUsername($username);
if ($frontendUser !== null) {
$frontendUsers[] = $frontendUser;
} else {
$usernamesWithoutFrontendUser[] = $username;
}
}
}
/**
* Applies the karma issuer action to the users provided
*
* @param array $userIds to apply the issuer action to
* @param string $issuerAction the issuer action code
* @param string $note for specifying the reason e.g. "T3CON19"
*/
public function manualKarmaIssuanceAction(array $userIds, string $issuerAction, string $note)
{
}
}
......@@ -92,6 +92,13 @@ class LedgerEntry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $user;
/**
* The note for the entry
*
* @var string
*/
protected $note;
/**
* Get the creation date
*
......@@ -303,4 +310,24 @@ class LedgerEntry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
$this->user = $user;
}
/**
* Get the note for the entry
*
* @return string
*/
public function getNote(): string
{
return $this->note;
}
/**
* Set the note for the entry
*
* @param string $note
*/
public function setNote(string $note)
{
$this->note = $note;
}
}
......@@ -22,12 +22,66 @@ plugin.tx_karma {
valueEarned = 10
}
}
manualIssuance {
campParticipation {
sourceCode = event
label = Attended Camp
valueEarned = 100
}
campOrganizer {
sourceCode = event
label = Organized Camp
valueEarned = 1000
}
campContributor {
sourceCode = event
label = Contributed at Camp
valueEarned = 500
}
sprintParticipation {
sourceCode = event
label = Attended Sprint
valueEarned = 200
}
sprintOrganizer {
sourceCode = event
label = Organized Sprint
valueEarned = 500
}
conferenceParticipation {
sourceCode = event
label = Attended Official Conference
valueEarned = 500
}
conferenceOrganizer {
sourceCode = event
label = Organized Official Conference
valueEarned = 5000
}
conferenceContributor {
sourceCode = event
label = Contributed at Official Conference
valueEarned = 2000
}
}
}
sourceCodes {
useraction {
label = typo3.org User
}
event {
label = Event
}
}
}
}
......
<section class="container" xmlns:f="http://www.w3.org/1999/html">
<h1>Issue Karma to Users</h1>
<f:flashMessages />
<f:form action="manualKarmaIssuanceReviewForm" method="post">
<div class="form-group">
<label for="manualKarmaIssuanceReviewForm_usernames">Usernames</label>
<f:form.textarea name="usernames" value="{usernames}" id="manualKarmaIssuanceReviewForm_usernames" class="form-control" rows="10" cols="50" />
<div class="text-muted">Usernames separated by comma or line breaks.</div>
</div>
<div class="form-group">
<label for="manualKarmaIssuanceReviewForm_issuerAction">Select the karma-earning action</label>
<f:form.select name="issuerAction" id="manualKarmaIssuanceReviewForm_issuerAction" options="{issuerActions}" value="{issuerAction}" prependOptionValue="" prependOptionLabel="Please select ..." />
</div>
<div class="form-group">
<label for="manualKarmaIssuanceReviewForm_note">Description</label>
<f:form.textfield name="note" value="{note}" id="manualKarmaIssuanceReviewForm_note" class="form-control" />
<div class="text-muted">Brief information about where the karma was earned. If the users attended a conference, write the name (and year/date, if not included in the name): &quot;T3CON19&quot;</div>
</div>
<div class="form-group">
<f:form.submit value="Review" />
</div>
</f:form>
</section>
\ No newline at end of file
<section class="container">
</section>
\ No newline at end of file
......@@ -13,6 +13,9 @@
<tr id="entry-{entry.uid}">
<td>{entry.crdate -> f:format.date(format:'j F, Y')}</td>
<td>{settings.sourceCodes.{entry.karmaSource}.label}: <f:alias map="{issuer: '{settings.issuers.{entry.issuer}}'}">{issuer.{entry.issuerAction}.label}</f:alias>
<f:if condition="{entry.note}">
<br><small>{entry.note}</small>
</f:if>
</td>
<td>{entry.immutableValue}</td>
<td>{entry.mutableValue}</td>
......
......@@ -3,12 +3,12 @@ defined('TYPO3_MODE') or die('Access denied.');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'T3o.' . $_EXTKEY,
'KarmaControl',
'KarmaIssuance',
[
'Manager' => 'test',
'Manager' => 'manualKarmaIssuanceForm,manualKarmaIssuanceReviewForm,manualKarmaIssuance',
],
[
'Manager' => 'test',
'Manager' => 'manualKarmaIssuanceForm,manualKarmaIssuanceReviewForm,manualKarmaIssuance',
]
);
......
......@@ -10,6 +10,6 @@ defined('TYPO3_MODE') or die('Access denied.');
/*
* FE Plugin
*/
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('T3o.' . $_EXTKEY, 'KarmaControl', 'Karma Manager');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('T3o.' . $_EXTKEY, 'KarmaIssuance', 'Manual Karma Issuance Interface');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('T3o.' . $_EXTKEY, 'UserKarmaList', 'Karma List for Users');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('T3o.' . $_EXTKEY, 'UserKarmaWidget', 'Karma Widget for Users');
......@@ -16,6 +16,7 @@ CREATE TABLE tx_karma_domain_model_ledgerentry (
karma_source varchar(16) DEFAULT '',
issuer varchar(32) DEFAULT '',
issuer_action varchar(32) DEFAULT '',
note tinytext DEFAULT '',
campaign int(11) unsigned DEFAULT '0',
user int(11) unsigned DEFAULT '0',
......