diff --git a/admin/editAppFamily.php b/admin/editAppFamily.php index dd204cf..8b4bb8b 100644 --- a/admin/editAppFamily.php +++ b/admin/editAppFamily.php @@ -24,95 +24,7 @@ if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSuperMain if(isset($_REQUEST['submit'])) { - // commit changes of form to database - if($_REQUEST['submit'] == "Update Database") - { - $oApp = new Application($_REQUEST['appId']); - $oApp->update($_REQUEST['appName'], $_REQUEST['description'], $_REQUEST['keywords'], $_REQUEST['webPage'], $_REQUEST['vendorId'], $_REQUEST['catId']); - } - else if($_REQUEST['submit'] == "Update URL") - { - $sWhatChanged = ""; - $bAppChanged = false; - - if (!empty($_REQUEST['url_desc']) && !empty($_REQUEST['url']) ) - { - // process added URL - if($_SESSION['current']->showDebuggingInfos()) { echo "

{$_REQUEST['url']}: {$_REQUEST['url_desc']}

"; } - - $aInsert = compile_insert_string( array( 'appId' => $_REQUEST['appId'], - 'type' => 'url', - 'description' => $_REQUEST['url_desc'], - 'url' => $_REQUEST['url'])); - - $sQuery = "INSERT INTO appData ({$aInsert['FIELDS']}) VALUES ({$aInsert['VALUES']})"; - - if($_SESSION['current']->showDebuggingInfos()) { echo "

query: $sQuery

"; } - - if (query_appdb($sQuery)) - { - addmsg("The URL was successfully added into the database", "green"); - $sWhatChanged .= " Added Url: Description: ".stripslashes($_REQUEST['url_desc'])."\n"; - $sWhatChanged .= " Url: ".stripslashes($_REQUEST['url'])."\n"; - $bAppChanged = true; - } - } - - // Process changed URLs - - for($i = 0; $i < $_REQUEST['rows']; $i++) - { - if($_SESSION['current']->showDebuggingInfos()) { echo "

{$_REQUEST['adescription'][$i]}: {$_REQUEST['aURL'][$i]}: {$_REQUEST['adelete'][$i]} : {$_REQUEST['aId'][$i]} : .{$_REQUEST['aOldDesc'][$i]}. : {$_REQUEST['aOldURL'][$i]}

"; } - - if ($_REQUEST['adelete'][$i] == "on") - { - $hResult = query_appdb("DELETE FROM appData WHERE id = '{$_REQUEST['aId'][$i]}'"); - - if($hResult) - { - addmsg("

Successfully deleted URL ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].")

\n",'green'); - $sWhatChanged .= "Deleted Url: Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n"; - $sWhatChanged .= " url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n"; - $bAppChanged = true; - } - - - } - else if( $_REQUEST['aURL'][$i] != $_REQUEST['aOldURL'][$i] || $_REQUEST['adescription'][$i] != $_REQUEST['aOldDesc'][$i]) - { - if(empty($_REQUEST['aURL'][$i]) || empty($_REQUEST['adescription'][$i])) - addmsg("The URL or description was blank. URL not changed in the database", "red"); - else - { - $sUpdate = compile_update_string( array( 'description' => $_REQUEST['adescription'][$i], - 'url' => $_REQUEST['aURL'][$i])); - if (query_appdb("UPDATE appData SET $sUpdate WHERE id = '{$_REQUEST['aId'][$i]}'")) - { - addmsg("

Successfully updated ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].")

\n",'green'); - $sWhatChanged .= "Changed Url: Old Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n"; - $sWhatChanged .= " Old Url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n"; - $sWhatChanged .= " New Description: ".stripslashes($_REQUEST['adescription'][$i])."\n"; - $sWhatChanged .= " New url: ".stripslashes($_REQUEST['aURL'][$i])."\n"; - $bAppChanged = true; - } - } - } - } - if ($bAppChanged) - { - $sEmail = get_notify_email_address_list($_REQUEST['appId']); - if($sEmail) - { - $sFullAppName = "Links for ".lookup_app_name($_REQUEST['appId'])." have been updated"; - $sMsg = APPDB_ROOT."appview.php?appId=".$_REQUEST['appId']."\r\n"; - $sMsg .= "\n"; - $sMsg .= $_SESSION['current']->sRealname." updated links for ".$sFullAppName." \r\n"; - $sMsg .= "\n"; - $sMsg .= $sWhatChanged."\n"; - mail_appdb($sEmail, $sFullAppName ,$sMsg); - } - } - } + process_app_version_changes(false); redirect(apidb_fullurl("appview.php?appId={$_REQUEST['appId']}")); } else diff --git a/admin/editAppVersion.php b/admin/editAppVersion.php index 12a04bc..0dfe756 100644 --- a/admin/editAppVersion.php +++ b/admin/editAppVersion.php @@ -18,95 +18,12 @@ if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintaine exit; } -if(isset($_REQUEST['submit1'])) +/* process the changes the user entered into the web form */ +if(isset($_REQUEST['submit'])) { - $oVersion = new Version($_REQUEST['versionId']); - $oApp = new Application($_REQUEST['appId']); - if($_REQUEST['submit1'] == "Update Database") - { - $oVersion->update($_REQUEST['versionName'], $_REQUEST['description'], $_REQUEST['maintainer_release'], $_REQUEST['maintainer_rating']); - } - else if($_REQUEST['submit1'] == "Update URL") - { - - $sWhatChanged = ""; - $bAppChanged = false; - - if (!empty($_REQUEST['url_desc']) && !empty($_REQUEST['url']) ) - { - // process added URL - $aInsert = compile_insert_string( array('versionId' => $_REQUEST['versionId'], - 'type' => 'url', - 'description' => $_REQUEST['url_desc'], - 'url' => $_REQUEST['url'])); - - $sQuery = "INSERT INTO appData ({$aInsert['FIELDS']}) VALUES ({$aInsert['VALUES']})"; - - if (query_appdb($sQuery)) - { - addmsg("The URL was successfully added into the database", "green"); - $sWhatChanged .= " Added Url: Description: ".stripslashes($_REQUEST['url_desc'])."\n"; - $sWhatChanged .= " Url: ".stripslashes($_REQUEST['url'])."\n"; - $bAppChanged = true; - } - } - - // Process changed URLs - for($i = 0; $i < $_REQUEST['rows']; $i++) - { - if ($_REQUEST['adelete'][$i] == "on") - { - $hResult = query_appdb("DELETE FROM appData WHERE id = '{$_REQUEST['aId'][$i]}'"); - - if($hResult) - { - addmsg("Successfully deleted URL ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].").","green"); - $sWhatChanged .= "Deleted Url: Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n"; - $sWhatChanged .= " url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n"; - $bAppChanged = true; - } - - - } - else if( $_REQUEST['aURL'][$i] != $_REQUEST['aOldURL'][$i] || $_REQUEST['adescription'][$i] != $_REQUEST['aOldDesc'][$i]) - { - if(empty($_REQUEST['aURL'][$i]) || empty($_REQUEST['adescription'][$i])) - addmsg("The URL or description was blank. URL not changed in the database", "red"); - else - { - $sUpdate = compile_update_string( array( 'description' => $_REQUEST['adescription'][$i], - 'url' => $_REQUEST['aURL'][$i])); - if (query_appdb("UPDATE appData SET $sUpdate WHERE id = '{$_REQUEST['aId'][$i]}'")) - { - addmsg("

Successfully updated ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].")

\n",'green'); - $sWhatChanged .= "Changed Url: Old Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n"; - $sWhatChanged .= " Old Url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n"; - $sWhatChanged .= " New Description: ".stripslashes($_REQUEST['adescription'][$i])."\n"; - $sWhatChanged .= " New url: ".stripslashes($_REQUEST['aURL'][$i])."\n"; - $bAppChanged = true; - } - } - } - } - if ($bAppChanged) - { - $sEmail = get_notify_email_address_list($_REQUEST['appId']); - if($sEmail) - { - $sSubject = "Links for ".$oApp->sName." ".$oVersion->sName." have been updated by ".$_SESSION['current']->sRealname; - $sMsg = APPDB_ROOT."appview.php?appId=".$_REQUEST['appId']."\n"; - $sMsg .= "\n"; - $sMsg .= "The following changes have been made:"; - $sMsg .= "\n"; - $sMsg .= $sWhatChanged."\n"; - $sMsg .= "\n"; - - mail_appdb($sEmail, $sSubject ,$sMsg); - } - } - } + process_app_version_changes(true); redirect(apidb_fullurl("appview.php?versionId=".$_REQUEST['versionId'])); -} else +} else /* or display the webform for making changes */ { ?> @@ -161,7 +78,7 @@ if(isset($_REQUEST['submit1'])) make_bugzilla_version_list("maintainer_release", $oVersion->sTestedRelease); echo '',"\n"; - echo '',"\n"; + echo '',"\n"; echo html_table_end(); echo html_frame_end(); @@ -206,7 +123,7 @@ if(isset($_REQUEST['submit1'])) echo 'New',"\n"; echo '',"\n"; - echo '',"\n"; + echo '',"\n"; echo '',"\n"; echo html_frame_end(); diff --git a/include/util.php b/include/util.php index fe2cc39..8d31794 100644 --- a/include/util.php +++ b/include/util.php @@ -466,4 +466,123 @@ function display_versions($iAppId, $aVersionsIds) } } +/* pass in $isVersion of true if we are processing changes for an app version */ +/* or false if processing changes for an application family */ +function process_app_version_changes($isVersion) +{ + if($isVersion) + { + $oVersion = new Version($_REQUEST['versionId']); + $oApp = new Application($_REQUEST['appId']); + } + + // commit changes of form to database + if(($_REQUEST['submit'] == "Update Database") && $isVersion) /* is a version */ + { + $oVersion->update($_REQUEST['versionName'], $_REQUEST['description'], $_REQUEST['maintainer_release'], $_REQUEST['maintainer_rating']); + } else if(($_REQUEST['submit'] == "Update Database") && !$isVersion) /* is an application */ + { + $oApp = new Application($_REQUEST['appId']); + $oApp->update($_REQUEST['appName'], $_REQUEST['description'], $_REQUEST['keywords'], $_REQUEST['webPage'], $_REQUEST['vendorId'], $_REQUEST['catId']); + } else if($_REQUEST['submit'] == "Update URL") + { + + $sWhatChanged = ""; + $bAppChanged = false; + + if (!empty($_REQUEST['url_desc']) && !empty($_REQUEST['url']) ) + { + // process added URL + if($_SESSION['current']->showDebuggingInfos()) { echo "

{$_REQUEST['url']}: {$_REQUEST['url_desc']}

"; } + + if($isVersion) + { + $aInsert = compile_insert_string( array('versionId' => $_REQUEST['versionId'], + 'type' => 'url', + 'description' => $_REQUEST['url_desc'], + 'url' => $_REQUEST['url'])); + } else + { + $aInsert = compile_insert_string( array( 'appId' => $_REQUEST['appId'], + 'type' => 'url', + 'description' => $_REQUEST['url_desc'], + 'url' => $_REQUEST['url'])); + + } + + $sQuery = "INSERT INTO appData ({$aInsert['FIELDS']}) VALUES ({$aInsert['VALUES']})"; + + if($_SESSION['current']->showDebuggingInfos()) { echo "

query: $sQuery

"; } + + if (query_appdb($sQuery)) + { + addmsg("The URL was successfully added into the database", "green"); + $sWhatChanged .= " Added Url: Description: ".stripslashes($_REQUEST['url_desc'])."\n"; + $sWhatChanged .= " Url: ".stripslashes($_REQUEST['url'])."\n"; + $bAppChanged = true; + } + } + + // Process changed URLs + for($i = 0; $i < $_REQUEST['rows']; $i++) + { + if($_SESSION['current']->showDebuggingInfos()) { echo "

{$_REQUEST['adescription'][$i]}: {$_REQUEST['aURL'][$i]}: {$_REQUEST['adelete'][$i]} : {$_REQUEST['aId'][$i]} : .{$_REQUEST['aOldDesc'][$i]}. : {$_REQUEST['aOldURL'][$i]}

"; } + + if ($_REQUEST['adelete'][$i] == "on") + { + $hResult = query_appdb("DELETE FROM appData WHERE id = '{$_REQUEST['aId'][$i]}'"); + + if($hResult) + { + addmsg("

Successfully deleted URL ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].")

\n",'green'); + $sWhatChanged .= "Deleted Url: Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n"; + $sWhatChanged .= " url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n"; + $bAppChanged = true; + } + + + } + else if( $_REQUEST['aURL'][$i] != $_REQUEST['aOldURL'][$i] || $_REQUEST['adescription'][$i] != $_REQUEST['aOldDesc'][$i]) + { + if(empty($_REQUEST['aURL'][$i]) || empty($_REQUEST['adescription'][$i])) + addmsg("The URL or description was blank. URL not changed in the database", "red"); + else + { + $sUpdate = compile_update_string( array( 'description' => $_REQUEST['adescription'][$i], + 'url' => $_REQUEST['aURL'][$i])); + if (query_appdb("UPDATE appData SET $sUpdate WHERE id = '{$_REQUEST['aId'][$i]}'")) + { + addmsg("

Successfully updated ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].")

\n",'green'); + $sWhatChanged .= "Changed Url: Old Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n"; + $sWhatChanged .= " Old Url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n"; + $sWhatChanged .= " New Description: ".stripslashes($_REQUEST['adescription'][$i])."\n"; + $sWhatChanged .= " New url: ".stripslashes($_REQUEST['aURL'][$i])."\n"; + $bAppChanged = true; + } + } + } + } + if ($bAppChanged) + { + $sEmail = get_notify_email_address_list($_REQUEST['appId']); + if($sEmail) + { + if($isVersion) + $sSubject = "Links for ".$oApp->sName." ".$oVersion->sName." have been updated by ".$_SESSION['current']->sRealname; + else + $sSubject = "Links for ".$oApp->sName." have been updated by ".$_SESSION['current']->sRealname; + + $sMsg = APPDB_ROOT."appview.php?appId=".$_REQUEST['appId']."\n"; + $sMsg .= "\n"; + $sMsg .= "The following changes have been made:"; + $sMsg .= "\n"; + $sMsg .= $sWhatChanged."\n"; + $sMsg .= "\n"; + + mail_appdb($sEmail, $sSubject ,$sMsg); + } + } + } +} + ?> \ No newline at end of file