mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 03:34:33 +02:00
Fix issue processwire/processwire-issues#1487
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
* For more details about how Process modules work, please see:
|
* For more details about how Process modules work, please see:
|
||||||
* /wire/core/Process.php
|
* /wire/core/Process.php
|
||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2021 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
* @property string $noticeUnknown
|
* @property string $noticeUnknown
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
* @method InputfieldWrapper buildFormChildren()
|
* @method InputfieldWrapper buildFormChildren()
|
||||||
* @method InputfieldWrapper buildFormSettings()
|
* @method InputfieldWrapper buildFormSettings()
|
||||||
* @method InputfieldWrapper buildFormDelete()
|
* @method InputfieldWrapper buildFormDelete()
|
||||||
|
* @method Inputfield buildFormCreatedUser() hookable in 3.0.194+
|
||||||
* @method void buildFormView($url)
|
* @method void buildFormView($url)
|
||||||
* @method InputfieldMarkup buildFormRoles()
|
* @method InputfieldMarkup buildFormRoles()
|
||||||
* @method void processInput(InputfieldWrapper $form, $level = 0, $formRoot = null)
|
* @method void processInput(InputfieldWrapper $form, $level = 0, $formRoot = null)
|
||||||
@@ -1381,20 +1382,33 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
|||||||
/**
|
/**
|
||||||
* Build the created user selection
|
* Build the created user selection
|
||||||
*
|
*
|
||||||
* @return InputfieldPageListSelect
|
* Hookable as of 3.0.194
|
||||||
|
*
|
||||||
|
* #pw-hooker
|
||||||
|
*
|
||||||
|
* @return Inputfield
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function buildFormCreatedUser() {
|
protected function ___buildFormCreatedUser() {
|
||||||
/** @var InputfieldPageListSelect $field */
|
$modules = $this->wire()->modules;
|
||||||
$field = $this->modules->get('InputfieldPageListSelect');
|
$config = $this->wire()->config;
|
||||||
$field->label = $this->_('Created by User');
|
$pages = $this->wire()->pages;
|
||||||
$field->attr('id+name', 'created_users_id');
|
$selector = "parent_id=$config->usersPageID, include=all, limit=100";
|
||||||
$field->attr('value', $this->page->created_users_id);
|
if(count($config->usersPageIDs) < 2 && $pages->count($selector) < 100) {
|
||||||
$field->parent_id = $this->config->usersPageID; // @todo support $config->usersPageIDs (array)
|
/** @var InputfieldPageListSelect $f */
|
||||||
$field->showPath = false;
|
$f = $modules->get('InputfieldPageListSelect');
|
||||||
$field->required = true;
|
$f->parent_id = $this->config->usersPageID;
|
||||||
|
$f->showPath = false;
|
||||||
return $field;
|
} else {
|
||||||
|
$f = $modules->get('InputfieldInteger');
|
||||||
|
$f->description = $this->_('Enter the created user’s ID.');
|
||||||
|
$f->notes = "{$this->page->created_users_id} = {$this->page->createdUser->name}";
|
||||||
|
}
|
||||||
|
$f->label = $this->_('Created by User');
|
||||||
|
$f->attr('id+name', 'created_users_id');
|
||||||
|
$f->attr('value', $this->page->created_users_id);
|
||||||
|
$f->required = true;
|
||||||
|
return $f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2331,6 +2345,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
|||||||
if(!$userID) return;
|
if(!$userID) return;
|
||||||
if($userID == $this->page->created_users_id) return; // no change
|
if($userID == $this->page->created_users_id) return; // no change
|
||||||
$user = $this->pages->get($userID);
|
$user = $this->pages->get($userID);
|
||||||
|
if(!$user->id) return;
|
||||||
if(!in_array($user->template->id, $this->config->userTemplateIDs)) return; // invalid user template
|
if(!in_array($user->template->id, $this->config->userTemplateIDs)) return; // invalid user template
|
||||||
if(!in_array($user->parent_id, $this->config->usersPageIDs)) return; // invalid user parent
|
if(!in_array($user->parent_id, $this->config->usersPageIDs)) return; // invalid user parent
|
||||||
$this->page->created_users_id = $userID;
|
$this->page->created_users_id = $userID;
|
||||||
|
Reference in New Issue
Block a user