Add om method for displaying a move child objects page. A link to this page is displayed in

an entry's view page automatically if the class that entry has the required methods
objectMoveChildren and objectGetId
This commit is contained in:
Alexander Nicolaysen Sørnes
2007-04-27 23:43:43 +00:00
committed by WineHQ
parent 2f3587f15d
commit eb49e9344d
3 changed files with 82 additions and 0 deletions

View File

@@ -592,6 +592,29 @@ class distribution {
{
return "<a href=\"".$this->objectMakeUrl()."\">$this->sName</a>";
}
function objectMoveChildren($iNewId)
{
/* Keep track of how many children we modified */
$iCount = 0;
foreach($this->aTestingIds as $iTestId)
{
$oTest = new testData($iTestId);
$oTest->iDistributionId = $iNewId;
if($oTest->update(TRUE))
$iCount++;
else
return FALSE;
}
return $iCount;
}
function objectGetid()
{
return $this->iDistributionId;
}
}
?>

View File

@@ -249,6 +249,52 @@ class ObjectManager
$this->delete_entry();
}
/* Display a page where the user can select which object the children of the current
object can be moved to */
function display_move_children()
{
$oObject = new $this->sClass($this->iId);
if(!$oObject->canEdit())
{
echo "Insufficient privileges.<br />\n";
return FALSE;
}
/* We only allow moving to non-queued objects */
if(!$hResult = $oObject->objectGetEntries(false, false))
{
echo "Failed to get list of objects.<br />\n";
return FALSE;
}
/* Display some help text */
echo "<p>Move all child objects of ".$oObject->objectMakeLink()." to the entry ";
echo "selected below, and delete ".$oObject->objectMakeLink()." afterwards.</p>\n";
echo "<table width=\"50%\" cellpadding=\"3\">\n";
echo html_tr(array(
"Name",
"Move here"),
"color4");
for($i = 0; $oRow = mysql_fetch_object($hResult); $i++)
{
$oCandidate = $oObject->objectGetInstanceFromRow($oRow);
if($oCandidate->objectGetId() == $this->iId)
{
$i++;
continue;
}
echo html_tr(array(
$oCandidate->objectMakeLink(),
"<a href=\"".$this->makeUrl("moveChildren", $this->iId).
"&iNewId=".$oCandidate->objectGetId()."\">Move here</a>"),
($i % 2) ? "color0" : "color1");
}
echo "</table>\n";
}
/* Display screen for submitting a new entry of given type */
function add_entry($sBackLink, $sErrors = "")
{
@@ -291,6 +337,15 @@ class ObjectManager
$oObject = new $this->sClass($this->iId);
/* Display a link to the move child objects page if the class has the necessary
functions and the user has edit rights. Not all classes have child objects. */
if(method_exists($oObject, "objectMoveChildren") &&
method_exists($oObject, "objectGetId") && $oObject->canEdit())
{
echo "<a href=\"".$this->makeUrl("showMoveChildren", $this->iId,
"Move Child Objects")."\">Move child objects</a><br /><br />\n";
}
$oObject->display();
echo html_back_link(1, $sBackLink);

View File

@@ -82,6 +82,10 @@ if($oObject->iId)
$oObject->display_entry_for_editing($REQUEST_URI, $sErrors);
break;
case "showMoveChildren":
$oObject->display_move_children();
break;
default:
$oObject->view($REQUEST_URI);
break;