Skip to content

Commit

Permalink
Merge pull request #29 from jweiland-net/doNotAddUserOnCliMode
Browse files Browse the repository at this point in the history
Do not add user on cli mode
  • Loading branch information
hojalatheef authored Jan 17, 2024
2 parents 0848dae + 5182e46 commit d379dc5
Show file tree
Hide file tree
Showing 16 changed files with 173 additions and 117 deletions.
20 changes: 16 additions & 4 deletions Classes/Traits/ApplicationContextTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,28 @@ trait ApplicationContextTrait
{
private function isBackendRequest(): bool
{
return ApplicationType::fromRequest($this->getTypo3Request())->isBackend();
$request = $this->getTypo3Request();
if ($request instanceof ServerRequestInterface) {
return ApplicationType::fromRequest($request)->isBackend();
}

// In CLI context there is no TYPO3_REQUEST
return false;
}

private function isFrontendRequest(): bool
{
return ApplicationType::fromRequest($this->getTypo3Request())->isFrontend();
$request = $this->getTypo3Request();
if ($request instanceof ServerRequestInterface) {
return ApplicationType::fromRequest($request)->isFrontend();
}

// In CLI context there is no TYPO3_REQUEST
return false;
}

private function getTypo3Request(): ServerRequestInterface
private function getTypo3Request(): ?ServerRequestInterface
{
return $GLOBALS['TYPO3_REQUEST'];
return $GLOBALS['TYPO3_REQUEST'] ?? null;
}
}
9 changes: 7 additions & 2 deletions Documentation/ChangeLog/Index.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt


.. _changelog:
.. _changelog:

=========
ChangeLog
=========

Version 3.0.6
=============

* [BUGFIX] Do not try to add user information to images in CLI mode.

Version 3.0.5
=============

Expand Down
9 changes: 5 additions & 4 deletions Documentation/Configuration/Index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt


.. _configuration:
.. _configuration:

=============
Configuration
Expand All @@ -13,5 +13,6 @@ Extension Settings
Owner
-----

If you upload files you have to activate a checkbox to give an owner unrestricted rights
to the uploaded files. The owner in the label is a placeholder and can be set in Extension Settings.
If you upload files you have to activate a checkbox to give an owner
unrestricted rights to the uploaded files. The owner in the label is a
placeholder and can be set in Extension Settings.
30 changes: 18 additions & 12 deletions Documentation/Developer/Index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt


.. _developer-manual:
.. _developer-manual:

================
Developer manual
Expand All @@ -14,18 +14,21 @@ checkfaluploads adds two columns to table sys_file:

**cruser_id**

This column will be filled automatically by `checkfaluploads` in TYPO3 BE context.
This column will be filled automatically by `checkfaluploads` in
TYPO3 BE context.

**fe_cruser_id**

This column will be automatically filled by the current logged in FE user, as long
as you use the officially TYPO3 API for FAL files. In any other cases you have to fill this column on your own.
This column will be automatically filled by the current logged in FE user, as
long as you use the officially TYPO3 API for FAL files. In any other cases you
have to fill this column on your own.

FalUploadService
================

We deliver a little API you can use in your own Extension to check, if an uploaded file from FE context
has the user rights checkbox marked. Add checkbox to your Fluid Template:
We deliver a little API you can use in your own Extension to check, if an
uploaded file from FE context has the user rights checkbox marked. Add checkbox
to your Fluid Template:

Checkbox via Fluid
------------------
Expand All @@ -37,7 +40,8 @@ Checkbox via Fluid
class="form-check-input"
value="1" />

Somewhere in your extbase extension you should have an UploadTypeConverter. Add following lines:
Somewhere in your extbase extension you should have an UploadTypeConverter.
Add following lines:

.. code-block:: php
Expand Down Expand Up @@ -82,8 +86,9 @@ ViewHelpers
ImageRightsMessageViewHelper
----------------------------

This ViewHelper reads the owner property of checkfaluploads extension settings and implements the owner
into a localized string. That way you can build a text like "I give all image rights to jweiland.net".
This ViewHelper reads the owner property of `checkfaluploads` extension
settings and implements the owner into a localized string. That way you can
build a text like "I give all image rights to jweiland.net".

.. code-block:: html

Expand All @@ -95,8 +100,9 @@ Or inline style:

{c:imageRightsMessage()}

If you want you can use your own translation of your own extension. In that case be sure you have added `%s` as
placeholder into your message of locallang.xml.
If you want you can use your own translation of your own extension. In that
case be sure you have added `%s` as placeholder into your message
of locallang.xlf.

.. code-block:: html

Expand Down
50 changes: 25 additions & 25 deletions Documentation/Includes.rst.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
.. More information about this file:
https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/GeneralConventions/FileStructure.html#includes-rst-txt
.. More information about this file:
https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/GeneralConventions/FileStructure.html#includes-rst-txt
.. ----------
.. text roles
.. ----------
.. ----------
.. text roles
.. ----------
.. role:: aspect(emphasis)
.. role:: bash(code)
.. role:: html(code)
.. role:: js(code)
.. role:: php(code)
.. role:: rst(code)
.. role:: sep(strong)
.. role:: sql(code)
.. role:: aspect(emphasis)
.. role:: bash(code)
.. role:: html(code)
.. role:: js(code)
.. role:: php(code)
.. role:: rst(code)
.. role:: sep(strong)
.. role:: sql(code)

.. role:: tsconfig(code)
:class: typoscript
.. role:: tsconfig(code)
:class: typoscript

.. role:: typoscript(code)
.. role:: xml(code)
:class: html
.. role:: typoscript(code)
.. role:: xml(code)
:class: html

.. role:: yaml(code)
.. role:: yaml(code)

.. default-role:: code
.. default-role:: code

.. ---------
.. highlight
.. ---------
.. ---------
.. highlight
.. ---------
.. By default, code blocks use PHP syntax highlighting
.. By default, code blocks use PHP syntax highlighting
.. highlight:: php
.. highlight:: php
5 changes: 2 additions & 3 deletions Documentation/Index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt


.. _start:
.. _start:

===============
Checkfaluploads
Expand Down Expand Up @@ -49,7 +49,6 @@ where the user gives unrestricted rights to the owner for the uploaded files.
Developer/Index
KnownProblems/Index
ChangeLog/Index
Links
Sitemap

.. Meta Menu
Expand Down
55 changes: 47 additions & 8 deletions Documentation/Installation/Index.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,59 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt


.. _installation:
.. _installation:

============
Installation
============

Target group: **Administrators**
Composer
========

The extension needs to be installed like any other extension of TYPO3 CMS:
If your TYPO3 installation works in composer mode, please execute following
command:

#. Visit ExtensionManager
.. code-block:: bash
#. Switch over to `Get Extensions`
composer req jweiland/checkfaluploads
vendor/bin/typo3 extension:setup --extension=checkfaluploads
#. Search for `checkfaluploads`
If you work with DDEV please execute this command:

#. Install extension
.. code-block:: bash
ddev composer req jweiland/checkfaluploads
ddev exec vendor/bin/typo3 extension:setup --extension=checkfaluploads
ExtensionManager
================

On non composer based TYPO3 installations you can install `checkfaluploads`
still over the ExtensionManager:

.. rst-class:: bignums

1. Login

Login to backend of your TYPO3 installation as an administrator or system
maintainer.

2. Open ExtensionManager

Click on `Extensions` from the left menu to open the ExtensionManager.

3. Update Extensions

Choose `Get Extensions` from the upper selectbox and click on
the `Update now` button at the upper right.

4. Install `checkfaluploads`

Use the search field to find `checkfaluploads`. Choose the `checkfaluploads`
line from the search result and click on the cloud icon to
install `checkfaluploads`.

Next step
=========

:ref:`Configure checkfaluploads <configuration>`.
15 changes: 8 additions & 7 deletions Documentation/Introduction/Index.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt


.. _introduction:
.. _introduction:

============
Introduction
============


.. _what-it-does:
.. _what-it-does:

What does it do?
================

With checkfaluploads we will add a new checkbox to filelist module and ElementBrowser
where the user gives unrestricted rights to the owner for the uploaded files.
Further the UID of the image uploading editor will be added to the `sys_file` record, so an admin can see who has
uploaded a file in history.
With checkfaluploads we will add a new checkbox to filelist module and
ElementBrowser where the user gives unrestricted rights to the owner for the
uploaded files. Further the UID of the image uploading editor will be added
to the `sys_file` record, so an admin can see who has uploaded a file
in history.
10 changes: 7 additions & 3 deletions Documentation/KnownProblems/Index.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt


.. _known-problems:
.. _known-problems:

==============
Known Problems
==============

Currently there are no known issues.
No user in CLI mode
===================

We only set FE or BE user in frontend or backend mode. As the user for CLI mode
is always the same one and only user, it does not make sense to add that
user as creator or editor to any files.
24 changes: 0 additions & 24 deletions Documentation/Links.rst

This file was deleted.

4 changes: 2 additions & 2 deletions Documentation/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
[general]

project = Check FAL Uploads
version = 3.0.5
version = 3.0.6
release = 3.0
copyright = by jweiland.net

[html_theme_options]

# "Edit on GitHub" button
github_repository = jweiland-net/checkfaluploads
github_branch = master
github_branch = TYPO3_10-4

# Footer links
project_home =
Expand Down
4 changes: 2 additions & 2 deletions Documentation/Sitemap.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:template: sitemap.html

.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt

=======
Sitemap
=======

.. The sitemap.html template will insert here the page tree automatically.
.. The sitemap.html template will insert here the page tree automatically.
Loading

0 comments on commit d379dc5

Please sign in to comment.