diff --git a/include/application.php b/include/application.php index 0126067..34a8001 100644 --- a/include/application.php +++ b/include/application.php @@ -1329,16 +1329,25 @@ class Application { } public function objectGetChildren($bIncludeDeleted = false) + { + return $this->objectGetChildrenClassSpecific('', $IncludeDeleted); + } + + public function objectGetChildrenClassSpecific($sClass = '', $bIncludeDeleted = false) { $aChildren = array(); /* Get versions */ - foreach($this->getVersions(false, true, $bIncludeDeleted) as $oVersion) + foreach($this->getVersions(false, true, $bIncludeDeleted) as $oVersion) { - $aChildren += $oVersion->objectGetChildren($bIncludeDeleted); + if($sClass != 'version') + $aChildren += $oVersion->objectGetChildren($bIncludeDeleted); $aChildren[] = $oVersion; } + if($sClass == 'version') + return $aChildren; + /* Get urls */ $sQuery = "SELECT * FROM appData WHERE type = '?' AND appId = '?'"; $hResult = query_parameters($sQuery, "url", $this->iAppId); diff --git a/include/objectManager.php b/include/objectManager.php index 326f6fd..cfabde9 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -886,13 +886,6 @@ class ObjectManager return FALSE; } - /* We only allow moving to non-queued objects */ - if(!$hResult = $oObject->objectGetEntries('accepted')) - { - echo "Failed to get list of objects.
\n"; - return FALSE; - } - /* Display some help text */ echo "

Move all child objects of ".$oObject->objectMakeLink()." to the entry "; echo "selected below, and delete ".$oObject->objectMakeLink()." afterwards.

\n"; @@ -903,21 +896,52 @@ class ObjectManager "Move here"), "color4"); - for($i = 0; $oRow = query_fetch_object($hResult); $i++) + if(method_exists($oObject, 'objectGetParent')) { - $oCandidate = new $this->sClass(null, $oRow); - if($oCandidate->objectGetId() == $this->iId) + $oParent = $oObject->objectGetParent(); + + $aParentChildren = $oParent->objectGetChildrenClassSpecific($this->sClass); + + echo "Children of " . $oParent->objectMakeLink() . "
"; + + $i = 0; + foreach($aParentChildren as $oCandidate) { + if($oCandidate->objectGetState() != 'accepted') + continue; + + echo html_tr(array($oCandidate->objectMakeLink(), + "makeUrl("moveChildren", $this->iId). "&iNewId=".$oCandidate->objectGetId()."\">Move here"), + ($i % 2) ? "color0" : "color1"); $i++; - continue; + } + } else + { + /* We only allow moving to non-queued objects */ + if(!$hResult = $oObject->objectGetEntries('accepted')) + { + echo "Failed to get list of objects.
\n"; + return FALSE; } - echo html_tr(array( - $oCandidate->objectMakeLink(), - "makeUrl("moveChildren", $this->iId). - "&iNewId=".$oCandidate->objectGetId()."\">Move here"), - ($i % 2) ? "color0" : "color1"); + for($i = 0; $oRow = query_fetch_object($hResult); $i++) + { + $oCandidate = new $this->sClass(null, $oRow); + if($oCandidate->objectGetId() == $this->iId) + { + $i++; + continue; + } + + echo html_tr(array( + $oCandidate->objectMakeLink(), + "makeUrl("moveChildren", $this->iId). + "&iNewId=".$oCandidate->objectGetId()."\">Move here"), + ($i % 2) ? "color0" : "color1"); + } } + + echo "\n"; } diff --git a/include/version.php b/include/version.php index 01592c6..6de74d3 100644 --- a/include/version.php +++ b/include/version.php @@ -775,7 +775,7 @@ class version { } /* Not standard OM function yet, but will be in the future */ - public function objectGetParent() + public function objectGetParent($sClass = '') { /* No id so we can't query the DB, but perhaps an entry is cached? */ if(!$this->iAppId) @@ -1697,6 +1697,11 @@ class version { } public function objectGetChildren($bIncludeDeleted = false) + { + return $this->objectGetChildrenClassSpecific('', $bIncludeDeleted); + } + + public function objectGetChildrenClassSpecific($sClass = '', $bIncludeDeleted = false) { $aChildren = array();