From 81d3db95b89be35398a2f320131bee531da3587a Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Sun, 5 Jun 2005 21:26:07 +0000 Subject: [PATCH] Add the ability for admins to move a version from one application to another. This is useful when there are duplicate applications and you want to move versions prior to removing the duplicate app. --- admin/editAppVersion.php | 13 +++++++ admin/moveAppVersion.php | 79 ++++++++++++++++++++++++++++++++++++++++ include/version.php | 2 +- 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 admin/moveAppVersion.php diff --git a/admin/editAppVersion.php b/admin/editAppVersion.php index 0dfe756..98247e2 100644 --- a/admin/editAppVersion.php +++ b/admin/editAppVersion.php @@ -128,6 +128,19 @@ if(isset($_REQUEST['submit'])) echo '',"\n"; echo html_frame_end(); echo ""; + + /* only admins can move versions */ + if($_SESSION['current']->hasPriv("admin")) + { + // move version form + echo '
',"\n"; + echo ''; + echo ''; + echo html_frame_start("Move version to another application","90%","",0); + echo '
',"\n"; + echo html_frame_end(); + } + echo html_back_link(1,BASE."appview.php?versionId=".$oVersion->iVersionId); apidb_footer(); } diff --git a/admin/moveAppVersion.php b/admin/moveAppVersion.php new file mode 100644 index 0000000..b93bd92 --- /dev/null +++ b/admin/moveAppVersion.php @@ -0,0 +1,79 @@ +hasPriv("admin")) +{ + errorpage("Insufficient Privileges!"); + exit; +} + +if(isset($_REQUEST['action'])) +{ + /* move this version to the given application */ + $oVersion = new Version($_REQUEST['versionId']); + $oVersion->update(null, null, null, null, $_REQUEST['appId']); + + /* redirect to the application we just moved this version to */ + redirect(apidb_fullurl("appview.php?appId=".$_REQUEST['appId'])); +} else /* or display the webform for making changes */ +{ +?> + +iAppId); + + apidb_header("Choose application to move this version under"); + + echo "\n"; + echo html_frame_start("Move ".$oApp->sName." ".$oVersion->sName, "90%","",0); + echo ''; + echo ''; + + + /* build a table of applications and their versions */ + echo html_table_begin("align=\"center\" style=\"border-collapse: collapse;\""); + + // NOTE: the left join here is expensive and takes some 5x as long as a normal select from appFamily and appVersion would take + // although this cheaper select leaves out all applications that lack versions + $sQuery = "select appName, appFamily.appId, versionName, versionId from appFamily left join appVersion "; + $sQuery.= "on appVersion.appId = appFamily.appId ORDER BY appFamily.appName, appFamily.appId, appVersion.versionName;"; + $hResult = query_appdb($sQuery); + $currentAppId = 0; + while($oRow = mysql_fetch_object($hResult)) + { + /* if the version ids differ then we should start a row with a new application */ + /* and the version that matches with it */ + if($currentAppId != $oRow->appId) + { + $currentAppId = $oRow->appId; + echo ''; + $url = BASE."appview.php?appId=".$oRow->appId; + echo ''.substr($oRow->appName, 0, 30).' - '.$oRow->appId.''; + echo "Move here"; + echo ''.$oRow->versionName.''; + } else /* just add another version */ + { + echo ''.$oRow->versionName.''; + } + echo "\n"; + } + + echo html_table_end(); + echo html_frame_end(); + echo "
"; + echo html_back_link(1, BASE."appview.php?versionId=".$oVersion->iVersionId); + apidb_footer(); +} +?> diff --git a/include/version.php b/include/version.php index 4069323..8cdf8a4 100644 --- a/include/version.php +++ b/include/version.php @@ -215,7 +215,7 @@ class Version { return false; $oAppBefore = new Application($this->iAppId); $oAppAfter = new Application($iAppId); - $sWhatChanged .= "Application was changed from ".$oAppBefore->sName." to ".$oAppAfter->sName.".\n\n"; + $sWhatChanged .= "Version was moved from application ".$oAppBefore->sName." to application ".$oAppAfter->sName.".\n\n"; $this->iAppId = $iAppId; } if($sWhatChanged)