Giter Club home page Giter Club logo

typo3-fal-quota's Introduction

FAL Quota for TYPO3

This extensions provides a virtual Quota for FAL using Signals/Slots if the underlying file system does not support or cannot provide one. A CLI command updates the quota usage periodically and sends notification mails to recipients defined per storage.

Features

  • Per storage definition of soft quota and hard limit, notification threshold and email recipients
  • Symfony Command task to update quotas and send notification mails

Installation

After installation, you may optionally create a scheduler task for notifications.

Installation using Composer

The recommended way to install FAL Quota is by using Composer:

composer require mehrwert/fal-quota

Installation as extension from TYPO3 Extension Repository (TER)

Download and install the extension with the Extensions module.

Submit bug reports or feature requests

Look at the Issues for what has been planned to be implemented in the (near) future.

DDEV local

To use the included DDEV local configuration, run

  • ddev start from the extensions root directory to start the container
  • ddev config to create required configuration files if not yet present
  • ddev launch typo3 to get to the TYPO3 backend directly

If you are setting up the environment for the first time, create a file named FIRST_INSTALL in .build/web/ and proceed with the TYPO3 installation as described in the official documentation.

Coding Standards

Please run ddev composer cs:fix after changes in PHP files.

Credits

This extension was created by Andreas Beutel in 2019 for mehrwert intermediale kommunikation GmbH.

Thanks to all contributors and everybody providing feedback.

typo3-fal-quota's People

Contributors

abeutel avatar fnagel avatar someplace53 avatar tstahn avatar

Watchers

 avatar  avatar  avatar

typo3-fal-quota's Issues

Backend View improvements

I like the the extensions but I have a few suggestions for improvements:

  1. make the table in the backend sortable (and maybe a filter would be nice, too)
  2. if a "normal" editor is given access to the "FAL Quota" module, remove the action button, as the editor cannot and should not use the button. (In case it is not obvious why I would give a normal editor access to the module, I want them to now how much quota the have left without asking me :-) )
  3. I am not sure why in the "FAL Quota" module (on the left) all filemounts are listed. I would probably get rid of it.

Thanks for the work already done :-)

Move update of current_usage into separate Command

Currently the update of the storage usage statistics (current_usage) is performed at the same time as the email notifications are sent (see QuotaCommand).

There are however valid use cases in which these usage statistics shall be updated without instantly sending notifications (i.e. usage is updated daily for internal reference, but mails to inform editors should be sent weekly instead).

We should accomodate for this and implement these functions independently.

Notify command does not seem to support multiple recipients despite using addAdditionalRecipients slot

When using the addAdditionalRecipients slot to extend the recipient list, only a single recipient receives the warning email.

Expected behaviour

The default quota_warning_recipients as well as all members of the added quota_warning_recipients group receive warning emails.

Actual behaviour

Instead of and the compiled list from quota_warning_recipients and quota_warning_recipients, only the very last recipient of quota_warning_recipients receives an email.

It seems the foreach in NotifyCommand::sendNotificationWithSymfonyMail() is not working as intended, see https://github.com/mehrwert/TYPO3-FAL-Quota/blob/master/Classes/Command/NotifyCommand.php#L200

I propose the followng change:

Before

foreach ($recipients as $recipient) {
    $mailMessage->to($recipient);
}

After

$mailMessage->setTo($recipients);

PHP 7.4
TYPO3 10.4.20

Email notification is not send if configured warning threshold is exceeded

Given the following configuration (see screenshots - threshold of 75 clearly exceeded), the fal_quota:quota:update command should send a notification email to the corresponding recipient – but doesn't.

Storage:
Bildschirmfoto_2021-01-13_um_14_59_09

FAL-Quota module:
Bildschirmfoto_2021-01-13_um_14_59_54

The condition used in QuotaCommand::checkThreshold() seems to be the issue here.

This is the debug output of $quotaConfiguration (values from above mentioned storage):

current_usage => 4105236127 (integer)
soft_quota => 5242880000 (integer)
hard_limit => 5347737600 (integer)
quota_warning_threshold => 75 (integer)
quota_warning_recipients => "<redacted>"

This is the condition used in QuotaCommand::checkThreshold():

if ($quotaConfiguration['soft_quota'] > 0 &&
    $quotaConfiguration['quota_warning_threshold'] > 0 &&
    $quotaConfiguration['current_usage'] > $quotaConfiguration['soft_quota']) {
    $currentThreshold = (int)($quotaConfiguration['current_usage'] / $quotaConfiguration['soft_quota'] * 100);
    if ($currentThreshold >= $quotaConfiguration['quota_warning_threshold'] && !empty($quotaConfiguration['quota_warning_recipients'])) {
        $this->sendNotification($storage, $quotaConfiguration, $currentThreshold);
    }
}

As one can see $quotaConfiguration['current_usage'] > $quotaConfiguration['soft_quota'] evaluates to false (see given $quotaConfiguration) which causes the threshold check to be never reached.

This is a logical flaw, because the threshold is practically obsolete as long as the "current_usage has to be larger than soft_quota" condition is in place.

Extension does not define its extension key in composer.json

composer install oder composer update commands lead to the following warning:

The TYPO3 extension package "mehrwert/fal-quota", does not define an extension key in its composer.json. Please report this to the author of this package. Specifying the extension key will be mandatory in future versions of TYPO3 (see: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ComposerJson/Index.html#extra)

As per documentation, providing the extra property in the extensions composer.json will solve this issue (which is also required for TYPO3 10 compatibility).

{
   "extra": {
      "typo3/cms": {
         "extension-key": "fal_quota"
      }
   }
}

Provide drud/ddev environment

We might want to think about including a drud/ddev dev environment instead of having everyone set up their own TYPO3 instance in whatever way they choose, in order to contribute to the codebase.

Not only would this make the setup itself easier (thus lowering the barrier for potential contributions), it would also provide us with a consistent environment for feature improvements (e.g. tests).

Examples:

Typo3-Exception in case hard limit exceeds available space

exception on typo3 10.4:
"Return value of Mehrwert\FalQuota\Hooks\DatamapDataHandlerHook::getLanguageService() must be an instance of TYPO3\CMS\Lang\LanguageService, instance of TYPO3\CMS\Core\Localization\LanguageService returned"

Solution:
Change line 15 of Classes/Hooks/DatamapDataHandlerHook.php
to: use TYPO3\CMS\Core\Localization\LanguageService;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.