Allow maintainers/administrators to reject an application submission instead of just deleting it

This commit is contained in:
Tony Lambregts
2005-08-15 03:44:03 +00:00
committed by WineHQ
parent c8275c3096
commit b7f1d55472
7 changed files with 726 additions and 47 deletions

View File

@@ -168,7 +168,7 @@ if ($_REQUEST['sub'])
echo '<td><input type=text name="versionName" value="'.$oVersion->sName.'" size="20"></td></tr>',"\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 '<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">'.$oVersion->sDescription.'</textarea></p></td></tr>',"\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 '<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 '<td><textarea name="replyText" rows="10" cols="35"></textarea></td></tr>',"\n";
@@ -177,7 +177,8 @@ if ($_REQUEST['sub'])
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\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="hidden" name="versionId" value="'.$oVersion->iVersionId.'" />';
echo '<input type="submit" value=" Submit Version Into Database " class="button">&nbsp',"\n"; echo '<input type="submit" value=" Submit Version Into Database " class="button">&nbsp',"\n";
echo '<input name="sub" type=submit value="Delete" class="button"></td></tr>',"\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"; echo '</table></form>',"\n";
} else // application } else // application
{ {
@@ -273,7 +274,7 @@ if ($_REQUEST['sub'])
// application desc // application desc
echo '<tr valign=top><td class=color0><b>Application Description</b></td>',"\n"; 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">'.$oApp->sDescription.'</textarea></p></td></tr>',"\n"; echo '<td><p style="width:700px"><textarea cols="80" rows="20" name="applicationDescription">'.stripslashes($oApp->sDescription).'</textarea></p></td></tr>',"\n";
// version name // version name
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n"; echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
@@ -281,7 +282,7 @@ if ($_REQUEST['sub'])
// version description // version description
echo '<tr valign=top><td class=color0><b>Version Description</b></td>',"\n"; 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 '<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 '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
@@ -291,6 +292,7 @@ if ($_REQUEST['sub'])
echo '<input type="hidden" name="appId" value="'.$oApp->iAppId.'" />'; echo '<input type="hidden" name="appId" value="'.$oApp->iAppId.'" />';
echo '<input type=submit value=" Submit App Into Database " class=button>&nbsp',"\n"; 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="Delete" class="button" />',"\n";
echo '<input name="sub" type="submit" value="Reject" class="button" />',"\n";
echo '</td></tr>',"\n"; echo '</td></tr>',"\n";
echo '</table></form>',"\n"; echo '</table></form>',"\n";
} }
@@ -363,6 +365,34 @@ if ($_REQUEST['sub'])
redirect(apidb_fullurl("admin/adminAppQueue.php")); redirect(apidb_fullurl("admin/adminAppQueue.php"));
} }
else if ($_REQUEST['sub'] == 'Reject')
{
if (is_numeric($_REQUEST['appId']) && !is_numeric($_REQUEST['versionId'])) // application
{
// get the queued versions that refers to the application entry we just removed
// and delete them as we implicitly added a version entry when adding a new application
$sQuery = "SELECT versionId FROM appVersion WHERE appVersion.appId = '".$_REQUEST['appId']."' AND appVersion.queued = 'true';";
$hResult = query_appdb($sQuery);
if($hResult)
{
while($oRow = mysql_fetch_object($hResult))
{
$oVersion = new Version($oRow->versionId);
$oVersion->reject(true);
}
}
// delete the application entry
$oApp = new Application($_REQUEST['appId']);
$oApp->reject();
} else if(is_numeric($_REQUEST['versionId'])) // version
{
$oVersion = new Version($_REQUEST['versionId']);
$oVersion->reject();
}
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else else
{ {
//error no sub! //error no sub!

View File

@@ -0,0 +1,419 @@
<?php
/*************************************/
/* code to View and resubmit Apps */
/*************************************/
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/tableve.php");
require(BASE."include/application.php");
require(BASE."include/mail.php");
function get_vendor_from_keywords($sKeywords)
{
$aKeywords = explode(" *** ",$sKeywords);
$iLastElt = (sizeOf($aKeywords)-1);
return($aKeywords[$iLastElt]);
}
if ($_REQUEST['sub'])
{
if(is_numeric($_REQUEST['appId']))
{
$oApp = new Application($_REQUEST['appId']);
// if we are processing a queued application there MUST be an implicitly queued
// version to go along with it. Find this version so we can display its information
// during application processing so the admin can make a better choice about
// whether to accept or reject the overall application
$sQuery = "Select versionId from appVersion where appId='".$_REQUEST['appId']."';";
$hResult = query_appdb($sQuery);
$oRow = mysql_fetch_object($hResult);
// make sure the user has permission to view this version
if(!$_SESSION['current']->hasAppVersionModifyPermission($oRow->versionId) &&
(($oRow->queued=="false")?true:false) &&
!$_SESSION['current']->isVersionSubmitter($oRow->versionId))
{
errorpage("Insufficient privileges.");
exit;
}
$oVersion = new Version($oRow->versionId);
} elseif(is_numeric($_REQUEST['versionId']))
{
// make sure the user has permission to view this version
if(!$_SESSION['current']->hasAppVersionModifyPermission($_REQUEST['versionId'])&&
(($oRow->queued=="false")?true:false) &&
!$_SESSION['current']->isVersionSubmitter($oRow->versionId))
{
errorpage("Insufficient privileges.");
exit;
}
$oVersion = new Version($_REQUEST['versionId']);
} else
{
//error no Id!
addmsg("Application Not Found!", "red");
redirect($_SERVER['PHP_SELF']);
}
//process according to sub flag
if ($_REQUEST['sub'] == 'view')
{
$x = new TableVE("view");
apidb_header("Admin Rejected App Queue");
?>
<link rel="stylesheet" href="./application.css" type="text/css">
<!-- load HTMLArea -->
<script type="text/javascript" src="../htmlarea/htmlarea_loader.js"></script>
<?php
echo '<form name="qform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">',"\n";
echo '<input type="hidden" name="sub" value="ReQueue">',"\n";
echo html_back_link(1,$_SERVER['PHP_SELF']);
if (!$oApp) //app version
{
echo html_frame_start("Potential duplicate versions in the database","90%","",0);
$oApp = new Application($oVersion->iAppId);
display_versions($oApp->iAppId, $oApp->aVersionsIds);
echo html_frame_end("&nbsp;");
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the full view of the application version that has been Rejected. \n";
echo "<b>App Version</b> This type of application will be nested under the selected application parent.\n";
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
{
echo html_frame_start("Potential duplicate applications in the database","90%","",0);
perform_search_and_output_results($oApp->sName);
echo html_frame_end("&nbsp;");
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the full view of the rejected application. \n";
echo "You need to pick a category before submitting \n";
echo "it into the database.\n";
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 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;
// If not, try for an exact match
// 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);
$sQuery = "SELECT vendorId FROM vendor WHERE vendorname = '".$sVendor."';";
$hResult = query_appdb($sQuery);
if($hResult)
{
$oRow = mysql_fetch_object($hResult);
$iVendorId = $oRow->vendorId;
}
}
// try for a partial match
if(!$iVendorId)
{
$sQuery = "select * from vendor where vendorname like '%".$sVendor."%';";
$hResult = query_appdb($sQuery);
if($hResult)
{
$oRow = mysql_fetch_object($hResult);
$iVendorId = $oRow->vendorId;
}
}
//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" 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="editor" 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=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";
}
echo html_frame_end("&nbsp;");
echo html_back_link(1,$_SERVER['PHP_SELF']);
}
else if ($_REQUEST['sub'] == 'ReQueue')
{
if (is_numeric($_REQUEST['appId']) && !is_numeric($_REQUEST['versionId'])) // application
{
// get the queued versions that refers to the application entry we just removed
// and delete them as we implicitly added a version entry when adding a new application
$sQuery = "SELECT versionId FROM appVersion WHERE appVersion.appId = '".$_REQUEST['appId']."' AND appVersion.queued = 'rejected';";
$hResult = query_appdb($sQuery);
if($hResult)
{
while($oRow = mysql_fetch_object($hResult))
{
$oVersion = new Version($oRow->versionId);
$oVersion->update($_REQUEST['versionName'], $_REQUEST['versionDescription'],null,null,$_REQUEST['appId']);
$oVersion->ReQueue();
}
}
// delete the application entry
$oApp = new Application($_REQUEST['appId']);
$oApp->update($_REQUEST['appName'], $_REQUEST['applicationDescription'], $_REQUEST['keywords'], $_REQUEST['webpage'], $_REQUEST['vendorId'], $_REQUEST['catId']);
$oApp->ReQueue();
} else if(is_numeric($_REQUEST['versionId'])) // version
{
$oVersion = new Version($_REQUEST['versionId']);
$oVersion->update($_REQUEST['versionName'], $_REQUEST['versionDescription'],null,null,$_REQUEST['appId']);
$oVersion->ReQueue();
}
redirect($_SERVER['PHP_SELF']);
}
else if ($_REQUEST['sub'] == 'Delete')
{
if (is_numeric($_REQUEST['appId']) && !is_numeric($_REQUEST['versionId'])) // application
{
// get the queued versions that refers to the application entry we just removed
// and delete them as we implicitly added a version entry when adding a new application
$sQuery = "SELECT versionId FROM appVersion WHERE appVersion.appId = '".$_REQUEST['appId']."' AND appVersion.queued = 'rejected';";
$hResult = query_appdb($sQuery);
if($hResult)
{
while($oRow = mysql_fetch_object($hResult))
{
$oVersion = new Version($oRow->versionId);
$oVersion->delete();
}
}
// delete the application entry
$oApp = new Application($_REQUEST['appId']);
$oApp->delete();
} else if(is_numeric($_REQUEST['versionId'])) // version
{
$oVersion = new Version($_REQUEST['versionId']);
$oVersion->delete();
}
redirect($_SERVER['PHP_SELF']);
}
else
{
// error no sub!
addmsg("Internal Routine Not Found!!", "red");
redirect($_SERVER['PHP_SELF']);
}
}
else // if ($_REQUEST['sub']) is not defined, display the main app queue page
{
apidb_header("Resubmit application");
// get queued apps that the current user should see
$hResult = $_SESSION['current']->getAppRejectQueueQuery(true); // query for the app family
if(!$hResult || !mysql_num_rows($hResult))
{
//no apps in queue
echo html_frame_start("Application Queue","90%");
echo '<p><b>The Resubmit Application Queue is empty.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of applications waiting for re-submition, or to be deleted.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can delete or edit and\n";
echo "re-submit it into the AppDB .<br>\n";
echo "</td></tr></table></div>\n\n";
//show applist
echo html_frame_start("","90%","",0);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">
<tr class=color4>
<td>Submission Date</td>
<td>Submitter</td>
<td>Vendor</td>
<td>Application</td>
<td align=\"center\">Action</td>
</tr>";
$c = 1;
while($oRow = mysql_fetch_object($hResult))
{
$oApp = new Application($oRow->appId);
$oSubmitter = new User($oApp->iSubmitterId);
if($oApp->iVendorId)
{
$oVendor = new Vendor($oApp->iVendorId);
$sVendor = $oVendor->sName;
} else
{
$sVendor = get_vendor_from_keywords($oApp->sKeywords);
}
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "<tr class=\"$bgcolor\">\n";
echo " <td>".print_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime))."</td>\n";
echo " <td>\n";
echo $oSubmitter->sEmail ? "<a href=\"mailto:".$oSubmitter->sEmail."\">":"";
echo $oSubmitter->sRealname;
echo $oSubmitter->sEmail ? "</a>":"";
echo " </td>\n";
echo " <td>".$sVendor."</td>\n";
echo " <td>".$oApp->sName."</td>\n";
echo " <td align=\"center\">[<a href=".$_SERVER['PHP_SELF']."?sub=view&appId=".$oApp->iAppId.">process</a>]</td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
// get queued versions (only versions where application are not queued already)
$hResult = $_SESSION['current']->getAppRejectQueueQuery(false); // query for the app version
if(!$hResult || !mysql_num_rows($hResult))
{
//no apps in queue
echo html_frame_start("Version Queue","90%");
echo '<p><b>The Resubmit Version Queue is empty.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of versions waiting for re-submition or deletion.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can delete or edit and re-submit it into \n";
echo "the AppDB .<br>\n";
echo "<p>Note that versions linked to application that have not been yet approved are not displayed in this list.</p>\n";
echo "the AppDB.<br>\n";
echo "</td></tr></table></div>\n\n";
//show applist
echo html_frame_start("","90%","",0);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">
<tr class=color4>
<td>Submission Date</td>
<td>Submitter</td>
<td>Vendor</td>
<td>Application</td>
<td>Version</td>
<td align=\"center\">Action</td>
</tr>";
$c = 1;
while($oRow = mysql_fetch_object($hResult))
{
$oVersion = new Version($oRow->versionId);
$oApp = new Application($oVersion->iAppId);
$oSubmitter = new User($oVersion->iSubmitterId);
$oVendor = new Vendor($oApp->iVendorId);
$sVendor = $oVendor->sName;
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "<tr class=\"$bgcolor\">\n";
echo " <td>".print_date(mysqltimestamp_to_unixtimestamp($oVersion->sSubmitTime))."</td>\n";
echo " <td>\n";
echo $oSubmitter->sEmail ? "<a href=\"mailto:".$oSubmitter->sEmail."\">":"";
echo $oSubmitter->sRealname;
echo $oSubmitter->sEmail ? "</a>":"";
echo " </td>\n";
echo " <td>".$sVendor."</td>\n";
echo " <td>".$oApp->sName."</td>\n";
echo " <td>".$oVersion->sName."</td>\n";
echo " <td align=\"center\">[<a href=".$_SERVER['PHP_SELF']."?sub=view&versionId=".$oVersion->iVersionId.">process</a>]</td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
}
apidb_footer();
?>

View File

@@ -19,7 +19,7 @@ class Application {
var $sKeywords; var $sKeywords;
var $sDescription; var $sDescription;
var $sWebpage; var $sWebpage;
var $bQueued; var $sQueued;
var $sSubmitTime; var $sSubmitTime;
var $iSubmitterId; var $iSubmitterId;
var $aVersionsIds; // an array that contains the versionId of every version linked to this app. var $aVersionsIds; // an array that contains the versionId of every version linked to this app.
@@ -58,7 +58,7 @@ class Application {
$this->sKeywords = $oRow->keywords; $this->sKeywords = $oRow->keywords;
$this->sDescription = $oRow->description; $this->sDescription = $oRow->description;
$this->sWebpage = $oRow->webPage; $this->sWebpage = $oRow->webPage;
$this->bQueued = ($oRow->queued=="true")?true:false; $this->sQueued = $oRow->queued;
} }
$this->aVersionsIds[] = $oRow->versionId; $this->aVersionsIds[] = $oRow->versionId;
} }
@@ -86,7 +86,7 @@ class Application {
$this->sKeywords = $oRow->keywords; $this->sKeywords = $oRow->keywords;
$this->sDescription = $oRow->description; $this->sDescription = $oRow->description;
$this->sWebpage = $oRow->webPage; $this->sWebpage = $oRow->webPage;
$this->bQueued = ($oRow->queued=="true")?true:false; $this->sQueued = $oRow->queued;
} }
} }
@@ -117,9 +117,9 @@ class Application {
{ {
// Security, if we are not an administrator the application must be queued. // Security, if we are not an administrator the application must be queued.
if(!($_SESSION['current']->hasPriv("admin"))) if(!($_SESSION['current']->hasPriv("admin")))
$this->bQueued = true; $this->sQueued = 'true';
else else
$this->bQueued = false; $this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'appName' => $sName, $aInsert = compile_insert_string(array( 'appName' => $sName,
'description'=> $sDescription, 'description'=> $sDescription,
@@ -128,7 +128,7 @@ class Application {
'vendorId' => $iVendorId, 'vendorId' => $iVendorId,
'catId' => $iCatId, 'catId' => $iCatId,
'submitterId'=> $_SESSION['current']->iUserId, 'submitterId'=> $_SESSION['current']->iUserId,
'queued' => $this->bQueued?"true":"false" )); 'queued' => $this->sQueued));
$sFields = "({$aInsert['FIELDS']})"; $sFields = "({$aInsert['FIELDS']})";
$sValues = "({$aInsert['VALUES']})"; $sValues = "({$aInsert['VALUES']})";
@@ -262,14 +262,14 @@ class Application {
function unQueue() function unQueue()
{ {
// If we are not in the queue, we can't move the application out of the queue. // If we are not in the queue, we can't move the application out of the queue.
if(!$this->bQueued) if(!$this->sQueued == 'true')
return false; return false;
$sUpdate = compile_update_string(array('queued' => "false", $sUpdate = compile_update_string(array('queued' => "false",
'keywords'=> str_replace(" *** ","",$this->sKeywords) )); 'keywords'=> str_replace(" *** ","",$this->sKeywords) ));
if(query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId)) if(query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
{ {
$this->bQueued = false; $this->sQueued = 'false';
// we send an e-mail to intersted people // we send an e-mail to intersted people
$this->mailSubmitter(); $this->mailSubmitter();
$this->mailSupermaintainers(); $this->mailSupermaintainers();
@@ -279,24 +279,77 @@ class Application {
} }
} }
function Reject()
{
// If we are not in the queue, we can't move the application out of the queue.
if(!$this->sQueued == 'true')
return false;
function mailSubmitter($bRejected=false) $sUpdate = compile_update_string(array('queued' => "rejected"));
if(query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
{
$this->sQueued = 'rejected';
// we send an e-mail to intersted people
$this->mailSubmitter("reject");
$this->mailSupermaintainers("reject");
// the application has been rejectedd
addmsg("The application has been rejected.", "green");
}
}
function ReQueue()
{
// If we are not in the rejected, we can't move the application into the queue.
if(!$this->sQueued == 'rejected')
return false;
$sUpdate = compile_update_string(array('queued' => "true"));
if(query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
{
$this->sQueued = 'true';
// we send an e-mail to intersted people
$this->mailSupermaintainers();
// the application has been re-queued
addmsg("The application has been re-queued.", "green");
}
}
function mailSubmitter($sAction="add")
{ {
if($this->iSubmitterId) if($this->iSubmitterId)
{ {
$oSubmitter = new User($this->iSubmitterId); $oSubmitter = new User($this->iSubmitterId);
if(!$bRejected) switch($sAction)
{ {
$sSubject = "Submitted application accepted"; case "add":
$sMsg = "The application you submitted (".$this->sName.") has been accepted."; {
} else $sSubject = "Submitted application accepted";
{ $sMsg = "The application you submitted (".$oApp->sName." ".$this->sName.") has been accepted.";
$sSubject = "Submitted application rejected"; }
$sMsg = "The application you submitted (".$this->sName.") has been rejected."; break;
} case "reject":
{
$sSubject = "Submitted application rejected";
$sMsg = "The application you submitted (".$oApp->sName." ".$this->sName.") has been rejected.";
$sMsg .= APPDB_ROOT."admin/resubmitRejectedApps.php?sub=view&appId=".$this->iAppId."\n";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */
}
break;
case "delete":
{
$sSubject = "Submitted application deleted";
$sMsg = "The application you submitted (".$oApp->sName." ".$this->sName.") has been deleted.";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */
}
break;
$sMsg .= $_REQUEST['replyText']."\n"; $sMsg .= $_REQUEST['replyText']."\n";
$sMsg .= "We appreciate your help in making the Application Database better for all users."; $sMsg .= "We appreciate your help in making the Application Database better for all users.";
}
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg); mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
} }
} }
@@ -307,7 +360,7 @@ class Application {
switch($sAction) switch($sAction)
{ {
case "add": case "add":
if(!$this->bQueued) if(!$this->sQueued == 'true')
{ {
$sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname; $sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?appId=".$this->iAppId."\n"; $sMsg = APPDB_ROOT."appview.php?appId=".$this->iAppId."\n";
@@ -323,7 +376,7 @@ class Application {
$sSubject = $this->sName." has been submitted by ".$_SESSION['current']->sRealname; $sSubject = $this->sName." has been submitted by ".$_SESSION['current']->sRealname;
$sMsg .= "This application has been queued."; $sMsg .= "This application has been queued.";
$sMsg .= "\n"; $sMsg .= "\n";
addmsg("The application you submitted will be added to the database database after being reviewed.", "green"); addmsg("The application you submitted will be added to the database after being reviewed.", "green");
} }
break; break;
case "edit": case "edit":
@@ -343,6 +396,18 @@ class Application {
addmsg("Application deleted.", "green"); addmsg("Application deleted.", "green");
break; break;
case "reject":
$sSubject = $this->sName." has been rejected by ".$_SESSION['current']->sRealname;
/* if replyText is set we should report the reason the application was rejected */
if($_REQUEST['replyText'])
{
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */
}
addmsg("Application rejected.", "green");
break;
} }
$sEmail = get_notify_email_address_list($this->iAppId); $sEmail = get_notify_email_address_list($this->iAppId);
if($sEmail) if($sEmail)

View File

@@ -5,7 +5,7 @@
require_once(BASE."include/maintainer.php"); require_once(BASE."include/maintainer.php");
require_once(BASE."include/application.php"); require_once(BASE."include/application.php");
require_once(BASE."include/user.php");
function global_sidebar_login() { function global_sidebar_login() {
@@ -32,6 +32,10 @@ function global_sidebar_login() {
$g->addmisc("<a href='".BASE."appview.php?versionId=$versionId'>".lookup_app_name($appId)." ".lookup_version_name($versionId)."</a>", "center"); $g->addmisc("<a href='".BASE."appview.php?versionId=$versionId'>".lookup_app_name($appId)." ".lookup_version_name($versionId)."</a>", "center");
} }
} }
$appsRejected = $_SESSION['current']->getAllRejectedApps();
if($appsRejected)
$g->addmisc("<a href='".BASE."admin/resubmitRejectedApps.php?'>Review Rejected Apps</a>", "center");
} }
else else
{ {

View File

@@ -533,6 +533,60 @@ class User {
return query_appdb($sQuery); return query_appdb($sQuery);
} }
function getAppRejectQueueQuery($queryAppFamily)
{
if($this->hasPriv("admin"))
{
if($queryAppFamily)
{
$sQuery = "SELECT appFamily.appId FROM appFamily WHERE queued = 'rejected'";
} else
{
$sQuery = "SELECT appVersion.versionId FROM appVersion, appFamily
WHERE appFamily.appId = appVersion.appId
AND appFamily.queued = 'false' AND appVersion.queued = 'rejected'";
}
} else
{
if($queryAppFamily)
{
$sQuery = "SELECT appFamily.appId FROM appFamily
WHERE queued = 'rejected'
AND appFamily.submitterId = '".$this->iUserId."';";
} else
{
$sQuery = "SELECT appVersion.versionId FROM appVersion, appFamily
WHERE appFamily.appId = appVersion.appId
AND appFamily.queued = 'false' AND appVersion.queued = 'rejected'
AND appVersion.submitterId = '".$this->iUserId."';";
}
}
return query_appdb($sQuery);
}
function getAllRejectedApps()
{
$result = query_appdb("SELECT appVersion.versionId, appFamily.appId
FROM appVersion, appFamily
WHERE appFamily.appId = appVersion.appId
AND (appFamily.queued = 'rejected' OR appVersion.queued = 'rejected')
AND appVersion.submitterId = '".$this->iUserId."';");
if(!$result || mysql_num_rows($result) == 0)
return;
$retval = array();
$c = 0;
while($row = mysql_fetch_object($result))
{
$retval[$c] = array($row->appId, $row->versionId);
$c++;
}
return $retval;
}
/** /**
* Does the user have permission to modify on this version? * Does the user have permission to modify on this version?
*/ */
@@ -553,6 +607,30 @@ class User {
else else
return false; return false;
} }
function isAppSubmitter($iAppId)
{
$sQuery = "SELECT appId FROM appFamily
WHERE submitterId = '".$this->iUserId."'
AND appId = '".$iAppId."';";
$hResult = query_appdb($sQuery);
if(mysql_num_rows($hResult))
return true;
else
return false;
}
function isVersionSubmitter($iVersionId)
{
$sQuery = "SELECT appVersion.versionId FROM appVersion, appFamily
WHERE appFamily.appId = appVersion.appId
AND appVersion.submitterId = '".$this->iUserId."'
AND appVersion.versionId = '".$iVersionId."';";
$hResult = query_appdb($sQuery);
if(mysql_num_rows($hResult))
return true;
else
return false;
}
} }

View File

@@ -22,6 +22,7 @@ class Version {
var $sSubmitTime; var $sSubmitTime;
var $iSubmitterId; var $iSubmitterId;
var $sDate; var $sDate;
var $sQueued;
var $aNotesIds; // an array that contains the noteId of every note linked to this version var $aNotesIds; // an array that contains the noteId of every note linked to this version
var $aCommentsIds; // an array that contains the commentId of every comment linked to this version var $aCommentsIds; // an array that contains the commentId of every comment linked to this version
var $aScreenshotsIds; // an array that contains the screenshotId of every screenshot linked to this version var $aScreenshotsIds; // an array that contains the screenshotId of every screenshot linked to this version
@@ -59,7 +60,7 @@ class Version {
$this->sTestedRelease = $oRow->maintainer_release; $this->sTestedRelease = $oRow->maintainer_release;
$this->sTestedRating = $oRow->maintainer_rating; $this->sTestedRating = $oRow->maintainer_rating;
$this->sWebpage = $oRow->webPage; $this->sWebpage = $oRow->webPage;
$this->bQueued = ($oRow->queued=="true")?true:false; $this->sQueued = $oRow->queued;
} }
} }
@@ -140,9 +141,9 @@ class Version {
{ {
// Security, if we are not an administrator or an appmaintainer the version must be queued. // Security, if we are not an administrator or an appmaintainer the version must be queued.
if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSupermaintainer($iAppId))) if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSupermaintainer($iAppId)))
$this->bQueued = true; $this->sQueued = 'true';
else else
$this->bQueued = false; $this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'versionName' => $sName, $aInsert = compile_insert_string(array( 'versionName' => $sName,
'description' => $sDescription, 'description' => $sDescription,
@@ -150,7 +151,7 @@ class Version {
'maintainer_rating' => $sTestedRating, 'maintainer_rating' => $sTestedRating,
'appId' => $iAppId, 'appId' => $iAppId,
'submitterId' => $_SESSION['current']->iUserId, 'submitterId' => $_SESSION['current']->iUserId,
'queued' => $this->bQueued?"true":"false" )); 'queued' => $this->sQueued ));
$sFields = "({$aInsert['FIELDS']})"; $sFields = "({$aInsert['FIELDS']})";
$sValues = "({$aInsert['VALUES']})"; $sValues = "({$aInsert['VALUES']})";
@@ -249,7 +250,9 @@ class Version {
function delete($bSilent=false) function delete($bSilent=false)
{ {
/* is the current user allowed to delete this version? */ /* is the current user allowed to delete this version? */
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($iVersionId)) if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($iVersionId) &&
!(($_SESSION['current']->iUserId == $this->iSubmitterId) && ($this->sQueued == 'rejected')))
{ {
return; return;
} }
@@ -300,7 +303,7 @@ class Version {
if(!$bSilent) if(!$bSilent)
$this->mailMaintainers("delete"); $this->mailMaintainers("delete");
$this->mailSubmitter(true); $this->mailSubmitter("delete");
} }
@@ -316,15 +319,15 @@ class Version {
} }
// If we are not in the queue, we can't move the version out of the queue. // If we are not in the queue, we can't move the version out of the queue.
if(!$this->bQueued) if(!$this->sQueued == 'true')
return false; return false;
$sUpdate = compile_update_string(array('queued' => "false")); $sUpdate = compile_update_string(array('queued' => "false"));
if(query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId)) if(query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
{ {
$this->bQueued = false; $this->sQueued = 'false';
// we send an e-mail to intersted people // we send an e-mail to intersted people
$this->mailSubmitter(); $this->mailSubmitter("unQueue");
$this->mailMaintainers(); $this->mailMaintainers();
// the version has been unqueued // the version has been unqueued
@@ -332,25 +335,91 @@ class Version {
} }
} }
function Reject($bSilent=false)
{
/* is the current user allowed to delete this version? */
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($iVersionId))
{
return;
}
function mailSubmitter($bRejected=false) // If we are not in the queue, we can't move the version out of the queue.
if(!$this->sQueued == 'true')
return false;
$sUpdate = compile_update_string(array('queued' => "rejected"));
if(query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
{
$this->sQueued = 'rejected';
// we send an e-mail to intersted people
if(!$bSilent)
{
$this->mailSubmitter("reject");
$this->mailMaintainers("reject");
}
// the version has been unqueued
addmsg("The version has been rejected.", "green");
}
}
function ReQueue()
{
/* is the current user allowed to delete this version? */
if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($iVersionId) &&
!$_SESSION['current']->iUserId == $this->iSubmitterId)
{
return;
}
$sUpdate = compile_update_string(array('queued' => "true"));
if(query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
{
$this->sQueued = 'true';
// we send an e-mail to intersted people
$this->mailMaintainers();
// the version has been unqueued
addmsg("The version has been re-submitted", "green");
}
}
function mailSubmitter($sAction="add")
{ {
if($this->iSubmitterId) if($this->iSubmitterId)
{ {
$oApp = new Application($this->appId); $oApp = new Application($this->appId);
$oSubmitter = new User($this->iSubmitterId); $oSubmitter = new User($this->iSubmitterId);
if(!$bRejected) switch($sAction)
{ {
$sSubject = "Submitted version accepted"; case "add":
$sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been accepted."; {
} else $sSubject = "Submitted version accepted";
{ $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been accepted.";
$sSubject = "Submitted version rejected"; }
$sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been rejected."; break;
case "reject":
{
$sSubject = "Submitted version rejected";
$sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been rejected.";
$sMsg .= APPDB_ROOT."admin/resubmitRejectedApps.php?sub=view&versionId=".$this->iVersionId."\n";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */
}
break;
case "delete":
{
$sSubject = "Submitted version deleted";
$sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been deleted.";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */
}
break;
} }
$sMsg .= $_REQUEST['replyText']."\n"; $sMsg .= $_REQUEST['replyText']."\n";
$sMsg .= "We appreciate your help in making the Version Database better for all users."; $sMsg .= "We appreciate your help in making the Version Database better for all users.";
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg); mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
} }
} }
@@ -362,7 +431,7 @@ class Version {
switch($sAction) switch($sAction)
{ {
case "add": case "add":
if(!$this->bQueued) if($this->sQueued == "false")
{ {
$sSubject = "Version ".$this->sName." of ".$oApp->sName." added by ".$_SESSION['current']->sRealname; $sSubject = "Version ".$this->sName." of ".$oApp->sName." added by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n"; $sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
@@ -380,7 +449,7 @@ class Version {
$sSubject = "Version '".$this->sName."' of '".$oApp->sName."' submitted by ".$_SESSION['current']->sRealname; $sSubject = "Version '".$this->sName."' of '".$oApp->sName."' submitted by ".$_SESSION['current']->sRealname;
$sMsg .= "This version has been queued."; $sMsg .= "This version has been queued.";
$sMsg .= "\n"; $sMsg .= "\n";
addmsg("The version you submitted will be added to the database database after being reviewed.", "green"); addmsg("The version you submitted will be added to the database after being reviewed.", "green");
} }
break; break;
case "edit": case "edit":
@@ -400,6 +469,20 @@ class Version {
addmsg("Version deleted.", "green"); addmsg("Version deleted.", "green");
break; break;
case "reject":
$sSubject = "Version '".$this->sName."' of '".$oApp->sName."' has been rejected by ".$_SESSION['current']->sRealname;
/* if replyText is set we should report the reason the application was rejected */
if($_REQUEST['replyText'])
{
$sMsg = APPDB_ROOT."admin/resubmitRejectedApps.php?versionId=".$this->iVersionId."\n";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */
}
addmsg("Version rejected.", "green");
break;
} }
$sEmail = get_notify_email_address_list(null, $this->iVersionId); $sEmail = get_notify_email_address_list(null, $this->iVersionId);
if($sEmail) if($sEmail)

View File

@@ -41,7 +41,7 @@ create table appFamily (
catId int, catId int,
submitTime timestamp(14) NOT NULL, submitTime timestamp(14) NOT NULL,
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
queued enum('true','false') NOT NULL default 'false', queued enum('true','false','rejected') NOT NULL default 'false',
key(appId) key(appId)
); );
@@ -58,7 +58,7 @@ create table appVersion (
maintainer_release text, maintainer_release text,
submitTime timestamp(14) NOT NULL, submitTime timestamp(14) NOT NULL,
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
queued enum('true','false') NOT NULL default 'false', queued enum('true','false','rejected') NOT NULL default 'false',
key(versionId) key(versionId)
); );