Add the ability for user to monitor changes to applications
This commit is contained in:
@@ -136,7 +136,7 @@ class Application {
|
||||
{
|
||||
$this->iAppId = mysql_insert_id();
|
||||
$this->application($this->iAppId);
|
||||
$this->mailSupermaintainers(); // Only administrators will be mailed as no supermaintainers exist for this app.
|
||||
$this->SendNotificationMail(); // Only administrators will be mailed as no supermaintainers exist for this app.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -210,7 +210,7 @@ class Application {
|
||||
$this->iCatId = $iCatId;
|
||||
}
|
||||
if($sWhatChanged)
|
||||
$this->mailSupermaintainers("edit",$sWhatChanged);
|
||||
$this->SendNotificationMail("edit",$sWhatChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ class Application {
|
||||
}
|
||||
|
||||
if(!$bSilent)
|
||||
$this->mailSupermaintainers("delete");
|
||||
$this->SendNotificationMail("delete");
|
||||
}
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ class Application {
|
||||
$this->sQueued = 'false';
|
||||
// we send an e-mail to intersted people
|
||||
$this->mailSubmitter();
|
||||
$this->mailSupermaintainers();
|
||||
$this->SendNotificationMail();
|
||||
|
||||
// the application has been unqueued
|
||||
addmsg("The application has been unqueued.", "green");
|
||||
@@ -291,7 +291,7 @@ class Application {
|
||||
$this->sQueued = 'rejected';
|
||||
// we send an e-mail to intersted people
|
||||
$this->mailSubmitter("reject");
|
||||
$this->mailSupermaintainers("reject");
|
||||
$this->SendNotificationMail("reject");
|
||||
|
||||
// the application has been rejectedd
|
||||
addmsg("The application has been rejected.", "green");
|
||||
@@ -308,7 +308,7 @@ class Application {
|
||||
{
|
||||
$this->sQueued = 'true';
|
||||
// we send an e-mail to intersted people
|
||||
$this->mailSupermaintainers();
|
||||
$this->SendNotificationMail();
|
||||
|
||||
// the application has been re-queued
|
||||
addmsg("The application has been re-queued.", "green");
|
||||
@@ -355,7 +355,7 @@ class Application {
|
||||
}
|
||||
|
||||
|
||||
function mailSupermaintainers($sAction="add",$sMsg=null)
|
||||
function SendNotificationMail($sAction="add",$sMsg=null)
|
||||
{
|
||||
switch($sAction)
|
||||
{
|
||||
|
||||
@@ -136,7 +136,7 @@ class Bug {
|
||||
}
|
||||
/*End of Hack */
|
||||
|
||||
$this->mailMaintainers();
|
||||
$this->SendNotificationMail();
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
@@ -156,7 +156,7 @@ class Bug {
|
||||
if($hResult = query_appdb($sQuery))
|
||||
{
|
||||
if(!$bSilent)
|
||||
$this->mailMaintainers(true);
|
||||
$this->SendNotificationMail(true);
|
||||
}
|
||||
if($this->iSubmitterId)
|
||||
{
|
||||
@@ -181,7 +181,7 @@ class Bug {
|
||||
$this->bQueued = false;
|
||||
// we send an e-mail to intersted people
|
||||
$this->mailSubmitter();
|
||||
$this->mailMaintainers();
|
||||
$this->SendNotificationMail();
|
||||
// the Bug has been unqueued
|
||||
addmsg("The Bug has been unqueued.", "green");
|
||||
}
|
||||
@@ -210,7 +210,7 @@ class Bug {
|
||||
}
|
||||
|
||||
|
||||
function mailMaintainers($bDeleted=false)
|
||||
function SendNotificationMail($bDeleted=false)
|
||||
{
|
||||
if(!$bDeleted)
|
||||
{
|
||||
|
||||
134
include/monitor.php
Normal file
134
include/monitor.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/***************************************/
|
||||
/* Monitor class and related functions */
|
||||
/***************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Monitor class for handling Monitors
|
||||
*/
|
||||
class Monitor {
|
||||
var $iMonitorId;
|
||||
var $iAppId;
|
||||
var $iVersionId;
|
||||
var $iUserId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* If $iMonitorId is provided, fetches Monitor.
|
||||
*/
|
||||
function Monitor($iMonitorId="")
|
||||
{
|
||||
if($iMonitorId)
|
||||
{
|
||||
$sQuery = "SELECT *
|
||||
FROM appMonitors
|
||||
WHERE MonitorId = '".$iMonitorId."'";
|
||||
$hResult = query_appdb($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
$this->iMonitorId = $oRow->monitorId;
|
||||
$this->iAppId = $oRow->appId;
|
||||
$this->iVersionId = $oRow->versionId;
|
||||
$this->iUserId = $oRow->userId;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function find($iUserId, $iAppId=0, $iVersionId=0)
|
||||
{
|
||||
if($iUserId)
|
||||
{
|
||||
if($iVersionId)
|
||||
{
|
||||
$sQuery = "SELECT *
|
||||
FROM appMonitors
|
||||
WHERE userId = '".$iUserId."'
|
||||
AND versionId = '".$iVersionId."'";
|
||||
$hResult = query_appdb($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
$this->iMonitorId = $oRow->monitorId;
|
||||
$this->iAppId = $oRow->appId;
|
||||
$this->iVersionId = $oRow->versionId;
|
||||
$this->iUserId = $oRow->userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a new Monitor.
|
||||
* Informs interested people about the creation.
|
||||
* Returns true on success, false on failure
|
||||
*/
|
||||
function create($iUserId, $iAppId=0, $iVersionId=0)
|
||||
{
|
||||
$aInsert = compile_insert_string(array( 'versionId' => $iVersionId,
|
||||
'appId' => $iAppId,
|
||||
'userId' => $iUserId ));
|
||||
|
||||
$sFields = "({$aInsert['FIELDS']})";
|
||||
$sValues = "({$aInsert['VALUES']})";
|
||||
if(query_appdb("INSERT INTO appMonitors $sFields VALUES $sValues", "Error while creating a new Monitor."))
|
||||
{
|
||||
$this->Monitor(mysql_insert_id());
|
||||
$sWhatChanged = "New monitor\n\n";
|
||||
$this->SendNotificationMail("add", $sWhatChanged);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the current Monitor from the database.
|
||||
* Informs interested people about the deletion.
|
||||
*/
|
||||
function delete($bSilent=false)
|
||||
{
|
||||
$hResult = query_appdb("DELETE FROM appMonitors WHERE MonitorId = '".$this->iMonitorId."'");
|
||||
if(!$bSilent)
|
||||
$this->SendNotificationMail("delete");
|
||||
}
|
||||
|
||||
|
||||
function SendNotificationMail($sAction="add",$sMsg=null)
|
||||
{
|
||||
switch($sAction)
|
||||
{
|
||||
case "add":
|
||||
if (isset($this->iVersionId))
|
||||
{
|
||||
$oVersion = new Version($this->iVersionId);
|
||||
$sSubject = "Monitor for ".lookup_app_name($oVersion->iAppId)." ".lookup_version_name($this->iVersionId);
|
||||
$sSubject .= " added: ".$_SESSION['current']->sRealname;
|
||||
$sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
|
||||
addmsg("You will now recieve an email whenever changes are made to this Application version.", "green");
|
||||
} else
|
||||
{
|
||||
$sSubject = "Monitor for ".lookup_app_name($this->iAppId)." added: ".$_SESSION['current']->sRealname;
|
||||
$sMsg .= APPDB_ROOT."appview.php?appId=".$this->iAppid."\n";
|
||||
addmsg("You will now recieve an email whenever changes are made to this Application.", "green");
|
||||
}
|
||||
break;
|
||||
case "delete":
|
||||
if (isset($this->iVersionId))
|
||||
{
|
||||
$oVersion = new Version($this->iVersionId);
|
||||
$sSubject = "Monitor for ".lookup_app_name($oVersion->iAppId)." ".lookup_version_name($this->iVersionId);
|
||||
$sSubject .= " removed: ".$_SESSION['current']->sRealname;
|
||||
$sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
|
||||
addmsg("You will no longer recieve an email whenever changes are made to this Application version.", "green");
|
||||
} else
|
||||
{
|
||||
$sSubject = "Monitor for ".lookup_app_name($this->iAppId)." removed: ".$_SESSION['current']->sRealname;
|
||||
$sMsg .= APPDB_ROOT."appview.php?appId=".$this->iAppid."\n";
|
||||
addmsg("You will no longer recieve an email whenever changes are made to this Application.", "green");
|
||||
}
|
||||
break;
|
||||
}
|
||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
||||
if($sEmail)
|
||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -55,7 +55,7 @@ class Note {
|
||||
{
|
||||
$this->note(mysql_insert_id());
|
||||
$sWhatChanged = "Description is:\n".$sDescription.".\n\n";
|
||||
$this->mailMaintainers("add", $sWhatChanged);
|
||||
$this->SendNotificationMail("add", $sWhatChanged);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -101,7 +101,7 @@ class Note {
|
||||
$this->iAppId = $oVersionAfter->iAppId;
|
||||
}
|
||||
if($sWhatChanged)
|
||||
$this->mailMaintainers("edit",$sWhatChanged);
|
||||
$this->SendNotificationMail("edit",$sWhatChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -114,11 +114,11 @@ class Note {
|
||||
{
|
||||
$hResult = query_appdb("DELETE FROM appNotes WHERE noteId = '".$this->iNoteId."'");
|
||||
if(!$bSilent)
|
||||
$this->mailMaintainers("delete");
|
||||
$this->SendNotificationMail("delete");
|
||||
}
|
||||
|
||||
|
||||
function mailMaintainers($sAction="add",$sMsg=null)
|
||||
function SendNotificationMail($sAction="add",$sMsg=null)
|
||||
{
|
||||
switch($sAction)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ class Url {
|
||||
{
|
||||
$this->iUrlId = mysql_insert_id();
|
||||
$this->url($this->iUrlId,$this->bQueued);
|
||||
$this->mailMaintainers();
|
||||
$this->SendNotificationMail();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -91,7 +91,7 @@ class Url {
|
||||
if($hResult = query_appdb($sQuery))
|
||||
{
|
||||
if(!$bSilent)
|
||||
$this->mailMaintainers(true);
|
||||
$this->SendNotificationMail(true);
|
||||
}
|
||||
if($this->iSubmitterId)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ class Url {
|
||||
{
|
||||
// we send an e-mail to intersted people
|
||||
$this->mailSubmitter();
|
||||
$this->mailMaintainers();
|
||||
$this->SendNotificationMail();
|
||||
// the url has been unqueued
|
||||
addmsg("The url has been unqueued.", "green");
|
||||
}
|
||||
@@ -170,7 +170,7 @@ class Url {
|
||||
$this->iAppId = $iAppId;
|
||||
}
|
||||
if($sWhatChanged)
|
||||
$this->mailMaintainers("edit",$sWhatChanged);
|
||||
$this->SendNotificationMail("edit",$sWhatChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class Url {
|
||||
}
|
||||
|
||||
|
||||
function mailMaintainers($bDeleted=false)
|
||||
function SendNotificationMail($bDeleted=false)
|
||||
{
|
||||
if(!$bDeleted)
|
||||
{
|
||||
|
||||
@@ -794,6 +794,41 @@ function get_notify_email_address_list($iAppId = null, $iVersionId = null)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve version Monitors.
|
||||
*/
|
||||
/*
|
||||
* If versionId was supplied we fetch superMonitors of application and Monitors of version.
|
||||
*/
|
||||
if($iVersionId)
|
||||
{
|
||||
$sQuery = "SELECT appMonitors.userId
|
||||
FROM appMonitors, appVersion
|
||||
WHERE appVersion.appId = appMonitors.appId
|
||||
AND appVersion.versionId = '".$iVersionId."'";
|
||||
}
|
||||
/*
|
||||
* If versionId was not supplied we fetch superMonitors of application and Monitors of all versions.
|
||||
*/
|
||||
elseif($iAppId)
|
||||
{
|
||||
$sQuery = "SELECT userId
|
||||
FROM appMonitors
|
||||
WHERE appId = '".$iAppId."'";
|
||||
}
|
||||
if($sQuery)
|
||||
{
|
||||
$hResult = query_appdb($sQuery);
|
||||
if(mysql_num_rows($hResult) > 0)
|
||||
{
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$aUserId[$c] = array($oRow->userId);
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve administrators.
|
||||
*/
|
||||
|
||||
@@ -159,7 +159,7 @@ class Version {
|
||||
{
|
||||
$this->iVersionId = mysql_insert_id();
|
||||
$this->version($this->iVersionId);
|
||||
$this->mailMaintainers();
|
||||
$this->SendNotificationMail();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -238,7 +238,7 @@ class Version {
|
||||
$this->iAppId = $iAppId;
|
||||
}
|
||||
if($sWhatChanged)
|
||||
$this->mailMaintainers("edit",$sWhatChanged);
|
||||
$this->SendNotificationMail("edit",$sWhatChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ class Version {
|
||||
}
|
||||
|
||||
if(!$bSilent)
|
||||
$this->mailMaintainers("delete");
|
||||
$this->SendNotificationMail("delete");
|
||||
|
||||
$this->mailSubmitter("delete");
|
||||
}
|
||||
@@ -328,7 +328,7 @@ class Version {
|
||||
$this->sQueued = 'false';
|
||||
// we send an e-mail to intersted people
|
||||
$this->mailSubmitter("unQueue");
|
||||
$this->mailMaintainers();
|
||||
$this->SendNotificationMail();
|
||||
|
||||
// the version has been unqueued
|
||||
addmsg("The version has been unqueued.", "green");
|
||||
@@ -355,7 +355,7 @@ class Version {
|
||||
if(!$bSilent)
|
||||
{
|
||||
$this->mailSubmitter("reject");
|
||||
$this->mailMaintainers("reject");
|
||||
$this->SendNotificationMail("reject");
|
||||
}
|
||||
// the version has been unqueued
|
||||
addmsg("The version has been rejected.", "green");
|
||||
@@ -377,7 +377,7 @@ class Version {
|
||||
{
|
||||
$this->sQueued = 'true';
|
||||
// we send an e-mail to intersted people
|
||||
$this->mailMaintainers();
|
||||
$this->SendNotificationMail();
|
||||
|
||||
// the version has been unqueued
|
||||
addmsg("The version has been re-submitted", "green");
|
||||
@@ -425,7 +425,7 @@ class Version {
|
||||
}
|
||||
|
||||
|
||||
function mailMaintainers($sAction="add",$sMsg=null)
|
||||
function SendNotificationMail($sAction="add",$sMsg=null)
|
||||
{
|
||||
$oApp = new Application($this->iAppId);
|
||||
switch($sAction)
|
||||
|
||||
Reference in New Issue
Block a user