Factor application/version editing code out of files and move it into the application and version classes. Add support to HtmlAreaLoaderScript() to be called multiple times on a single page without generating javascript that overwrites the previous html area settings.

This commit is contained in:
Chris Morgan
2005-10-10 02:37:55 +00:00
committed by WineHQ
parent f6f935a36e
commit 49300a8707
8 changed files with 457 additions and 454 deletions

View File

@@ -136,11 +136,9 @@ if ($_REQUEST['sub'])
if (!$oApp) //app version
{
HtmlAreaLoaderScript(array("editor"));
echo html_frame_start("Potential duplicate versions in the database","90%","",0);
$oApp = new Application($oVersion->iAppId);
display_versions($oApp->iAppId, $oApp->aVersionsIds);
$oAppForVersion = new Application($oVersion->iAppId);
display_versions($oAppForVersion->iAppId, $oAppForVersion->aVersionsIds);
echo html_frame_end(" ");
//help
@@ -152,37 +150,9 @@ if ($_REQUEST['sub'])
echo "<p>Click delete to remove the selected item from the queue an email will automatically be sent to the\n";
echo "submitter to let him know the item was deleted.</p>\n\n";
echo "</td></tr></table></div>\n\n";
echo html_frame_start("New Version Form",400,"",0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
//app parent
echo '<tr valign=top><td class=color0><b>Application</b></td><td>',"\n";
$x->make_option_list("appId",$oVersion->iAppId,"appFamily","appId","appName");
echo '</td></tr>',"\n";
//version
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
echo '<td><input type=text name="versionName" value="'.$oVersion->sName.'" size="20"></td></tr>',"\n";
echo '<tr valign=top><td class=color0><b>Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor" name="versionDescription">'.stripslashes($oVersion->sDescription).'</textarea></p></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
echo '<td><textarea name="replyText" rows="10" cols="35"></textarea></td></tr>',"\n";
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
echo '<input type="hidden" name="versionId" value="'.$oVersion->iVersionId.'" />';
echo '<input type="submit" value=" Submit Version Into Database " class="button">&nbsp',"\n";
echo '<input name="sub" type=submit value="Delete" class="button">',"\n";
echo '<input name="sub" type=submit value="Reject" class="button"></td></tr>',"\n";
echo '</table></form>',"\n";
} else // application
{
HtmlAreaLoaderScript(array("editor", "editor2"));
echo html_frame_start("Potential duplicate applications in the database","90%","",0);
echo html_frame_start("Potential duplicate applications in the database", "90%", "", 0);
perform_search_and_output_results($oApp->sName);
echo html_frame_end("&nbsp;");
@@ -206,19 +176,6 @@ if ($_REQUEST['sub'])
echo "submitter to let them know the item was deleted.</p>\n\n";
echo "</td></tr></table></div>\n\n";
//view application details
echo html_frame_start("New Application Form",400,"",0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
//category
echo '<tr valign=top><td class="color0>"<b>Category</b></td><td>',"\n";
$x->make_option_list("catId",$oApp->iCatId,"appCategory","catId","catName");
echo '</td></tr>',"\n";
//name
echo '<tr valign=top><td class="color0"><b>App Name</b></td>',"\n";
echo '<td><input type="text" name="appName" value="'.$oApp->sName.'" size=20></td></tr>',"\n";
/*
* vendor/alt vendor fields
* if user selected a predefined vendorId:
@@ -260,44 +217,41 @@ if ($_REQUEST['sub'])
//vendor field
if($iVendorId)
$sVendor = "";
echo '<tr valign=top><td class="color0"><b>App Vendor</b></td>',"\n";
echo '<td><input type=text name="sVendor" value="'.$sVendor.'" size="20"></td>',"\n";
echo '</tr>',"\n";
echo '<tr valign=top><td class="color0">&nbsp;</td><td>',"\n";
$x->make_option_list("vendorId", $iVendorId ,"vendor","vendorId","vendorName");
echo '</td></tr>',"\n";
//url
echo '<tr valign=top><td class="color0"><b>App URL</b></td>',"\n";
echo '<td><input type=text name="webpage" value="'.$oApp->sWebpage.'" size="20"></td></tr>',"\n";
// application desc
echo '<tr valign=top><td class=color0><b>Application Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea id="editor" cols="80" rows="20" name="applicationDescription">'.stripslashes($oApp->sDescription).'</textarea></p></td></tr>',"\n";
// version name
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
echo '<td><input type=text name="versionName" value="'.$oVersion->sName.'" size="20"></td></tr>',"\n";
// version description
echo '<tr valign=top><td class=color0><b>Version Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor2" name="versionDescription">'.stripslashes($oVersion->sDescription).'</textarea></p></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
echo '<td><textarea name="replyText" rows=10 cols=35></textarea></td></tr>',"\n";
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
echo '<input type="hidden" name="appId" value="'.$oApp->iAppId.'" />';
echo '<input type=submit value=" Submit App Into Database " class=button>&nbsp',"\n";
echo '<input name="sub" type="submit" value="Delete" class="button" />',"\n";
echo '<input name="sub" type="submit" value="Reject" class="button" />',"\n";
echo '</td></tr>',"\n";
echo '</table></form>',"\n";
}
echo html_frame_end("&nbsp;");
/* output the appropriate editors depending on whether we are processing an application */
/* and a version or just a version */
if($oApp)
{
$oApp->OutputEditor($sVendor);
$oVersion->OutputEditor(false);
} else
{
$oVersion->OutputEditor(true);
}
echo html_frame_start("Reply text", "90%", "", 0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
echo '<td><textarea name="replyText" style="width: 100%" cols="80" rows="10"></textarea></td></tr>',"\n";
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
if ($oApp) //application
{
echo '<input type="hidden" name="appId" value="'.$oApp->iAppId.'" />';
echo '<input type=submit value=" Submit App Into Database " class=button>&nbsp',"\n";
} else // app version
{
echo '<input type="hidden" name="versionId" value="'.$oVersion->iVersionId.'" />';
echo '<input type="submit" value=" Submit Version Into Database " class="button">&nbsp',"\n";
}
echo '<input name="sub" type="submit" value="Delete" class="button" />',"\n";
echo '<input name="sub" type="submit" value="Reject" class="button" />',"\n";
echo '</td></tr>',"\n";
echo '</table>',"\n";
echo '</form>',"\n";
echo html_frame_end();
echo html_back_link(1,'adminAppQueue.php');
}
else if ($_REQUEST['sub'] == 'add')
@@ -305,10 +259,10 @@ if ($_REQUEST['sub'])
if (is_numeric($_REQUEST['appId']) && !is_numeric($_REQUEST['versionId'])) // application
{
// add new vendor
if($sVendor)
if($_REQUEST['appVendorName'])
{
$oVendor = new Vendor();
$oVendor->create($sVendor);
$oVendor->create($_REQUEST['appVendorName'],$_REQUEST['appWebpage']);
}
$oApp = new Application($_REQUEST['appId']);

View File

@@ -30,56 +30,41 @@ if(isset($_REQUEST['submit']))
else
// Show the form for editing the Application Family
{
HtmlAreaLoaderScript(array("editor"));
$family = new TableVE("edit");
$result = query_appdb("SELECT * from appFamily WHERE appId = '{$_REQUEST['appId']}'");
$oApp = new Application($_REQUEST['appId']);
if(!mysql_num_rows($result))
if(!$oApp)
{
errorpage('Application does not exist');
}
$ob = mysql_fetch_object($result);
if($_SESSION['current']->showDebuggingInfos()) { echo "<p align=center><b>appName:</b> $ob->appName </p>"; }
if($_SESSION['current']->showDebuggingInfos()) { echo "<p align=center><b>appName:</b> $oApp->sName </p>"; }
apidb_header("Edit Application Family");
echo "<form method=\"post\" action=\"editAppFamily.php\">\n";
echo html_frame_start("Data for Application ID $ob->appId", "90%","",0);
echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
echo '<input type="hidden" name="appId" value="'.$ob->appId.'">';
echo '<tr><td class=color1>Name</td><td class=color0><input size=80% type="text" name="appName" type="text" value="'.$ob->appName.'"></td></tr>',"\n";
echo '<tr><td class=color4>Vendor</td><td class=color0>';
$family->make_option_list("vendorId", $ob->vendorId, "vendor", "vendorId", "vendorName");
echo '</td></tr>',"\n";
echo '<tr><td class=color1>Keywords</td><td class=color0><input size=80% type="text" name="keywords" value="'.$ob->keywords.'"></td></tr>',"\n";
echo '<tr><td class="color4">Description</td><td class="color0">', "\n";
if(trim(strip_tags($ob->description))=="") $ob->description="<p>Enter description here</p>";
echo '<p style="width:700px">', "\n";
echo '<textarea rows="20" cols="80" id="editor" name="description">'.$ob->description.'</textarea></td></tr>',"\n";
echo '</p>';
echo '<tr><td class=color1>Web Page</td><td class=color0><input size=80% type="text" name="webPage" value="'.$ob->webPage.'"></td></tr>',"\n";
echo '<tr><td class=color4>Category</td><td class=color0>';
$family->make_option_list("catId", $ob->catId, "appCategory", "catId", "catName");
echo '</td></tr>',"\n";
echo '<tr><td colspan=2 align=center class=color3><input type="submit" name=submit value="Update Database"></td></tr>',"\n";
echo '<input type="hidden" name="appId" value="'.$oApp->iAppId.'">';
echo html_table_end();
echo html_frame_end();
$oApp->OutputEditor("");
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">', "\n";
echo '<tr><td colspan=2 align=center><input type="submit" name=submit value="Update Database"></td></tr>',"\n";
echo '</table>', "\n";
echo "</form>";
// url edit form
echo "<p>";
// url edit form
echo '<form enctype="multipart/form-data" action="editAppFamily.php" method="post">',"\n";
echo '<input type=hidden name="appId" value='.$ob->appId.'>';
echo '<input type=hidden name="appId" value='.$oApp->iAppId.'>';
echo html_frame_start("Edit URL","90%","",0);
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
$i = 0;
$result = query_appdb("SELECT * FROM appData WHERE appId = $ob->appId AND type = 'url' AND versionId = 0");
$result = query_appdb("SELECT * FROM appData WHERE appId = $oApp->iAppId AND type = 'url' AND versionId = 0");
if($result && mysql_num_rows($result) > 0)
{
echo '<tr><td class=color1><b>Delete</b></td><td class=color1>',"\n";
@@ -110,14 +95,14 @@ else
echo '<tr><td class=color1>New</td><td class=color1><input size=45% type="text" name="url_desc"></td>',"\n";
echo '<td class=color1><input size=45% name="url" type="text"></td></tr>',"\n";
echo '<tr><td colspan=3 align=center class=color3><input type="submit" name=submit value="Update URL"></td></tr>',"\n";
echo '</table>',"\n";
echo html_frame_end();
echo "</form>";
echo html_back_link(1,BASE."appview.php?appId=$ob->appId");
echo html_back_link(1,BASE."appview.php?appId=$ob->appId");
}
apidb_footer();

View File

@@ -26,49 +26,23 @@ if(isset($_REQUEST['submit']))
} else /* or display the webform for making changes */
{
HtmlAreaLoaderScript(array("editor")); /* load the appropriate htmlarea controls */
$oVersion = new Version($_REQUEST['versionId']);
/* if the sDescription is empty, put the default in */
if(trim(strip_tags($oVersion->sDescription))=="")
$oVersion->sDescription = GetDefaultVersionDescription();
apidb_header("Edit Application Version");
echo "<form method=post action='editAppVersion.php'>\n";
echo html_frame_start("Data for Application ID: ".$oVersion->iAppId." Version ID: ".$oVersion->iVersionId, "90%","",0);
echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
$oVersion->OutputEditor(false); /* false = not allowing the user to modify the parent application */
echo '<input type="hidden" name="appId" value='.$oVersion->iAppId.' />';
echo '<input type="hidden" name="versionId" value='.$oVersion->iVersionId.' />';
echo '<tr><td class=color1>Name</td><td class=color0>'.lookup_app_name($oVersion->iAppId).'</td></tr>',"\n";
echo '<tr><td class=color4>Version</td><td class=color0><input size=80% type="text" name="versionName" type="text" value="'.$oVersion->sName.'" /></td></tr>',"\n";
echo '<tr><td class="color4">Version specific description</td><td class="color0">', "\n";
// FIXME: put templates in config file or somewhere else.
if(trim(strip_tags($oVersion->sDescription))=="")
{
$oVersion->sDescription = "<p>This is a template; enter version-specific description here</p>";
$oVersion->sDescription .= "<p>
<span class=\"title\">Wine compatibility</span><br />
<span class=\"subtitle\">What works:</span><br />
- settings<br />
- help<br />
<br /><span class=\"subtitle\">What doesn't work:</span><br />
- erasing<br />
<br /><span class=\"subtitle\">What was not tested:</span><br />
- burning<br />
</p>";
$oVersion->sDescription .= "<p><span class=\"title\">Tested versions</span><br /><table class=\"historyTable\" width=\"90%\" border=\"1\">
<thead class=\"historyHeader\"><tr>
<td>App. version</td><td>Wine version</td><td>Installs?</td><td>Runs?</td><td>Rating</td>
</tr></thead>
<tbody><tr>
<td class=\"gold\">3.23</td><td class=\"gold\">20050111</td><td class=\"gold\">yes</td><td class=\"gold\">yes</td><td class=\"gold\">Gold</td>
</tr><tr>
<td class=\"silver\">3.23</td><td class=\"silver\">20041201</td><td class=\"silver\">yes</td><td class=\"silver\">yes</td><td class=\"silver\">Silver</td>
</tr><tr>
<td class=\"bronze\">3.21</td><td class=\"bronze\">20040615</td><td class=\"bronze\">yes</td><td class=\"bronze\">yes</td><td class=\"bronze\">Bronze</td>
</tr></tbody></table></p><p> <br /> </p>";
}
echo '<p style="width:700px">', "\n";
echo '<textarea cols="80" rows="30" id="editor" name="description">'.$oVersion->sDescription.'</textarea></td></tr>',"\n";
echo '</p>';
echo html_frame_start("Info", "90%", "", 0);
echo "<table border=0 cellpadding=2 cellspacing=0>\n";
echo '<tr><td class="color4">Rating</td><td class="color0">',"\n";
make_maintainer_rating_list("maintainer_rating", $oVersion->sTestedRating);
echo '</td></tr>',"\n";

View File

@@ -74,8 +74,6 @@ if ($_REQUEST['sub'])
if (!$oApp) //app version
{
HtmlAreaLoaderScript(array("editor"));
echo html_frame_start("Potential duplicate versions in the database","90%","",0);
$oApp = new Application($oVersion->iAppId);
display_versions($oApp->iAppId, $oApp->aVersionsIds);
@@ -89,35 +87,8 @@ if ($_REQUEST['sub'])
echo "<p>Click delete to remove the selected item from the queue an email will automatically be sent to the\n";
echo "submitter to let him know the item was deleted.</p>\n\n";
echo "</td></tr></table></div>\n\n";
echo html_frame_start("Rejected Version Form",400,"",0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
//app parent
echo '<tr valign=top><td class=color0><b>Application</b></td><td>',"\n";
$x->make_option_list("appId",$oVersion->iAppId,"appFamily","appId","appName");
echo '</td></tr>',"\n";
//version
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
echo '<td><input type=text name="versionName" value="'.$oVersion->sName.'" size="20"></td></tr>',"\n";
echo '<tr valign=top><td class=color0><b>Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor" name="versionDescription">'.stripslashes($oVersion->sDescription).'</textarea></p></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
echo '<td><textarea name="replyText" rows="10" cols="35"></textarea></td></tr>',"\n";
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
echo '<input type="hidden" name="versionId" value="'.$oVersion->iVersionId.'" />';
echo '<input type="submit" value="Re-Submit Version Into Database " class="button">&nbsp',"\n";
echo '<input name="sub" type=submit value="Delete" class="button"></td></tr>',"\n";
echo '</table></form>',"\n";
} else // application
{
HtmlAreaLoaderScript(array("editor"));
echo html_frame_start("Potential duplicate applications in the database","90%","",0);
perform_search_and_output_results($oApp->sName);
echo html_frame_end("&nbsp;");
@@ -131,20 +102,6 @@ if ($_REQUEST['sub'])
echo "submitter to let them know the item was deleted.</p>\n\n";
echo "</td></tr></table></div>\n\n";
//view application details
echo html_frame_start("New Application Form",400,"",0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
//category
echo '<tr valign=top><td class="color0>"<b>Category</b></td><td>',"\n";
$x->make_option_list("catId",$oApp->iCatId,"appCategory","catId","catName");
echo '</td></tr>',"\n";
//name
echo '<tr valign=top><td class="color0"><b>App Name</b></td>',"\n";
echo '<td><input type="text" name="appName" value="'.$oApp->sName.'" size=20></td></tr>',"\n";
// vendor/alt vendor fields
// if user selected a predefined vendorId:
$iVendorId = $oApp->iVendorId;
@@ -153,7 +110,6 @@ if ($_REQUEST['sub'])
// Use the first match if we found one and clear out the vendor field,
// otherwise don't pick a vendor
// N.B. The vendor string is the last word of the keywords field !
if(!$iVendorId)
{
$sVendor = get_vendor_from_keywords($oApp->sKeywords);
@@ -164,7 +120,6 @@ if ($_REQUEST['sub'])
$oRow = mysql_fetch_object($hResult);
$iVendorId = $oRow->vendorId;
}
}
// try for a partial match
@@ -182,44 +137,39 @@ if ($_REQUEST['sub'])
//vendor field
if($iVendorId)
$sVendor = "";
echo '<tr valign=top><td class="color0"><b>App Vendor</b></td>',"\n";
echo '<td><input type=text name="sVendor" value="'.$sVendor.'" size="20"></td>',"\n";
echo '</tr>',"\n";
echo '<tr valign=top><td class="color0">&nbsp;</td><td>',"\n";
$x->make_option_list("vendorId", $iVendorId ,"vendor","vendorId","vendorName");
echo '</td></tr>',"\n";
}
//url
echo '<tr valign=top><td class="color0"><b>App URL</b></td>',"\n";
echo '<td><input type=text name="webpage" value="'.$oApp->sWebpage.'" size="20"></td></tr>',"\n";
// application desc
echo '<tr valign=top><td class=color0><b>Application Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor" name="applicationDescription">'.stripslashes($oApp->sDescription).'</textarea></p></td></tr>',"\n";
if($oApp)
{
$oApp->OutputEditor($sVendor);
$oVersion->OutputEditor(false);
} else
{
$oVersion->OutputEditor(true);
}
// version name
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
echo '<td><input type=text name="versionName" value="'.$oVersion->sName.'" size="20"></td></tr>',"\n";
// version description
echo '<tr valign=top><td class=color0><b>Version Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor2" name="versionDescription">'.$oVersion->sDescription.'</textarea></p></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
echo '<td><textarea name="replyText" rows=10 cols=35></textarea></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
echo '<td><textarea name="replyText" style="width: 100%" rows="10" cols="35"></textarea></td></tr>',"\n";
if($oApp) // application
{
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
echo '<input type="hidden" name="appId" value="'.$oApp->iAppId.'" />';
echo '<input type=submit value=" Re-Submit App Into Database " class=button>&nbsp',"\n";
echo '<input name="sub" type="submit" value="Delete" class="button" />',"\n";
echo '</td></tr>',"\n";
echo '</table></form>',"\n";
} else // version
{
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
echo '<input type="hidden" name="versionId" value="'.$oVersion->iVersionId.'" />';
echo '<input type="submit" value="Re-Submit Version Into Database " class="button">&nbsp',"\n";
echo '<input name="sub" type=submit value="Delete" class="button"></td></tr>',"\n";
echo '</table></form>',"\n";
}
echo html_frame_end("&nbsp;");
echo html_back_link(1,$_SERVER['PHP_SELF']);
echo html_back_link(1, $_SERVER['PHP_SELF']);
}
else if ($_REQUEST['sub'] == 'ReQueue')
{

View File

@@ -8,34 +8,6 @@ require(BASE."include/tableve.php");
require(BASE."include/mail.php");
require(BASE."include/application.php");
/*
* Templates
* FIXME: put templates in config file or somewhere else.
*/
$sAppDescription = "<p>Enter a description of the application here</p>";
$sVersionDescription = "<p>This is a template; enter version-specific description here</p>
<p>
<span class=\"title\">Wine compatibility</span><br />
<span class=\"subtitle\">What works:</span><br />
- settings<br />
- help<br />
<br /><span class=\"subtitle\">What doesn't work:</span><br />
- erasing<br />
<br /><span class=\"subtitle\">What was not tested:</span><br />
- burning<br />
</p>
<p><span class=\"title\">Tested versions</span><br /><table class=\"historyTable\" width=\"90%\" border=\"1\">
<thead class=\"historyHeader\"><tr>
<td>App. version</td><td>Wine version</td><td>Installs?</td><td>Runs?</td><td>Rating</td>
</tr></thead>
<tbody><tr>
<td class=\"gold\">3.23</td><td class=\"gold\">20050111</td><td class=\"gold\">yes</td><td class=\"gold\">yes</td><td class=\"gold\">Gold</td>
</tr><tr>
<td class=\"silver\">3.23</td><td class=\"silver\">20041201</td><td class=\"silver\">yes</td><td class=\"silver\">yes</td><td class=\"silver\">Silver</td>
</tr><tr>
<td class=\"bronze\">3.21</td><td class=\"bronze\">20040615</td><td class=\"bronze\">yes</td><td class=\"bronze\">yes</td><td class=\"bronze\">Bronze</td>
</tr></tbody></table></p><p><br /></p>";
if(!$_SESSION['current']->isLoggedIn())
{
// you must be logged in to submit app
@@ -44,50 +16,43 @@ if(!$_SESSION['current']->isLoggedIn())
exit;
}
// Check the input of a submitted form. And output with a list
// of errors. (<ul></ul>)
function checkInput($fields)
{
$errors = "";
if (strlen($fields['appName']) > 200 )
$errors .= "<li>Your application name is too long.</li>\n";
if (empty($fields['appName']) && !$fields['appId'])
$errors .= "<li>Please enter an application name.</li>\n";
if (empty($fields['versionName']))
$errors .= "<li>Please enter an application version.</li>\n";
// No vendor entered, and nothing in the list is selected
if (empty($fields['vendorName']) && !$fields['vendorId'] && !$fields['appId'])
$errors .= "<li>Please enter a vendor.</li>\n";
if (empty($fields['appDescription']) && !$fields['appId'])
$errors .= "<li>Please enter a description of your application.</li>\n";
if (empty($errors))
return "";
else
return $errors;
}
/*
* User submitted an application
*/
if (isset($_REQUEST['appName']))
{
// Check input and exit if we found errors
$errors = "";
// Check input and exit if we found errors
$oApplication = new Application();
$errors .= $oApplication->CheckOutputEditorInput();
$oVersion = new Version();
$errors .= $oVersion->CheckOutputEditorInput();
$errors = checkInput($_REQUEST);
if(empty($errors))
{
if($vendorName) $_REQUEST['vendorId']="";
if($_REQUEST['appVendorName'])
{
$_REQUEST['vendorId']="";
//FIXME: fix this when we fix vendor submission
if($_SESSION['current']->hasPriv("admin"))
{
$oVendor = new Vendor();
$oVendor->create($_REQUEST['appVendorName'],$_REQUEST['appWebpage']);
}
}
$oApplication->GetOutputEditorValues(); /* load the values from $_REQUEST */
//FIXME: remove this when we fix vendor submission
$oApplication->sKeywords = $_REQUEST['appKeywords']." *** ".$_REQUEST['appVendorName'];
$oApplication->create();
$oVersion->GetOutputEditorValues();
$oVersion->iAppId = $oApplication->iAppId; /* get the iAppId from the application that was just created */
$oVersion->create();
$oApplication = new Application();
$oApplication->create($_REQUEST['appName'], $_REQUEST['appDescription'], $_REQUEST['keywords']." *** ".$_REQUEST['vendorName'], $_REQUEST['webpage'], $_REQUEST['vendorId'], $_REQUEST['catId']);
$oVersion = new Version();
$oVersion->create($_REQUEST['versionName'], $_REQUEST['versionDescription'], null, null, $oApplication->iAppId);
redirect(apidb_fullurl("index.php"));
}
@@ -99,12 +64,14 @@ if (isset($_REQUEST['appName']))
elseif (isset($_REQUEST['versionName']) && is_numeric($_REQUEST['appId']))
{
// Check input and exit if we found errors
$errors = checkInput($_REQUEST);
$oVersion = new Version();
$errors = $oVersion->CheckOutputEditorInput();
if(empty($errors))
{
$oVersion = new Version();
$oVersion->create($_REQUEST['versionName'], $_REQUEST['versionDescription'], null, null, $_REQUEST['appId']);
$oVersion->GetOutputEditorValues();
$oVersion->create();
redirect(apidb_fullurl("index.php"));
}
}
@@ -155,78 +122,31 @@ if (isset($_REQUEST['apptype']))
echo '<p></p>',"\n";
}
// new application and version
if ($_REQUEST['apptype'] == 1)
if($_REQUEST['apptype'] == 1 && (trim(strip_tags($_REQUEST['appDescription']))==""))
{
HtmlAreaLoaderScript(array("editor", "editor2"));
echo html_frame_start("New Application Form",400,"",0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
echo '<tr valign=top><td class="color0"><b>Application name</b></td>',"\n";
echo '<td><input type="text" name="appName" value="'.$_REQUEST['appName'].'" size="20"></td></tr>',"\n";
// app Category
$w = new TableVE("view");
echo '<tr valign=top><td class="color0"><b>Category</b></td><td>',"\n";
$w->make_option_list("catId",$_REQUEST['catId'],"appCategory","catId","catName");
echo '</td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>Vendor</b></td>',"\n";
echo '<td><input type=text name="vendorName" value="'.$_REQUEST['vendorName'].'" size="20"></td></tr>',"\n";
// alt vendor
$x = new TableVE("view");
echo '<tr valign=top><td class="color0">&nbsp;</td><td>',"\n";
$x->make_option_list("vendorId",$_REQUEST['vendorId'],"vendor","vendorId","vendorName");
echo '</td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>URL</b></td>',"\n";
echo '<td><input type=text name="webpage" value="'.$_REQUEST['webpage'].'" size=20></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>Keywords</b></td>',"\n";
echo '<td><input size="80%" type="text" name="keywords" value="'.$_REQUEST['keywords'].'"></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>Application Description</b></td>',"\n";
if(trim(strip_tags($_REQUEST['appDescription']))=="")
{
$_REQUEST['appDescription'] = $sAppDescription;
}
echo '<td><p><textarea cols="80" rows="20" id="editor" name="appDescription">';
echo $_REQUEST['appDescription'].'</textarea></p></td></tr>',"\n";
}
// new version
else
{
HtmlAreaLoaderScript(array("editor2"));
echo html_frame_start("New Version Form",400,"",0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
// app parent
$x = new TableVE("view");
echo '<tr valign=top><td class=color0><b>Application</b></td><td>',"\n";
$x->make_option_list("appId",$_REQUEST['appId'],"appFamily","appId","appName");
echo '</td></tr>',"\n";
$_REQUEST['appDescription'] = GetDefaultApplicationDescription();
}
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
echo '<td><input type="text" name="versionName" value="'.$_REQUEST['versionName'].'" size="20"></td></tr>',"\n";
if(trim(strip_tags($_REQUEST['versionDescription']))=="")
{
$_REQUEST['versionDescription'] = $sVersionDescription;
}
echo '<tr valign=top><td class=color0><b>Version description</b></td>',"\n";
echo '<td><p style="width:700px">',"\n";
echo '<textarea cols="80" rows="20" id="editor2" name="versionDescription">',"\n";
$_REQUEST['versionDescription'] = GetDefaultVersionDescription();
}
/* if magic quotes are enabled we need to strip them before we output the 'versionDescription' */
/* again. Otherwise we will stack up magic quotes each time the user resubmits after having */
/* an error */
if(get_magic_quotes_gpc())
echo stripslashes($_REQUEST['versionDescription']).'</textarea></p></td></tr>',"\n";
else
echo $_REQUEST['versionDescription'].'</textarea></p></td></tr>',"\n";
$oApp = new Application();
$oApp->GetOutputEditorValues(); /* retrieve the values from the current $_REQUEST */
$oVersion = new Version();
$oVersion->GetOutputEditorValues(); /* retrieve the values from the current $_REQUEST */
/* output the appropriate editors depending on whether we are processing an */
/* application and a version or just a version */
if($_REQUEST['apptype'] == 1)
{
$oApp->OutputEditor($_REQUEST['appVendorName']);
$oVersion->OutputEditor(false);
} else
{
$oVersion->OutputEditor(true);
}
echo '<input type="hidden" name="apptype" value="'.$_REQUEST['apptype'].'">',"\n";
@@ -243,7 +163,6 @@ if (isset($_REQUEST['apptype']))
echo '<input type=submit value="Submit New Version" class="button"> </td></tr>',"\n";
}
echo '</table>',"\n";
echo html_frame_end();
echo "</form>";
}
apidb_footer();

View File

@@ -113,7 +113,7 @@ class Application {
/**
* Creates a new application.
*/
function create($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null)
function create()
{
// Security, if we are not an administrator the application must be queued.
if(!($_SESSION['current']->hasPriv("admin")))
@@ -121,12 +121,12 @@ class Application {
else
$this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'appName' => $sName,
'description'=> $sDescription,
'keywords' => $sKeywords,
'webPage' => $sWebpage,
'vendorId' => $iVendorId,
'catId' => $iCatId,
$aInsert = compile_insert_string(array( 'appName' => $this->sName,
'description'=> $this->sDescription,
'keywords' => $this->sKeywords,
'webPage' => $this->sWebpage,
'vendorId' => $this->iVendorId,
'catId' => $this->iCatId,
'submitterId'=> $_SESSION['current']->iUserId,
'queued' => $this->sQueued));
$sFields = "({$aInsert['FIELDS']})";
@@ -148,66 +148,63 @@ class Application {
* Update application.
* Returns true on success and false on failure.
*/
function update($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null)
function update()
{
$sWhatChanged = "";
if ($sName && $sName!=$this->sName)
/* create an instance of ourselves so we can see what has changed */
$oApp = new Application($this->iAppId);
if ($this->sName && ($this->sName!=$oApp->sName))
{
$sUpdate = compile_update_string(array('appName' => $sName));
$sUpdate = compile_update_string(array('appName' => $this->sName));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
$sWhatChanged .= "Name was changed from ".$this->sName." to ".$sName.".\n\n";
$this->sName = $sName;
$sWhatChanged .= "Name was changed from ".$oApp->sName." to ".$this->sName.".\n\n";
}
if ($sDescription && $sDescription!=$this->sDescription)
if ($this->sDescription && ($this->sDescription!=$oApp->sDescription))
{
$sUpdate = compile_update_string(array('description' => $sDescription));
$sUpdate = compile_update_string(array('description' => $this->sDescription));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
$sWhatChanged .= "Description was changed from\n ".$this->sDescription."\n to \n".$sDescription.".\n\n";
$this->sDescription = $sDescription;
$sWhatChanged .= "Description was changed from\n ".$oApp->sDescription."\n to \n".$this->sDescription.".\n\n";
}
if ($sKeywords && $sKeywords!=$this->sKeywords)
if ($this->sKeywords && ($this->sKeywords!=$oApp->sKeywords))
{
$sUpdate = compile_update_string(array('keywords' => $sKeywords));
$sUpdate = compile_update_string(array('keywords' => $this->sKeywords));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
$sWhatChanged .= "Keywords were changed from\n ".$this->sKeywords."\n to \n".$sKeywords.".\n\n";
$this->sKeywords = $sKeywords;
$sWhatChanged .= "Keywords were changed from\n ".$oApp->sKeywords."\n to \n".$this->sKeywords.".\n\n";
}
if ($sWebpage && $sWebpage!=$this->sWebpage)
if ($this->sWebpage && ($this->sWebpage!=$oApp->sWebpage))
{
$sUpdate = compile_update_string(array('webPage' => $sWebpage));
$sUpdate = compile_update_string(array('webPage' => $this->sWebpage));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
$sWhatChanged .= "Web page was changed from ".$this->sWebpage." to ".$sWebpage.".\n\n";
$this->sWebpage = $sWebpage;
$sWhatChanged .= "Web page was changed from ".$oApp->sWebpage." to ".$this->sWebpage.".\n\n";
}
if ($iVendorId && $iVendorId!=$this->iVendorId)
if ($this->iVendorId && ($this->iVendorId!=$oApp->iVendorId))
{
$sUpdate = compile_update_string(array('vendorId' => $iVendorId));
$sUpdate = compile_update_string(array('vendorId' => $this->iVendorId));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
$oVendorBefore = new Vendor($this->iVendorId);
$oVendorAfter = new Vendor($iVendorId);
$oVendorBefore = new Vendor($oApp->iVendorId);
$oVendorAfter = new Vendor($this->iVendorId);
$sWhatChanged .= "Vendor was changed from ".$oVendorBefore->sName." to ".$oVendorBefore->sName.".\n\n";
$this->iVendorId = $iVendorId;
}
if ($iCatId && $iCatId!=$this->iCatId)
if ($this->iCatId && ($this->iCatId!=$oApp->iCatId))
{
$sUpdate = compile_update_string(array('catId' => $iCatId));
$sUpdate = compile_update_string(array('catId' => $this->iCatId));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
$oCatBefore = new Category($this->iCatId);
$oCatAfter = new Category($iCatId);
$oCatBefore = new Category($oApp->iCatId);
$oCatAfter = new Category($this->iCatId);
$sWhatChanged .= "Vendor was changed from ".$oCatBefore->sName." to ".$oCatAfter->sName.".\n\n";
$this->iCatId = $iCatId;
}
if($sWhatChanged)
$this->SendNotificationMail("edit",$sWhatChanged);
@@ -415,6 +412,98 @@ class Application {
if($sEmail)
mail_appdb($sEmail, $sSubject ,$sMsg);
}
/* output a html table and this applications values to the fields for editing */
function OutputEditor($sVendorName)
{
HtmlAreaLoaderScript(array("app_editor"));
echo html_frame_start("Application Form", "90%", "", 0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
echo '<tr valign=top><td class="color0"><b>Application name</b></td>',"\n";
echo '<td><input size="20" type="text" name="appName" value="'.$this->sName.'"></td></tr>',"\n";
// app Category
$w = new TableVE("view");
echo '<tr valign=top><td class="color0"><b>Category</b></td><td>',"\n";
$w->make_option_list("appCatId", $this->iCatId,"appCategory","catId","catName");
echo '</td></tr>',"\n";
// vendor name
echo '<tr valign=top><td class="color0"><b>Vendor</b></td>',"\n";
echo '<td><input size="20" type=text name="appVendorName" value="'.$sVendorName.'"></td></tr>',"\n";
// alt vendor
$x = new TableVE("view");
echo '<tr valign=top><td class="color0">&nbsp;</td><td>',"\n";
$x->make_option_list("appVendorId", $this->iVendorId,"vendor","vendorId","vendorName");
echo '</td></tr>',"\n";
// url
echo '<tr valign=top><td class="color0"><b>URL</b></td>',"\n";
echo '<td><input size="20" type=text name="appWebpage" value="'.$this->sWebpage.'"></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>Keywords</b></td>',"\n";
echo '<td><input size="90%" type="text" name="appKeywords" value="'.$this->sKeywords.'"></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>Application Description</b></td>',"\n";
echo '<td><p><textarea cols="80" rows="20" id="app_editor" name="appDescription">';
if(get_magic_quotes_gpc())
echo stripslashes($this->sDescription).'</textarea></p></td></tr>',"\n";
else
echo $this->sDescription.'</textarea></p></td></tr>',"\n";
echo "</table>\n";
echo html_frame_end();
}
function CheckOutputEditorInput()
{
$errors = "";
if (empty($_REQUEST['appCatId']) && !$_REQUEST['appId'])
$errors .= "<li>Please enter a category for your application.</li>\n";
if (strlen($_REQUEST['appName']) > 200 )
$errors .= "<li>Your application name is too long.</li>\n";
if (empty($_REQUEST['appName']) && !$_REQUEST['appId'])
$errors .= "<li>Please enter an application name.</li>\n";
// No vendor entered, and nothing in the list is selected
if (empty($_REQUEST['appVendorName']) && !$_REQUEST['appVendorId'] && !$_REQUEST['appId'])
$errors .= "<li>Please enter a vendor.</li>\n";
if (empty($_REQUEST['appDescription']) && !$_REQUEST['appId'])
$errors .= "<li>Please enter a description of your application.</li>\n";
return $errors;
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
{
if(get_magic_quotes_gpc())
{
$this->sName = stripslashes($_REQUEST['appName']);
$this->sDescription = stripslashes($_REQUEST['appDescription']);
$this->iCatId = stripslashes($_REQUEST['appCatId']);
$this->iVendorId = stripslashes($_REQUEST['appVendorId']);
$this->sWebpage = stripslashes($_REQUEST['appWebpage']);
$this->sKeywords = stripslashes($_REQUEST['appKeywords']);
} else
{
$this->sName = $_REQUEST['appName'];
$this->sDescription = $_REQUEST['appDescription'];
$this->iCatId = $_REQUEST['appCatId'];
$this->iVendorId = $_REQUEST['appVendorId'];
$this->sWebpage = $_REQUEST['appWebpage'];
$this->sKeywords = $_REQUEST['appKeywords'];
}
}
}
@@ -459,4 +548,9 @@ function trim_description($sDescription)
$aDesc = explode("</p><p /><p>",$aDesc[0],2);
return trim(strip_tags($aDesc[0]));
}
function GetDefaultApplicationDescription()
{
return "<p>Enter a description of the application here</p>";
}
?>

View File

@@ -583,23 +583,23 @@ function display_versions($iAppId, $aVersionsIds)
/* or false if processing changes for an application family */
function process_app_version_changes($isVersion)
{
/* load up the version or application depending on which values are set */
if($isVersion)
{
$oVersion = new Version($_REQUEST['versionId']);
else
$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']);
$oVersion->GetOutputEditorValues();
$oVersion->update();
} 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']);
$oApp->GetOutputEditorValues();
$oApp->update();
} else if($_REQUEST['submit'] == "Update URL")
{
$sWhatChanged = "";
$bAppChanged = false;
@@ -810,6 +810,8 @@ function GetSimplifiedPath($relative)
function HtmlAreaLoaderScript($aTextareas)
{
static $outputIndex = 0;
echo '
<script type="text/javascript">';
// You must set _editor_url to the URL (including trailing slash) where
@@ -831,22 +833,32 @@ function HtmlAreaLoaderScript($aTextareas)
<script type="text/javascript" src="'.BASE.'xinha/htmlarea.js"></script>
<script type="text/javascript">
xinha_editors = null;
xinha_init = null;
xinha_config = null;
xinha_plugins = null;
xinha_editors_'.$outputIndex.' = null;
xinha_init_'.$outputIndex.' = null;';
/* only need to nll out the first set of config and plugins */
/* as we will reuse these for additional htmlareas */
if($outputIndex == 0)
{
echo '
xinha_config_'.$outputIndex.' = null;
xinha_plugins_'.$outputIndex.' = null;';
}
echo '
// This contains the names of textareas we will make into Xinha editors
xinha_init = xinha_init ? xinha_init : function()
xinha_init_'.$outputIndex.' = xinha_init_'.$outputIndex.' ? xinha_init_'.$outputIndex.' : function()
{';
/** STEP 1 ***************************************************************
* First, what are the plugins you will be using in the editors on this
* page. List all the plugins you will need, even if not all the editors
* will use all the plugins.
************************************************************************/
if($outputIndex == 0)
{
echo '
xinha_plugins = xinha_plugins ? xinha_plugins :
xinha_plugins_'.$outputIndex.' = xinha_plugins_'.$outputIndex.' ? xinha_plugins_'.$outputIndex.' :
[
\'CharacterMap\',
\'CharCounter\',
@@ -862,7 +874,13 @@ function HtmlAreaLoaderScript($aTextareas)
];
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :)
if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;';
if(!HTMLArea.loadPlugins(xinha_plugins_'.$outputIndex.', xinha_init_'.$outputIndex.')) return;';
} else
{
echo '
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :)
if(!HTMLArea.loadPlugins(xinha_plugins_0, xinha_init_'.$outputIndex.')) return;';
}
/** STEP 2 ***************************************************************
* Now, what are the names of the textareas you will be turning into
@@ -872,7 +890,7 @@ function HtmlAreaLoaderScript($aTextareas)
// NOTE: we generate the editor names here so we can easily have any number of htmlarea editors
// and can reuse all of this code
echo '
xinha_editors = xinha_editors ? xinha_editors :
xinha_editors_'.$outputIndex.' = xinha_editors_'.$outputIndex.' ? xinha_editors_'.$outputIndex.' :
[';
$firstEntry = true;
@@ -903,12 +921,13 @@ function HtmlAreaLoaderScript($aTextareas)
* xinha_config.height = \'420px\';
*
*************************************************************************/
/* We only need the configuration output for the first htmlarea on a given page */
if($outputIndex == 0)
{
echo '
xinha_config_'.$outputIndex.' = new HTMLArea.Config();
xinha_config = new HTMLArea.Config();
xinha_config.toolbar = [
xinha_config_'.$outputIndex.'.toolbar = [
["popupeditor"],
["separator","fontsize","bold","italic","underline","strikethrough"],
["separator","forecolor","hilitecolor","textindicator"],
@@ -920,9 +939,9 @@ function HtmlAreaLoaderScript($aTextareas)
["separator","killword","removeformat","toggleborders","lefttoright", "righttoleft","separator","htmlmode","about"]
];
xinha_config.pageStyle = "@import url('.BASE."application.css".');";
xinha_config_'.$outputIndex.'.pageStyle = "@import url('.BASE."application.css".');";
';
}
/** STEP 4 ***************************************************************
* We first create editors for the textareas.
@@ -942,7 +961,8 @@ function HtmlAreaLoaderScript($aTextareas)
************************************************************************/
echo '
xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);';
xinha_editors_'.$outputIndex.' = HTMLArea.makeEditors(xinha_editors_'.$outputIndex.',
xinha_config_0, xinha_plugins_0);';
/** STEP 5 ***************************************************************
* If you want to change the configuration variables of any of the
@@ -960,12 +980,28 @@ function HtmlAreaLoaderScript($aTextareas)
* Xinha editors.
************************************************************************/
echo '
HTMLArea.startEditors(xinha_editors);
HTMLArea.startEditors(xinha_editors_'.$outputIndex.');
}';
if($outputIndex != 0)
{
echo '
var old_on_load = window.onload;
window.onload = function() {
if (typeof old_on_load == "function") old_on_load();
xinha_init_'.$outputIndex.'();
}';
} else
{
echo '
window.onload = xinha_init_'.$outputIndex.';';
}
window.onload = xinha_init;
echo '
</SCRIPT>
';
$outputIndex++; /* increment the output index */
}
?>

View File

@@ -137,7 +137,7 @@ class Version {
/**
* Creates a new version.
*/
function create($sName=null, $sDescription=null, $sTestedRelease=null, $sTestedRating=null, $iAppId=null)
function create()
{
// Security, if we are not an administrator or an appmaintainer the version must be queued.
if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSupermaintainer($iAppId)))
@@ -145,11 +145,11 @@ class Version {
else
$this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'versionName' => $sName,
'description' => $sDescription,
'maintainer_release'=> $sTestedRelease,
'maintainer_rating' => $sTestedRating,
'appId' => $iAppId,
$aInsert = compile_insert_string(array( 'versionName' => $this->sName,
'description' => $this->sDescription,
'maintainer_release'=> $this->sTestedRelease,
'maintainer_rating' => $this->sTestedRating,
'appId' => $this->iAppId,
'submitterId' => $_SESSION['current']->iUserId,
'queued' => $this->sQueued ));
$sFields = "({$aInsert['FIELDS']})";
@@ -163,7 +163,9 @@ class Version {
return true;
}
else
{
return false;
}
}
@@ -172,71 +174,66 @@ class Version {
* FIXME: Use compile_update_string instead of addslashes.
* Returns true on success and false on failure.
*/
function update($sName=null, $sDescription=null, $sTestedRelease=null, $sTestedRating=null, $iAppId=null)
function update()
{
$sWhatChanged = "";
if ($sName && $sName!=$this->sName)
$oVersion = new Version($this->iVersionId);
if ($this->sName && ($this->sName!=$oVersion->sName))
{
$sUpdate = compile_update_string(array('versionName' => $sName));
$sUpdate = compile_update_string(array('versionName' => $this->sName));
if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
return false;
$sWhatChanged .= "Name was changed from:\n\t'".$this->sName."'\nto:\n\t'".$sName."'\n\n";
$this->sName = $sName;
$sWhatChanged .= "Name was changed from:\n\t'".$oVersion->sName."'\nto:\n\t'".$this->sName."'\n\n";
}
if ($sDescription && $sDescription!=$this->sDescription)
if ($this->sDescription && ($this->sDescription!=$oVersion->sDescription))
{
$sUpdate = compile_update_string(array('description' => $sDescription));
$sUpdate = compile_update_string(array('description' => $this->sDescription));
if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
return false;
if($this->sDescription != "")
$sWhatChanged .= "Description was changed from\n ".$this->sDescription."\n to \n".$sDescription.".\n\n";
if($oVersion->sDescription != "")
$sWhatChanged .= "Description was changed from\n ".$oVersion->sDescription."\n to \n".$this->sDescription.".\n\n";
else
$sWhatChanged .= "Description was changed to \n".$sDescription.".\n\n";
$this->sDescription = $sDescription;
$sWhatChanged .= "Description was changed to \n".$this->sDescription.".\n\n";
}
if ($sTestedRelease && $sTestedRelease!=$this->sTestedRelease)
if ($this->sTestedRelease && ($this->sTestedRelease!=$oVersion->sTestedRelease))
{
$sUpdate = compile_update_string(array('maintainer_release' => $sTestedRelease));
if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
return false;
if($this->sTestedRelease != "")
$sWhatChanged .= "Last tested release was changed from ".$this->sTestedRelease." to ".$sTestedRelease.".\n\n";
if($oVersion->sTestedRelease != "")
$sWhatChanged .= "Last tested release was changed from ".$oVersion->sTestedRelease." to ".$this->sTestedRelease.".\n\n";
else
$sWhatChanged .= "Last tested release was changed to ".$sTestedRelease.".\n\n";
$this->sTestedRelease = $sTestedRelease;
$sWhatChanged .= "Last tested release was changed to ".$this->sTestedRelease.".\n\n";
}
if ($sTestedRating && $sTestedRating!=$this->sTestedRating)
if ($this->sTestedRating && ($this->sTestedRating!=$oVersion->sTestedRating))
{
$sUpdate = compile_update_string(array('maintainer_rating' => $sTestedRating));
if (!query_appdb("UPDATE appVersion SET maintainer_rating = '".$sTestedRating."' WHERE versionId = ".$this->iVersionId))
$sUpdate = compile_update_string(array('maintainer_rating' => $this->sTestedRating));
if (!query_appdb("UPDATE appVersion SET ".$sUpdate."' WHERE versionId = ".$this->iVersionId))
return false;
if($this->sTestedRating != "")
$sWhatChanged .= "Rating was changed from ".$this->sTestedRating." to ".$sTestedRating.".\n\n";
$sWhatChanged .= "Rating was changed from ".$oVersion->sTestedRating." to ".$this->sTestedRating.".\n\n";
else
$sWhatChanged .= "Rating was changed to ".$sTestedRating.".\n\n";
$this->sTestedRating = $sTestedRating;
$sWhatChanged .= "Rating was changed to ".$this->sTestedRating.".\n\n";
}
if ($iAppId && $iAppId!=$this->iAppId)
if ($this->iAppId && ($this->iAppId!=$oVersion->iAppId))
{
$sUpdate = compile_update_string(array('appId' => $iAppId));
$sUpdate = compile_update_string(array('appId' => $this->iAppId));
if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
return false;
$oAppBefore = new Application($this->iAppId);
$oAppAfter = new Application($iAppId);
$oAppBefore = new Application($oVersion->iAppId);
$oAppAfter = new Application($this->iAppId);
$sWhatChanged .= "Version was moved from application ".$oAppBefore->sName." to application ".$oAppAfter->sName.".\n\n";
$this->iAppId = $iAppId;
}
if($sWhatChanged)
$this->SendNotificationMail("edit",$sWhatChanged);
return true;
@@ -489,5 +486,99 @@ class Version {
if($sEmail)
mail_appdb($sEmail, $sSubject ,$sMsg);
}
/* output html and the current versions information for editing */
/* if $editParentApplication is true that means we need to display fields */
/* to let the user change the parent application of this version */
/* otherwise, if $editParentAppliation is false, we leave them out */
function OutputEditor($editParentApplication)
{
HtmlAreaLoaderScript(array("version_editor"));
echo html_frame_start("Version Form", "90%", "", 0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
if($editParentApplication)
{
// app parent
$x = new TableVE("view");
echo '<tr valign=top><td class=color0><b>Application</b></td>', "\n";
echo '<td>',"\n";
$x->make_option_list("appId",$this->iAppId,"appFamily","appId","appName");
echo '</td></tr>',"\n";
}
// version name
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
echo '<td><input size="20" type="text" name="versionName" value="'.$this->sName.'"></td></tr>',"\n";
// version description
echo '<tr valign=top><td class=color0><b>Version description</b></td>',"\n";
echo '<td><p><textarea cols="80" rows="20" id="version_editor" name="versionDescription">',"\n";
/* if magic quotes are enabled we need to strip them before we output the 'versionDescription' */
/* again. Otherwise we will stack up magic quotes each time the user resubmits after having */
/* an error */
if(get_magic_quotes_gpc())
echo stripslashes($this->sDescription).'</textarea></p></td></tr>',"\n";
else
echo $this->sDescription.'</textarea></p></td></tr>',"\n";
echo '</table>',"\n";
echo html_frame_end();
}
function CheckOutputEditorInput()
{
$errors = "";
if (empty($_REQUEST['versionName']))
$errors .= "<li>Please enter an application version.</li>\n";
if (empty($_REQUEST['versionDescription']))
$errors .= "<li>Please enter a version description.</li>\n";
return $errors;
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
{
if(get_magic_quotes_gpc())
{
$this->sName = stripslashes($_REQUEST['versionName']);
$this->sDescription = stripslashes($_REQUEST['versionDescription']);
} else
{
$this->sName = $_REQUEST['versionName'];
$this->sDescription = $_REQUEST['versionDescription'];
}
}
}
function GetDefaultVersionDescription()
{
return "<p>This is a template; enter version-specific description here</p>
<p>
<span class=\"title\">Wine compatibility</span><br />
<span class=\"subtitle\">What works:</span><br />
- settings<br />
- help<br />
<br /><span class=\"subtitle\">What doesn't work:</span><br />
- erasing<br />
<br /><span class=\"subtitle\">What was not tested:</span><br />
- burning<br />
</p>
<p><span class=\"title\">Tested versions</span><br /><table class=\"historyTable\" width=\"90%\" border=\"1\">
<thead class=\"historyHeader\"><tr>
<td>App. version</td><td>Wine version</td><td>Installs?</td><td>Runs?</td><td>Rating</td>
</tr></thead>
<tbody><tr>
<td class=\"gold\">3.23</td><td class=\"gold\">20050111</td><td class=\"gold\">yes</td><td class=\"gold\">yes</td><td class=\"gold\">Gold</td>
</tr><tr>
<td class=\"silver\">3.23</td><td class=\"silver\">20041201</td><td class=\"silver\">yes</td><td class=\"silver\">yes</td><td class=\"silver\">Silver</td>
</tr><tr>
<td class=\"bronze\">3.21</td><td class=\"bronze\">20040615</td><td class=\"bronze\">yes</td><td class=\"bronze\">yes</td><td class=\"bronze\">Bronze</td>
</tr></tbody></table></p><p><br /></p>";
}
?>