diff --git a/admin/editAppFamily.php b/admin/editAppFamily.php index 1738f5d..8ecfd3c 100644 --- a/admin/editAppFamily.php +++ b/admin/editAppFamily.php @@ -125,6 +125,93 @@ if(isset($_REQUEST['submit'])) } } } + 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); + } + } + + redirect(apidb_fullurl("appview.php?appId={$_REQUEST['appId']}")); + exit; + } } else // Show the form for editing the Application Family @@ -175,6 +262,50 @@ else echo html_frame_end(); echo ""; + // url edit form + echo '
',"\n"; + echo ''; + echo html_frame_start("Edit URL","90%","",0); + echo '',"\n"; + + $i = 0; + $result = query_appdb("SELECT * FROM appData WHERE appId = $ob->appId AND type = 'url' AND versionId = 0"); + if($result && mysql_num_rows($result) > 0) + { + echo '',"\n"; + while($ob = mysql_fetch_object($result)) + { + $temp0 = "adelete[".$i."]"; + $temp1 = "adescription[".$i."]"; + $temp2 = "aURL[".$i."]"; + $temp3 = "aId[".$i."]"; + $temp4 = "aOldDesc[".$i."]"; + $temp5 = "aOldURL[".$i."]"; + echo '',"\n"; + echo '',"\n"; + echo ''; + echo ''; + echo '',"\n"; + $i++; + } + } else + { + echo '',"\n"; + echo '',"\n"; + } + echo "\n"; + echo ""; + + echo '',"\n"; + echo '',"\n"; + + echo '',"\n"; + + echo '
Delete',"\n"; + echo 'DescriptionURL
',"\n"; + echo '
DescriptionURL
New
',"\n"; + echo html_frame_end(); + echo "
"; echo html_back_link(1,BASE."appview.php?appId=$ob->appId"); } diff --git a/appview.php b/appview.php index 8d04b98..0147c72 100644 --- a/appview.php +++ b/appview.php @@ -220,6 +220,18 @@ if($_REQUEST['appId']) // main URL echo " URL".$appLinkURL."\n"; + // optional links + $result = query_appdb("SELECT * FROM appData WHERE appId = ".$_REQUEST['appId']." AND versionID = 0 AND type = 'url'"); + if($result && mysql_num_rows($result) > 0) + { + echo " Links\n"; + while($ob = mysql_fetch_object($result)) + { + echo " ".substr(stripslashes($ob->description),0,30)."
\n"; + } + echo " \n"; + } + // image $img = get_screenshot_img($oApp->iAppId); echo "$img\n"; diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql index 1b7082b..c627dd3 100644 --- a/tables/appdb_tables.sql +++ b/tables/appdb_tables.sql @@ -154,6 +154,7 @@ create table appComments ( */ create table appData ( id int not null auto_increment, + appId int not null, versionId int default 0, type enum('image', 'url', 'bug'), description text,