Skip to content

Commit

Permalink
Merge pull request #22 from docmcfly/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
docmcfly authored Dec 17, 2023
2 parents 4d9ddfc + 6af40aa commit f3550a6
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 595 deletions.
62 changes: 0 additions & 62 deletions Classes/Controller/DutyRosterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,68 +159,6 @@ public function downloadIcsAction(string $id)



/**
* @param string $id
*/
public function reasonsForPreventionAction(string $id): string
{

$parsedBody = $this->request->getParsedBody();

if (is_array($parsedBody)) {


$from = $this->getValidDate($parsedBody['from']);
$until = $this->getValidDate($parsedBody['until']);
$visibility = $this->getEventVisiblity($parsedBody);

if ($from != null && $until != null) {
return json_encode($this->eventRepository->findEventsAt($this->getStorageUid($id), $from, $until, $visibility));
}
}

$tmp = date_parse_from_format('Y-m-d', $parsedBody['from']);
return json_encode([
'parsedBody' => $parsedBody,

'isArray' => is_array($parsedBody),

'from' => $from,
'preg' => preg_match(DutyRosterController::DATE_PATTERN, $parsedBody['from']) > 0,
'fd' => $tmp,
'e' => isset($tmp['errors']),
'ec' => count($tmp['errors'])
]);

}

private function getEventVisiblity($parsedBody): int
{
if (!isset($parsedBody['visibility'])) {
return PublicOption::PUBLIC;
} else if (strtoupper($parsedBody['visibility']) === 'ALL') {
return PublicOption::ALL;
} else if (strtoupper($parsedBody['visibility']) === 'INTERNAL') {
return PublicOption::INTERNAL;
} else {
return PublicOption::PUBLIC;
}
}


private function getValidDate(string $rawDate): ?\DateTime
{
if (preg_match(DutyRosterController::DATE_PATTERN, $rawDate)) {
$date = date_parse_from_format('Y-m-d', $rawDate);
if (!isset($date['errors']) || count($date['errors']) == 0) {
$dt = new \DateTime();
$dt->setTime(0, 0, 0, 0);
$dt->setDate($date['year'], $date['month'], $date['day']);
return $dt;
}
}
return null;
}


}
20 changes: 8 additions & 12 deletions Classes/Domain/Repository/EventRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public function findPublicEvents(int $limit = EventRepository::UNLIMITED, array
$s = $qb->execute();
$return = array();

while ($row = $s->fetch()) {
while ($row = $s->fetchAssociative()) {
$return[] = $this->findByUid($row['uid']);
}
return $return;
}



public function findEventsAt(array $storageUids, \DateTime $from, \DateTime $until, int $visibility, int $limit = EventRepository::UNLIMITED, bool $inclusiveCanceledEvents = false): array
public function findEventsAt(\DateTime $from, \DateTime $until, int $visibility = PublicOption::ALL, int $limit = EventRepository::UNLIMITED, bool $inclusiveCanceledEvents = false): array
{
$qb = $this->getQueryBuilder('tx_participants_domain_model_event');

Expand Down Expand Up @@ -157,26 +157,22 @@ public function findEventsAt(array $storageUids, \DateTime $from, \DateTime $unt
$qb->andWhere($visibilityRule);
}

if ($storageUids == null) {
$qb->andWhere($qb->expr()
->in('tx_participants_domain_model_event.pid', $this->createQuery()
->getQuerySettings()
->getStoragePageIds()));
} else {
$qb->andWhere($qb->expr()
->in('tx_participants_domain_model_event.pid', $storageUids));
}

if ($limit != EventRepository::UNLIMITED) {
$qb->setMaxResults($limit);
}

$qb->andWhere($qb->expr()
->in('tx_participants_domain_model_event.pid', $this->createQuery()
->getQuerySettings()
->getStoragePageIds()));

if (!$inclusiveCanceledEvents) {
$qb->andWhere($qb->expr()
->eq('tx_participants_domain_model_event.canceled', 0));
}

$s = $qb->execute();

$return = [];
if (1 == 0) { // add debug infos
$debug = [];
Expand Down
54 changes: 54 additions & 0 deletions Classes/Service/ReasonsForPreventionService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
namespace Cylancer\Participants\Service;
use Cylancer\Participants\Domain\PublicOption;
use Cylancer\Participants\Domain\Repository\EventRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;

/**
* This file is part of the "TaskManagement" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2022 C. Gogolin <[email protected]>
*
* @package Cylancer\Participants\Service
*/
class ReasonsForPreventionService
{

public static function reasonsForPreventionAction(array $storageUids, \DateTime $from, \DateTime $until, string $visibility = 'ALL'): array
{

$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);

$eventRepository = GeneralUtility::makeInstance(EventRepository::class, $objectManager);

$eventRepository->injectPersistenceManager($persistenceManager);
$querySettings = $eventRepository->createQuery()->getQuerySettings();
$querySettings->setStoragePageIds($storageUids);
$eventRepository->setDefaultQuerySettings($querySettings);#

return $eventRepository->findEventsAt( $from, $until, ReasonsForPreventionService::mapVisiblity($visibility));

}


private static function mapVisiblity($visibility): int
{
if (!isset($visibility)) {
return PublicOption::PUBLIC;
} else if (strtoupper($visibility) === 'ALL') {
return PublicOption::ALL;
} else if (strtoupper($visibility) === 'INTERNAL') {
return PublicOption::INTERNAL;
} else {
return PublicOption::PUBLIC;
}
}


}
46 changes: 23 additions & 23 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ plugin.tx_participants {
}
}
dutyRoster{
# JSON format
ajax{
pageType = 105
}
# # JSON format
# ajax{
# pageType = 105
# }
# iCal format
iCal {
pageType = 102
Expand Down Expand Up @@ -93,25 +93,25 @@ tx_participants_personalDutyRoster_iCal {



tx_participants_dutyRoster_ajaxConnect = PAGE
tx_participants_dutyRoster_ajaxConnect {
typeNum < plugin.tx_participants.view.settings.dutyRoster.ajax.pageType
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/json
xthml_cleaning = 0
admPanel = 0
debug = 0
no_cache = 1
}
10 = USER
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = Participants
pluginName = DutyRoster
vendorName = Cylancer
}
}
# tx_participants_dutyRoster_ajaxConnect = PAGE
# tx_participants_dutyRoster_ajaxConnect {
# typeNum < plugin.tx_participants.view.settings.dutyRoster.ajax.pageType
# config {
# disableAllHeaderCode = 1
# additionalHeaders = Content-type:application/json
# xthml_cleaning = 0
# admPanel = 0
# debug = 0
# no_cache = 1
# }
# 10 = USER
# 10 {
# userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
# extensionName = Participants
# pluginName = DutyRoster
# vendorName = Cylancer
# }
# }

tx_participants_dutyRosterICal = PAGE
tx_participants_dutyRosterICal {
Expand Down
11 changes: 1 addition & 10 deletions Resources/Private/Templates/PersonalDutyRoster/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@

<body>
<f:layout name="Default" />
This Template is responsible for creating a table of domain objects. If you modify this template, do not forget to
change the overwrite settings in
/Configuration/ExtensionBuilder/settings.yaml: Resources: Private: Templates: List.html: keep Otherwise your changes
will be overwritten the next time you save
the extension in the extension builder
<f:section name="content">
<f:asset.css identifier="personalDutyRoster_bootstrap-toggle.min.css"
href="EXT:participants/Resources/Public/Css/bootstrap-toggle.min.css" />
<f:asset.css identifier="personalDutyRoster_custom_style"
<f:asset.css identifier="personalDutyRoster_custom_style"
href="EXT:participants/Resources/Public/Css/tx_participants_custom_style.css" />
<f:asset.script identifier="personalDutyRoster_jquery-3.6.3-min.js"
src="EXT:participants/Resources/Public/JavaScript/Dist/jquery-3.6.3-min.js" />
<f:asset.script identifier="personalDutyRoster_bootstrap-toggle.min.js"
src="EXT:participants/Resources/Public/JavaScript/Dist/bootstrap-toggle.min.js" defer="true" />
<f:if condition="{personalDutyRosterFilterSettings.usable()}">
<div class="accordion" id="accordionExample">
<div class="card">
Expand Down
84 changes: 0 additions & 84 deletions Resources/Public/Css/bootstrap-toggle.css

This file was deleted.

29 changes: 0 additions & 29 deletions Resources/Public/Css/bootstrap-toggle.min.css

This file was deleted.

5 changes: 5 additions & 0 deletions Resources/Public/Css/tx_participants_custom_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
min-width: 13em;
}

.tx_participants .btn-check:disabled + label {
-webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
filter: grayscale(100%);
}

.error {
color: #d31f1f;
}
Loading

0 comments on commit f3550a6

Please sign in to comment.