Skip to content

Commit

Permalink
Merge pull request #19 from docmcfly/UPD2024
Browse files Browse the repository at this point in the history
Upd2024
  • Loading branch information
docmcfly authored Oct 23, 2023
2 parents 0b6e94a + e0c5872 commit 4d9ddfc
Show file tree
Hide file tree
Showing 20 changed files with 799 additions and 612 deletions.
13 changes: 7 additions & 6 deletions Classes/Controller/CommitmentSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,20 @@ public function showAction(): void
/**
* create a time out
*
* @param
* CommitmentSettings commitmentSettings
* @return void
* @param CommitmentSettings commitmentSettings
* @return ForwardResponse
*/
public function saveAction(CommitmentSettings $commitmentSettings)
public function saveAction(CommitmentSettings $commitmentSettings): ForwardResponse
{
/**
*
* @var FrontendUser $u
*/
$u = $this->frontendUserRepository->findByUid($this->frontendUserService->getCurrentUserUid());
if ($u != null) {
$u->setApplyPlanningData($commitmentSettings->getApplyPlanningData());
if ($commitmentSettings->getApplyPlanningData() !== null) {
$u->setApplyPlanningData($commitmentSettings->getApplyPlanningData());
}
$u->setInfoMailWhenPersonalDutyRosterChanged($commitmentSettings->getInfoMailWhenPersonalDutyRosterChanged());
$u->setPersonalDutyEventReminder($commitmentSettings->getPersonalDutyEventReminder());
$this->frontendUserRepository->update($u);
Expand All @@ -80,4 +81,4 @@ public function saveAction(CommitmentSettings $commitmentSettings)

return GeneralUtility::makeInstance(ForwardResponse::class, 'show');
}
}
}
49 changes: 27 additions & 22 deletions Classes/Controller/PersonalDutyRosterController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Cylancer\Participants\Controller;

use Cylancer\Participants\Domain\PresentState;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Cylancer\Participants\Utility\Utility;
use TYPO3\CMS\Core\Database\ConnectionPool;
Expand Down Expand Up @@ -63,9 +64,14 @@ class PersonalDutyRosterController extends ActionController
/** @var PersistenceManager */
private $persistenceManager = null;

public function __construct(FrontendUserService $frontendUserService, CommitmentRepository $commitmentRepository, FrontendUserRepository $frontendUserRepository, //
FrontendUserGroupRepository $frontendUserGroupRepository, PersistenceManager $persistenceManager)
{
public function __construct(
FrontendUserService $frontendUserService,
CommitmentRepository $commitmentRepository,
FrontendUserRepository $frontendUserRepository,
//
FrontendUserGroupRepository $frontendUserGroupRepository,
PersistenceManager $persistenceManager
) {
$this->frontendUserService = $frontendUserService;
$this->commitmentRepository = $commitmentRepository;
$this->frontendUserRepository = $frontendUserRepository;
Expand Down Expand Up @@ -106,10 +112,11 @@ public function setPersonalDutyRosterFilterAction(PersonalDutyRosterGroupFilterS
}
// add new settings (hidden groups)
foreach ($personalDutyRosterFilterSettings->getSettings() as $entry) {
if (! $entry->getVisible()) {
if (!$entry->getVisible()) {
$u->addHiddenPersonalDutyRosterGroups($entry->getFrontendUserGroup());
}
}
$u->setOnlyScheduledEvents($personalDutyRosterFilterSettings->getOnlyScheduledEvents());
// debug($u);
$this->frontendUserRepository->update($u);
}
Expand All @@ -131,7 +138,7 @@ public function showAction(): void
* @var PersonalDutyRosterGroupFilterSettings $personalDutyRosterFilterSettings
* @var array $personalDutyRosterGroups
*/
list ($personalDutyRosterGroups, $personalDutyRosterFilterSettings) = $this->getPersonalDutyRosterFilterSettings();
list($personalDutyRosterGroups, $personalDutyRosterFilterSettings) = $this->getPersonalDutyRosterFilterSettings();
// debug($personalDutyRosterGroups);
// debug($personalDutyRosterFilterSettings);

Expand All @@ -141,6 +148,8 @@ public function showAction(): void
/** @var FrontendUser $user */
$user = $this->frontendUserRepository->findByUid($this->frontendUserService->getCurrentUserUid());

$personalDutyRosterFilterSettings->setOnlyScheduledEvents($user->getOnlyScheduledEvents());

$canViewMembers = false;
$allowGroup = $this->settings['canViewMembers'];
foreach ($user->getUserGroup() as $ug) {
Expand Down Expand Up @@ -180,7 +189,7 @@ public function showAction(): void
/**
* The view contains a iCal list.
*
* @param Integer $id
* @param int $id
* @return void
*/
public function downloadAllVisibleCalendarEntriesAction(int $id): void
Expand All @@ -192,7 +201,7 @@ public function downloadAllVisibleCalendarEntriesAction(int $id): void
/**
* The view contains a iCal list.
*
* @param Integer $id
* @param int $id
* @return void
*/
public function downloadAllPromisedVisibleCalendarEntriesAction(int $id): void
Expand All @@ -214,7 +223,7 @@ public function downloadAllPromisedVisibleCalendarEntriesAction(int $id): void
/**
* The view contains a iCal list.
*
* @param Integer $id
* @param int $id
* @return void
*/
public function downloadAllPromisedCalendarEntriesAction(int $id): void
Expand Down Expand Up @@ -243,7 +252,7 @@ public function setPresentAction(Commitment $commitment): string
$eventUid = $commitment->getEvent()->getUid();
$return['$eventUid'] = $eventUid;
$return['present'] = $commitment->getPresent();
if (! $commitment->_isNew() && $commitment->_isDirty('present')) {
if (!$commitment->_isNew() && $commitment->_isDirty('present')) {
$settings = $this->getPreparedSettings(intval($this->request->getArgument('id')));
$this->commitmentRepository->update($commitment);
$this->persistenceManager->persistAll();
Expand Down Expand Up @@ -284,8 +293,9 @@ public function getMembersAction(Commitment $commitment): string
$eventUid = $commitment->getEvent()->getUid();
$settings = $this->request->hasArgument('id') ? $this->getPreparedSettings(intval($this->request->getArgument('id'))) : $this->getPreparedSettings();
$return['event_uid'] = $eventUid;
$return['members'] = $this->commitmentRepository->getEventMembers($settings[PersonalDutyRosterController::PLANNING_STORAGE_UID], $eventUid);
$return['dropouts'] = $this->commitmentRepository->getEventCancels($settings[PersonalDutyRosterController::PLANNING_STORAGE_UID], $eventUid);
$return['members'] = $this->commitmentRepository->getEventCommitments(PresentState::PRESENT, $settings[PersonalDutyRosterController::PLANNING_STORAGE_UID], $eventUid, null);
$return['dropouts'] = $this->commitmentRepository->getEventCommitments(PresentState::NOT_PRESENT, $settings[PersonalDutyRosterController::PLANNING_STORAGE_UID], $eventUid);
$return['undecideds'] = $this->commitmentRepository->getEventCommitments(PresentState::UNKNOWN, $settings[PersonalDutyRosterController::PLANNING_STORAGE_UID], $eventUid);
return json_encode($return);
} else {
$return['members'] = [];
Expand Down Expand Up @@ -319,17 +329,13 @@ private function getPreparedSettings(int $id = null): array
{
$piFlexform = null;
if ($id == null) {
if (isset($this->configurationManager->getContentObject()->data['list_type']) && $this->configurationManager->getContentObject()->data['list_type'] == PersonalDutyRosterController::LIST_TYPE) {
$piFlexform = $this->configurationManager->getContentObject()->data['pi_flexform'];
} else {
throw new \Exception("The content object is not correct plugin (controller).");
}
return $this->prepareSettings($this->settings);
} else {
$qb = $this->getQueryBuilder('tt_content');
$s = $qb->select('list_type', 'pi_flexform')
->from('tt_content')
->where($qb->expr()
->eq('uid', $qb->createNamedParameter($id)))
->eq('uid', $qb->createNamedParameter($id)))
->execute();
// debug($qb->getSql());
if ($row = $s->fetch()) {
Expand Down Expand Up @@ -394,11 +400,11 @@ private function getPersonalDutyRosterFilterSettings(array $personalDutyRosterGr
* @var PersonalDutyRosterGroupFilterSettings $personalDutyRosterFilterSettings
*/
$personalDutyRosterFilterSettings = $this->objectManager->get(PersonalDutyRosterGroupFilterSettings::class);
if (! $ignoreCurrentUserSettings) {
if (!$ignoreCurrentUserSettings) {
foreach ($optionalHiddenPersonalDutyRosterGroups as $optionalGroups) {
if (in_array($optionalGroups, $personalDutyRosterGroups)) {
$ug = $this->frontendUserGroupRepository->findByUid($optionalGroups);
$personalDutyRosterFilterSettings->add($ug, ! array_key_exists($ug->getUid(), $userHiddenDutyRosterGroups));
$personalDutyRosterFilterSettings->add($ug, !array_key_exists($ug->getUid(), $userHiddenDutyRosterGroups));
}
}
}
Expand Down Expand Up @@ -426,7 +432,7 @@ private function getCurrentUserCommitments(int $id, bool $ignoreCurrentUserSetti
$planningStorageUid = $this->settings[PersonalDutyRosterController::PLANNING_STORAGE_UID];
$dutyRosterStorageUids = $this->settings[PersonalDutyRosterController::DUTY_ROSTER_STORAGE_UIDS];

list ($personalDutyRosterGroups, $personalDutyRosterFilterSettings) = $this->getPersonalDutyRosterFilterSettings($personalDutyRosterGroups, $optionalHiddenPersonalDutyRosterGroups, $ignoreCurrentUserSettings);
list($personalDutyRosterGroups, $personalDutyRosterFilterSettings) = $this->getPersonalDutyRosterFilterSettings($personalDutyRosterGroups, $optionalHiddenPersonalDutyRosterGroups, $ignoreCurrentUserSettings);

// debug($hiddenTargetGroups);
// debug($this->getTargetGroups($settings));
Expand Down Expand Up @@ -454,6 +460,5 @@ private function getQueryBuilder(string $table): QueryBuilder
private function toIntArray(string $value): array
{
return GeneralUtility::intExplode(',', $value);
;
}
}
}
Loading

0 comments on commit 4d9ddfc

Please sign in to comment.