Allow Maintainers to edit Application version. Send out email indicating what they changed.

This commit is contained in:
Tony Lambregts
2004-11-17 23:02:07 +00:00
committed by Jeremy Newman
parent 91a821fdde
commit b1b785fd04
2 changed files with 186 additions and 129 deletions

View File

@@ -5,107 +5,147 @@ include("path.php");
include(BASE."include/"."incl.php"); include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php"); include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php"); include(BASE."include/"."qclass.php");
require(BASE."include/"."application.php");
//check for admin privs //check for admin privs
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) ) if(!loggedin() || (!havepriv("admin") && !isMaintainer($appId, $versionId)) )
{ {
errorpage("Insufficient Privileges!"); errorpage("Insufficient Privileges!");
exit; exit;
} }
apidb_header("Edit Application Version"); if($HTTP_POST_VARS)
$t = new TableVE("edit");
if($cmd)
{ {
$statusMessage = ''; if($submit1 == "Update Database")
//process screenshot upload {
if($cmd == "screenshot_upload") $statusMessage = '';
// Get the old values from the database
$query = "SELECT * FROM appVersion WHERE appId = $appId and versionId = $versionId";
$result = mysql_query($query);
$ob = mysql_fetch_object($result);
$old_versionName = $ob->versionName;
$old_keywords = $ob->keywords;
$old_description = $ob->description;
$old_webPage = $ob->webPage;
$versionName = addslashes($versionName);
$description = addslashes($description);
$webPage = addslashes($webPage);
$VersionChanged = false;
if ($old_versionName <> $versionName)
{ {
if(debugging()) $WhatChanged .= "Version name: Old Value: ".stripslashes($old_versionName)."\n";
{ $WhatChanged .= " New Value: ".stripslashes($versionName)."\n";
echo "<p align=center>Screenshot: ($appId) file=$imagefile size=$imagefile_size\n"; $VersionChanged = true;
echo " name=$imagefile_name type=$imagefile_type<br>"; }
} if ($old_keywords <> $keywords)
{
if(!copy($imagefile, "../data/screenshots/".basename($imagefile_name))) $WhatChanged .= " Key Words: Old Value: ".stripslashes($old_keywords)."\n";
{ $WhatChanged .= " New Value: ".stripslashes($keywords)."\n";
// whoops, copy failed. do something $VersionChanged = true;
echo html_frame_start("Edit Application","300"); }
echo "<p><b>debug: copy failed; $imagefile; $imagefile_name</b></p>\n"; if ($old_webPage <> $webPage)
echo html_frame_end(); {
echo html_back_link(1,"editAppVersion.php?appId=$appId&versionID=$versionId"); $WhatChanged .= " Web Page: Old Value: ".stripslashes($old_webPage)."\n";
apidb_footer(); $WhatChanged .= " New Value: ".stripslashes($webPage)."\n";
exit; $VersionChanged = true;
} }
if ($old_description <> $description)
$query = "INSERT INTO appData VALUES (null, $appId, $versionId, 'image', ". {
"'".addslashes($screenshot_desc)."', '".basename($imagefile_name)."')"; $WhatChanged .= " Description: Old Value:\n";
$WhatChanged .= "-----------------------:\n";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; } $WhatChanged .= stripslashes($old_description)."\n";
$WhatChanged .= "-----------------------:\n";
if (mysql_query($query)) $WhatChanged .= " Description: Vew Value:\n";
{ $WhatChanged .= "-----------------------:\n";
$WhatChanged .= stripslashes($description)."\n";
$WhatChanged .= "-----------------------:\n";
$VersionChanged = true;
}
//did anything change?
if ($VersionChanged)
{
$query = "UPDATE appVersion SET versionName = '".$versionName."', ".
"keywords = '".$keywords."', ".
"description = '".$description."', ".
"webPage = '".$webPage."'".
" WHERE appId = $appId and versionId = $versionId";
if (mysql_query($query))
{
//success //success
$statusMessage = "<p>The image was successfully added into the database</p>\n"; $email = getNotifyEmailAddressList($appId, $versionId);
if($email)
{
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms .= APPDB_ROOT."appView.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n";
$ms .= ($current->username ? $current->username : "Anonymous")." changed ".$fullAppName."\n";
$ms .= "\n";
$ms .= $WhatChanged."\n";
$ms .= "\n";
$ms .= STANDARD_NOTIFY_FOOTER;
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
} else
{
$email = "no one";
}
addmsg("mesage sent to: ".$email, green);
addmsg("The Version was successfully updated in the database", "green");
redirect(apidb_fullurl("appview.php?appId=$appId&versionId=$versionId"));
} }
else else
{ {
//error //error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."<br></b></p>\n"; $statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
if(debugging()) { $statusMessage .= "<p>$query</p>"; } addmsg($statusMessage, "red");
redirect(apidb_fullurl("admin/editAppVersion.php?appId=$appId&versionId=$versionId"));
} }
} else
{
addmsg("Nothing changed", "red");
redirect(apidb_fullurl("admin/editAppVersion.php?appId=$appId&versionId=$versionId"));
} }
// display status message
if ($statusMessage)
{
echo html_frame_start("Edit Application","300");
echo "<p><b>$statusMessage</b></p>\n";
echo html_frame_end();
echo html_back_link(1,"editAppVersion.php?appId=$appId&versionId=$versionId");
} }
exit;
} } else
else if($HTTP_POST_VARS)
{ {
$t->update($HTTP_POST_VARS); $query = "SELECT versionName, keywords, ".
} "description, webPage from appVersion WHERE ".
else "appId = '$appId' and versionId = '$versionId'";
{
$table = "appVersion";
$query = "SELECT * FROM $table WHERE appId = $appId AND versionId = $versionId";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; } if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
$t->edit($query); $result = mysql_query($query);
list($versionName, $keywords, $description, $webPage) = mysql_fetch_row($result);
apidb_header("Edit Application Version");
//image upload box echo "<form method=post action='editAppVersion.php'>\n";
echo '<form enctype="multipart/form-data" action="editAppVersion.php" name=imageForm method="post">',"\n"; echo html_frame_start("Data for Application ID: $appId Version ID: $versionId", "90%","",0);
echo html_frame_start("Upload Screenshot","400","",0); echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
echo '<tr><td class=color1>Image</td><td class=color0><input name="imagefile" type="file"></td></tr>',"\n"; echo '<input type=hidden name="appId" value='.$appId.'>';
echo '<tr><td class=color1>Description</td><td class=color0><input type="text" name="screenshot_desc"></td></tr>',"\n"; echo '<input type=hidden name="appId" value='.$appId.'>';
echo '<input type=hidden name="versionId" value='.$versionId.'>';
echo '<tr><td class=color1>Name</td><td class=color0>'.lookupAppName($appId).'</td></tr>',"\n";
echo '<tr><td class=color4>Version</td><td class=color0><input size=80% type="text" name="versionName" type="text" value="'.$versionName.'"></td></tr>',"\n";
echo '<tr><td class=color1>Keywords</td><td class=color0><input size=80% type="text" name="keywords" value="'.$keywords.'"></td></tr>',"\n";
echo '<tr><td class=color4>Description</td><td class=color0>', "\n";
echo '<textarea cols=$80 rows=$30 name="description">'.stripslashes($description).'</textarea></td></tr>',"\n";
echo '<tr><td class=color1>Web Page</td><td class=color0><input size=80% type="text" name="webPage" value="'.$webPage.'"></td></tr>',"\n";
echo '<tr><td colspan=2 align=center class=color3><input type="submit" value="Send File"></td></tr>',"\n"; echo '<tr><td colspan=2 align=center class=color3><input type="submit" name=submit1 value="Update Database"></td></tr>',"\n";
echo '</table>',"\n"; echo html_table_end();
echo html_frame_end(); echo html_frame_end();
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000">',"\n";
echo '<input type="hidden" name="cmd" value="screenshot_upload">',"\n";
echo '<input type="hidden" name="appId" value="'.$appId.'">',"\n";
echo '<input type="hidden" name="versionId" value="'.$versionId.'"></form>',"\n";
echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId");
echo html_back_link(1);
apidb_footer();
} }
apidb_footer();
?> ?>

View File

@@ -346,59 +346,68 @@ if($appId && !$versionId)
} }
else if($appId && $versionId) else if($appId && $versionId)
{ {
$app = new Application($appId); $app = new Application($appId);
$data = $app->data; $data = $app->data;
if(!$data )
{
// Oops! application not found or other error. do something
errorpage('Internal Database Access Error. No App found.');
exit;
}
if(!$data) { $ver = $app->getAppVersion($versionId);
// Oops! application not found or other error. do something if(!$ver)
errorpage('Internal Database Access Error'); {
exit; // Oops! Version not found or other error. do something
} errorpage('Internal Database Access Error. No Version Found.');
exit;
}
// rating menu // rating menu
if(loggedin()) { if(loggedin())
apidb_sidebar_add("rating_menu"); {
} apidb_sidebar_add("rating_menu");
}
// admin menu // admin menu
if(loggedin() && (havepriv("admin") || $current->ownsApp($appId))) { if(loggedin() && havepriv("admin"))
apidb_sidebar_add("admin_menu"); {
} apidb_sidebar_add("admin_menu");
}
// header // header
$ver = $app->getAppVersion($versionId); apidb_header("Viewing App Version - ".$data->appName);
apidb_header("Viewing App Version - ".$data->appName);
//cat //cat
display_catpath($app->data->catId); display_catpath($app->data->catId);
//set URL //set URL
$appLinkURL = ($data->webPage) ? "<a href='$data->webPage'>".substr(stripslashes($data->webPage),0,30)."</a>": "&nbsp;"; $appLinkURL = ($ver->webPage) ? "<a href='$ver->webPage'>".substr(stripslashes($ver->webPage),0,30)."</a>": "&nbsp;";
//start version display //start version display
echo html_frame_start("","98%","",0); echo html_frame_start("","98%","",0);
echo '<tr><td class=color4 valign=top>',"\n"; echo '<tr><td class=color4 valign=top>',"\n";
echo '<table width="250" border=0 cellpadding=3 cellspacing=1">',"\n"; echo '<table width="250" border=0 cellpadding=3 cellspacing=1">',"\n";
echo "<tr class=color0 valign=top><td width=100> <b>Name</b></td><td width='100%'>".stripslashes($data->appName)."</td>\n"; echo "<tr class=color0 valign=top><td width=100> <b>Name</b></td><td width='100%'>".stripslashes($data->appName)."</td>\n";
echo "<tr class=color1 valign=top><td width=100> <b>Ver Id</b></td><td width='100%'> $ver->versionId</td>\n"; echo "<tr class=color1 valign=top><td width=100> <b>Ver Id</b></td><td width='100%'> $ver->versionId</td>\n";
echo "<tr class=color0 valign=top><td> <b>Version</b></td><td>".stripslashes($ver->versionName)."</td></tr>\n"; echo "<tr class=color0 valign=top><td> <b>Version</b></td><td>".stripslashes($ver->versionName)."</td></tr>\n";
echo "<tr class=color1 valign=top><td> <b>URL</b></td><td>".stripslashes($appLinkURL)."</td></tr>\n"; echo "<tr class=color1 valign=top><td> <b>URL</b></td><td>".stripslashes($appLinkURL)."</td></tr>\n";
//Rating Area //Rating Area
$r_win = rating_stars_for_version($versionId, "windows"); $r_win = rating_stars_for_version($versionId, "windows");
$r_fake = rating_stars_for_version($versionId, "fake"); $r_fake = rating_stars_for_version($versionId, "fake");
echo "<tr class=color0 valign=top><td> <b>Rating</b></td><td> $r_win \n"; echo "<tr class=color0 valign=top><td> <b>Rating</b></td><td> $r_win \n";
echo "<br> $r_fake </td></tr>\n"; echo "<br> $r_fake </td></tr>\n";
//notes //notes
display_notes($appId, $versionId); display_notes($appId, $versionId);
//Image //Image
$img = get_screenshot_img($appId, $versionId); $img = get_screenshot_img($appId, $versionId);
echo "<tr><td align=center colspan=2>$img</td></tr>\n"; echo "<tr><td align=center colspan=2>$img</td></tr>\n";
// Display all maintainers of this application // Display all maintainers of this application
echo "<tr class=color0><td align=left colspan=2><b>Maintainers of this application:</b>\n"; echo "<tr class=color0><td align=left colspan=2><b>Maintainers of this application:</b>\n";
@@ -438,27 +447,35 @@ else if($appId && $versionId)
{ {
echo '<input type=submit value="Log in to become an app maintainer" class=button>'; echo '<input type=submit value="Log in to become an app maintainer" class=button>';
} }
echo "</center></td></tr>"; echo "</center></td></tr>";
echo "</table><td class=color2 valign=top width='100%'>\n"; if (loggedin() && (havepriv("admin") || isMaintainer($appId, $versionId)))
{
echo "<tr><td colspan = 2><center>";
echo "<a href=admin/editAppVersion.php?appId=".$appId."&versionId=".$versionId.">Edit version</a>";
echo "</center></td></tr>";
}
echo "</table><td class=color2 valign=top width='100%'>\n";
//Desc Image //Desc Image
echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br>\n"; echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br>\n";
echo add_br(stripslashes($ver->description)); echo add_br(stripslashes($ver->description));
echo "</td></tr>"; echo "</td></tr>";
/* close the table */ /* close the table */
echo "</table>\n"; echo "</table>\n";
echo html_frame_end(); echo html_frame_end();
//TODO: code to view/add user experience records //TODO: code to view/add user experience record
if(!$versionId) { // if(!$versionId)
$versionId = 0; // {
} // $versionId = 0;
// }
// Comments Section // Comments Section
view_app_comments($appId, $versionId); view_app_comments($appId, $versionId);
} }
else else