Quellcode durchsuchen

add the ot:users:enfeedit command

Olivier Massot vor 5 Jahren
Ursprung
Commit
d756f0e97e

+ 75 - 0
ot_admin/Classes/Command/EnableFeEditingCommand.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace Opentalent\OtAdmin\Command;
+
+
+use Opentalent\OtAdmin\Controller\SiteController;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * This CLI command enable front-end editing for all be-users
+ *
+ * @package Opentalent\OtAdmin\Command
+ */
+class EnableFeEditingCommand extends Command
+{
+
+    /**
+     * -- This method is expected by Typo3, do not rename ou remove --
+     *
+     * Allows to configure the command.
+     * Allows to add a description, a help text, and / or define arguments.
+     *
+     */
+    protected function configure()
+    {
+        $this
+            ->setName("ot:users:enfeedit")
+            ->setDescription("Enable front-end editing for all be-users");
+    }
+
+    /**
+     * -- This method is expected by Typo3, do not rename ou remove --
+     *
+     * Executes the command for creating the new organization
+     *
+     * @param InputInterface $input
+     * @param OutputInterface $output
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $io = new SymfonyStyle($input, $output);
+
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getQueryBuilderForTable('be_users');
+        $queryBuilder->getRestrictions()->removeAll();
+
+        $statement = $queryBuilder
+            ->select('be_users.*')
+            ->from('be_users')
+            ->where(
+                $queryBuilder->expr()->eq('be_users.usergroup', $queryBuilder->createNamedParameter(3, \PDO::PARAM_INT))
+            )
+            ->execute()
+            ;
+
+        while ($row = $statement->fetch()) {
+            $id = (int)$row['uid'];
+            $BE_USER = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
+            $user = $BE_USER->getRawUserByUid($id);
+            $BE_USER->user = $user;
+            $BE_USER->backendSetUC();
+            $BE_USER->uc['frontend_editing'] = 1;
+            $BE_USER->writeUC($BE_USER->uc);
+        }
+
+        $io->success(sprintf("-- done --"));
+    }
+
+}

+ 5 - 12
ot_admin/Classes/Controller/SiteController.php

@@ -132,8 +132,6 @@ class SiteController extends ActionController
             $this->cnnPool->getConnectionForTable($table)->beginTransaction();
         }
 
-        $pages = [];
-
         try {
             // Create the site pages:
             // > Root page
@@ -357,7 +355,7 @@ class SiteController extends ActionController
                          "            url = " . $organization->getNetworkUrl() .
                          "        }" .
                          "    }" .
-                         "}" .
+                         "}";
 
             $queryBuilder = $this->cnnPool->getQueryBuilderForTable('sys_template');
             $queryBuilder->insert('sys_template')
@@ -367,7 +365,8 @@ class SiteController extends ActionController
                     'sitetitle' => $organization->getName(),
                     'root' => 1,
                     'clear' => 3,
-                    'include_static_file' => 'EXT:fluid_styled_content/Configuration/TypoScript/,EXT:fluid_styled_content/Configuration/TypoScript/Styling/,EXT:ot_widgets/Configuration/TypoScript,EXT:form/Configuration/TypoScript/,EXT:news/Configuration/TypoScript,EXT:ot_templating/Configuration/TypoScript',
+                    'config' => "config = 'config.frontend_editing = 1\nconfig.absRefPrefix = /',",
+                    'include_static_file' => 'EXT:fluid_styled_content/Configuration/TypoScript/,EXT:fluid_styled_content/Configuration/TypoScript/Styling/,EXT:form/Configuration/TypoScript/,EXT:news/Configuration/TypoScript,EXT:frontend_editing/Configuration/TypoScript,EXT:frontend_editing/Configuration/TypoScript/FluidStyledContent9,EXT:ot_templating/Configuration/TypoScript',
                     'constants' => $constants
                 ])
                 ->execute();
@@ -402,19 +401,13 @@ class SiteController extends ActionController
                 'routes'=>[]
                 ];
             $yamlConfig = Yaml::dump($config, 4);
-            
-
 
             // Create the contact form
-            $contscatForm = "";
+            $contactForm = "";
 
             // Create the BE user
 
-
-            // Create the user_upload directory
-
-//            throw new \Exception('not implemented');
-
+            // Create the user_upload directory (sys_filemounts)
 
             // Try to commit the result
             foreach ($tables as $table) {

+ 3 - 0
ot_admin/Configuration/Commands.php

@@ -12,6 +12,9 @@
 return [
     'ot:site:create' => [
         'class' => Opentalent\OtAdmin\Command\CreateOrganizationCommand::class
+    ],
+    'ot:users:enfeedit' => [
+        'class' => Opentalent\OtAdmin\Command\EnableFeEditingCommand::class
     ]
 ];
 

+ 6 - 0
ot_admin/Configuration/Services.yaml

@@ -12,3 +12,9 @@ services:
       - name: 'ot:site:create'
         command: 'ot:site:create'
         schedulable: false
+
+  Opentalent\OtAdmin\Command\EnableFeEditingCommand:
+    tags:
+      - name: 'ot:users:enfeedit'
+        command: 'ot:users:enfeedit'
+        schedulable: false

+ 0 - 3
ot_admin/ext_localconf.php

@@ -1,3 +0,0 @@
-<?php
-defined('TYPO3_MODE') || die();
-

+ 1 - 1
ot_templating/Resources/Private/Templates/Page/E404.html

@@ -5,7 +5,7 @@
 <f:layout name="{ot:template.current()}/E404" />
 
 <f:section name='Configuration'>
-    <flux:form id="E404" label="Gabarit Page introuvable" extensionName="Opentalent.OtTemplating">
+    <flux:form id="e404" label="Gabarit Page introuvable" extensionName="Opentalent.OtTemplating">
     </flux:form>
 
     <f:comment><!-- Backend layout grid --></f:comment>