Skip to content

Commit

Permalink
Merge pull request #23 from docmcfly/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
docmcfly authored Jan 2, 2024
2 parents f3550a6 + 3ad1a8b commit 86dd107
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 69 deletions.
3 changes: 1 addition & 2 deletions Classes/Controller/TaskForceOverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function showAction(): void
}

$usersWithTimeout = array_unique($usersWithTimeout);

$timeOuts = array();
foreach ($tmp as $reason => $to) {
$tmpUsersTimeOuts = array();
Expand All @@ -123,7 +122,7 @@ public function showAction(): void
}

$canViewCurrentlyOfDuty = false;
if ($this->settings[TaskForceOverviewController::CAN_VIEW_CURRENTLY_OFF_DUTY] != null) {
if ($this->frontendUserService->isLogged() && $this->settings[TaskForceOverviewController::CAN_VIEW_CURRENTLY_OFF_DUTY] != null) {
/** @var FrontendUserGroup $frontendUserGroup */
foreach ($this->frontendUserService->getCurrentUser()->getUsergroup() as $frontendUserGroup) {
if (in_array($this->settings[TaskForceOverviewController::CAN_VIEW_CURRENTLY_OFF_DUTY], $this->frontendUserService->getSubGroups($frontendUserGroup))) {
Expand Down
45 changes: 24 additions & 21 deletions Classes/Controller/TimeOutManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function listAction(): void
$this->view->assign('addTimeOut', $addTimeOut);
$this->view->assign('reasons', $reasons);
} else {
$validationResults->addError('notLoggedInd');
$validationResults->addError('notLoggedIn');
}
$this->view->assign(TimeOutManagementController::VALIDATIOPN_RESULTS, $validationResults);
}
Expand All @@ -100,7 +100,7 @@ public function listAction(): void
*/
public function deleteAction(TimeOut $timeout = null): void
{
if ($this->frontendUserService->isLogged() && $timeout->getUser()->getUid() === $this->frontendUserService->getCurrentUserUid()) {
if ($this->frontendUserService->isLogged() && $timeout->getUser() != null && $timeout->getUser()->getUid() === $this->frontendUserService->getCurrentUserUid()) {
$this->timeOutRepository->remove($timeout);
}
$this->redirect('list');
Expand All @@ -109,9 +109,8 @@ public function deleteAction(TimeOut $timeout = null): void
/**
* create a time out
*
* @param
* AddTimeOut addTimeOut
* @return Object
* @param AddTimeOut addTimeOut
* @return object
*/
public function createAction(AddTimeOut $addTimeOut = null): object
{
Expand Down Expand Up @@ -164,30 +163,34 @@ private function validate(AddTimeOut $addTimeOut = null): ValidationResults
/** @var ValidationResults $validationResults **/
$validationResults = $this->getValidationResults();

if ($addTimeOut == null) {
$validationResults->addError('mysteryError');
if (!$this->frontendUserService->isLogged()) {
$validationResults->addError('notLoggedIn');

} else {
if (empty(trim($addTimeOut->getFrom()))) {
$validationResults->addError('invalidFrom');
if ($addTimeOut == null) {
$validationResults->addError('mysteryError');
} else {
$from = \DateTime::createFromFormat('!' . TimeOutManagementController::GERMAN_DATE_FORMAT, $addTimeOut->getFrom());
if ($from === false) {
if (empty(trim($addTimeOut->getFrom()))) {
$validationResults->addError('invalidFrom');
} else {
$from = \DateTime::createFromFormat('!' . TimeOutManagementController::GERMAN_DATE_FORMAT, $addTimeOut->getFrom());
if ($from === false) {
$validationResults->addError('invalidFrom');
}
}
}
if (empty(trim($addTimeOut->getUntil()))) {
$validationResults->addError('invalidUntil');
} else {
$until = \DateTime::createFromFormat('!' . TimeOutManagementController::GERMAN_DATE_FORMAT, $addTimeOut->getUntil());
if ($until === false) {
if (empty(trim($addTimeOut->getUntil()))) {
$validationResults->addError('invalidUntil');
} else {
$until = \DateTime::createFromFormat('!' . TimeOutManagementController::GERMAN_DATE_FORMAT, $addTimeOut->getUntil());
if ($until === false) {
$validationResults->addError('invalidUntil');
}
}
if (!$validationResults->hasErrors() && $from->getTimestamp() > $until->getTimestamp()) {
$validationResults->addError('untilBeforeFrom');
}
}
if (!$validationResults->hasErrors() && $from->getTimestamp() > $until->getTimestamp()) {
$validationResults->addError('untilBeforeFrom');
}
}

return $validationResults;
}

Expand Down
7 changes: 5 additions & 2 deletions Classes/Domain/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Event extends AbstractEntity
*
* @var string
*/
protected $time = '00:00';
protected $time = '00:00:00';

/**
*
Expand Down Expand Up @@ -350,7 +350,7 @@ public function setDate(\DateTime $date): void
*/
public function getTime(): \DateTime
{
return \DateTime::createFromFormat('H:i:s', $this->time);
return $this->time == null ? \DateTime::createFromFormat('H:i:s', '00:00:00') : \DateTime::createFromFormat('H:i:s', $this->time);
}

/**
Expand Down Expand Up @@ -639,4 +639,7 @@ public function setCanceled(bool $canceled): void
{
$this->canceled = $canceled;
}



}
2 changes: 2 additions & 0 deletions Classes/Domain/Repository/TimeOutRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function getTimeOuts()
$q->lessThanOrEqual('from', $today),
$q->greaterThanOrEqual('until', $today)
]));
// $queryParser = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class);
// debug($queryParser->convertQueryToDoctrineQueryBuilder($q)->getSQL());
return $q->execute();
}
}
3 changes: 3 additions & 0 deletions Classes/Domain/TCA/EventTca.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -25,6 +26,7 @@ public function computeTitle(&$parameters)
$typeTitle = '';
$description = '';
$qb = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_participants_domain_model_event')->createQueryBuilder();
$qb->getRestrictions()->removeByType(HiddenRestriction::class);
$statement = $qb->select('tx_participants_domain_model_eventtype.title')
->addSelect('tx_participants_domain_model_eventtype.description')
->addSelect('tx_participants_domain_model_event.uid')
Expand All @@ -34,6 +36,7 @@ public function computeTitle(&$parameters)
->where($qb->expr()
->eq('tx_participants_domain_model_event.uid', $qb->createNamedParameter(intval($parameters['row']['uid']))))
->execute();

while ($row = $statement->fetchAssociative()) {
$description = strip_tags($row['description']);
if (strlen($description) > 10) {
Expand Down
10 changes: 6 additions & 4 deletions Classes/Domain/TCA/EventTypeTca.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class EventTypeTca
public function computeTitleDescription(&$parameters)
{
$record = BackendUtility::getRecord($parameters['table'], $parameters['row']['uid']);
$description = strip_tags($record['description']);
if (strlen($description) > 24) {
$description = substr($description, 0, 24) . '';
if ($record != null) {
$description = isset($record['description']) ? strip_tags($record['description']) : '';
if (strlen($description) > 24) {
$description = substr($description, 0, 24) . '';
}
$parameters['title'] = $record['title'] . (trim($description) == '' ? '' : ' (' . $description . ')');
}
$parameters['title'] = $record['title'] . (trim($description) == '' ? '' : ' (' . $description . ')');
}
}
35 changes: 6 additions & 29 deletions Classes/Service/FrontendUserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(FrontendUserRepository $frontendUserRepository)

/**
*
* @param Object $obj
* @param object $obj
* @return int
*/
public static function getUid(Object $object): int
Expand All @@ -47,9 +47,9 @@ public static function getUid(Object $object): int

/**
*
* @return FrontendUser Returns the current frontend user
* @return FrontendUser|bool Returns the current frontend user
*/
public function getCurrentUser(): FrontendUser
public function getCurrentUser(): FrontendUser|false
{
if (! $this->isLogged()) {
return false;
Expand Down Expand Up @@ -78,7 +78,8 @@ public function getCurrentUserUid(): int
public function isLogged(): bool
{
$context = GeneralUtility::makeInstance(Context::class);
return $context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
$isPreview = ($context->hasAspect('frontend.preview') && $context->getPropertyFromAspect('frontend.preview', 'isPreview'));
return !$isPreview && $context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
}

/**
Expand All @@ -105,30 +106,6 @@ public function contains($userGroup, $feugid, &$loopProtect = array()): bool
}
}

/**
*
* @param FrontendUserGroup $userGroup
* @param integer $fegid
* @param array $loopProtect
* @return boolean
*/
public function getAllGroups($userGroup, $return = array(), &$loopProtect = array()): bool
{
$return = array();
if ($userGroup->getUid() == $feugid) {
return true;
} else {
if (! in_array($userGroup->getUid(), $loopProtect)) {
$loopProtect[] = $userGroup->getUid();
foreach ($userGroup->getSubgroup() as $sg) {
if ($this->contains($sg, $feugid, $loopProtect)) {
return true;
}
}
}
return false;
}
}

/**
*
Expand Down Expand Up @@ -213,7 +190,7 @@ private function _getTopGroups(int $ug, array &$return = []): array
->where($qb->expr()
->inSet('subgroup', $ug))
->execute();
while ($row = $s->fetch()) {
while ($row = $s->fetchAllAssociative()) {
$uid = intVal($row['uid']);
if (! in_array($uid, $return)) {
$return = array_unique(array_merge($return, $this->_getTopGroups($uid, $return)));
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/fe_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
]
],
'readOnly' => true,
'default' => 1,
'default' => 0,
]
],
'info_mail_when_personal_duty_roster_changed' => [
Expand Down
5 changes: 3 additions & 2 deletions Configuration/TCA/tx_participants_domain_model_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
'interface' => [
'showRecordFieldList' => 'l10n_parent, l10n_diffsource, hidden, canceled, event_type, date, full_day, time, '
. 'duration, usergroups, show_public_usergroups, public_usergroups, description, public, public_description, '
. 'show_public_description '
. 'show_public_description, sys_language_uid'
],
'types' => [
'1' => [
'showitem' => ' l10n_parent, l10n_diffsource, hidden, canceled, event_type, public, date, full_day, time, duration,'
. '--div--;LLL:EXT:participants/Resources/Private/Language/locallang_db.xlf:tx_participants_domain_model_event.tabGroupSettings, usergroups, show_public_usergroups, public_usergroups, '
. '--div--;LLL:EXT:participants/Resources/Private/Language/locallang_db.xlf:tx_participants_domain_model_event.tabDescription, description, show_public_description, public_description '
. '--div--;LLL:EXT:participants/Resources/Private/Language/locallang_db.xlf:tx_participants_domain_model_event.tabDescription, description, show_public_description, public_description, '
. '--div--;LLL:EXT:participants/Resources/Private/Language/locallang_db.xlf:tx_participants_domain_model_event.tabMiscellaneous, sys_language_uid'
]
],
'columns' => [
Expand Down
4 changes: 2 additions & 2 deletions Configuration/TCA/tx_participants_domain_model_eventtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
'iconfile' => 'EXT:participants/Resources/Public/Icons/tx_participants_domain_model_event_type.gif'
],
'interface' => [
'showRecordFieldList' => ' l10n_parent, l10n_diffsource, hidden, title, description, public'
'showRecordFieldList' => ' l10n_parent, l10n_diffsource, hidden, title, description, public, sys_language_uid'
],
'types' => [
'1' => [
'showitem' => ' l10n_parent, l10n_diffsource, hidden, title, public, description, usergroups, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime'
'showitem' => ' l10n_parent, l10n_diffsource, hidden, title, public, description, usergroups, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime, sys_language_uid'
]
],
'columns' => [
Expand Down
4 changes: 4 additions & 0 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@
<source>Description</source>
<target state="tanslated">Beschreibung</target>
</trans-unit>
<trans-unit id="tx_participants_domain_model_event.tabMiscellaneous">
<source>Miscellaneous</source>
<target state="tanslated">Sonstiges</target>
</trans-unit>

<!-- FE_GROUPS -->
<trans-unit id="tx_participants_domain_model_feGroups.acronym">
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@
<trans-unit id="tx_participants_domain_model_event.tabDescription">
<source>Description</source>
</trans-unit>
<trans-unit id="tx_participants_domain_model_event.tabMiscellaneous">
<source>Miscellaneous</source>
</trans-unit>


<!-- FE_GROUPS -->
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Partials/UserCard.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<f:then>
<f:if condition="{userProfileLink}">
<f:then>
<f:link.typolink parameter="{userProfileLink}">
<f:link.typolink parameter="{userProfileLink}" absolute="true">
<strong>{user.firstName}&nbsp;{user.lastName}</strong>
</f:link.typolink>
</f:then>
Expand All @@ -16,7 +16,7 @@
<f:else>
<f:if condition="{taskForceListLink}">
<f:then>
<f:link.typolink parameter="{taskForceListLink}#name_{user.username}">
<f:link.typolink parameter="{taskForceListLink}#name_{user.username}" absolute="true">
<strong>{user.firstName}&nbsp;{user.lastName}</strong>
</f:link.typolink>
</f:then>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Templates/PersonalDutyRoster/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h5>
objectName="personalDutyRosterFilterSettings">
<div class="card-body">
<div class="form-group">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4">
<div class="row row-cols-1 row-cols-sm-1 row-cols-md-2 row-cols-lg-3">
<f:for each="{personalDutyRosterFilterSettings.settings}" as="set"
iteration="iter">
<div class="form-check col">
Expand Down
13 changes: 11 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 1,
'version' => '3.7.0',
'version' => '3.7.9',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-11.5.99',
Expand All @@ -29,7 +29,16 @@
/**
* Change log:
*
3.7.9 :: Fix : Fix the default user setting for automatic apply commitments.
3.7.8 :: Fix : Fix the return value type in the frontend user service.
3.7.7 :: Fix : Adapts the personal duty roster folter column counts.
3.7.6 :: Fix : Link from TaskForceOverview to the user list.
3.7.5 :: Fix : Frontend user service: Better handling of simulated users.
3.7.4 :: Fix : Timeout management: You can only delete a period only without exceptions if the user is logged in.
3.7.3 :: Fix : Duty roster excepts events with a null time.
3.7.2 :: Fix : Event description is not displayed in the list view if the event is hidden (disabled).
3.7.1 :: Fix : Add missing lanugage setting in the event and event type record.
3.7.0 :: Chg : Switch to the new reason for prevention service api.
3.6.6 :: Add : Personal duty roster -> disabled buttons are grey.
3.6.5 :: Fix : Optimize the commitment description text output.
Expand Down
2 changes: 1 addition & 1 deletion ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ CREATE TABLE tx_participants_domain_model_event (
public SMALLINT (5) UNSIGNED DEFAULT '2' NOT NULL,
full_day SMALLINT (5) UNSIGNED DEFAULT '0' NOT NULL,
date date DEFAULT '2000-01-01' NOT NULL,
time time DEFAULT '19:00:00',
time time DEFAULT '19:00:00' NOT NULL,
duration SMALLINT (5) UNSIGNED DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
Expand Down

0 comments on commit 86dd107

Please sign in to comment.