Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .tools/psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3791,6 +3791,12 @@
</InvalidArgument>
</file>
<file src="src/MetaInfo/Form/Field/RestrictionField.php">
<MixedArgumentTypeCoercion>
<code><![CDATA[$value]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$this->value]]></code>
</MixedAssignment>
<PossiblyInvalidOperand>
<code><![CDATA[$id]]></code>
<code><![CDATA[$id]]></code>
Expand Down
12 changes: 12 additions & 0 deletions src/MetaInfo/Form/Field/RestrictionField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Redaxo\Core\MetaInfo\Form\MetaInfoForm;
use Redaxo\Core\Translation\I18n;

use function is_array;

/**
* @internal
*/
Expand All @@ -26,9 +28,19 @@ public function __construct($tag = '', ?MetaInfoForm $form = null, array $attrib
{
parent::__construct('', $form, $attributes);

$this->setSeparator(',');
$this->setNotice(I18n::msg('ctrl'));
}

/** @return void */
public function setValue($value)
{
if (is_array($value)) {
$value = implode(',', $value);
}
$this->value = $value;
}

public function setAllCheckboxLabel(string $label): void
{
$this->allCheckboxLabel = $label;
Expand Down
4 changes: 2 additions & 2 deletions src/MetaInfo/Handler/ArticleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ protected function buildFilterCondition(array $params)
// Alle Metafelder des Pfades sind erlaubt
foreach ($OOArt->getPathAsArray() as $pathElement) {
if ('' != $pathElement) {
$s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
$s .= ' OR FIND_IN_SET(' . $pathElement . ', `p`.`restrictions`)';
}
}

$t = ' OR `p`.`templates` LIKE "%|' . $OOArt->getValue('template_id') . '|%"';
$t = ' OR FIND_IN_SET(' . $OOArt->getValue('template_id') . ', `p`.`templates`)';

$restrictionsCondition = 'AND (`p`.`restrictions` = "" OR `p`.`restrictions` IS NULL ' . $s . ') AND (`p`.`templates` = "" OR `p`.`templates` IS NULL ' . $t . ')';
}
Expand Down
4 changes: 2 additions & 2 deletions src/MetaInfo/Handler/CategoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ protected function buildFilterCondition(array $params)
// Alle Metafelder des Pfades sind erlaubt
foreach ($OOCat->getPathAsArray() as $pathElement) {
if ('' != $pathElement) {
$s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
$s .= ' OR FIND_IN_SET(' . $pathElement . ', `p`.`restrictions`)';
}
}

// Auch die Kategorie selbst kann Metafelder haben
$s .= ' OR `p`.`restrictions` LIKE "%|' . $params['id'] . '|%"';
$s .= ' OR FIND_IN_SET(' . $params['id'] . ', `p`.`restrictions`)';
}

return 'AND (`p`.`restrictions` = "" OR `p`.`restrictions` IS NULL ' . $s . ')';
Expand Down
4 changes: 2 additions & 2 deletions src/MetaInfo/Handler/MediaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ protected function buildFilterCondition(array $params)
// Alle Metafelder des Pfades sind erlaubt
foreach ($OOCat->getPathAsArray() as $pathElement) {
if ('' != $pathElement) {
$s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
$s .= ' OR FIND_IN_SET(' . $pathElement . ', `p`.`restrictions`)';
}
}
}

// Auch die Kategorie selbst kann Metafelder haben
$s .= ' OR `p`.`restrictions` LIKE "%|' . $catId . '|%"';
$s .= ' OR FIND_IN_SET(' . $catId . ', `p`.`restrictions`)';

$restrictionsCondition = 'AND (`p`.`restrictions` = "" OR `p`.`restrictions` IS NULL ' . $s . ')';
}
Expand Down
Loading