ChangeSet ID: 31115 CVSROOT: /opt/cvs-commit Module name: appdb Changes by: wineowner@winehq.org 2007/04/27 18:43:43
Modified files: . : objectManager.php include : distribution.php objectManager.php
Log message: Alexander Nicolaysen Sørnes alex@thehandofagony.com 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
Patch: http://cvs.winehq.org/patch.py?id=31115
Old revision New revision Changes Path 1.9 1.10 +4 -0 appdb/objectManager.php 1.27 1.28 +23 -0 appdb/include/distribution.php 1.18 1.19 +55 -0 appdb/include/objectManager.php
Index: appdb/objectManager.php diff -u -p appdb/objectManager.php:1.9 appdb/objectManager.php:1.10 --- appdb/objectManager.php:1.9 27 Apr 2007 23:43:43 -0000 +++ appdb/objectManager.php 27 Apr 2007 23:43:43 -0000 @@ -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; Index: appdb/include/distribution.php diff -u -p appdb/include/distribution.php:1.27 appdb/include/distribution.php:1.28 --- appdb/include/distribution.php:1.27 27 Apr 2007 23:43:43 -0000 +++ appdb/include/distribution.php 27 Apr 2007 23:43:43 -0000 @@ -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; + } }
?> Index: appdb/include/objectManager.php diff -u -p appdb/include/objectManager.php:1.18 appdb/include/objectManager.php:1.19 --- appdb/include/objectManager.php:1.18 27 Apr 2007 23:43:43 -0000 +++ appdb/include/objectManager.php 27 Apr 2007 23:43:43 -0000 @@ -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);