Skip to content

Commit

Permalink
Merge pull request #35 from beatrycze-volk/fix-access
Browse files Browse the repository at this point in the history
[BUGFIX] Fix start and end date in `Access` class
  • Loading branch information
beatrycze-volk authored Oct 7, 2024
2 parents 50a2546 + 404ac57 commit 8ab3e2b
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Classes/Command/DigasBaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected function notifyUser(User $feUser, array $userDocumentEntries)
$documentsList[] = [
'recordId' => $accessEntry->getDlfDocument()->getRecordId(),

Check failure on line 212 in Classes/Command/DigasBaseCommand.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to method getRecordId() on an unknown class Slub\SlubWebDigas\Domain\Model\KitodoDocument.
'documentTitle' => $accessEntry->getDlfDocument()->getTitle(),

Check failure on line 213 in Classes/Command/DigasBaseCommand.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to method getTitle() on an unknown class Slub\SlubWebDigas\Domain\Model\KitodoDocument.
'endtime' => $accessEntry->getEndtime(),
'endTime' => $accessEntry->getEndTime(),
'rejected' => $accessEntry->getRejected(),
'rejectedReason' => $accessEntry->getRejectedReason()
];
Expand Down
20 changes: 10 additions & 10 deletions Classes/Controller/AccessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public function initializeAction()
{
parent::initializeAction();

// remove "disabled", "starttime" & "endtime" column to show hidden access
// remove "disabled", "start_time" & "end_time" column to show hidden access
unset($GLOBALS['TCA']['tx_digasfemanagement_domain_model_access']['ctrl']['enablecolumns']['disabled']);
unset($GLOBALS['TCA']['tx_digasfemanagement_domain_model_access']['ctrl']['enablecolumns']['starttime']);
unset($GLOBALS['TCA']['tx_digasfemanagement_domain_model_access']['ctrl']['enablecolumns']['endtime']);
unset($GLOBALS['TCA']['tx_digasfemanagement_domain_model_access']['ctrl']['enablecolumns']['start_time']);
unset($GLOBALS['TCA']['tx_digasfemanagement_domain_model_access']['ctrl']['enablecolumns']['end_time']);
}

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ public function listAction(User $user = null)
elseif ($document->getHidden() === true) {
$accessPending[] = $document;
} // access expired documents: endTime is lower than today's date
elseif ($document->getEndtime() < time()) {
elseif ($document->getEndTime() < time()) {
$accessExpired[] = $document;
} // access granted documents
else {
Expand Down Expand Up @@ -291,8 +291,8 @@ protected function processFormData(User $user, Access $access, string $action =
$this->forward($action, null, null, ['user' => $user, 'access' => $access, 'error' => $access->getUid()]);
}

// set record unhidden - set starttime & endtime
$access->setStarttime(strtotime('today'));
// set record unhidden - set start_time & end_time
$access->setStartTimeString('today');
$access->setHidden(false);

// (re-)set reject state and reason
Expand All @@ -314,8 +314,8 @@ public function validateApproval(Access $access, User $user, string $action) : b
{
$validate = true;

// starttime < endtime
if ($access->getEndtimeString() && $access->getEndtimeString() < strtotime("today + 1day")) {
// start_time < end_time
if ($access->getEndTime() && $access->getEndTime() < strtotime("today + 1day")) {

$validate = false;
$this->addFlashMessage(
Expand Down Expand Up @@ -404,8 +404,8 @@ public function rejectAction(Access $access, User $user)

$access->setHidden(1);
$access->setRejected(1);
$access->setStarttime(0);
$access->setEndtime(0);
$access->setStartTime(0);
$access->setEndTime(0);
$access->setExpireNotification(0);
$access->setAccessGrantedNotification(0);
$access->setInformUser(0);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/BasketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public function requestAction()
$accessRejectedNewRequest->setAccessGrantedNotification(0);
$accessRejectedNewRequest->setRejected(0);
$accessRejectedNewRequest->setHidden(1);
$accessRejectedNewRequest->setStarttime(0);
$accessRejectedNewRequest->setEndtime(0);
$accessRejectedNewRequest->setStartTime(0);
$accessRejectedNewRequest->setEndTime(0);
$accessRejectedNewRequest->setInformUser(0);
$this->accessRepository->update($accessRejectedNewRequest);
$documents[] = $accessRejectedNewRequest;
Expand Down
90 changes: 46 additions & 44 deletions Classes/Domain/Model/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,32 @@ class Access extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
protected $hidden;

/**
* starttimeString
* startTime
*
* @var string
* @var int
*/
protected $starttimeString;
protected $startTime;

/**
* endtimeString
* endTime
*
* @var string
* @var int
*/
protected $endtimeString;
protected $endTime;

/**
* starttime
* startTimeString
*
* @var int
* @var string
*/
protected $starttime;
protected $startTimeString;

/**
* endtime
* endTimeString
*
* @var int
* @var string
*/
protected $endtime;
protected $endTimeString;

/**
* @var int Timestamp of email notification to user for granted access
Expand Down Expand Up @@ -202,87 +202,89 @@ public function setHidden($hidden)
}

/**
* Returns the starttime
* Returns the start time
*
* @return string $starttime
* @return int $startTime
*/
public function getStarttime()
public function getStartTime()
{
return $this->starttime;
return $this->startTime;
}

/**
* Sets the starttime
* Sets the start time
*
* @param string $starttime
* @param int $startTime
* @return void
*/
public function setStarttime($starttime)
public function setStartTime(int $startTime)
{
$this->starttime = $starttime;
$this->startTime = $startTime;
}

/**
* Returns the endtime
* Returns the end time
*
* @return int $endtime
* @return int $endTime
*/
public function getEndtime()
public function getEndTime()
{
return $this->endtime;
return $this->endTime;
}

/**
* Sets the endtime
* Sets the end time
*
* @param int $endtime
* @param int $endTime
* @return void
*/
public function setEndtime($endtime)
public function setEndTime(int $endTime)
{
$this->endtime = $endtime;
$this->endTime = $endTime;
}

/**
* Returns the starttimeString
* Returns the start time as string
*
* @return int $starttimeString
* @return string $startTimeString
*/
public function getStarttimeString()
public function getStartTimeString()
{
return $this->starttimeString;
return $this->startTimeString;
}

/**
* Sets the starttimeString
* Sets the start time as string
*
* @param string $starttimeString
* @param string $startTimeString
* @return void
*/
public function setStarttimeString($starttimeString)
public function setStartTimeString(string $startTimeString)
{
$this->starttimeString = strtotime($starttimeString);
$this->startTime = strtotime($startTimeString);
$this->startTimeString = $startTimeString;
}

/**
* Returns the endtimeString
* Returns the end time as string
*
* @return int $endtimeString
* @return int $endTimeString
*/
public function getEndtimeString()
public function getEndTimeString()
{
return $this->endtimeString;
return $this->endTimeString;
}

/**
* Sets the endtimeString
* Sets the end time as string
*
* @param int $endtimeString
* @param string $endTimeString
* @return void
*/
public function setEndtimeString($endtimeString)
public function setEndTimeString(string $endTimeString)
{
$this->endtimeString = strtotime($endtimeString);
$this->endTime = $endTimeString;
$this->endTimeString = strtotime($endTimeString);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Classes/Domain/Repository/AccessRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function countByFeUserAndOpen(int $feUserId): int
public function findAccessGrantedEntriesByUser(int $feUserId): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->tableName)->createQueryBuilder();
// starttime + endtime get checked by typo3 core logic
// start_time + end_time get checked by typo3 core logic
//remove hidden restriction
$queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class);

Expand Down Expand Up @@ -130,7 +130,7 @@ public function findAccessGrantedEntriesByUser(int $feUserId): array
public function findAccessGrantedUsers()
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->tableName)->createQueryBuilder();
// starttime + endtime get checked by typo3 core logic
// start_time + end_time get checked by typo3 core logic
//remove hidden restriction
$queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class);

Expand Down Expand Up @@ -160,7 +160,7 @@ public function findExpirationUsers($expirationTimestamp)
$rows = $queryBuilder->select('*')
->where(
$queryBuilder->expr()->eq($this->tableName . '.expire_notification', 0),
$queryBuilder->expr()->lte($this->tableName . '.endtime', $expirationTimestamp)
$queryBuilder->expr()->lte($this->tableName . '.end_time', $expirationTimestamp)
)
->from($this->tableName)
->groupBy($this->tableName . '.fe_user')
Expand All @@ -180,11 +180,11 @@ public function findExpiringEntriesByUser(int $feUserId, $expirationTimestamp)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->tableName)->createQueryBuilder();

// starttime + endtime get checked by typo3 core logic
// start_time + end_time get checked by typo3 core logic
$rows = $queryBuilder->select('*')
->where(
$queryBuilder->expr()->eq($this->tableName . '.expire_notification', 0),
$queryBuilder->expr()->lte($this->tableName . '.endtime', $expirationTimestamp),
$queryBuilder->expr()->lte($this->tableName . '.end_time', $expirationTimestamp),
$queryBuilder->expr()->eq($this->tableName . '.fe_user', $feUserId)
)
->from($this->tableName)
Expand Down
14 changes: 7 additions & 7 deletions Configuration/TCA/tx_digasfemanagement_domain_model_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'start_time' => 'start_time',
'end_time' => 'end_time',
],
'searchFields' => '',
'iconfile' => 'EXT:digas_fe_management/Resources/Public/Icons/tx_digasfemanagement_domain_model_access.gif'
Expand All @@ -28,7 +28,7 @@
'showitem' => 'dlf_document,record_id,',
],
'access_dlf_documents' => [
'showitem' => 'hidden,rejected,--linebreak--,starttime,endtime,--linebreak--,',
'showitem' => 'hidden,rejected,--linebreak--,start_time,end_time,--linebreak--,',
],
'access_notifications' => [
'showitem' => 'access_granted_notification,expire_notification, inform_user',
Expand All @@ -50,8 +50,8 @@
'default' => 1
],
],
'starttime' => [
'label' => 'LLL:EXT:digas_fe_management/Resources/Private/Language/locallang_db.xlf:tx_digasfemanagement_domain_model_access.starttime',
'start_time' => [
'label' => 'LLL:EXT:digas_fe_management/Resources/Private/Language/locallang_db.xlf:tx_digasfemanagement_domain_model_access.start_time',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
Expand All @@ -60,8 +60,8 @@
'default' => 0,
],
],
'endtime' => [
'label' => 'LLL:EXT:digas_fe_management/Resources/Private/Language/locallang_db.xlf:tx_digasfemanagement_domain_model_access.endtime',
'end_time' => [
'label' => 'LLL:EXT:digas_fe_management/Resources/Private/Language/locallang_db.xlf:tx_digasfemanagement_domain_model_access.end_time',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'start_time' => 'start_time',
'end_time' => 'end_time',
],
'searchFields' => 'title,fe_user,search_params',
'iconfile' => 'EXT:digas_fe_management/Resources/Public/Icons/tx_digasfemanagement_domain_model_search.gif'
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<source><![CDATA[Kitodo document uid]]></source>
<target><![CDATA[Kitodo uid]]></target>
</trans-unit>
<trans-unit id="tx_digasfemanagement_domain_model_access.endtime" approved="yes">
<trans-unit id="tx_digasfemanagement_domain_model_access.end_time" approved="yes">
<source><![CDATA[Access end]]></source>
<target><![CDATA[Zugriff ende]]></target>
</trans-unit>
Expand All @@ -85,7 +85,7 @@
<source><![CDATA[Rejected reason]]></source>
<target><![CDATA[Zugriff verweigert Begründung]]></target>
</trans-unit>
<trans-unit id="tx_digasfemanagement_domain_model_access.starttime" approved="yes">
<trans-unit id="tx_digasfemanagement_domain_model_access.start_time" approved="yes">
<source><![CDATA[Access start]]></source>
<target><![CDATA[Zugriff start]]></target>
</trans-unit>
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@
<trans-unit id="tx_digasfemanagement_domain_model_access">
<source>Kitodo FE user access</source>
</trans-unit>
<trans-unit id="tx_digasfemanagement_domain_model_access.starttime">
<trans-unit id="tx_digasfemanagement_domain_model_access.start_time">
<source>Access start</source>
</trans-unit>
<trans-unit id="tx_digasfemanagement_domain_model_access.endtime">
<trans-unit id="tx_digasfemanagement_domain_model_access.end_time">
<source>Access end</source>
</trans-unit>
<trans-unit id="tx_digasfemanagement_domain_model_access.dlf_document">
Expand Down
Loading

0 comments on commit 8ab3e2b

Please sign in to comment.