NavigationConfigForm: Show only an owner's parents to admins

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-21 15:29:14 +02:00
parent 3f70351239
commit 8239ec8fb5
1 changed files with 12 additions and 3 deletions

View File

@ -181,9 +181,12 @@ class NavigationConfigForm extends ConfigForm
/**
* Return a list of available parent items for the given type of navigation item
*
* @param string $type
* @param string $owner
*
* @return array
*/
public function listAvailableParents($type)
public function listAvailableParents($type, $owner = null)
{
$children = $this->itemToLoad ? $this->getFlattenedChildren($this->itemToLoad) : array();
@ -192,7 +195,7 @@ class NavigationConfigForm extends ConfigForm
if (
$sectionName !== $this->itemToLoad
&& $sectionConfig->type === $type
&& $sectionConfig->owner === $this->getUser()->getUsername()
&& $sectionConfig->owner === ($owner ?: $this->getUser()->getUsername())
&& !in_array($sectionName, $children, true)
) {
$names[] = $sectionName;
@ -564,7 +567,13 @@ class NavigationConfigForm extends ConfigForm
);
if (! $shared && $itemForm->requiresParentSelection()) {
if ($this->itemToLoad && $this->hasBeenShared($this->itemToLoad)) {
$itemConfig = $this->getShareConfig()->getSection($this->itemToLoad);
$availableParents = $this->listAvailableParents($itemType, $itemConfig->owner);
} else {
$availableParents = $this->listAvailableParents($itemType);
}
$this->addElement(
'select',
'parent',