',"\n";
echo '',"\n";
}
@@ -363,6 +365,34 @@ if ($_REQUEST['sub'])
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
{
//error no sub!
diff --git a/admin/resubmitRejectedApps.php b/admin/resubmitRejectedApps.php
new file mode 100644
index 0000000..95fe3ad
--- /dev/null
+++ b/admin/resubmitRejectedApps.php
@@ -0,0 +1,419 @@
+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");
+?>
+
+
+
+',"\n";
+ echo '',"\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(" ");
+
+ //help
+ echo "
\n\n";
+ echo "
This is the full view of the application version that has been Rejected. \n";
+
+ echo "App Version This type of application will be nested under the selected application parent.\n";
+ echo "
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.
\n\n";
+ echo "
\n\n";
+
+ echo html_frame_start("Rejected Version Form",400,"",0);
+ echo "
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 "
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.
',"\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 '
\n\n";
+ echo html_frame_end(" ");
+
+ }
+}
+apidb_footer();
+?>
diff --git a/include/application.php b/include/application.php
index 4ba4902..9319cab 100644
--- a/include/application.php
+++ b/include/application.php
@@ -19,7 +19,7 @@ class Application {
var $sKeywords;
var $sDescription;
var $sWebpage;
- var $bQueued;
+ var $sQueued;
var $sSubmitTime;
var $iSubmitterId;
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->sDescription = $oRow->description;
$this->sWebpage = $oRow->webPage;
- $this->bQueued = ($oRow->queued=="true")?true:false;
+ $this->sQueued = $oRow->queued;
}
$this->aVersionsIds[] = $oRow->versionId;
}
@@ -86,7 +86,7 @@ class Application {
$this->sKeywords = $oRow->keywords;
$this->sDescription = $oRow->description;
$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.
if(!($_SESSION['current']->hasPriv("admin")))
- $this->bQueued = true;
+ $this->sQueued = 'true';
else
- $this->bQueued = false;
+ $this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'appName' => $sName,
'description'=> $sDescription,
@@ -128,7 +128,7 @@ class Application {
'vendorId' => $iVendorId,
'catId' => $iCatId,
'submitterId'=> $_SESSION['current']->iUserId,
- 'queued' => $this->bQueued?"true":"false" ));
+ 'queued' => $this->sQueued));
$sFields = "({$aInsert['FIELDS']})";
$sValues = "({$aInsert['VALUES']})";
@@ -262,14 +262,14 @@ class Application {
function unQueue()
{
// 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;
$sUpdate = compile_update_string(array('queued' => "false",
'keywords'=> str_replace(" *** ","",$this->sKeywords) ));
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
$this->mailSubmitter();
$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)
{
$oSubmitter = new User($this->iSubmitterId);
- if(!$bRejected)
+ switch($sAction)
{
- $sSubject = "Submitted application accepted";
- $sMsg = "The application you submitted (".$this->sName.") has been accepted.";
- } else
- {
- $sSubject = "Submitted application rejected";
- $sMsg = "The application you submitted (".$this->sName.") has been rejected.";
- }
+ case "add":
+ {
+ $sSubject = "Submitted application accepted";
+ $sMsg = "The application you submitted (".$oApp->sName." ".$this->sName.") has been accepted.";
+ }
+ 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 .= "We appreciate your help in making the Application Database better for all users.";
-
+ }
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
}
}
@@ -307,7 +360,7 @@ class Application {
switch($sAction)
{
case "add":
- if(!$this->bQueued)
+ if(!$this->sQueued == 'true')
{
$sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname;
$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;
$sMsg .= "This application has been queued.";
$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;
case "edit":
@@ -343,6 +396,18 @@ class Application {
addmsg("Application deleted.", "green");
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);
if($sEmail)
diff --git a/include/sidebar_login.php b/include/sidebar_login.php
index 7d1b195..dbe7141 100644
--- a/include/sidebar_login.php
+++ b/include/sidebar_login.php
@@ -5,7 +5,7 @@
require_once(BASE."include/maintainer.php");
require_once(BASE."include/application.php");
-
+require_once(BASE."include/user.php");
function global_sidebar_login() {
@@ -32,6 +32,10 @@ function global_sidebar_login() {
$g->addmisc("".lookup_app_name($appId)." ".lookup_version_name($versionId)."", "center");
}
}
+ $appsRejected = $_SESSION['current']->getAllRejectedApps();
+ if($appsRejected)
+ $g->addmisc("Review Rejected Apps", "center");
+
}
else
{
diff --git a/include/user.php b/include/user.php
index 50a8747..a32afad 100644
--- a/include/user.php
+++ b/include/user.php
@@ -533,6 +533,60 @@ class User {
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?
*/
@@ -553,6 +607,30 @@ class User {
else
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;
+ }
}
diff --git a/include/version.php b/include/version.php
index 0e45e26..6879360 100644
--- a/include/version.php
+++ b/include/version.php
@@ -22,6 +22,7 @@ class Version {
var $sSubmitTime;
var $iSubmitterId;
var $sDate;
+ var $sQueued;
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 $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->sTestedRating = $oRow->maintainer_rating;
$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.
if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSupermaintainer($iAppId)))
- $this->bQueued = true;
+ $this->sQueued = 'true';
else
- $this->bQueued = false;
+ $this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'versionName' => $sName,
'description' => $sDescription,
@@ -150,7 +151,7 @@ class Version {
'maintainer_rating' => $sTestedRating,
'appId' => $iAppId,
'submitterId' => $_SESSION['current']->iUserId,
- 'queued' => $this->bQueued?"true":"false" ));
+ 'queued' => $this->sQueued ));
$sFields = "({$aInsert['FIELDS']})";
$sValues = "({$aInsert['VALUES']})";
@@ -249,7 +250,9 @@ class Version {
function delete($bSilent=false)
{
/* 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;
}
@@ -300,7 +303,7 @@ class Version {
if(!$bSilent)
$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(!$this->bQueued)
+ if(!$this->sQueued == 'true')
return false;
$sUpdate = compile_update_string(array('queued' => "false"));
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
- $this->mailSubmitter();
+ $this->mailSubmitter("unQueue");
$this->mailMaintainers();
// 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)
{
$oApp = new Application($this->appId);
$oSubmitter = new User($this->iSubmitterId);
- if(!$bRejected)
+ switch($sAction)
{
- $sSubject = "Submitted version accepted";
- $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been accepted.";
- } else
- {
- $sSubject = "Submitted version rejected";
- $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been rejected.";
+ case "add":
+ {
+ $sSubject = "Submitted version accepted";
+ $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been accepted.";
+ }
+ 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 .= "We appreciate your help in making the Version Database better for all users.";
-
+
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
}
}
@@ -362,7 +431,7 @@ class Version {
switch($sAction)
{
case "add":
- if(!$this->bQueued)
+ if($this->sQueued == "false")
{
$sSubject = "Version ".$this->sName." of ".$oApp->sName." added by ".$_SESSION['current']->sRealname;
$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;
$sMsg .= "This version has been queued.";
$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;
case "edit":
@@ -400,6 +469,20 @@ class Version {
addmsg("Version deleted.", "green");
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);
if($sEmail)
diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql
index 9e5daed..a3a1245 100644
--- a/tables/appdb_tables.sql
+++ b/tables/appdb_tables.sql
@@ -41,7 +41,7 @@ create table appFamily (
catId int,
submitTime timestamp(14) NOT NULL,
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)
);
@@ -58,7 +58,7 @@ create table appVersion (
maintainer_release text,
submitTime timestamp(14) NOT NULL,
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)
);