When selecting 'Move Child Objects' for versions, only show versions of parent app

This commit is contained in:
Alexander Nicolaysen Sørnes
2009-04-16 00:26:20 +02:00
committed by Alexander Nicolaysen Sørnes
parent 3df5e22800
commit f84c811569
3 changed files with 57 additions and 19 deletions

View File

@@ -1329,16 +1329,25 @@ class Application {
} }
public function objectGetChildren($bIncludeDeleted = false) public function objectGetChildren($bIncludeDeleted = false)
{
return $this->objectGetChildrenClassSpecific('', $IncludeDeleted);
}
public function objectGetChildrenClassSpecific($sClass = '', $bIncludeDeleted = false)
{ {
$aChildren = array(); $aChildren = array();
/* Get versions */ /* Get versions */
foreach($this->getVersions(false, true, $bIncludeDeleted) as $oVersion) foreach($this->getVersions(false, true, $bIncludeDeleted) as $oVersion)
{ {
if($sClass != 'version')
$aChildren += $oVersion->objectGetChildren($bIncludeDeleted); $aChildren += $oVersion->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oVersion; $aChildren[] = $oVersion;
} }
if($sClass == 'version')
return $aChildren;
/* Get urls */ /* Get urls */
$sQuery = "SELECT * FROM appData WHERE type = '?' AND appId = '?'"; $sQuery = "SELECT * FROM appData WHERE type = '?' AND appId = '?'";
$hResult = query_parameters($sQuery, "url", $this->iAppId); $hResult = query_parameters($sQuery, "url", $this->iAppId);

View File

@@ -886,13 +886,6 @@ class ObjectManager
return FALSE; return FALSE;
} }
/* We only allow moving to non-queued objects */
if(!$hResult = $oObject->objectGetEntries('accepted'))
{
echo "Failed to get list of objects.<br>\n";
return FALSE;
}
/* Display some help text */ /* Display some help text */
echo "<p>Move all child objects of ".$oObject->objectMakeLink()." to the entry "; echo "<p>Move all child objects of ".$oObject->objectMakeLink()." to the entry ";
echo "selected below, and delete ".$oObject->objectMakeLink()." afterwards.</p>\n"; echo "selected below, and delete ".$oObject->objectMakeLink()." afterwards.</p>\n";
@@ -903,6 +896,34 @@ class ObjectManager
"Move here"), "Move here"),
"color4"); "color4");
if(method_exists($oObject, 'objectGetParent'))
{
$oParent = $oObject->objectGetParent();
$aParentChildren = $oParent->objectGetChildrenClassSpecific($this->sClass);
echo "Children of " . $oParent->objectMakeLink() . " <br />";
$i = 0;
foreach($aParentChildren as $oCandidate)
{
if($oCandidate->objectGetState() != 'accepted')
continue;
echo html_tr(array($oCandidate->objectMakeLink(),
"<a href=\"".$this->makeUrl("moveChildren", $this->iId). "&amp;iNewId=".$oCandidate->objectGetId()."\">Move here</a>"),
($i % 2) ? "color0" : "color1");
$i++;
}
} else
{
/* We only allow moving to non-queued objects */
if(!$hResult = $oObject->objectGetEntries('accepted'))
{
echo "Failed to get list of objects.<br>\n";
return FALSE;
}
for($i = 0; $oRow = query_fetch_object($hResult); $i++) for($i = 0; $oRow = query_fetch_object($hResult); $i++)
{ {
$oCandidate = new $this->sClass(null, $oRow); $oCandidate = new $this->sClass(null, $oRow);
@@ -918,6 +939,9 @@ class ObjectManager
"&amp;iNewId=".$oCandidate->objectGetId()."\">Move here</a>"), "&amp;iNewId=".$oCandidate->objectGetId()."\">Move here</a>"),
($i % 2) ? "color0" : "color1"); ($i % 2) ? "color0" : "color1");
} }
}
echo "</table>\n"; echo "</table>\n";
} }

View File

@@ -775,7 +775,7 @@ class version {
} }
/* Not standard OM function yet, but will be in the future */ /* 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? */ /* No id so we can't query the DB, but perhaps an entry is cached? */
if(!$this->iAppId) if(!$this->iAppId)
@@ -1697,6 +1697,11 @@ class version {
} }
public function objectGetChildren($bIncludeDeleted = false) public function objectGetChildren($bIncludeDeleted = false)
{
return $this->objectGetChildrenClassSpecific('', $bIncludeDeleted);
}
public function objectGetChildrenClassSpecific($sClass = '', $bIncludeDeleted = false)
{ {
$aChildren = array(); $aChildren = array();