diff --git a/admin/editAppFamily.php b/admin/editAppFamily.php index 5f986ea..095b325 100644 --- a/admin/editAppFamily.php +++ b/admin/editAppFamily.php @@ -8,83 +8,197 @@ include(BASE."include/"."qclass.php"); global $apidb_root; -//FIXME: need to check for admin privs if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) ) { errorpage("Insufficient Privileges!"); exit; } -apidb_header("Edit Application Family"); - -$t = new TableVE("edit"); - -if($cmd) +if($HTTP_POST_VARS) { $statusMessage = ''; - - //process add URL - if($cmd == "add_url") - { - $query = "INSERT INTO appData VALUES (null, $appId, 0, 'url', ". - "'$url_desc', '$url')"; - - if(debugging()) { echo "
query: $query
"; } - - if (mysql_query($query)) - { - //success - $statusMessage = "The URL was successfully added into the database
\n"; - } - else - { - //error - $statusMessage = "Database Error!
".mysql_error()."
$statusMessage
\n"; - echo html_frame_end(); - echo html_back_link(1,"editAppFamily.php?appId=$appId"); - } - -} -else if($HTTP_POST_VARS) -{ // commit changes of form to database - $t->update($HTTP_POST_VARS); -} -else -{ + if($submit1 == "Update Database") + { + $statusMessage = ''; + $appName = addslashes($appName); + $description = addslashes($description); + $webPage = addslashes($webPage); + if (!mysql_query("UPDATE appFamily SET appName = '".$appName."', ". + "vendorId = $vendorId, keywords = '".$keywords."', ". + "description = '".$description."', ". + "webPage = '".$webPage."', ". + "catId = $catId". + " WHERE appId = $appId")) + { + $statusMessage = "Database Error!
".mysql_error()."
$url: $url_desc
"; } + + if ($url_desc && $url ) + { + $query = "INSERT INTO appData VALUES (null, $appId, 0, 'url','$url_desc', '$url')"; + + if(debugging()) { echo "query: $query
"; } + + if (mysql_query($query)) + { + //success + addmsg("The URL was successfully added into the database", "green"); + } + else + { + //error + $statusMessage = "Database Error!
".mysql_error()."
$adescription[$i]: $aURL[$i]: $adelete[$i] : $aId[$i] : .$aOldDesc[$i]. : $aOldURL[$i]
"; } + + if ($adelete[$i] == "on") + { + if(debugging()) { echo "$adescription[$i]: $aURL[$i]: $adelete[$i] : $aId[$i] : $aOldDesc[$i] : $aOldURL[$i]
"; } + $result = mysql_query("DELETE FROM appData WHERE id = '$aId[$i]'"); - // show form + if(!$result) + { + //error + $statusMessage = "Database Error!
".mysql_error()." deleting URL ".$aOldDesc[$i]." (".$aOldURL[$i].")
Successfully deleted URL ".$aOldDesc[$i]." (".$aOldURL[$i].")
\n"; + addmsg($statusMessage, "green"); + } + } + else if( $aURL[$i] != $aOldURL[$i] || $adescription[$i] != $aOldDesc[$i]) + { + if(!$aURL[$i] || !$adescription[$i]) + addmsg("The URL or description was blank. URL not changed in the database", "red"); + else + { + if(debugging()) { echo "$adescription[$i]: $aURL[$i]: $adelete[$i] : $aId[$i] : $aOldDesc[$i] : $aOldURL[$i]
"; } + $adescription[$i] = addslashes($adescription[$i]); + $aURL[$i] = addslashes($aURL[$i]); + if (!mysql_query("UPDATE appData SET description = '".$adescription[$i]."' , url = '".$aURL[$i]."'". + " WHERE Id = $aId[$i]")) + { + //error + $statusMessage = "Database Error!
".mysql_error()." updateing URL ".$aOldDesc[$i]." (".$aOldURL[$i].")
Successfully updated ".$aOldDesc[$i]." (".$aOldURL[$i].")
\n"; + addmsg($statusMessage, "green"); + } + } + } + } + } +} +//Show the form for editing the Application Family +{ + $family = new TableVE("edit"); + + $result = mysql_query("SELECT appId, appName, vendorId, keywords, ". + "description, webPage, catId from appFamily WHERE ". + "appId = '$appId'"); + if(!$result) + { + errorpage("You must be logged in to edit preferences"); + exit; + } + + list($appId, $appName, $vendorId, $keywords, $description, $webPage, $catId) = mysql_fetch_row($result); + if(debugging()) { echo "appName: $appName
"; } + + // show edit app family form $table = "appFamily"; $query = "SELECT * FROM $table WHERE appId = $appId"; if(debugging()) { echo "query: $query
"; } + apidb_header("Edit Application Family"); - $t->edit($query); + echo "