mirror of
https://github.com/processwire/processwire.git
synced 2025-08-18 20:41:16 +02:00
Fix issue processwire/processwire-issues#364
This commit is contained in:
@@ -269,6 +269,23 @@ class PagesType extends Wire implements \IteratorAggregate, \Countable {
|
||||
return $pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a Selector string, return the page IDs that match
|
||||
*
|
||||
* @param string $selectorString
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @since 3.0.128
|
||||
* @see Pages::findIDs()
|
||||
*
|
||||
*/
|
||||
public function findIDs($selectorString, $options = array()) {
|
||||
if(!isset($options['findAll'])) $options['findAll'] = true;
|
||||
if(empty($options['caller'])) $options['caller'] = $this->className() . ".findIDs($selectorString)";
|
||||
$ids = $this->wire('pages')->findIDs($this->selectorString($selectorString), $options);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first match of your selector string
|
||||
*
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* Code by Ryan Cramer
|
||||
* Sponsored by Avoine
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* @todo add support for "custom: OR-group" option (https://processwire.com/talk/topic/13116-or-selecters-for-different-fields/)
|
||||
@@ -162,6 +162,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
|
||||
'timePlaceholder',
|
||||
'previewColumns',
|
||||
'limitFields',
|
||||
'maxUsers',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1938,9 +1939,13 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
|
||||
$ids = array();
|
||||
foreach($s->values as $key => $name) {
|
||||
$property = ctype_digit("$name") ? 'id' : 'name';
|
||||
$users = $this->wire('users')->find("$property$s->operator" .
|
||||
$this->wire('sanitizer')->selectorValue($this->wire('sanitizer')->pageNameUTF8($name)));
|
||||
foreach($users as $u) $ids[$u->id] = $u->id;
|
||||
$operator = $s->operator === '!=' ? '=' : $s->operator;
|
||||
if($property === 'name') {
|
||||
$value = $this->wire('sanitizer')->selectorValue($this->wire('sanitizer')->pageNameUTF8($name));
|
||||
} else {
|
||||
$value = (int) $name; // id
|
||||
}
|
||||
$ids = array_merge($ids, $this->wire('users')->findIDs("$property$operator$value"));
|
||||
}
|
||||
if($s->operator != '=' && $s->operator != '!=') {
|
||||
$userSelectors->remove($s);
|
||||
|
Reference in New Issue
Block a user