NavigationConfigForm: Provide all available parents for non-shared items

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-18 11:01:02 +02:00
parent 9477c53b43
commit 335ed8c74f

View File

@ -185,41 +185,27 @@ class NavigationConfigForm extends ConfigForm
*/ */
public function listAvailableParents($type) public function listAvailableParents($type)
{ {
$shared = false; $children = $this->itemToLoad ? $this->getFlattenedChildren($this->itemToLoad) : array();
$children = array();
if ($this->itemToLoad) { $names = array();
$shared = $this->hasBeenShared($this->itemToLoad); foreach ($this->getShareConfig() as $sectionName => $sectionConfig) {
$children = $this->getFlattenedChildren($this->itemToLoad); if (
} elseif (($checkbox = $this->getElement('shared')) !== null) { $sectionName !== $this->itemToLoad
if ($checkbox->isChecked()) { && $sectionConfig->type === $type
$shared = true; && $sectionConfig->owner === $this->getUser()->getUsername()
} else { && !in_array($sectionName, $children, true)
$requestData = $this->getRequestData(); ) {
$shared = isset($requestData['shared']) && $requestData['shared']; $names[] = $sectionName;
} }
} }
$names = array(); foreach ($this->getUserConfig() as $sectionName => $sectionConfig) {
if ($shared) { if (
foreach ($this->getShareConfig() as $sectionName => $sectionConfig) { $sectionName !== $this->itemToLoad
if ( && $sectionConfig->type === $type
$sectionName !== $this->itemToLoad && !in_array($sectionName, $children, true)
&& $sectionConfig->type === $type ) {
&& $sectionConfig->owner === $this->getUser()->getUsername() $names[] = $sectionName;
&& !in_array($sectionName, $children, true)
) {
$names[] = $sectionName;
}
}
} else {
foreach ($this->getUserConfig() as $sectionName => $sectionConfig) {
if (
$sectionName !== $this->itemToLoad
&& $sectionConfig->type === $type
&& !in_array($sectionName, $children, true)
) {
$names[] = $sectionName;
}
} }
} }