Add a moveChildren method to the objectManager and implement objectMoveChildren for version
and version_queue. Use this to move versions.
This commit is contained in:
committed by
WineHQ
parent
886cdeafa3
commit
cf81d542ee
@@ -52,6 +52,29 @@ class appData
|
|||||||
return $hResult;
|
return $hResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update($bSilent = FALSE)
|
||||||
|
{
|
||||||
|
if(!$this->canEdit())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
$sQuery = "UPDATE appData SET versionId = '?', appId = '?', sDescription = '?'
|
||||||
|
WHERE id = '?'";
|
||||||
|
$hResult = query_parameters($this->iVersionId, $this->iAppId,
|
||||||
|
$this->sDescription, $this->iId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
{
|
||||||
|
if(!$bResult)
|
||||||
|
addmsg("Failed to update add data", "red");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$bSilent)
|
||||||
|
addmsg("Updated app data successfully", "green");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
function listSubmittedBy($iUserId, $bQueued = true)
|
function listSubmittedBy($iUserId, $bQueued = true)
|
||||||
{
|
{
|
||||||
$hResult = query_parameters("SELECT * FROM appData WHERE
|
$hResult = query_parameters("SELECT * FROM appData WHERE
|
||||||
|
|||||||
@@ -220,6 +220,35 @@ class ObjectManager
|
|||||||
echo "Failure.\n";
|
echo "Failure.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Move all the object's children to another object of the same type, and
|
||||||
|
delete the original object afterwards */
|
||||||
|
function move_children($iNewId)
|
||||||
|
{
|
||||||
|
$oObject = new $this->sClass($this->iId);
|
||||||
|
$oNewObject = new $this->sClass($iNewId);
|
||||||
|
|
||||||
|
/* The user needs to have edit rights to both the old and the new object
|
||||||
|
If you have edit rights to an object then you should have edit rights
|
||||||
|
to its child objects as well */
|
||||||
|
if(!$oObject->canEdit() || !$oNewObject->canEdit())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
$iAffected = $oObject->objectMoveChildren($iNewId);
|
||||||
|
|
||||||
|
if($iAffected)
|
||||||
|
{
|
||||||
|
$sPlural = ($iAffected == 1) ? "": "s";
|
||||||
|
addmsg("Moved $iAffected child object$sPlural", "green");
|
||||||
|
} else if($iAfffected === FALSE)
|
||||||
|
{
|
||||||
|
/* We don't want to delete this object if some children were not moved */
|
||||||
|
addmsg("Failed to move child objects", "red");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->delete_entry();
|
||||||
|
}
|
||||||
|
|
||||||
/* Display screen for submitting a new entry of given type */
|
/* Display screen for submitting a new entry of given type */
|
||||||
function add_entry($sBackLink, $sErrors = "")
|
function add_entry($sBackLink, $sErrors = "")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1366,6 +1366,49 @@ class Version {
|
|||||||
echo "<p>To view a submission, click on its name. ".
|
echo "<p>To view a submission, click on its name. ".
|
||||||
"From that page you can edit, delete or approve it into the AppDB.</p>\n";
|
"From that page you can edit, delete or approve it into the AppDB.</p>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function objectMoveChildren($iNewId)
|
||||||
|
{
|
||||||
|
/* Keep track of how many items we have updated */
|
||||||
|
$iCount = 0;
|
||||||
|
|
||||||
|
/* Move test results */
|
||||||
|
$sQuery = "SELECT * FROM testResults WHERE versionId = '?'";
|
||||||
|
$hResult = query_parameters($sQuery, $this->iVersionId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
|
{
|
||||||
|
$oTestData = new testData($oRow->testingId);
|
||||||
|
$oTestData->iVersionId = $iNewId;
|
||||||
|
if($oTestData->update())
|
||||||
|
$iCount++;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Move all app data */
|
||||||
|
$sQuery = "SELECT * FROM appData WHERE versionId = '?'";
|
||||||
|
$hResult = query_parameters($sQuery, $this->iVersionId);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
while($oRow = mysql_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 $iCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -197,10 +197,10 @@ class version_queue
|
|||||||
array(Comment::get_comment_count_for_versionid(
|
array(Comment::get_comment_count_for_versionid(
|
||||||
$oVersion->iVersionId), 'align="center"'),
|
$oVersion->iVersionId), 'align="center"'),
|
||||||
html_ahref("Move here",
|
html_ahref("Move here",
|
||||||
"admin/adminAppQueue.php?sSub=movetest&sAppType=version&".
|
"objectManager.php?sClass=version_queue&bIsQueue=true&".
|
||||||
"iVersionId="
|
"sAction=moveChildren&iId=".
|
||||||
.$this->oVersion->iVersionId."&iVersionIdMergeTo=".
|
$this->oVersion->iVersionId."&iNewId=".
|
||||||
$oVersion->iVersionId)
|
$oVersion->iVersionId."&sTitle=Version+Queue"),
|
||||||
),
|
),
|
||||||
($i % 2) ? "color0" : "color1");
|
($i % 2) ? "color0" : "color1");
|
||||||
|
|
||||||
@@ -215,6 +215,11 @@ class version_queue
|
|||||||
{
|
{
|
||||||
version::objectDisplayQueueProcessingHelp();
|
version::objectDisplayQueueProcessingHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function objectMoveChildren($iNewId)
|
||||||
|
{
|
||||||
|
return $this->oVersion->objectMoveChildren($iNewId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ if($sErrors === TRUE)
|
|||||||
if($oObject->iId && $aClean['sAction'] == "delete")
|
if($oObject->iId && $aClean['sAction'] == "delete")
|
||||||
$oObject->delete_entry();
|
$oObject->delete_entry();
|
||||||
|
|
||||||
|
/* Provided the necessary values are present, an object's children may be moved
|
||||||
|
without any confirmation */
|
||||||
|
if($oObject->iId && $aClean['sAction'] == "moveChildren" && $aClean['iNewId'])
|
||||||
|
$oObject->move_children($aClean['iNewId']);
|
||||||
|
|
||||||
apidb_header($oObject->sTitle);
|
apidb_header($oObject->sTitle);
|
||||||
|
|
||||||
/* display a particular element */
|
/* display a particular element */
|
||||||
|
|||||||
Reference in New Issue
Block a user