mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
Additional fix for processwire/processwire-issues#817
This commit is contained in:
@@ -70,7 +70,8 @@ class PageAccess {
|
||||
public function getAccessParent(Page $page, $type = 'view', $level = 0) {
|
||||
if(!$page->id) return $page->wire('pages')->newNullPage();
|
||||
if(!in_array($type, $this->types)) $type = $this->getType($type);
|
||||
if($page->template->useRoles || $page->id === 1) {
|
||||
|
||||
if($page->id === 1 || $page->template->useRoles) {
|
||||
// found an access parent
|
||||
if($type != 'view' && $level > 0 && $page->template->noInherit != 0) {
|
||||
// access parent prohibits inheritance of edit-related permissions
|
||||
@@ -78,8 +79,18 @@ class PageAccess {
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
$parent = $page->parent();
|
||||
if($parent->id) return $this->getAccessParent($parent, $type, $level+1);
|
||||
|
||||
$parent = null;
|
||||
|
||||
if($type === 'edit' && $page->isTrash() && $page->id != $page->wire('config')->trashPageID) {
|
||||
// pages in trash have an edit access parent as whatever it was prior to being trashed
|
||||
$info = $page->wire('pages')->trasher()->parseTrashPageName($page->name);
|
||||
if(!empty($info['parent_id'])) $parent = $page->wire('pages')->get((int) $info['parent_id']);
|
||||
}
|
||||
|
||||
if(!$parent || !$parent->id) $parent = $page->parent();
|
||||
if($parent->id) return $this->getAccessParent($parent, $type, $level + 1);
|
||||
|
||||
return $page->wire('pages')->newNullPage();
|
||||
}
|
||||
|
||||
|
@@ -1104,7 +1104,7 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
|
||||
*/
|
||||
protected function ___nameChangedWarning(Page $page, $namePrevious) {
|
||||
return sprintf(
|
||||
$this->_('Warning, the name you selected "%1$s" has been changed to "%2$s".'),
|
||||
$this->_('Warning, the name you selected "%1$s" was already in use and has been changed to "%2$s".'),
|
||||
$namePrevious, $page->name
|
||||
);
|
||||
}
|
||||
|
@@ -341,13 +341,26 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
||||
$class = $this->allowRenderTypes[$this->render];
|
||||
$className = wireClassName($class, true);
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->wire('user');
|
||||
$superuser = $user->isSuperuser();
|
||||
|
||||
if(!class_exists($className, false)) require_once(dirname(__FILE__) . "/$class.php");
|
||||
|
||||
if(is_null($limit)) $limit = $this->limit;
|
||||
if(is_null($start)) $start = $this->start;
|
||||
|
||||
if($limit) {
|
||||
$children = $this->find("start=$start, limit=$limit, status<" . Page::statusMax, $page);
|
||||
$selector = "start=$start, limit=$limit, status<" . Page::statusMax;
|
||||
|
||||
if($this->useTrash && !$superuser) {
|
||||
$trashID = $this->wire('config')->trashPageID;
|
||||
if($page->id == $trashID && $user->hasPermission('page-edit') && $page->listable()) {
|
||||
$selector .= ", check_access=0";
|
||||
}
|
||||
}
|
||||
|
||||
$children = $this->find($selector, $page);
|
||||
} else {
|
||||
$children = $this->wire('pages')->newPageArray();
|
||||
}
|
||||
@@ -358,7 +371,7 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
||||
$renderer->setLimit($limit);
|
||||
$renderer->setPageLabelField($this->getPageLabelField());
|
||||
$renderer->setLabel('trash', $this->trashLabel);
|
||||
$renderer->setUseTrash($this->useTrash || $this->wire('user')->isSuperuser());
|
||||
$renderer->setUseTrash($this->useTrash || $superuser);
|
||||
$renderer->setQtyType($this->qtyType);
|
||||
|
||||
return $renderer;
|
||||
|
Reference in New Issue
Block a user