Skip to content

Commit

Permalink
Todos (#3654)
Browse files Browse the repository at this point in the history
* #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
  • Loading branch information
craigh authored Jul 14, 2017
1 parent ef04041 commit 81c8070
Show file tree
Hide file tree
Showing 40 changed files with 158 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand All @@ -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,
]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/Zikula/Bundle/CoreBundle/Bundle/MetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}

Expand Down
28 changes: 1 addition & 27 deletions src/lib/Zikula/Bundle/CoreBundle/Bundle/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 = [];
Expand Down
1 change: 0 additions & 1 deletion src/lib/Zikula/Bundle/CoreBundle/CoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
//** `<input>` 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 `<select>`s in some browsers, due to the limited stylability of `<select>`s in CSS.
@input-border-radius: @border-radius-base;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '/';
Expand Down
4 changes: 0 additions & 4 deletions src/lib/Zikula/Bundle/CoreBundle/Yaml/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 0 additions & 4 deletions src/lib/Zikula/Bundle/CoreBundle/Yaml/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 0 additions & 4 deletions src/lib/Zikula/Bundle/CoreBundle/Yaml/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<route id="doc" path="/installdoc/{name}">
<default key="_controller">zikula_core_installer.controller.doc:displayAction</default>
<default key="name">INSTALL-1.4.md</default>
<default key="name">INSTALL-2.0.md</default>
<condition>request.query.get('name') matches "/[^\/]+.md/"</condition>
</route>
</routes>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/Zikula/Common/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ protected function initialize()

/**
* Load zikula resource files
*
* @todo better load resource
*/
private function loadResources()
{
Expand Down
16 changes: 15 additions & 1 deletion src/system/BlocksModule/Block/Form/Type/FincludeBlockType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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.'));
}
}
}
6 changes: 6 additions & 0 deletions src/system/BlocksModule/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/system/ExtensionsModule/Entity/ExtensionEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/system/ExtensionsModule/Helper/ExtensionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
5 changes: 3 additions & 2 deletions src/system/ExtensionsModule/Schema/schema.composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"type": "object",
"additionalProperties": true
}
}
},
"required": ["psr-4"]
},
"require": {
"type": "object",
Expand Down Expand Up @@ -90,5 +91,5 @@
"additionalProperties": true
}
},
"required": ["name", "description", "type", "license", "authors", "require", "extra"]
"required": ["name", "description", "type", "license", "authors", "require", "extra", "autoload"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"name": "Zikula Team"
}
],
"autoload": {
"psr-4": { "Zikula\\FooModule\\": "" }
},
"require": {
"php": ">=5.5.9"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"name": "Zikula Team"
}
],
"autoload": {
"psr-4": { "Zikula\\FooModule\\": "" }
},
"require": {
"php": ">=5.5.9"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"name": "Zikula Team"
}
],
"autoload": {
"psr-4": { "Zikula\\FooModule\\": "" }
},
"require": {
"php": ">=5.5.9"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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.",
]],
];
}
Expand Down
31 changes: 26 additions & 5 deletions src/system/GroupsModule/Controller/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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('<br>', $messages);
}
}
Loading

0 comments on commit 81c8070

Please sign in to comment.