Allow Maintainers to edit Application version. Send out email indicating what they changed.
This commit is contained in:
committed by
Jeremy Newman
parent
91a821fdde
commit
b1b785fd04
@@ -5,107 +5,147 @@ include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
require(BASE."include/"."application.php");
|
||||
|
||||
|
||||
//check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
|
||||
if(!loggedin() || (!havepriv("admin") && !isMaintainer($appId, $versionId)) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Edit Application Version");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
|
||||
if($cmd)
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$statusMessage = '';
|
||||
|
||||
//process screenshot upload
|
||||
if($cmd == "screenshot_upload")
|
||||
{
|
||||
if(debugging())
|
||||
{
|
||||
echo "<p align=center>Screenshot: ($appId) file=$imagefile size=$imagefile_size\n";
|
||||
echo " name=$imagefile_name type=$imagefile_type<br>";
|
||||
}
|
||||
|
||||
if(!copy($imagefile, "../data/screenshots/".basename($imagefile_name)))
|
||||
{
|
||||
// whoops, copy failed. do something
|
||||
echo html_frame_start("Edit Application","300");
|
||||
echo "<p><b>debug: copy failed; $imagefile; $imagefile_name</b></p>\n";
|
||||
echo html_frame_end();
|
||||
echo html_back_link(1,"editAppVersion.php?appId=$appId&versionID=$versionId");
|
||||
apidb_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = "INSERT INTO appData VALUES (null, $appId, $versionId, 'image', ".
|
||||
"'".addslashes($screenshot_desc)."', '".basename($imagefile_name)."')";
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
if (mysql_query($query))
|
||||
{
|
||||
if($submit1 == "Update Database")
|
||||
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$WhatChanged .= "Version name: Old Value: ".stripslashes($old_versionName)."\n";
|
||||
$WhatChanged .= " New Value: ".stripslashes($versionName)."\n";
|
||||
$VersionChanged = true;
|
||||
}
|
||||
if ($old_keywords <> $keywords)
|
||||
{
|
||||
$WhatChanged .= " Key Words: Old Value: ".stripslashes($old_keywords)."\n";
|
||||
$WhatChanged .= " New Value: ".stripslashes($keywords)."\n";
|
||||
$VersionChanged = true;
|
||||
}
|
||||
if ($old_webPage <> $webPage)
|
||||
{
|
||||
$WhatChanged .= " Web Page: Old Value: ".stripslashes($old_webPage)."\n";
|
||||
$WhatChanged .= " New Value: ".stripslashes($webPage)."\n";
|
||||
$VersionChanged = true;
|
||||
}
|
||||
if ($old_description <> $description)
|
||||
{
|
||||
$WhatChanged .= " Description: Old Value:\n";
|
||||
$WhatChanged .= "-----------------------:\n";
|
||||
$WhatChanged .= stripslashes($old_description)."\n";
|
||||
$WhatChanged .= "-----------------------:\n";
|
||||
$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
|
||||
$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
|
||||
{
|
||||
//error
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."<br></b></p>\n";
|
||||
if(debugging()) { $statusMessage .= "<p>$query</p>"; }
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
else if($HTTP_POST_VARS)
|
||||
exit;
|
||||
} else
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appVersion";
|
||||
$query = "SELECT * FROM $table WHERE appId = $appId AND versionId = $versionId";
|
||||
|
||||
$query = "SELECT versionName, keywords, ".
|
||||
"description, webPage from appVersion WHERE ".
|
||||
"appId = '$appId' and versionId = '$versionId'";
|
||||
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 enctype="multipart/form-data" action="editAppVersion.php" name=imageForm method="post">',"\n";
|
||||
echo html_frame_start("Upload Screenshot","400","",0);
|
||||
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 '<tr><td class=color1>Description</td><td class=color0><input type="text" name="screenshot_desc"></td></tr>',"\n";
|
||||
|
||||
echo '<tr><td colspan=2 align=center class=color3><input type="submit" value="Send File"></td></tr>',"\n";
|
||||
|
||||
echo '</table>',"\n";
|
||||
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 "<form method=post action='editAppVersion.php'>\n";
|
||||
echo html_frame_start("Data for Application ID: $appId Version ID: $versionId", "90%","",0);
|
||||
echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
|
||||
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId");
|
||||
echo '<input type=hidden name="appId" value='.$appId.'>';
|
||||
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" name=submit1 value="Update Database"></td></tr>',"\n";
|
||||
|
||||
echo html_table_end();
|
||||
echo html_frame_end();
|
||||
|
||||
echo html_back_link(1);
|
||||
apidb_footer();
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
|
||||
121
appview.php
121
appview.php
@@ -346,59 +346,68 @@ if($appId && !$versionId)
|
||||
}
|
||||
else if($appId && $versionId)
|
||||
{
|
||||
$app = new Application($appId);
|
||||
$data = $app->data;
|
||||
|
||||
if(!$data) {
|
||||
// Oops! application not found or other error. do something
|
||||
errorpage('Internal Database Access Error');
|
||||
exit;
|
||||
}
|
||||
$app = new Application($appId);
|
||||
$data = $app->data;
|
||||
if(!$data )
|
||||
{
|
||||
// Oops! application not found or other error. do something
|
||||
errorpage('Internal Database Access Error. No App found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// rating menu
|
||||
if(loggedin()) {
|
||||
apidb_sidebar_add("rating_menu");
|
||||
}
|
||||
$ver = $app->getAppVersion($versionId);
|
||||
if(!$ver)
|
||||
{
|
||||
// Oops! Version not found or other error. do something
|
||||
errorpage('Internal Database Access Error. No Version Found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// admin menu
|
||||
if(loggedin() && (havepriv("admin") || $current->ownsApp($appId))) {
|
||||
apidb_sidebar_add("admin_menu");
|
||||
}
|
||||
// rating menu
|
||||
if(loggedin())
|
||||
{
|
||||
apidb_sidebar_add("rating_menu");
|
||||
}
|
||||
|
||||
// admin menu
|
||||
if(loggedin() && havepriv("admin"))
|
||||
{
|
||||
apidb_sidebar_add("admin_menu");
|
||||
}
|
||||
|
||||
// header
|
||||
apidb_header("Viewing App Version - ".$data->appName);
|
||||
|
||||
//cat
|
||||
display_catpath($app->data->catId);
|
||||
|
||||
// header
|
||||
$ver = $app->getAppVersion($versionId);
|
||||
apidb_header("Viewing App Version - ".$data->appName);
|
||||
|
||||
//cat
|
||||
display_catpath($app->data->catId);
|
||||
|
||||
//set URL
|
||||
$appLinkURL = ($data->webPage) ? "<a href='$data->webPage'>".substr(stripslashes($data->webPage),0,30)."</a>": " ";
|
||||
//set URL
|
||||
$appLinkURL = ($ver->webPage) ? "<a href='$ver->webPage'>".substr(stripslashes($ver->webPage),0,30)."</a>": " ";
|
||||
|
||||
//start version display
|
||||
echo html_frame_start("","98%","",0);
|
||||
echo html_frame_start("","98%","",0);
|
||||
|
||||
echo '<tr><td class=color4 valign=top>',"\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=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=color1 valign=top><td> <b>URL</b></td><td>".stripslashes($appLinkURL)."</td></tr>\n";
|
||||
echo '<tr><td class=color4 valign=top>',"\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=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=color1 valign=top><td> <b>URL</b></td><td>".stripslashes($appLinkURL)."</td></tr>\n";
|
||||
|
||||
//Rating Area
|
||||
$r_win = rating_stars_for_version($versionId, "windows");
|
||||
$r_fake = rating_stars_for_version($versionId, "fake");
|
||||
//Rating Area
|
||||
$r_win = rating_stars_for_version($versionId, "windows");
|
||||
$r_fake = rating_stars_for_version($versionId, "fake");
|
||||
|
||||
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
|
||||
display_notes($appId, $versionId);
|
||||
//notes
|
||||
display_notes($appId, $versionId);
|
||||
|
||||
//Image
|
||||
//Image
|
||||
$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
|
||||
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 "</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
|
||||
echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br>\n";
|
||||
echo add_br(stripslashes($ver->description));
|
||||
echo "</td></tr>";
|
||||
//Desc Image
|
||||
echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br>\n";
|
||||
echo add_br(stripslashes($ver->description));
|
||||
echo "</td></tr>";
|
||||
|
||||
/* close the table */
|
||||
echo "</table>\n";
|
||||
|
||||
echo html_frame_end();
|
||||
echo html_frame_end();
|
||||
|
||||
//TODO: code to view/add user experience records
|
||||
if(!$versionId) {
|
||||
$versionId = 0;
|
||||
}
|
||||
//TODO: code to view/add user experience record
|
||||
// if(!$versionId)
|
||||
// {
|
||||
// $versionId = 0;
|
||||
// }
|
||||
|
||||
// Comments Section
|
||||
view_app_comments($appId, $versionId);
|
||||
// Comments Section
|
||||
view_app_comments($appId, $versionId);
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user