Implement version::objectMoveChildren() on top of version::objectGetChildren()
This commit is contained in:
@@ -118,6 +118,22 @@ class appData
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
return new version($this->iVersionId);
|
||||||
|
else
|
||||||
|
return new application($this->iAppId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
$this->iVersionId = $iNewId;
|
||||||
|
else
|
||||||
|
$this->iAppId = $iNewId;
|
||||||
|
}
|
||||||
|
|
||||||
function listSubmittedBy($iUserId, $bQueued = true)
|
function listSubmittedBy($iUserId, $bQueued = true)
|
||||||
{
|
{
|
||||||
$sExtra = '';
|
$sExtra = '';
|
||||||
|
|||||||
@@ -187,10 +187,20 @@ class Bug
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: figure out what we might want to do here but lie and
|
|
||||||
// return true until then
|
|
||||||
function update()
|
function update()
|
||||||
{
|
{
|
||||||
|
$oBug = new bug($this->iLinkId);
|
||||||
|
|
||||||
|
if($this->iVersionId && $this->iVersionId != $oBug->iVersionId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("UPDATE buglinks SET versionId = '?'
|
||||||
|
WHERE linkId = '?'",
|
||||||
|
$this->iVersionId, $this->iLinkId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +288,16 @@ class Bug
|
|||||||
return array(null, null, null);
|
return array(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
return new version($this->iVersionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
$this->iVersionId = $iNewId;
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
|
|||||||
@@ -136,13 +136,20 @@ class Comment {
|
|||||||
*/
|
*/
|
||||||
function update($sSubject=null, $sBody=null, $iParentId=null, $iVersionId=null)
|
function update($sSubject=null, $sBody=null, $iParentId=null, $iVersionId=null)
|
||||||
{
|
{
|
||||||
|
$oComment = new comment($this->iCommentId);
|
||||||
|
|
||||||
|
if(!$iVersionId && $this->iVersionId != $oComment->iVersionId)
|
||||||
|
$iVersionId = $this->iVersionId;
|
||||||
|
if(!$iParentId && $this->iParentId != $oComment->iParentId)
|
||||||
|
$iParentId = $this->iParentId;
|
||||||
|
|
||||||
if ($iParentId)
|
if ($iParentId)
|
||||||
{
|
{
|
||||||
if (!query_parameters("UPDATE appComments SET parentId = '?' WHERE commentId = '?'",
|
if (!query_parameters("UPDATE appComments SET parentId = '?' WHERE commentId = '?'",
|
||||||
$iParentId, $this->iCommentId))
|
$iParentId, $this->iCommentId))
|
||||||
return false;
|
return false;
|
||||||
$this->iParentId = $iParentId;
|
$this->iParentId = $iParentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($iVersionId)
|
if ($iVersionId)
|
||||||
{
|
{
|
||||||
@@ -523,6 +530,32 @@ class Comment {
|
|||||||
return array($sSubject, $sMessage, $aRecipients);
|
return array($sSubject, $sMessage, $aRecipients);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
switch($sClass)
|
||||||
|
{
|
||||||
|
case 'version':
|
||||||
|
return new version($this->iVersionId);
|
||||||
|
|
||||||
|
case 'comment':
|
||||||
|
return new comment($this->iParentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
switch($sClass)
|
||||||
|
{
|
||||||
|
case 'version':
|
||||||
|
$this->iVersionId = $iNewId;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'comment':
|
||||||
|
$this->iParentId = $iNewId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
{
|
{
|
||||||
$aObjects = array();
|
$aObjects = array();
|
||||||
|
|||||||
@@ -63,9 +63,16 @@ class downloadurl
|
|||||||
return $sReturn;
|
return $sReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function objectSetParent($iId, $sClass = 'version')
|
public function objectGetParent($sClass = '')
|
||||||
{
|
{
|
||||||
$this->iVersionId = $iId;
|
$oAppData = new appData($this->iId, null, $this);
|
||||||
|
return $oAppData->objectGetParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
$oAppData = new appData($this->iId, null, $this);
|
||||||
|
return $oAppData->objectSetParent($iNewId, $sClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
|
|||||||
@@ -899,15 +899,52 @@ class maintainer
|
|||||||
return array($aItemsPerPage, $iDefaultPerPage);
|
return array($aItemsPerPage, $iDefaultPerPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
return new version($this->iVersionId);
|
||||||
|
else
|
||||||
|
return new application($this->iAppId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
$this->iVersionId = $iNewId;
|
||||||
|
else
|
||||||
|
$this->iAppId = $iNewId;
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
{
|
{
|
||||||
/* We have none */
|
/* We have none */
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function update()
|
public function update()
|
||||||
{
|
{
|
||||||
/* STUB: No updating possible at the moment */
|
$oMaintainer = new maintainer($this->iMaintainerId);
|
||||||
|
|
||||||
|
if($this->iVersionId && $oMaintainer->iVersionId != $this->iVersionId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("UPDATE appMaintainers SET versionId = '?'
|
||||||
|
WHERE maintainerId = '?'",
|
||||||
|
$this->iVersionId, $this->iMaintainerId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->iAppId && $oMaintainer->iAppId != $this->iAppId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("UPDATE appMaintainers SET appId = '?'
|
||||||
|
WHERE maintainerId = '?'",
|
||||||
|
$this->iAppId, $this->iMaintainerId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,22 @@ class Monitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
return new version($this->iVersionId);
|
||||||
|
else
|
||||||
|
return new application($this->iAppId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
$this->iVersionId = $iNewId;
|
||||||
|
else
|
||||||
|
$this->iAppId = $iNewId;
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
{
|
{
|
||||||
/* We have none */
|
/* We have none */
|
||||||
@@ -103,7 +119,28 @@ class Monitor {
|
|||||||
|
|
||||||
function update()
|
function update()
|
||||||
{
|
{
|
||||||
/* Stub */
|
$oMonitor = new monitor($this->iMonitorId);
|
||||||
|
|
||||||
|
if($this->iVersionId && $oMonitor->iVersionId != $this->iVersionId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("UPDATE appMonitors SET versionId = '?'
|
||||||
|
WHERE monitorId = '?'",
|
||||||
|
$this->iVersionId, $this->iMonitorId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->iAppId && $oMonitor->iAppId != $this->iAppId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("UPDATE appMonitors SET appId = '?'
|
||||||
|
WHERE monitorId = '?'",
|
||||||
|
$this->iAppId, $this->iMonitorId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -378,6 +378,22 @@ class Note {
|
|||||||
return array(null, null, null);
|
return array(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
return new version($this->iVersionId);
|
||||||
|
else
|
||||||
|
return new application($this->iAppId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
if($this->iVersionId)
|
||||||
|
$this->iVersionId = $iNewId;
|
||||||
|
else
|
||||||
|
$this->iAppId = $iNewId;
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
|
|||||||
@@ -294,6 +294,18 @@ class screenshot
|
|||||||
return $this->oScreenshotImage->get_width();
|
return $this->oScreenshotImage->get_width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
$oAppData = new appData($this->iScreenshotId, null, $this);
|
||||||
|
return $oAppData->objectGetParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
$oAppData = new appData($this->iScreenshotId, null, $this);
|
||||||
|
return $oAppData->objectSetParent($iNewId, $sClass);
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
{
|
{
|
||||||
/* We have none */
|
/* We have none */
|
||||||
|
|||||||
@@ -511,6 +511,18 @@ class Url {
|
|||||||
return array(null, null, null);
|
return array(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectGetParent($sClass = '')
|
||||||
|
{
|
||||||
|
$oAppData = new appData($this->iUrlId, null, $this);
|
||||||
|
return $oAppData->objectGetParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectSetParent($iNewId, $sClass = '')
|
||||||
|
{
|
||||||
|
$oAppData = new appData($this->iUrlId, null, $this);
|
||||||
|
return $oAppData->objectSetParent($iNewId, $sClass);
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetChildren($bIncludeDeleted = false)
|
function objectGetChildren($bIncludeDeleted = false)
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
|
|||||||
@@ -1723,18 +1723,19 @@ class version {
|
|||||||
return $aTests;
|
return $aTests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function objectGetChildren($bIncludeDeleted = false)
|
public function objectGetChildren($bIncludeDeleted = false, $bRecursive = true)
|
||||||
{
|
{
|
||||||
return $this->objectGetChildrenClassSpecific('', $bIncludeDeleted);
|
return $this->objectGetChildrenClassSpecific('', $bIncludeDeleted, $bRecursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function objectGetChildrenClassSpecific($sClass = '', $bIncludeDeleted = false)
|
public function objectGetChildrenClassSpecific($sClass = '', $bIncludeDeleted = false, $bRecursive = true)
|
||||||
{
|
{
|
||||||
$aChildren = array();
|
$aChildren = array();
|
||||||
|
|
||||||
foreach($this->getTestResults($bIncludeDeleted) as $oTest)
|
foreach($this->getTestResults($bIncludeDeleted) as $oTest)
|
||||||
{
|
{
|
||||||
$aChildren += $oTest->objectGetChildren($bIncludeDeleted);
|
if($bRecursive)
|
||||||
|
$aChildren += $oTest->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oTest;
|
$aChildren[] = $oTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1748,7 +1749,9 @@ class version {
|
|||||||
while($oRow = mysql_fetch_object($hResult))
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
{
|
{
|
||||||
$oMaintainer = new maintainer(0, $oRow);
|
$oMaintainer = new maintainer(0, $oRow);
|
||||||
$aChildren += $oMaintainer->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
if($bRecursive)
|
||||||
|
$aChildren += $oMaintainer->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oMaintainer;
|
$aChildren[] = $oMaintainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1762,7 +1765,9 @@ class version {
|
|||||||
while($oRow = mysql_fetch_object($hResult))
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
{
|
{
|
||||||
$oMonitor = new monitor(0, $oRow);
|
$oMonitor = new monitor(0, $oRow);
|
||||||
$aChildren += $oMonitor->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
if($bRecursive)
|
||||||
|
$aChildren += $oMonitor->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oMonitor;
|
$aChildren[] = $oMonitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1776,7 +1781,9 @@ class version {
|
|||||||
while($oRow = mysql_fetch_object($hResult))
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
{
|
{
|
||||||
$oNote = new note(0, $oRow);
|
$oNote = new note(0, $oRow);
|
||||||
$aChildren += $oNote->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
if($bRecursive)
|
||||||
|
$aChildren += $oNote->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oNote;
|
$aChildren[] = $oNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1790,7 +1797,9 @@ class version {
|
|||||||
while($oRow = mysql_fetch_object($hResult))
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
{
|
{
|
||||||
$oScreenshot = new screenshot(0, $oRow);
|
$oScreenshot = new screenshot(0, $oRow);
|
||||||
$aChildren += $oScreenshot->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
if($bRecursive)
|
||||||
|
$aChildren += $oScreenshot->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oScreenshot;
|
$aChildren[] = $oScreenshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1798,7 +1807,9 @@ class version {
|
|||||||
foreach($this->get_buglink_ids() as $iBugId)
|
foreach($this->get_buglink_ids() as $iBugId)
|
||||||
{
|
{
|
||||||
$oBug = new bug($iBugId);
|
$oBug = new bug($iBugId);
|
||||||
$aChildren += $oBug->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
if($bRecursive)
|
||||||
|
$aChildren += $oBug->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oBug;
|
$aChildren[] = $oBug;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1812,7 +1823,8 @@ class version {
|
|||||||
while($oRow = mysql_fetch_object($hResult))
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
{
|
{
|
||||||
$oComment = new comment(0, $oRow);
|
$oComment = new comment(0, $oRow);
|
||||||
$aChildren += $oComment->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
/* No need to grab child comments since they're all part of the SQL result */
|
||||||
$aChildren[] = $oComment;
|
$aChildren[] = $oComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1826,7 +1838,9 @@ class version {
|
|||||||
while($oRow = mysql_fetch_object($hResult))
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
{
|
{
|
||||||
$oUrl = new url(0, $oRow);
|
$oUrl = new url(0, $oRow);
|
||||||
$aChildren += $oUrl->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
if($bRecursive)
|
||||||
|
$aChildren += $oUrl->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oUrl;
|
$aChildren[] = $oUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1840,7 +1854,9 @@ class version {
|
|||||||
while($oRow = mysql_fetch_object($hResult))
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
{
|
{
|
||||||
$oDownload = new downloadurl(0, $oRow);
|
$oDownload = new downloadurl(0, $oRow);
|
||||||
$aChildren += $oDownload->objectGetChildren($bIncludeDeleted);
|
|
||||||
|
if($bRecursive)
|
||||||
|
$aChildren += $oDownload->objectGetChildren($bIncludeDeleted);
|
||||||
$aChildren[] = $oDownload;
|
$aChildren[] = $oDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1852,38 +1868,16 @@ class version {
|
|||||||
/* Keep track of how many items we have updated */
|
/* Keep track of how many items we have updated */
|
||||||
$iCount = 0;
|
$iCount = 0;
|
||||||
|
|
||||||
/* Move test results */
|
/* We also move entries marked as deleted */
|
||||||
$sQuery = "SELECT * FROM testResults WHERE versionId = '?'";
|
$aChildren = $this->objectGetChildren(true, false);
|
||||||
$hResult = query_parameters($sQuery, $this->iVersionId);
|
|
||||||
|
|
||||||
if(!$hResult)
|
foreach($aChildren as $oChild)
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
while($oRow = query_fetch_object($hResult))
|
|
||||||
{
|
{
|
||||||
$oTestData = new testData($oRow->testingId);
|
$oChild->objectSetParent($iNewId, 'version');
|
||||||
$oTestData->iVersionId = $iNewId;
|
if($oChild->update())
|
||||||
if($oTestData->update())
|
|
||||||
$iCount++;
|
$iCount++;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/* Move all app data */
|
|
||||||
$sQuery = "SELECT * FROM appData WHERE versionId = '?'";
|
|
||||||
$hResult = query_parameters($sQuery, $this->iVersionId);
|
|
||||||
|
|
||||||
if(!$hResult)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
while($oRow = query_fetch_object($hResult))
|
|
||||||
{
|
|
||||||
$oAppData = new appData($oRow->testingId);
|
|
||||||
$oAppData->iVersionId = $iNewId;
|
|
||||||
if($oAppData->update(TRUE))
|
|
||||||
$iCount++;
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the number of updated objects if everything was successful */
|
/* Return the number of updated objects if everything was successful */
|
||||||
|
|||||||
Reference in New Issue
Block a user