From 81c80701744bd6fe4b758523fa1c62dce38c3c4e Mon Sep 17 00:00:00 2001 From: Craig Heydenburg Date: Fri, 14 Jul 2017 10:41:48 -0400 Subject: [PATCH] Todos (#3654) * #3644 * #3644 * Use SchemaValidationHelper to accomplish all validation for an extension * #3646 * convert todo to simple note * remove todo * #3647 * remove deprecated plugin type * remove todo * remove todo * refs #3530 * #3648 * #3648 * don't restrict filenames in doc controller * #3454 * rem todo * inject translator * restrict doc controller arg @Guite * #3649 * send specific message about group membership * send specific message about group membership * ci * translate validation error * remove todo * #3650 * #3651 * #3644 * #3652, #2915 * #2915 * #2842 * rem todo * #2842 * #3653 * revert mistaken change --- .../Bundle/Helper/BootstrapHelper.php | 5 +-- .../Bundle/CoreBundle/Bundle/MetaData.php | 4 +-- .../Bundle/CoreBundle/Bundle/Scanner.php | 28 +-------------- .../Zikula/Bundle/CoreBundle/CoreBundle.php | 1 - .../ClickjackProtectionListener.php | 2 +- .../public/css/bootstrap_variables.less | 1 - .../Translation/ZikulaJsFileExtractor.php | 2 +- .../Zikula/Bundle/CoreBundle/Yaml/Dumper.php | 4 --- .../Zikula/Bundle/CoreBundle/Yaml/Inline.php | 4 --- .../Zikula/Bundle/CoreBundle/Yaml/Yaml.php | 4 --- .../Controller/DocController.php | 6 +--- .../Resources/config/routing/routing.xml | 3 +- .../HookBundle/Controller/HookController.php | 2 +- .../Zikula/Common/Translator/Translator.php | 2 -- .../Block/Form/Type/FincludeBlockType.php | 16 ++++++++- .../Resources/config/services.yml | 6 ++++ .../Entity/ExtensionEntity.php | 2 +- .../Helper/ExtensionDependencyHelper.php | 2 +- .../Helper/ExtensionHelper.php | 2 +- .../Schema/schema.composer.json | 5 +-- .../Tests/Fixtures/minimum_composer.json | 3 ++ .../Fixtures/minimum_error1_composer.json | 3 ++ .../Fixtures/minimum_error2_composer.json | 23 ++++++++++++ .../minimum_syntax_error_composer.json | 3 ++ .../Helper/ComposerValidationHelperTest.php | 2 ++ .../Controller/ApplicationController.php | 31 +++++++++++++--- .../Controller/MembershipController.php | 36 +++++++++++++++---- .../EventListener/OptionValidatorListener.php | 20 +++++++++-- .../MenuModule/Form/Type/MenuItemType.php | 2 +- .../ThemeModule/Controller/VarController.php | 1 - src/system/ThemeModule/Engine/Engine.php | 1 - .../DefaultPageAssetSetterListener.php | 5 +-- .../DefaultPageVarSetterListener.php | 2 +- .../ExtensionInstallationListener.php | 1 - .../Controller/AccessController.php | 2 +- .../UserAdministrationController.php | 4 +-- .../AbstractNativeAuthenticationMethod.php | 2 +- .../UserAdministrationController.php | 2 +- .../ZAuthModule/Form/Type/ConfigType.php | 4 +-- .../PrinterTheme/ZikulaPrinterTheme.php | 2 +- 40 files changed, 158 insertions(+), 92 deletions(-) create mode 100644 src/system/ExtensionsModule/Tests/Fixtures/minimum_error2_composer.json diff --git a/src/lib/Zikula/Bundle/CoreBundle/Bundle/Helper/BootstrapHelper.php b/src/lib/Zikula/Bundle/CoreBundle/Bundle/Helper/BootstrapHelper.php index df536277de..c2e62c4e74 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Bundle/Helper/BootstrapHelper.php +++ b/src/lib/Zikula/Bundle/CoreBundle/Bundle/Helper/BootstrapHelper.php @@ -111,9 +111,6 @@ private function insert(MetaData $metadata) case 'zikula-theme': $type = 'T'; break; - case 'zikula-plugin': - $type = 'P'; - break; default: throw new \InvalidArgumentException(sprintf('Unknown type %s', $metadata->getType())); } @@ -123,7 +120,7 @@ private function insert(MetaData $metadata) 'autoload' => $autoload, 'bundleclass' => $class, 'bundletype' => $type, - 'bundlestate' => AbstractBundle::STATE_ACTIVE, // todo - this has to be changed + 'bundlestate' => AbstractBundle::STATE_ACTIVE, ]); } diff --git a/src/lib/Zikula/Bundle/CoreBundle/Bundle/MetaData.php b/src/lib/Zikula/Bundle/CoreBundle/Bundle/MetaData.php index 613f941c8e..521b961ef1 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Bundle/MetaData.php +++ b/src/lib/Zikula/Bundle/CoreBundle/Bundle/MetaData.php @@ -284,11 +284,11 @@ public function getThemeFilteredVersionInfoArray() 'description' => $this->getDescription(), 'version' => $this->getVersion(), // 'capabilities' => $this->getCapabilities(), - // @todo temp - add to DB and move to inverse in legacy code and refactor later checks + // It would be better to add capabilities to DB and move to inverse in legacy code and refactor later checks. refs #3644 'user' => isset($capabilities['user']) ? $capabilities['user'] : true, 'admin' => isset($capabilities['admin']) ? $capabilities['admin'] : true, 'system' => isset($capabilities['system']) ? $capabilities['system'] : false, - 'xhtml' => isset($capabilities['xhtml']) ? $capabilities['xhtml'] : true, // @todo is this valid any longer? + 'xhtml' => isset($capabilities['xhtml']) ? $capabilities['xhtml'] : true, // this is not truly valid in 2.0 ]; } diff --git a/src/lib/Zikula/Bundle/CoreBundle/Bundle/Scanner.php b/src/lib/Zikula/Bundle/CoreBundle/Bundle/Scanner.php index a621af2fe7..0fd91b0368 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Bundle/Scanner.php +++ b/src/lib/Zikula/Bundle/CoreBundle/Bundle/Scanner.php @@ -66,7 +66,7 @@ public function decode($file) $base = substr($base, strlen($zkRoot) + 1); $json = json_decode($this->getFileContents($file), true); - if (\JSON_ERROR_NONE === json_last_error() && true === $this->validateBasic($json)) { + if (\JSON_ERROR_NONE === json_last_error()) { // add base-path for future use $json['extra']['zikula']['base-path'] = $base; @@ -102,32 +102,6 @@ public function getThemesMetaData($indexByShortName = false) return $this->getMetaData('zikula-theme', $indexByShortName); } - // @todo this can probably be removed in favour of ComposerValidationHelper - private function validateBasic($json) - { - if (!isset($json['type'])) { - return false; - } - - switch ($json['type']) { - case 'zikula-module': - case 'zikula-theme': - break; - default: - return false; - } - - if (!isset($json['autoload']['psr-4'])) { - return false; - } - - if (!isset($json['extra']['zikula']['class'])) { - return false; - } - - return true; - } - private function getMetaData($type, $indexByShortName) { $array = []; diff --git a/src/lib/Zikula/Bundle/CoreBundle/CoreBundle.php b/src/lib/Zikula/Bundle/CoreBundle/CoreBundle.php index dded497f0a..339c47593a 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/CoreBundle.php +++ b/src/lib/Zikula/Bundle/CoreBundle/CoreBundle.php @@ -31,7 +31,6 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new OverrideBlameableListenerPass()); - // todo - see if we can do this only on module install/upgrade - drak $container->addCompilerPass(new ValidateServiceDefinitionsPass(), PassConfig::TYPE_AFTER_REMOVING); } } diff --git a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ClickjackProtectionListener.php b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ClickjackProtectionListener.php index 5c3623ed7c..d687dc8e5c 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ClickjackProtectionListener.php +++ b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ClickjackProtectionListener.php @@ -18,7 +18,7 @@ /** * Sets x-origin headers to prevent clickjacking attacks. * - * TODO consider https://github.com/nelmio/NelmioSecurityBundle for a future major release + * Consider https://github.com/nelmio/NelmioSecurityBundle for a future major release refs #3646 */ class ClickjackProtectionListener implements EventSubscriberInterface { diff --git a/src/lib/Zikula/Bundle/CoreBundle/Resources/public/css/bootstrap_variables.less b/src/lib/Zikula/Bundle/CoreBundle/Resources/public/css/bootstrap_variables.less index 984f624b91..00f945a3c9 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Resources/public/css/bootstrap_variables.less +++ b/src/lib/Zikula/Bundle/CoreBundle/Resources/public/css/bootstrap_variables.less @@ -194,7 +194,6 @@ //** `` border color @input-border: #ccc; -// TODO: Rename `@input-border-radius` to `@input-border-radius-base` in v4 //** Default `.form-control` border radius // This has no effect on ``s in CSS. @input-border-radius: @border-radius-base; diff --git a/src/lib/Zikula/Bundle/CoreBundle/Translation/ZikulaJsFileExtractor.php b/src/lib/Zikula/Bundle/CoreBundle/Translation/ZikulaJsFileExtractor.php index 92abe35fb1..b60d97cdb6 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Translation/ZikulaJsFileExtractor.php +++ b/src/lib/Zikula/Bundle/CoreBundle/Translation/ZikulaJsFileExtractor.php @@ -18,7 +18,7 @@ class ZikulaJsFileExtractor implements FileVisitorInterface { - const JAVASCRIPT_DOMAIN = 'zikula_javascript'; // @todo figure out way to compute the bundle's translation domain? + const JAVASCRIPT_DOMAIN = 'zikula_javascript'; // figure out way to compute the bundle's translation domain? #3650 const SINGULAR_CAPTURE_REGEX = '\s?([\'"])((?:(?!\1).)*)\1\s?'; const PLURAL_CAPTURE_REGEX = '\s?([\'"])((?:(?!\1).)*)\1\s?,\s?([\'"])((?:(?!\3).)*)\3\s?'; const REGEX_DELIMITER = '/'; diff --git a/src/lib/Zikula/Bundle/CoreBundle/Yaml/Dumper.php b/src/lib/Zikula/Bundle/CoreBundle/Yaml/Dumper.php index 40ee516d31..c30f8a4b5c 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Yaml/Dumper.php +++ b/src/lib/Zikula/Bundle/CoreBundle/Yaml/Dumper.php @@ -13,10 +13,6 @@ /** * Dumper dumps PHP variables to YAML strings. - * - * @todo remove after migration to Symfony 3.x and use new parameters instead - * @see https://github.com/zikula/core/issues/2889 - * @see http://symfony.com/blog/new-in-symfony-3-1-customizable-yaml-parsing-and-dumping */ class Dumper extends \Symfony\Component\Yaml\Dumper { diff --git a/src/lib/Zikula/Bundle/CoreBundle/Yaml/Inline.php b/src/lib/Zikula/Bundle/CoreBundle/Yaml/Inline.php index 036f97d54d..7c49c605d3 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Yaml/Inline.php +++ b/src/lib/Zikula/Bundle/CoreBundle/Yaml/Inline.php @@ -13,10 +13,6 @@ /** * Inline implements a YAML parser/dumper for the YAML inline syntax. - * - * @todo remove after migration to Symfony 3.x and use new parameters instead - * @see https://github.com/zikula/core/issues/2889 - * @see http://symfony.com/blog/new-in-symfony-3-1-customizable-yaml-parsing-and-dumping */ class Inline extends \Symfony\Component\Yaml\Inline { diff --git a/src/lib/Zikula/Bundle/CoreBundle/Yaml/Yaml.php b/src/lib/Zikula/Bundle/CoreBundle/Yaml/Yaml.php index 1f436462db..82c81a392b 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/Yaml/Yaml.php +++ b/src/lib/Zikula/Bundle/CoreBundle/Yaml/Yaml.php @@ -13,10 +13,6 @@ /** * Yaml offers convenience methods to load and dump YAML. - * - * @todo remove after migration to Symfony 3.x and use new parameters instead - * @see https://github.com/zikula/core/issues/2889 - * @see http://symfony.com/blog/new-in-symfony-3-1-customizable-yaml-parsing-and-dumping */ class Yaml extends \Symfony\Component\Yaml\Yaml { diff --git a/src/lib/Zikula/Bundle/CoreInstallerBundle/Controller/DocController.php b/src/lib/Zikula/Bundle/CoreInstallerBundle/Controller/DocController.php index 03d3559aa3..fc730c7e3b 100644 --- a/src/lib/Zikula/Bundle/CoreInstallerBundle/Controller/DocController.php +++ b/src/lib/Zikula/Bundle/CoreInstallerBundle/Controller/DocController.php @@ -73,12 +73,8 @@ public function __construct( * @param string $name * @return Response */ - public function displayAction(Request $request, $name = 'INSTALL-1.4.md') + public function displayAction(Request $request, $name = 'INSTALL-2.0.md') { - // @TODO this is temporary method of restricting the user input - if (!in_array($name, ['INSTALL-1.4.md', 'UPGRADE-1.4.md', 'CHANGELOG.md', 'README.md'])) { - $name = 'INSTALL-1.4.md'; - } $this->setBasePath($request); if (file_exists($this->basePath . "/$name")) { diff --git a/src/lib/Zikula/Bundle/CoreInstallerBundle/Resources/config/routing/routing.xml b/src/lib/Zikula/Bundle/CoreInstallerBundle/Resources/config/routing/routing.xml index 346da7c304..2b8e6018c0 100644 --- a/src/lib/Zikula/Bundle/CoreInstallerBundle/Resources/config/routing/routing.xml +++ b/src/lib/Zikula/Bundle/CoreInstallerBundle/Resources/config/routing/routing.xml @@ -32,6 +32,7 @@ zikula_core_installer.controller.doc:displayAction - INSTALL-1.4.md + INSTALL-2.0.md + request.query.get('name') matches "/[^\/]+.md/" diff --git a/src/lib/Zikula/Bundle/HookBundle/Controller/HookController.php b/src/lib/Zikula/Bundle/HookBundle/Controller/HookController.php index b3088ec510..ed882a9700 100644 --- a/src/lib/Zikula/Bundle/HookBundle/Controller/HookController.php +++ b/src/lib/Zikula/Bundle/HookBundle/Controller/HookController.php @@ -394,7 +394,7 @@ private function checkAjaxToken($token = null) if (!$currentRequest->isXmlHttpRequest()) { throw new \Exception(); } - // @todo how to SET the $_SERVER['HTTP_X_ZIKULA_AJAX_TOKEN'] ? + // how/where is $_SERVER['HTTP_X_ZIKULA_AJAX_TOKEN'] set? refs #3454 $headerToken = ($currentRequest->server->has('HTTP_X_ZIKULA_AJAX_TOKEN')) ? $currentRequest->server->get('HTTP_X_ZIKULA_AJAX_TOKEN') : null; if ($headerToken == $currentRequest->getSession()->getId()) { return; diff --git a/src/lib/Zikula/Common/Translator/Translator.php b/src/lib/Zikula/Common/Translator/Translator.php index abf3936900..39fb53a747 100644 --- a/src/lib/Zikula/Common/Translator/Translator.php +++ b/src/lib/Zikula/Common/Translator/Translator.php @@ -123,8 +123,6 @@ protected function initialize() /** * Load zikula resource files - * - * @todo better load resource */ private function loadResources() { diff --git a/src/system/BlocksModule/Block/Form/Type/FincludeBlockType.php b/src/system/BlocksModule/Block/Form/Type/FincludeBlockType.php index a29ccad8a6..f46fdbf58a 100644 --- a/src/system/BlocksModule/Block/Form/Type/FincludeBlockType.php +++ b/src/system/BlocksModule/Block/Form/Type/FincludeBlockType.php @@ -22,12 +22,26 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; use Zikula\BlocksModule\Block\FincludeBlock; use Zikula\Common\Translator\IdentityTranslator; +use Zikula\Common\Translator\TranslatorInterface; /** * Class FincludeBlockType */ class FincludeBlockType extends AbstractType { + /** + * @var TranslatorInterface + */ + private $translator; + + /** + * @param TranslatorInterface $translator + */ + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + public function buildForm(FormBuilderInterface $builder, array $options) { $translator = $options['translator']; @@ -76,7 +90,7 @@ public function configureOptions(OptionsResolver $resolver) public function validateFileAgainstMimeType($data, ExecutionContextInterface $context) { if (('text/html' == mime_content_type($data['filo'])) && (0 !== $data['typo'])) { - $context->addViolation('For Html files please select the Html file type.'); // @todo get translator instance from somewhere? + $context->addViolation($this->translator->__('For Html files please select the Html file type.')); } } } diff --git a/src/system/BlocksModule/Resources/config/services.yml b/src/system/BlocksModule/Resources/config/services.yml index 9dc81c5ac2..ee3aa50bd9 100644 --- a/src/system/BlocksModule/Resources/config/services.yml +++ b/src/system/BlocksModule/Resources/config/services.yml @@ -52,6 +52,12 @@ services: tags: - { name: form.type } + zikula_blocks_module.block.finclude_block_type: + class: Zikula\BlocksModule\Block\Form\Type\FincludeBlockType + arguments: ['@translator.default'] + tags: + - { name: form.type, alias: Zikula\BlocksModule\Block\Form\Type\FincludeBlockType } + twig.extension.zikula_blocks_module: class: Zikula\BlocksModule\Twig\Extension\BlocksExtension public: false diff --git a/src/system/ExtensionsModule/Entity/ExtensionEntity.php b/src/system/ExtensionsModule/Entity/ExtensionEntity.php index 91524e7abc..f82a6afd58 100644 --- a/src/system/ExtensionsModule/Entity/ExtensionEntity.php +++ b/src/system/ExtensionsModule/Entity/ExtensionEntity.php @@ -235,7 +235,7 @@ public function setCore_max($core_max) public function setCorecompatibility($coreCompatibility) { - // @todo temporarily use core_min to store the string - rename and remove core_max + // temporarily use core_min to store the string - rename and remove core_max refs #3649 $this->core_min = $coreCompatibility; } } diff --git a/src/system/ExtensionsModule/Helper/ExtensionDependencyHelper.php b/src/system/ExtensionsModule/Helper/ExtensionDependencyHelper.php index 33b4ff9035..444b16c833 100644 --- a/src/system/ExtensionsModule/Helper/ExtensionDependencyHelper.php +++ b/src/system/ExtensionsModule/Helper/ExtensionDependencyHelper.php @@ -170,7 +170,7 @@ private function bundleDependencySatisfied(ExtensionDependencyEntity &$dependenc return true; } if (strpos($dependency->getModname(), 'composer/') !== false) { - // @todo this specifically is for `composer/installers` but will catch all with `composer/` + // this specifically is for `composer/installers` but will catch all with `composer/` return true; } diff --git a/src/system/ExtensionsModule/Helper/ExtensionHelper.php b/src/system/ExtensionsModule/Helper/ExtensionHelper.php index 7713f4c2d2..6c97b0b5a9 100644 --- a/src/system/ExtensionsModule/Helper/ExtensionHelper.php +++ b/src/system/ExtensionsModule/Helper/ExtensionHelper.php @@ -108,7 +108,7 @@ public function upgrade(ExtensionEntity $extension) $bundle = $this->container->get('kernel')->getModule($extension->getName()); - // @TODO: Need to check status of Dependencies here to be sure they are met for upgraded extension. + // Check status of Dependencies here to be sure they are met for upgraded extension. #3647 $installer = $this->getExtensionInstallerInstance($bundle); $result = $installer->upgrade($extension->getVersion()); diff --git a/src/system/ExtensionsModule/Schema/schema.composer.json b/src/system/ExtensionsModule/Schema/schema.composer.json index 4b6c683d97..6bd31641a1 100644 --- a/src/system/ExtensionsModule/Schema/schema.composer.json +++ b/src/system/ExtensionsModule/Schema/schema.composer.json @@ -48,7 +48,8 @@ "type": "object", "additionalProperties": true } - } + }, + "required": ["psr-4"] }, "require": { "type": "object", @@ -90,5 +91,5 @@ "additionalProperties": true } }, - "required": ["name", "description", "type", "license", "authors", "require", "extra"] + "required": ["name", "description", "type", "license", "authors", "require", "extra", "autoload"] } diff --git a/src/system/ExtensionsModule/Tests/Fixtures/minimum_composer.json b/src/system/ExtensionsModule/Tests/Fixtures/minimum_composer.json index 1c9a8b779f..3f142b44f0 100644 --- a/src/system/ExtensionsModule/Tests/Fixtures/minimum_composer.json +++ b/src/system/ExtensionsModule/Tests/Fixtures/minimum_composer.json @@ -8,6 +8,9 @@ "name": "Zikula Team" } ], + "autoload": { + "psr-4": { "Zikula\\FooModule\\": "" } + }, "require": { "php": ">=5.5.9" }, diff --git a/src/system/ExtensionsModule/Tests/Fixtures/minimum_error1_composer.json b/src/system/ExtensionsModule/Tests/Fixtures/minimum_error1_composer.json index 82649e563c..6238ed66cd 100644 --- a/src/system/ExtensionsModule/Tests/Fixtures/minimum_error1_composer.json +++ b/src/system/ExtensionsModule/Tests/Fixtures/minimum_error1_composer.json @@ -7,6 +7,9 @@ "name": "Zikula Team" } ], + "autoload": { + "psr-4": { "Zikula\\FooModule\\": "" } + }, "require": { "php": ">=5.5.9" }, diff --git a/src/system/ExtensionsModule/Tests/Fixtures/minimum_error2_composer.json b/src/system/ExtensionsModule/Tests/Fixtures/minimum_error2_composer.json new file mode 100644 index 0000000000..9592a7f412 --- /dev/null +++ b/src/system/ExtensionsModule/Tests/Fixtures/minimum_error2_composer.json @@ -0,0 +1,23 @@ +{ + "name": "zikula/foo-module", + "description": "A foo module.", + "type": "zikula-module", + "license": "MIT", + "authors": [ + { + "name": "Zikula Team" + } + ], + "autoload": { + "psr-0": { "Zikula\\Module\\FooModule\\": "" } + }, + "require": { + "php": ">=5.5.9" + }, + "extra": { + "zikula": { + "class": "Zikula\\SpecModule\\ZikulaFooModule", + "core-compatibility": ">=1.4.2" + } + } +} diff --git a/src/system/ExtensionsModule/Tests/Fixtures/minimum_syntax_error_composer.json b/src/system/ExtensionsModule/Tests/Fixtures/minimum_syntax_error_composer.json index a5f861132c..ea53cad95a 100644 --- a/src/system/ExtensionsModule/Tests/Fixtures/minimum_syntax_error_composer.json +++ b/src/system/ExtensionsModule/Tests/Fixtures/minimum_syntax_error_composer.json @@ -8,6 +8,9 @@ "name": "Zikula Team" } ], + "autoload": { + "psr-4": { "Zikula\\FooModule\\": "" } + }, "require": { "php": ">=5.5.9" }, diff --git a/src/system/ExtensionsModule/Tests/Helper/ComposerValidationHelperTest.php b/src/system/ExtensionsModule/Tests/Helper/ComposerValidationHelperTest.php index 9a851a7899..9ca0c3805c 100644 --- a/src/system/ExtensionsModule/Tests/Helper/ComposerValidationHelperTest.php +++ b/src/system/ExtensionsModule/Tests/Helper/ComposerValidationHelperTest.php @@ -61,6 +61,7 @@ public function getFileNamesProvider() ['minimum_composer.json', true, []], ['maximum_composer.json', true, []], ['minimum_error1_composer.json', false, ["Error found in composer file of Fixtures (/../Fixtures) in property \"description\": The property description is required."]], + ['minimum_error2_composer.json', false, ["Error found in composer file of Fixtures (/../Fixtures) in property \"autoload.psr-4\": The property psr-4 is required."]], ['minimum_syntax_error_composer.json', false, ["Unable to decode composer file of Fixtures (/../Fixtures): Syntax error. Ensure the composer.json file has a valid syntax."]], ['empty_composer.json', false, [ "Error found in composer file of Fixtures (/../Fixtures) in property \"name\": The property name is required.", @@ -70,6 +71,7 @@ public function getFileNamesProvider() "Error found in composer file of Fixtures (/../Fixtures) in property \"authors\": The property authors is required.", "Error found in composer file of Fixtures (/../Fixtures) in property \"require\": The property require is required.", "Error found in composer file of Fixtures (/../Fixtures) in property \"extra\": The property extra is required.", + "Error found in composer file of Fixtures (/../Fixtures) in property \"autoload\": The property autoload is required.", ]], ]; } diff --git a/src/system/GroupsModule/Controller/ApplicationController.php b/src/system/GroupsModule/Controller/ApplicationController.php index 514bd475fa..a18a37d495 100644 --- a/src/system/GroupsModule/Controller/ApplicationController.php +++ b/src/system/GroupsModule/Controller/ApplicationController.php @@ -103,11 +103,12 @@ public function createAction(Request $request, GroupEntity $group) throw new AccessDeniedException($this->__('Error! You must register for a user account on this site before you can apply for membership of a group.')); } $userEntity = $this->get('zikula_users_module.user_repository')->find($currentUserApi->get('uid')); - if (($group->getGtype() == CommonHelper::GTYPE_CORE) - || ($group->getState() == CommonHelper::STATE_CLOSED) - || ($group->getNbumax() > 0 && $group->getUsers()->count() > $group->getNbumax()) - || ($group->getUsers()->contains($userEntity))) { - $this->addFlash('error', $this->__('Sorry!, You cannot apply to join the requested group')); // @todo more specific info would be better + $groupTypeIsCore = $group->getGtype() == CommonHelper::GTYPE_CORE; + $groupStateIsClosed = $group->getState() == CommonHelper::STATE_CLOSED; + $groupCountIsLimit = $group->getNbumax() > 0 && $group->getUsers()->count() > $group->getNbumax(); + $alreadyGroupMember = $group->getUsers()->contains($userEntity); + if ($groupTypeIsCore || $groupStateIsClosed || $groupCountIsLimit || $alreadyGroupMember) { + $this->addFlash('error', $this->getSpecificGroupMessage($groupTypeIsCore, $groupStateIsClosed, $groupCountIsLimit, $alreadyGroupMember)); return $this->redirectToRoute('zikulagroupsmodule_group_list'); } @@ -146,4 +147,24 @@ public function createAction(Request $request, GroupEntity $group) 'group' => $group, ]; } + + private function getSpecificGroupMessage($groupTypeIsCore, $groupStateIsClosed, $groupCountIsLimit, $alreadyGroupMember) + { + $messages = []; + $messages[] = $this->__('Sorry!, You cannot apply to join the requested group'); + if ($groupTypeIsCore) { + $messages[] = $this->__('This group is a core-only group'); + } + if ($groupStateIsClosed) { + $messages[] = $this->__('This group is closed.'); + } + if ($groupCountIsLimit) { + $messages[] = $this->__('This group is has reached its membership limit.'); + } + if ($alreadyGroupMember) { + $messages[] = $this->__('You are already a member of this group.'); + } + + return implode('
', $messages); + } } diff --git a/src/system/GroupsModule/Controller/MembershipController.php b/src/system/GroupsModule/Controller/MembershipController.php index e5ba0b5d08..93e018f324 100644 --- a/src/system/GroupsModule/Controller/MembershipController.php +++ b/src/system/GroupsModule/Controller/MembershipController.php @@ -146,12 +146,13 @@ public function joinAction(GroupEntity $group) } /** @var UserEntity $userEntity */ $userEntity = $this->get('zikula_users_module.user_repository')->find($currentUserApi->get('uid')); - if (($group->getGtype() == CommonHelper::GTYPE_PRIVATE) - || ($group->getGtype() == CommonHelper::GTYPE_CORE) - || ($group->getState() == CommonHelper::STATE_CLOSED) - || ($group->getNbumax() > 0 && $group->getUsers()->count() > $group->getNbumax()) - || ($group->getUsers()->contains($userEntity))) { - $this->addFlash('error', $this->__('Cannot join the requested group')); // @todo more specific info would be better + $groupTypeIsPrivate = $group->getGtype() == CommonHelper::GTYPE_PRIVATE; + $groupTypeIsCore = $group->getGtype() == CommonHelper::GTYPE_CORE; + $groupStateIsClosed = $group->getState() == CommonHelper::STATE_CLOSED; + $groupCountIsLimit = $group->getNbumax() > 0 && $group->getUsers()->count() > $group->getNbumax(); + $alreadyGroupMember = $group->getUsers()->contains($userEntity); + if ($groupTypeIsPrivate || $groupTypeIsCore || $groupStateIsClosed || $groupCountIsLimit || $alreadyGroupMember) { + $this->addFlash('error', $this->getSpecificGroupMessage($groupTypeIsPrivate, $groupTypeIsCore, $groupStateIsClosed, $groupCountIsLimit, $alreadyGroupMember)); } else { $userEntity->addGroup($group); $this->get('doctrine')->getManager()->flush(); @@ -284,4 +285,27 @@ public function getUsersByFragmentAsTableAction(Request $request) 'csrfToken' => $request->get('csrfToken') ], new PlainResponse()); } + + private function getSpecificGroupMessage($groupTypeIsPrivate, $groupTypeIsCore, $groupStateIsClosed, $groupCountIsLimit, $alreadyGroupMember) + { + $messages = []; + $messages[] = $this->__('Sorry!, You cannot apply to join the requested group'); + if ($groupTypeIsPrivate) { + $messages[] = $this->__('This group is a private group'); + } + if ($groupTypeIsCore) { + $messages[] = $this->__('This group is a core-only group'); + } + if ($groupStateIsClosed) { + $messages[] = $this->__('This group is closed.'); + } + if ($groupCountIsLimit) { + $messages[] = $this->__('This group is has reached its membership limit.'); + } + if ($alreadyGroupMember) { + $messages[] = $this->__('You are already a member of this group.'); + } + + return implode('
', $messages); + } } diff --git a/src/system/MenuModule/Form/EventListener/OptionValidatorListener.php b/src/system/MenuModule/Form/EventListener/OptionValidatorListener.php index 0ce0dbb16f..4d58a510e1 100644 --- a/src/system/MenuModule/Form/EventListener/OptionValidatorListener.php +++ b/src/system/MenuModule/Form/EventListener/OptionValidatorListener.php @@ -15,9 +15,23 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; +use Zikula\Common\Translator\TranslatorInterface; class OptionValidatorListener implements EventSubscriberInterface { + /** + * @var TranslatorInterface + */ + private $translator; + + /** + * @param TranslatorInterface $translator + */ + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + public static function getSubscribedEvents() { return [ @@ -44,14 +58,16 @@ public function onPostSubmit(FormEvent $event) $option['value'] = false; break; default: - $form->addError(new FormError($option['key'] . ' must be either (string) "true" or "false").')); // @todo translate + $error = $this->translator->__f('%k must be either (string) "%t" or "%f").', ['%k' => $option['key'], '%t' => 'true', '%f' => 'false']); + $form->addError(new FormError($error)); } break; case 'array': $option['value'] = str_replace("'", '"', $option['value']); $json = json_decode($option['value'], true); if (null === $json) { - $form->addError(new FormError($option['key'] . ' must have a value that can be json_decoded.')); // @todo translate + $error = $this->translator->__f('%k must have a value that can be json_decoded.', ['%k' => $option['key']]); + $form->addError(new FormError($error)); } break; } diff --git a/src/system/MenuModule/Form/Type/MenuItemType.php b/src/system/MenuModule/Form/Type/MenuItemType.php index c7db074bef..499eb911a7 100644 --- a/src/system/MenuModule/Form/Type/MenuItemType.php +++ b/src/system/MenuModule/Form/Type/MenuItemType.php @@ -60,7 +60,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->get('options') ->addModelTransformer(new KeyValueTransformer()) ->addEventSubscriber(new KeyValueFixerListener()) - ->addEventSubscriber(new OptionValidatorListener()) + ->addEventSubscriber(new OptionValidatorListener($options['translator'])) ; if ($options['includeRoot']) { $builder->add('root', EntityType::class, [ diff --git a/src/system/ThemeModule/Controller/VarController.php b/src/system/ThemeModule/Controller/VarController.php index c598325f77..c82d9d21fd 100644 --- a/src/system/ThemeModule/Controller/VarController.php +++ b/src/system/ThemeModule/Controller/VarController.php @@ -24,7 +24,6 @@ class VarController extends AbstractController /** * Configure a theme's variables based on provided .yml definitions for each field. * @Route("/admin/var/{themeName}") - * @todo change route name to /admin/variable/{themeName} when similar named is removed? * @Theme("admin") * @Template * diff --git a/src/system/ThemeModule/Engine/Engine.php b/src/system/ThemeModule/Engine/Engine.php index 403491c730..674e1f7431 100644 --- a/src/system/ThemeModule/Engine/Engine.php +++ b/src/system/ThemeModule/Engine/Engine.php @@ -272,7 +272,6 @@ private function setMatchingRealm() unset($themeConfig['admin'], $themeConfig['home'], $themeConfig['master']); // remove to avoid scanning/matching in loop $pathInfo = $request->getPathInfo(); foreach ($themeConfig as $realm => $config) { - // @todo is there a faster way to do this? if (!empty($config['pattern'])) { $pattern = ';' . str_replace('/', '\\/', $config['pattern']) . ';i'; // delimiters are ; and i means case-insensitive $valuesToMatch = []; diff --git a/src/system/ThemeModule/EventListener/DefaultPageAssetSetterListener.php b/src/system/ThemeModule/EventListener/DefaultPageAssetSetterListener.php index e24bca5ead..3d1378bccd 100644 --- a/src/system/ThemeModule/EventListener/DefaultPageAssetSetterListener.php +++ b/src/system/ThemeModule/EventListener/DefaultPageAssetSetterListener.php @@ -164,8 +164,9 @@ private function addFosJsRouting() private function addJsTranslation() { - // @todo consider option of dumping the translations to /web - // @todo add bundle translations? need domain name e.g. zikulapagesmodule + // consider option of dumping the translations to /web + // add bundle translations? need domain name e.g. zikulapagesmodule + // #3650 $jsScript = $this->router->generate('bazinga_jstranslation_js', ['domain' => 'zikula_javascript'], RouterInterface::ABSOLUTE_URL); $this->jsAssetBag->add([ $this->assetHelper->resolve('bundles/bazingajstranslation/js/translator.min.js') => AssetBag::WEIGHT_JS_TRANSLATOR, diff --git a/src/system/ThemeModule/EventListener/DefaultPageVarSetterListener.php b/src/system/ThemeModule/EventListener/DefaultPageVarSetterListener.php index 31ae0ecbb2..ea7f3e2c4c 100644 --- a/src/system/ThemeModule/EventListener/DefaultPageVarSetterListener.php +++ b/src/system/ThemeModule/EventListener/DefaultPageVarSetterListener.php @@ -93,7 +93,7 @@ public function setDefaultPageVars(GetResponseEvent $event) $this->pageVars->set('meta.charset', $this->kernel->getCharset()); $this->pageVars->set('meta.description', $this->variableApi->getSystemVar('defaultmetadescription')); $this->pageVars->set('homepath', $this->router->generate('home')); - $this->pageVars->set('coredata', ['version' => ZikulaKernel::VERSION]); // @todo add more info? + $this->pageVars->set('coredata', ['version' => ZikulaKernel::VERSION]); } public static function getSubscribedEvents() diff --git a/src/system/ThemeModule/EventListener/ExtensionInstallationListener.php b/src/system/ThemeModule/EventListener/ExtensionInstallationListener.php index 9c408b3314..27c8b6c9a9 100644 --- a/src/system/ThemeModule/EventListener/ExtensionInstallationListener.php +++ b/src/system/ThemeModule/EventListener/ExtensionInstallationListener.php @@ -56,7 +56,6 @@ public static function getSubscribedEvents() CoreEvents::MODULE_ENABLE => ['clearCombinedAssetCache'], CoreEvents::MODULE_DISABLE => ['clearCombinedAssetCache'], CoreEvents::MODULE_REMOVE => ['clearCombinedAssetCache'], - // @todo create theme events for same and add here ]; } } diff --git a/src/system/UsersModule/Controller/AccessController.php b/src/system/UsersModule/Controller/AccessController.php index 35a15ed63d..cb57befb34 100644 --- a/src/system/UsersModule/Controller/AccessController.php +++ b/src/system/UsersModule/Controller/AccessController.php @@ -138,7 +138,7 @@ public function loginAction(Request $request) } } // login failed - // @todo implement auto-register setting. If true, do so and proceed from here. + // implement auto-register setting here. If true, do so and proceed. #2915 $this->addFlash('error', $this->__('Login failed.')); $returnUrl = $this->dispatchLoginFailedEvent($user, $returnUrl, $authenticationMethod); diff --git a/src/system/UsersModule/Controller/UserAdministrationController.php b/src/system/UsersModule/Controller/UserAdministrationController.php index 5ee2ab47b8..cc887eb3af 100644 --- a/src/system/UsersModule/Controller/UserAdministrationController.php +++ b/src/system/UsersModule/Controller/UserAdministrationController.php @@ -326,7 +326,7 @@ public function deleteAction(Request $request, UserEntity $user = null) } } if ($valid && $deleteConfirmationForm->isValid()) { - // @todo send email to 'denied' registrations. see MailHelper::sendNotification (regdeny) + // send email to 'denied' registrations. see MailHelper::sendNotification (regdeny) #2915 $deletedUsers = $this->get('zikula_users_module.user_repository')->query(['uid' => ['operator' => 'in', 'operand' => $userIds]]); foreach ($deletedUsers as $deletedUser) { $eventName = $deletedUser->getActivated() == UsersConstant::ACTIVATED_ACTIVE ? UserEvents::DELETE_ACCOUNT : RegistrationEvents::DELETE_REGISTRATION; @@ -364,7 +364,7 @@ public function searchAction(Request $request) ]); $form->handleRequest($request); if ($form->isSubmitted()) { - // @TODO the users.search.process_edit event is no longer dispatched with this method. could it be done in a Transformer? + // the users.search.process_edit event is no longer dispatched with this method. could it be done in a Transformer? #3652 $deleteForm = $this->createForm(DeleteType::class, [], [ 'choices' => $this->get('zikula_users_module.user_repository')->queryBySearchForm($form->getData()), 'action' => $this->generateUrl('zikulausersmodule_useradministration_delete'), diff --git a/src/system/ZAuthModule/AuthenticationMethod/AbstractNativeAuthenticationMethod.php b/src/system/ZAuthModule/AuthenticationMethod/AbstractNativeAuthenticationMethod.php index 6c52d1a409..503f1fa2f9 100644 --- a/src/system/ZAuthModule/AuthenticationMethod/AbstractNativeAuthenticationMethod.php +++ b/src/system/ZAuthModule/AuthenticationMethod/AbstractNativeAuthenticationMethod.php @@ -103,7 +103,7 @@ protected function authenticateByField(array $data, $field = 'uname') $mapping = $this->getMapping($field, $data[$field]); if ($mapping) { if ($this->passwordApi->passwordsMatch($data['pass'], $mapping->getPass())) { - // @todo is this the place to update the hash method? + // is this the place to update the hash method? #2842 return $mapping->getUid(); } else { $this->session->getFlashBag()->add('error', $this->translator->__('Incorrect login credentials')); diff --git a/src/system/ZAuthModule/Controller/UserAdministrationController.php b/src/system/ZAuthModule/Controller/UserAdministrationController.php index 953c68e7b8..4a6b00e231 100644 --- a/src/system/ZAuthModule/Controller/UserAdministrationController.php +++ b/src/system/ZAuthModule/Controller/UserAdministrationController.php @@ -76,7 +76,7 @@ public function listAction(Request $request, $sort = 'uid', $sortdir = 'DESC', $ if (!empty($letter) && 'all' != $letter) { $filter['uname'] = ['operator' => 'like', 'operand' => "$letter%"]; } - $limit = 25; // @todo make this configurable? + $limit = 25; $mappings = $this->get('zikula_zauth_module.authentication_mapping_repository')->query( $filter, diff --git a/src/system/ZAuthModule/Form/Type/ConfigType.php b/src/system/ZAuthModule/Form/Type/ConfigType.php index 8959c046da..481b9cd7da 100644 --- a/src/system/ZAuthModule/Form/Type/ConfigType.php +++ b/src/system/ZAuthModule/Form/Type/ConfigType.php @@ -42,7 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'help' => $options['translator']->__('This affects both passwords created during registration, as well as passwords modified by users or administrators. Enter an integer greater than zero.'), 'constraints' => [ new NotBlank(), - new GreaterThanOrEqual(['value' => 3]) // @todo + new GreaterThanOrEqual(['value' => 5]) ] ]) ->add(ZAuthConstant::MODVAR_HASH_METHOD, ChoiceType::class, [ @@ -51,7 +51,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'choices' => [ 'SHA1' => 'sha1', 'SHA256' => 'sha256', - // @todo bcrypt + // add bcrypt #2842 ] ]) ->add(ZAuthConstant::MODVAR_PASSWORD_STRENGTH_METER_ENABLED, CheckboxType::class, [ diff --git a/src/themes/PrinterTheme/ZikulaPrinterTheme.php b/src/themes/PrinterTheme/ZikulaPrinterTheme.php index c53fbe857b..21a1dfbdde 100644 --- a/src/themes/PrinterTheme/ZikulaPrinterTheme.php +++ b/src/themes/PrinterTheme/ZikulaPrinterTheme.php @@ -44,7 +44,7 @@ private function createFootnotes($string) $text = preg_replace_callback( '/]*href\s*=\s*\"?([^>\"]*)\"?[^>]*>(.*?)<\/a.*?>/i', function ($matches) { - // @todo - work out why some links need decoding twice (&amp;....) + // work out why some links need decoding twice (&amp;....) #3653 $this->links[] = html_entity_decode(html_entity_decode($matches[1])); // return the replaced link return '' . $matches[2] . ' [' . count($this->links) . ']';