2004-12-12 03:51:51 +00:00
|
|
|
<?php
|
|
|
|
|
/*****************************/
|
|
|
|
|
/* functions for maintainers */
|
|
|
|
|
/*****************************/
|
2006-08-21 18:57:44 +00:00
|
|
|
require_once(BASE."include/application.php");
|
|
|
|
|
require_once(BASE."include/version.php");
|
2006-09-01 02:23:24 +00:00
|
|
|
require_once(BASE."include/user.php");
|
2004-11-09 22:41:18 +00:00
|
|
|
|
2007-07-20 22:24:37 +00:00
|
|
|
//FIXME: when we have php5 move this into the maintainer class as a constant var
|
|
|
|
|
define('iNotificationIntervalDays', 7); // days between each notification level
|
|
|
|
|
|
|
|
|
|
// class that can retrieve the queued entries for a given maintainer instance
|
|
|
|
|
class queuedEntries
|
|
|
|
|
{
|
|
|
|
|
var $aVersionIds;
|
|
|
|
|
var $aScreenshotIds;
|
|
|
|
|
var $aTestDataIds;
|
|
|
|
|
|
|
|
|
|
var $oMaintainer; // the maintainer we are retrieving entries for
|
|
|
|
|
|
|
|
|
|
function queuedEntries($oMaintainer)
|
|
|
|
|
{
|
|
|
|
|
$this->oMaintainer = $oMaintainer;
|
|
|
|
|
|
|
|
|
|
$this->aVersionIds = array();
|
|
|
|
|
$this->aScreenshotIds = array();
|
|
|
|
|
$this->aTestDataIds = array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// returns true if none of the arrays have any entries in them
|
|
|
|
|
function isEmpty()
|
|
|
|
|
{
|
|
|
|
|
if((count($this->aVersionIds) == 0) &&
|
|
|
|
|
(count($this->aScreenshotIds) == 0) &&
|
|
|
|
|
(count($this->aTestDataIds) == 0))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function retrieveQueuedEntries()
|
|
|
|
|
{
|
|
|
|
|
$bDebugOutputEnabled = false;
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "retrieveQueuedEntries() starting\n";
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
|
// retrieve a list of versions to check for queued data
|
|
|
|
|
$aVersionsToCheck = array();
|
|
|
|
|
if($this->oMaintainer->bSuperMaintainer)
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "maintainer is super maintainer\n";
|
|
|
|
|
|
|
|
|
|
$oApp = new Application($this->oMaintainer->iAppId);
|
|
|
|
|
|
|
|
|
|
//TODO: would like to rely on the constructor but we might be a user with 'admin'
|
|
|
|
|
// privileges and that would mean we would end up retrieved queued versions for
|
|
|
|
|
// this application or unqueued versions depending on which user we were
|
|
|
|
|
$hResult = $oApp->_internal_retrieve_all_versions();
|
|
|
|
|
|
|
|
|
|
while($oVersionRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
{
|
|
|
|
|
echo "oVersionRow is: ";
|
|
|
|
|
print_r($oVersionRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$oVersion = new Version($oVersionRow->versionId);
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
{
|
|
|
|
|
echo "Processing version: ";
|
|
|
|
|
print_r($oVersion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($oVersion->sQueued == "true")
|
|
|
|
|
{
|
|
|
|
|
$this->aVersions[] = $oVersion->objectGetId();
|
|
|
|
|
} else // version isn't queued
|
|
|
|
|
{
|
|
|
|
|
// add the unqueued version to the list of versions to check for queued data
|
|
|
|
|
$aVersionsToCheck[] = $oVersion->iVersionId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else // just a normal maintainer
|
|
|
|
|
{
|
|
|
|
|
$aVersionsToCheck[] = $this->oMaintainer->iVersionId;
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "Normal maintainer of version ".$this->oMaintainer->iVersionId."\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// go through all of the verions to see what queued data they have
|
|
|
|
|
foreach($aVersionsToCheck as $iVersionId)
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "Processing iVersionId of ".$iVersionId."\n";
|
|
|
|
|
|
|
|
|
|
//////////////////
|
|
|
|
|
// queued testdata
|
|
|
|
|
|
|
|
|
|
// retrieve queued testdata for this version
|
|
|
|
|
$sQuery = "select * from testResults where versionId = '?' and queued = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $iVersionId, "true");
|
|
|
|
|
|
|
|
|
|
// go through the test results looking for the oldest queued data
|
|
|
|
|
while($oTestingRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "\tQueued TestData found\n";
|
|
|
|
|
$oTestData = new TestData(null, $oTestingRow);
|
|
|
|
|
|
|
|
|
|
$this->aTestDataIds[] = $oTestData->objectGetId();
|
|
|
|
|
}
|
|
|
|
|
// queued testdata
|
|
|
|
|
//////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////
|
|
|
|
|
// queued screenshots
|
|
|
|
|
$sQuery = "select * from appData where type = 'screenshot' and versionId = '?' and queued = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $iVersionId, "true");
|
|
|
|
|
while($oScreenshotRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
$oScreenshot = new Screenshot(null, $oScreenshotRow);
|
|
|
|
|
|
|
|
|
|
$this->aScreenshotIds[] = $oScreenshot->objectGetId();
|
|
|
|
|
}
|
|
|
|
|
// queued screenshots
|
|
|
|
|
//////////////////////
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-21 23:49:36 +00:00
|
|
|
// contains the results of a notification update so other logic
|
|
|
|
|
// can act on these results
|
|
|
|
|
class notificationUpdate
|
|
|
|
|
{
|
|
|
|
|
var $sEmail;
|
|
|
|
|
var $sSubject;
|
|
|
|
|
var $sMsg; // contents of the email we will send to the maintainer
|
|
|
|
|
var $iTargetLevel; // the target notification level based upon the
|
|
|
|
|
// maintiners queued entries
|
|
|
|
|
|
|
|
|
|
function notificationUpdate($sEmail, $sSubject, $sMsg, $iTargetLevel)
|
|
|
|
|
{
|
|
|
|
|
$this->sEmail = $sEmail;
|
|
|
|
|
$this->sSubject = $sSubject;
|
|
|
|
|
$this->sMsg = $sMsg;
|
|
|
|
|
$this->iTargetLevel = $iTargetLevel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
class maintainer
|
2004-12-10 00:18:01 +00:00
|
|
|
{
|
2006-07-24 16:20:40 +00:00
|
|
|
var $iMaintainerId;
|
|
|
|
|
var $iAppId;
|
|
|
|
|
var $iVersionId;
|
|
|
|
|
var $iUserId;
|
|
|
|
|
var $sMaintainReason;
|
|
|
|
|
var $bSuperMaintainer;
|
2007-07-20 22:24:37 +00:00
|
|
|
var $aSubmitTime; //FIXME: should be 'sSubmitTime'
|
2006-07-24 16:20:40 +00:00
|
|
|
var $bQueued;
|
2007-03-04 23:22:57 +00:00
|
|
|
var $sReplyText;
|
2006-07-24 16:20:40 +00:00
|
|
|
|
2007-07-20 22:24:37 +00:00
|
|
|
// parameters used in the queued data notification system
|
|
|
|
|
// that lets maintainers know that their applications/versions have
|
|
|
|
|
// queued data for them to process
|
|
|
|
|
var $iNotificationLevel; // the current warning level of this maintainer
|
|
|
|
|
var $sNotificationTime; // the time when we last warned this maintainer
|
|
|
|
|
|
2007-06-10 18:51:33 +00:00
|
|
|
function maintainer($iMaintainerId = null, $oRow = null)
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
2007-07-20 22:24:37 +00:00
|
|
|
// set a default notification level of 0
|
|
|
|
|
$this->iNotificationLevel = 0;
|
|
|
|
|
|
2007-06-10 18:51:33 +00:00
|
|
|
if(!$iMaintainerId && !$oRow)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(!$oRow)
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
2007-06-10 18:51:33 +00:00
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE maintainerId = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $iMaintainerId);
|
|
|
|
|
if($hResult)
|
|
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($oRow)
|
|
|
|
|
{
|
|
|
|
|
$this->iMaintainerId = $oRow->maintainerId;
|
|
|
|
|
$this->iAppId = $oRow->appId;
|
|
|
|
|
$this->iVersionId = $oRow->versionId;
|
|
|
|
|
$this->iUserId = $oRow->userId;
|
|
|
|
|
$this->sMaintainReason = $oRow->maintainReason;
|
|
|
|
|
$this->bSuperMaintainer = $oRow->superMaintainer;
|
|
|
|
|
$this->aSubmitTime = $oRow->submitTime;
|
|
|
|
|
$this->bQueued = $oRow->queued;
|
2007-07-20 22:24:37 +00:00
|
|
|
|
|
|
|
|
$this->iNotificationLevel = $oRow->notificationLevel;
|
|
|
|
|
$this->sNotificationTime = $oRow->notificationTime;
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function create()
|
|
|
|
|
{
|
|
|
|
|
/* user id, appid, and maintain reason must be valid to continue */
|
|
|
|
|
if(!$this->iUserId || !$this->iAppId || !$this->sMaintainReason)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
$hResult = query_parameters("INSERT INTO appMaintainers (appId, versionId, ".
|
|
|
|
|
"userId, maintainReason, superMaintainer, submitTime, queued) ".
|
|
|
|
|
"VALUES ('?', '?', '?', '?', '?', ?, '?')",
|
|
|
|
|
$this->iAppId, $this->iVersionId,
|
|
|
|
|
$this->iUserId, $this->sMaintainReason,
|
2006-12-09 04:34:07 +00:00
|
|
|
$this->bSuperMaintainer, "NOW()", $this->mustBeQueued() ? "true" : "false");
|
2006-07-24 16:20:40 +00:00
|
|
|
|
|
|
|
|
/* this objects id is the insert id returned by mysql */
|
|
|
|
|
$this->iMaintainerId = mysql_insert_id();
|
|
|
|
|
|
2007-04-01 00:08:12 +00:00
|
|
|
/* If this is a non-queued maintainer submission, remove the user's non-
|
|
|
|
|
super maintainer entries for the application's versions. This check is
|
|
|
|
|
also done in unQueue() */
|
|
|
|
|
if(!$this->mustBeQueued() & $this->bSuperMaintainer)
|
|
|
|
|
$this->removeUserFromAppVersions();
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
return $hResult;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-04 23:22:57 +00:00
|
|
|
function unQueue()
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
|
|
|
|
/* if the user isn't already a supermaintainer of the application and */
|
|
|
|
|
/* if they are trying to become a maintainer and aren't already a maintainer of */
|
|
|
|
|
/* the version, then continue processing the request */
|
|
|
|
|
|
|
|
|
|
$oUser = new User($this->iUserId);
|
|
|
|
|
|
|
|
|
|
if(!$oUser->isSuperMaintainer($this->iAppId) &&
|
|
|
|
|
((!$this->bSuperMaintainer && !$oUser->isMaintainer($this->iVersionId)) | $this->bSuperMaintainer))
|
|
|
|
|
{
|
|
|
|
|
/* unqueue the maintainer entry */
|
|
|
|
|
$hResult = query_parameters("UPDATE appMaintainers SET queued='false' WHERE userId = '?' AND maintainerId = '?'",
|
|
|
|
|
$this->iUserId, $this->iMaintainerId);
|
|
|
|
|
|
|
|
|
|
if($hResult)
|
|
|
|
|
{
|
|
|
|
|
$sStatusMessage = "<p>The maintainer was successfully added into the database</p>\n";
|
|
|
|
|
|
|
|
|
|
//Send Status Email
|
|
|
|
|
$sEmail = $oUser->sEmail;
|
|
|
|
|
if ($sEmail)
|
|
|
|
|
{
|
2006-12-30 06:13:46 +00:00
|
|
|
if($this->iVersionId)
|
2007-04-08 23:04:31 +00:00
|
|
|
{
|
|
|
|
|
$oVersion = new Version($this->iVersionId);
|
|
|
|
|
$sURL = $oVersion->objectMakeUrl();
|
|
|
|
|
$sName = version::fullName($this->iVersionId);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$oApp = new Application($this->iAppId);
|
|
|
|
|
$sURL = $oApp->objectMakeUrl();
|
|
|
|
|
$sName = $oApp->sName;
|
|
|
|
|
}
|
2006-12-30 06:13:46 +00:00
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
$sSubject = "Application Maintainer Request Report";
|
2007-04-08 23:04:31 +00:00
|
|
|
$sMsg = "Your application to be the maintainer of $sName has been accepted.\n";
|
2006-12-30 06:13:46 +00:00
|
|
|
$sMsg .= "$sURL\n";
|
2007-03-04 23:22:57 +00:00
|
|
|
$sMsg .= "$this->sReplyText\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
$sMsg .= "We appreciate your help in making the Application Database better for all users.\n\n";
|
|
|
|
|
|
|
|
|
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
2006-12-30 06:13:46 +00:00
|
|
|
}
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
{
|
2006-12-03 16:26:38 +00:00
|
|
|
/* Delete entry, but only if queued */
|
|
|
|
|
query_parameters("DELETE from appMaintainers WHERE userId = '?' AND maintainerId = '?' AND queued = 'true'", $this->iUserId, $this->iMaintainerId);
|
2006-07-24 16:20:40 +00:00
|
|
|
|
|
|
|
|
if($oUser->isSuperMaintainer($this->iAppId) && !$this->bSuperMaintainer)
|
|
|
|
|
$sStatusMessage = "<p>User is already a super maintainer of this application</p>\n";
|
|
|
|
|
else
|
|
|
|
|
$sStatusMessage = "<p>User is already a maintainer/super maintainer of this application/version</p>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-01 00:08:12 +00:00
|
|
|
/* Delete any maintainer entries the user had for the application's versions,
|
|
|
|
|
if this is a super maintainer request */
|
|
|
|
|
if($this->bSuperMaintainer)
|
|
|
|
|
$this->removeUserFromAppVersions();
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
return $sStatusMessage;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-04 23:22:57 +00:00
|
|
|
function reject()
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
|
|
|
|
$oUser = new User($this->iUserId);
|
|
|
|
|
$sEmail = $oUser->sEmail;
|
|
|
|
|
if ($sEmail)
|
|
|
|
|
{
|
|
|
|
|
$oApp = new Application($oRow->appId);
|
|
|
|
|
$oVersion = new Version($oRow->versionId);
|
|
|
|
|
$sSubject = "Application Maintainer Request Report";
|
|
|
|
|
$sMsg = "Your application to be the maintainer of ".$oApp->sName." ".$oVersion->sName." was rejected. ";
|
2007-03-04 23:22:57 +00:00
|
|
|
$sMsg .= $this->sReplyText;
|
2006-07-24 16:20:40 +00:00
|
|
|
$sMsg .= "";
|
|
|
|
|
$sMsg .= "-The AppDB admins\n";
|
2007-03-04 23:22:57 +00:00
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//delete main item
|
|
|
|
|
$sQuery = "DELETE from appMaintainers where maintainerId = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $this->iMaintainerId);
|
|
|
|
|
|
|
|
|
|
return $hResult;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-09 04:34:07 +00:00
|
|
|
function mustBeQueued()
|
|
|
|
|
{
|
|
|
|
|
/* In place for future fine-grained permisson system, only allow admins for now */
|
|
|
|
|
if($_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
else
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
function delete()
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "DELETE from appMaintainers where maintainerId = '?'";
|
2007-07-24 21:52:55 +00:00
|
|
|
$hResult = query_parameters($sQuery, $this->iMaintainerId);
|
|
|
|
|
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteMaintainer($oUser, $iAppId = null, $iVersionId = null)
|
2004-12-10 00:18:01 +00:00
|
|
|
{
|
2006-07-24 16:20:40 +00:00
|
|
|
/* remove supermaintainer */
|
|
|
|
|
if($iAppId && ($iVersionId == null))
|
|
|
|
|
{
|
|
|
|
|
$superMaintainer = 1;
|
|
|
|
|
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'
|
|
|
|
|
AND appId = '?' AND superMaintainer = '?'",
|
|
|
|
|
$oUser->iUserId, $iAppId, $superMaintainer);
|
|
|
|
|
} else if($iAppId && $iVersionId) /* remove a normal maintainer */
|
|
|
|
|
{
|
|
|
|
|
$superMaintainer = 0;
|
|
|
|
|
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'
|
|
|
|
|
AND appId = '?' AND versionId = '?' AND superMaintainer = '?'",
|
|
|
|
|
$oUser->iUserId, $iAppId, $iVersionId, $superMaintainer);
|
|
|
|
|
} else if(($iAppId == null) && ($iVersionId == null)) /* remove all maintainership by this user */
|
|
|
|
|
{
|
|
|
|
|
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'",
|
|
|
|
|
$oUser->iUserId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($hResult)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteMaintainersForVersion($oVersion)
|
|
|
|
|
{
|
2007-01-24 04:10:05 +00:00
|
|
|
if(!$oVersion->iVersionId)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
$hResult = query_parameters("DELETE from appMaintainers WHERE versionId='?'",
|
|
|
|
|
$oVersion->iVersionId);
|
2007-03-25 20:29:58 +00:00
|
|
|
return $hResult;
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteMaintainersForApplication($oApp)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "DELETE from appMaintainers WHERE appId='?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $oApp->iAppId);
|
|
|
|
|
return $hResult;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-24 18:30:16 +00:00
|
|
|
function ObjectGetEntries($bQueued, $bRejected)
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
2007-03-24 18:30:16 +00:00
|
|
|
/* Not implemented */
|
|
|
|
|
if($bRejected)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2007-01-20 17:41:43 +00:00
|
|
|
/* Excluding requests for queued apps and versions, as these will be
|
|
|
|
|
handled automatically */
|
2007-06-10 18:51:33 +00:00
|
|
|
$sQuery = "SELECT DISTINCT appMaintainers.* FROM
|
2007-03-17 00:51:20 +00:00
|
|
|
appMaintainers, appFamily, appVersion WHERE
|
|
|
|
|
appMaintainers.queued = '?'
|
|
|
|
|
AND
|
|
|
|
|
appFamily.appId = appVersion.appId
|
|
|
|
|
AND
|
|
|
|
|
(
|
|
|
|
|
(
|
|
|
|
|
appFamily.appId = appMaintainers.appId
|
|
|
|
|
AND
|
|
|
|
|
appFamily.queued = 'false'
|
|
|
|
|
AND
|
|
|
|
|
appMaintainers.versionId = ''
|
|
|
|
|
)
|
|
|
|
|
OR
|
|
|
|
|
(
|
|
|
|
|
appVersion.versionId = appMaintainers.versionId
|
|
|
|
|
AND
|
|
|
|
|
appVersion.queued = 'false'
|
|
|
|
|
)
|
|
|
|
|
)";
|
2006-07-24 16:20:40 +00:00
|
|
|
|
|
|
|
|
if($bQueued)
|
|
|
|
|
{
|
|
|
|
|
if($_SESSION['current']->hasPriv("admin"))
|
2007-03-17 00:51:20 +00:00
|
|
|
return query_parameters($sQuery, $bQueued ? "true" : "false");
|
2006-07-24 16:20:40 +00:00
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
return query_parameters($sQuery, $bQueued ? "true" : "false");
|
|
|
|
|
}
|
2004-12-10 00:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
/* retrieve a maintainer object from a row returned by */
|
|
|
|
|
/* ObjectGetEntries() */
|
|
|
|
|
function ObjectGetObjectFromObjectGetEntriesRow($oRow)
|
|
|
|
|
{
|
|
|
|
|
return new maintainer($oRow->maintainerId);
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-20 22:24:37 +00:00
|
|
|
// returns the number of applications/versions a particular user maintains
|
2006-07-24 16:20:40 +00:00
|
|
|
function getMaintainerCountForUser($oUser, $bSuperMaintainer)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT count(*) as cnt from appMaintainers WHERE userid = '?' AND superMaintainer = '?'".
|
|
|
|
|
" AND queued ='?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $oUser->iUserId, $bSuperMaintainer ? "1" : "0", "false");
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return 0;
|
|
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
return $oRow->cnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the applications and versions that this user maintains
|
|
|
|
|
*/
|
|
|
|
|
function getAppsMaintained($oUser)
|
|
|
|
|
{
|
|
|
|
|
/* retrieve the list of application and order them by application name */
|
|
|
|
|
$hResult = query_parameters("SELECT appMaintainers.appId, versionId, superMaintainer, appName FROM ".
|
|
|
|
|
"appFamily, appMaintainers WHERE appFamily.appId = appMaintainers.appId ".
|
|
|
|
|
"AND userId = '?' AND appMaintainers.queued = '?' ORDER BY appName",
|
|
|
|
|
$oUser->iUserId, "false");
|
|
|
|
|
if(!$hResult || mysql_num_rows($hResult) == 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
$aAppsMaintained = array();
|
|
|
|
|
$c = 0;
|
|
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
$aAppsMaintained[$c] = array($oRow->appId, $oRow->versionId, $oRow->superMaintainer);
|
|
|
|
|
$c++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $aAppsMaintained;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-24 18:30:16 +00:00
|
|
|
function objectGetEntriesCount($bQueued, $bRejected)
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
2007-03-24 18:30:16 +00:00
|
|
|
/* Not implemented */
|
|
|
|
|
if($bRejected)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2007-01-20 17:41:43 +00:00
|
|
|
/* Excluding requests for queued apps and versions, as these are handled
|
|
|
|
|
automatically. One SELECT for super maintainers, one for maintainers. */
|
2007-03-11 20:39:02 +00:00
|
|
|
$sQuery = "SELECT COUNT(DISTINCT maintainerId) as queued_maintainers FROM
|
|
|
|
|
appMaintainers, appFamily, appVersion WHERE
|
|
|
|
|
appMaintainers.queued = '?'
|
|
|
|
|
AND
|
|
|
|
|
appFamily.appId = appVersion.appId
|
|
|
|
|
AND
|
|
|
|
|
(
|
|
|
|
|
(
|
|
|
|
|
appFamily.appId = appMaintainers.appId
|
|
|
|
|
AND
|
|
|
|
|
appFamily.queued = 'false'
|
|
|
|
|
AND
|
|
|
|
|
appMaintainers.versionId = ''
|
|
|
|
|
)
|
|
|
|
|
OR
|
|
|
|
|
(
|
|
|
|
|
appVersion.versionId = appMaintainers.versionId
|
|
|
|
|
AND
|
|
|
|
|
appVersion.queued = 'false'
|
|
|
|
|
)
|
|
|
|
|
)";
|
|
|
|
|
|
|
|
|
|
if(!($hResult = query_parameters($sQuery, $bQueued ? "true" : "false")))
|
2007-01-20 17:41:43 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
$oRow = mysql_fetch_object($hResult);
|
2007-01-20 17:41:43 +00:00
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
return $oRow->queued_maintainers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* see how many maintainer entries we have in the database */
|
|
|
|
|
function getMaintainerCount()
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT count(*) as maintainers FROM appMaintainers where queued='false'";
|
|
|
|
|
$hResult = query_parameters($sQuery);
|
|
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
return $oRow->maintainers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* see how many unique maintainers we actually have */
|
|
|
|
|
function getNumberOfMaintainers()
|
|
|
|
|
{
|
|
|
|
|
$hResult = query_parameters("SELECT DISTINCT userId FROM appMaintainers WHERE queued='false';");
|
|
|
|
|
return mysql_num_rows($hResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isUserMaintainer($oUser, $iVersionId = null)
|
|
|
|
|
{
|
|
|
|
|
/* if we are a super maintainer, we are a maintainer of this version as well */
|
|
|
|
|
$oVersion = new Version($iVersionId);
|
|
|
|
|
if($oUser->isSuperMaintainer($oVersion->iAppId))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
/* otherwise check if we maintain this specific version */
|
|
|
|
|
if($iVersionId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND versionId = '?' AND queued = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $oUser->iUserId, $iVersionId, "false");
|
|
|
|
|
} else // are we maintaining any version ?
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND queued = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $oUser->iUserId, "false");
|
|
|
|
|
}
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return mysql_num_rows($hResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isUserSuperMaintainer($oUser, $iAppId = null)
|
|
|
|
|
{
|
|
|
|
|
if($iAppId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND appId = '?' AND superMaintainer = '1' AND queued = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $oUser->iUserId, $iAppId, "false");
|
|
|
|
|
} else /* are we super maintainer of any applications? */
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND superMaintainer = '1' AND queued = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $oUser->iUserId, "false");
|
|
|
|
|
}
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return false;
|
|
|
|
|
return mysql_num_rows($hResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if given an appid or a version id return a handle for a query that has */
|
|
|
|
|
/* the user ids that are maintainers for this particular appid or version id */
|
|
|
|
|
function getMaintainersForAppIdVersionId($iAppId = null, $iVersionId = null)
|
|
|
|
|
{
|
|
|
|
|
$hResult = null;
|
|
|
|
|
|
|
|
|
|
if($iVersionId)
|
|
|
|
|
{
|
2007-03-10 03:35:06 +00:00
|
|
|
$hResult = query_parameters("SELECT userId from appMaintainers, appVersion
|
2007-04-16 23:19:44 +00:00
|
|
|
WHERE
|
|
|
|
|
appMaintainers.queued = 'false'
|
|
|
|
|
AND
|
|
|
|
|
appVersion.versionId = '?'
|
|
|
|
|
AND
|
|
|
|
|
(
|
|
|
|
|
appMaintainers.versionId = appVersion.versionId
|
|
|
|
|
OR
|
|
|
|
|
(
|
|
|
|
|
appMaintainers.appId = appVersion.appId
|
|
|
|
|
AND superMaintainer = '1'
|
|
|
|
|
)
|
|
|
|
|
)", $iVersionId);
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions.
|
|
|
|
|
*/
|
|
|
|
|
elseif($iAppId)
|
|
|
|
|
{
|
|
|
|
|
$hResult = query_parameters("SELECT userId
|
|
|
|
|
FROM appMaintainers
|
|
|
|
|
WHERE appId = '?' AND queued = 'false'",
|
|
|
|
|
$iAppId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $hResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* get the userIds of super maintainers for this appId
|
|
|
|
|
*/
|
|
|
|
|
function getSuperMaintainersUserIdsFromAppId($iAppId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT userId FROM ".
|
|
|
|
|
"appMaintainers WHERE appId = '?' " .
|
|
|
|
|
"AND superMaintainer = '1' AND queued='?';";
|
|
|
|
|
$hResult = query_parameters($sQuery, $iAppId, "false");
|
|
|
|
|
$aUserIds = array();
|
|
|
|
|
$c = 0;
|
|
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
$aUserIds[$c] = $oRow->userId;
|
|
|
|
|
$c++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $aUserIds;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-17 21:04:43 +00:00
|
|
|
function ObjectGetHeader()
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
2007-03-04 23:22:57 +00:00
|
|
|
$aCells = array(
|
|
|
|
|
"Submission Date",
|
|
|
|
|
"Application Name",
|
|
|
|
|
"Version",
|
|
|
|
|
"Super maintainer?",
|
|
|
|
|
"Submitter");
|
|
|
|
|
|
2007-03-17 21:04:43 +00:00
|
|
|
return $aCells;
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 00:50:35 +00:00
|
|
|
function ObjectGetTableRow()
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
|
|
|
|
$oUser = new User($this->iUserId);
|
|
|
|
|
$oApp = new Application($this->iAppId);
|
|
|
|
|
$oVersion = new Version($this->iVersionId);
|
|
|
|
|
|
2007-07-23 19:56:43 +00:00
|
|
|
$oTableRow = new TableRow();
|
|
|
|
|
|
|
|
|
|
$oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->aSubmitTime)));
|
|
|
|
|
$oTableRow->AddTextCell($oApp->objectMakeLink());
|
|
|
|
|
$oTableRow->AddTextCell(($this->bSuperMaintainer) ? "N/A" : $oVersion->objectMakeLink());
|
|
|
|
|
$oTableRow->AddTextCell(($this->bSuperMaintainer) ? "Yes" : "No");
|
|
|
|
|
$oTableRow->AddTextCell($oUser->objectMakeLink());
|
|
|
|
|
|
|
|
|
|
$oOMTableRow = new OMTableRow($oTableRow);
|
|
|
|
|
return $oOMTableRow;
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ObjectDisplayQueueProcessingHelp()
|
|
|
|
|
{
|
|
|
|
|
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
|
|
|
|
|
echo "Please enter an accurate and personalized reply anytime a maintainer request is rejected.\n";
|
|
|
|
|
echo "Its not polite to reject someones attempt at trying to help out without explaining why.\n";
|
|
|
|
|
echo "</td></tr></table></div>\n\n";
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-04 23:22:57 +00:00
|
|
|
function canEdit()
|
|
|
|
|
{
|
|
|
|
|
if($_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-17 03:18:49 +00:00
|
|
|
function outputEditor()
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
|
|
|
|
//view application details
|
|
|
|
|
echo html_frame_start("New Maintainer Form",600,"",0);
|
|
|
|
|
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
2007-03-04 23:22:57 +00:00
|
|
|
echo "<input type=\"hidden\" name=\"iMaintainerId\" ".
|
|
|
|
|
"value=\"$this->iMaintainerId\" />";
|
2007-04-21 18:23:11 +00:00
|
|
|
|
|
|
|
|
/* User name */
|
|
|
|
|
$oSubmitter = new user($this->iUserId);
|
|
|
|
|
echo html_tr(array(
|
|
|
|
|
array("<b>User name</b>", 'style="text-align:right" class="color0"'),
|
|
|
|
|
$oSubmitter->objectMakeLink()
|
|
|
|
|
));
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
/**
|
|
|
|
|
* Show the other maintainers of this application, if there are any
|
|
|
|
|
*/
|
|
|
|
|
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>Other maintainers of this app:</b></td>',"\n";
|
|
|
|
|
|
2007-03-17 19:39:29 +00:00
|
|
|
/* Fetch maintainers and super maintainers */
|
|
|
|
|
$oVersion = new Version($this->iVersionId);
|
|
|
|
|
$aOtherMaintainers = $oVersion->getMaintainersUserIds();
|
|
|
|
|
$aOtherSuperMaintainers =
|
|
|
|
|
Maintainer::getSuperMaintainersUserIdsFromAppId($this->iAppId);
|
2006-07-24 16:20:40 +00:00
|
|
|
|
2007-03-17 19:39:29 +00:00
|
|
|
if($aOtherMaintainers || $aOtherSuperMaintainers)
|
|
|
|
|
$bFoundMaintainers = true;
|
|
|
|
|
else
|
|
|
|
|
$bFoundMaintainers = false;
|
2006-07-24 16:20:40 +00:00
|
|
|
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "<td>\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
/* display maintainers for the version */
|
2007-03-17 19:39:29 +00:00
|
|
|
if($aOtherMaintainers)
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
2007-03-17 19:39:29 +00:00
|
|
|
while(list($index, $iUserId) = each($aOtherMaintainers))
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
|
|
|
|
$oUser = new User($iUserId);
|
2007-05-13 16:54:33 +00:00
|
|
|
|
|
|
|
|
// because Version::getMaintainersUserIds() includes super maintainers
|
|
|
|
|
// we need to exclude these from the list of maintainers that we are
|
|
|
|
|
// building
|
|
|
|
|
if(!maintainer::isUserSuperMaintainer($oUser, $oVersion->iAppId))
|
|
|
|
|
echo "$oUser->sRealname<br />\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* display super maintainers for the given app */
|
2007-03-17 19:39:29 +00:00
|
|
|
|
|
|
|
|
if($aOtherSuperMaintainers)
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
2007-03-17 19:39:29 +00:00
|
|
|
while(list($index, $iUserId) = each($aOtherSuperMaintainers))
|
2006-07-24 16:20:40 +00:00
|
|
|
{
|
|
|
|
|
$oUser = new User($iUserId);
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "$oUser->sRealname*<br />\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!$bFoundMaintainers)
|
|
|
|
|
{
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "No other maintainers";
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "</td></tr>\n";
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
// Show which other apps the user maintains
|
2007-03-17 19:39:29 +00:00
|
|
|
echo '<tr valign="top"><td class="color0" style=\'text-align:right\'><b>This user also maintains these apps:</b></td><td>',"\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
|
|
|
|
|
$oUser = new User($this->iUserId);
|
|
|
|
|
$aOtherApps = Maintainer::getAppsMaintained($oUser);
|
|
|
|
|
if($aOtherApps)
|
|
|
|
|
{
|
|
|
|
|
while(list($index, list($iAppIdOther, $iVersionIdOther, $bSuperMaintainerOther)) = each($aOtherApps))
|
|
|
|
|
{
|
|
|
|
|
$oApp = new Application($iAppIdOther);
|
2007-03-17 19:39:29 +00:00
|
|
|
|
|
|
|
|
if($bSuperMaintainerOther)
|
|
|
|
|
echo $oApp->objectMakeLink()."*<br />\n";
|
|
|
|
|
else
|
|
|
|
|
echo $oVersion->fullNameLink($iVersionIdOther)."<br />\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
{
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "User maintains no other applications";
|
2006-07-24 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "</td></tr>\n";
|
|
|
|
|
|
2006-07-24 16:20:40 +00:00
|
|
|
$oApp = new Application($this->iAppId);
|
|
|
|
|
$oVersion = new Version($this->iVersionId);
|
|
|
|
|
|
|
|
|
|
//app name
|
|
|
|
|
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>App Name:</b></td>',"\n";
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "<td>".$oApp->objectMakeLink()."</td></tr>\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
|
|
|
|
|
//version
|
|
|
|
|
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>App Version:</b></td>',"\n";
|
2007-03-17 19:39:29 +00:00
|
|
|
echo "<td>".$oVersion->objectMakeLink()."</td></tr>\n";
|
2006-07-24 16:20:40 +00:00
|
|
|
|
|
|
|
|
//maintainReason
|
|
|
|
|
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>Maintainer request reason:</b></td>',"\n";
|
|
|
|
|
echo '<td><textarea name="sMaintainReason" rows=10 cols=35>'.$this->sMaintainReason.'</textarea></td></tr>',"\n";
|
|
|
|
|
echo '</table>';
|
|
|
|
|
|
|
|
|
|
echo html_frame_end(" ");
|
|
|
|
|
}
|
2007-03-04 23:22:57 +00:00
|
|
|
|
|
|
|
|
function ObjectGetId()
|
|
|
|
|
{
|
|
|
|
|
return $this->iMaintainerId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getOutputEditorValues($aClean)
|
|
|
|
|
{
|
|
|
|
|
$this->sReplyText = $aClean['sReplyText'];
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function update()
|
|
|
|
|
{
|
|
|
|
|
/* STUB: No updating possible at the moment */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDefaultReply()
|
|
|
|
|
{
|
|
|
|
|
$sReplyTextHelp = "Enter a personalized reason for accepting or rejecting the ".
|
|
|
|
|
"user's maintainer request here";
|
|
|
|
|
|
|
|
|
|
return $sReplyTextHelp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function objectHideDelete()
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2007-03-17 00:50:10 +00:00
|
|
|
|
|
|
|
|
function display()
|
|
|
|
|
{
|
|
|
|
|
/* STUB: There is not much use for this, but it may be implemented later */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function objectMakeUrl()
|
|
|
|
|
{
|
|
|
|
|
/* STUB: There is not much use for this, but it may be implemented later */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function objectMakeLink()
|
|
|
|
|
{
|
|
|
|
|
/* STUB: There is not much use for this, but it may be implemented later */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2007-04-01 00:08:12 +00:00
|
|
|
|
|
|
|
|
/* Delete a user's non-super maintainer entries for an application. This is useful
|
|
|
|
|
to ensure that the user has no maintainer entries for an app he supermaintains */
|
|
|
|
|
function removeUserFromAppVersions()
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "DELETE FROM appMaintainers WHERE
|
|
|
|
|
superMaintainer = '0'
|
|
|
|
|
AND
|
|
|
|
|
appId = '?'
|
|
|
|
|
AND
|
|
|
|
|
userId = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $this->iAppId, $this->iUserId);
|
|
|
|
|
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2007-04-29 23:00:01 +00:00
|
|
|
|
|
|
|
|
function allowAnonymousSubmissions()
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-07-20 22:24:37 +00:00
|
|
|
|
2007-07-21 23:49:36 +00:00
|
|
|
function fetchNotificationUpdate()
|
2007-07-20 22:24:37 +00:00
|
|
|
{
|
|
|
|
|
$bDebugOutputEnabled = false;
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "notifyMaintainerOfQueuedData()\n";
|
|
|
|
|
|
|
|
|
|
// if a maintainer has an non-zero warning level
|
|
|
|
|
// has it been enough days since we last warned them to warrent
|
|
|
|
|
// checking to see if we should warn them again?
|
|
|
|
|
if($this->iNotificationLevel != 0)
|
|
|
|
|
{
|
|
|
|
|
$iLastWarnTime = strtotime($this->sNotificationTime);
|
|
|
|
|
$iLastWarnAgeInSeconds = strtotime("now") - $iLastWarnTime;
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "iLastWarnAgeInSeconds: ".$iLastWarnAgeInSeconds."\n";
|
|
|
|
|
|
|
|
|
|
// if it hasn't been at least $iNotificationIntervalDays since the last
|
|
|
|
|
// warning we can skip even checking the user
|
|
|
|
|
if($iLastWarnAgeInSeconds < (iNotificationIntervalDays * 24 * 60 * 60))
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "iNotificationIntervalDays has not elapsed, skipping checking the user\n";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "notification level is: ".$this->iNotificationLevel."\n";
|
|
|
|
|
|
|
|
|
|
// instantiate the user so we can retrieve particular values
|
|
|
|
|
$oUser = new User($this->iUserId);
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
{
|
|
|
|
|
echo "this->iUserId: ".$this->iUserId."\n";
|
|
|
|
|
print_r($oUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get the time the user signed up
|
|
|
|
|
// if queued entries have been queued since before the user signed up
|
|
|
|
|
// we can't punish them for this fact
|
|
|
|
|
$iMaintainerSignupTime = strtotime($this->aSubmitTime);
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "iMaintainerSignupTime: ".$iMaintainerSignupTime."\n";
|
|
|
|
|
|
|
|
|
|
// store the oldest queued entry
|
|
|
|
|
$iOldestQueuedEntryTime = strtotime("now");
|
|
|
|
|
|
|
|
|
|
// construct the subject of the notification email that we may send
|
|
|
|
|
$sSubject = "Notification of queued data for ";
|
|
|
|
|
$sMsg = "You are receiving this email to notify you that there is queued data";
|
|
|
|
|
$sMsg.=" for the ";
|
|
|
|
|
if($this->bSuperMaintainer)
|
|
|
|
|
{
|
|
|
|
|
$oApp = new Application($this->iAppId);
|
|
|
|
|
$sSubject.= $oApp->sName;
|
|
|
|
|
$sMsg.='application, '.$oApp->objectMakeLink().', that you maintain.'."\n";
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$sFullname = version::fullName($this->iVersionId);
|
|
|
|
|
$oVersion = new Version($this->iVersionId);
|
|
|
|
|
$sSubject.= $sFullname;
|
|
|
|
|
$sMsg.='version, <a href="'.$oVersion->objectMakeUrl().'">'.$sFullname.
|
|
|
|
|
'</a>, that you maintain.'."\n";
|
|
|
|
|
}
|
|
|
|
|
$sSubject.=" ready for your processing";
|
|
|
|
|
|
|
|
|
|
// retrieve the queued entries
|
|
|
|
|
$oQueuedEntries = new queuedEntries($this);
|
|
|
|
|
$oQueuedEntries->retrieveQueuedEntries();
|
|
|
|
|
if($oQueuedEntries->isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "No entries, returning\n";
|
|
|
|
|
|
|
|
|
|
//no entries, we might as well return here
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// process each of the queued versions
|
|
|
|
|
foreach($oQueuedEntries->aVersionIds as $iVersionId)
|
|
|
|
|
{
|
|
|
|
|
$oVersion = new Version($iVersionId);
|
|
|
|
|
|
|
|
|
|
$sMsg .= 'Version <a href="'.$oVersion->objectMakeUrl().'">'.$sFullname.
|
|
|
|
|
'</a> is queued and ready for processing.';
|
|
|
|
|
|
|
|
|
|
$iSubmitTime = strtotime($oVersion->sSubmitTime);
|
|
|
|
|
|
|
|
|
|
// is this submission time older than the oldest queued time?
|
|
|
|
|
// if so this is the new oldest time
|
|
|
|
|
if($iSubmitTime < $iOldestQueuedEntryTime)
|
|
|
|
|
{
|
|
|
|
|
$iOldestQueuedEntryTime = $iSubmitTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(count($oQueuedEntries->aVersionIds) != 0)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: should use a function to generate these urls and use it here and
|
|
|
|
|
// in sidebar_maintainer.php and sidebar_admin.php
|
|
|
|
|
$sMsg = 'Please visit <a href="'.BASE."objectManager.php?sClass=version_queue&bIsQueue=true&sTitle=".
|
|
|
|
|
"Version%20Queue".'">AppDB Version queue</a> to process queued versions for applications you maintain.\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////
|
|
|
|
|
// queued testdata
|
|
|
|
|
|
|
|
|
|
// go through the test results looking for the oldest queued data
|
|
|
|
|
foreach($oQueuedEntries->aTestDataIds as $iTestDataId)
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "Testresult found\n";
|
|
|
|
|
$oTestData = new TestData($iTestDataId);
|
|
|
|
|
|
|
|
|
|
$iSubmitTime = strtotime($oTestData->sSubmitTime);
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "iSubmitTime is ".$iSubmitTime."\n";
|
|
|
|
|
|
|
|
|
|
// is this submission time older than the oldest queued time?
|
|
|
|
|
// if so this is the new oldest time
|
|
|
|
|
if($iSubmitTime < $iOldestQueuedEntryTime)
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "setting new oldest time\n";
|
|
|
|
|
|
|
|
|
|
$iOldestQueuedEntryTime = $iSubmitTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$iTestResultCount = count($oQueuedEntries->aTestDataIds);
|
|
|
|
|
if($iTestResultCount != 0)
|
|
|
|
|
{
|
|
|
|
|
// grammar is slightly different for singular vs. plural
|
|
|
|
|
if($iTestResultCount == 1)
|
|
|
|
|
$sMsg.="There is $iTestResultCount queued test result. ";
|
|
|
|
|
else
|
|
|
|
|
$sMsg.="There are $iTestResultCount queued test results. ";
|
|
|
|
|
|
|
|
|
|
// FIXME: should use a function to generate these urls and use it here and
|
|
|
|
|
// in sidebar_maintainer.php and sidebar_admin.php
|
|
|
|
|
$sMsg .= 'Please visit <a href="'.BASE."objectManager.php?sClass=testData_queue&bIsQueue=true&sTitle=".
|
|
|
|
|
"Test%20Results%20Queue".'">AppDB Test Data queue</a> to process queued test data for versions you maintain.\r\n';
|
|
|
|
|
}
|
|
|
|
|
// queued testdata
|
|
|
|
|
//////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////
|
|
|
|
|
// queued screenshots
|
|
|
|
|
foreach($oQueuedEntries->aScreenshotIds as $iScreenshotId)
|
|
|
|
|
{
|
|
|
|
|
$oScreenshot = new Screenshot($iScreenshotId);
|
|
|
|
|
|
|
|
|
|
$iSubmitTime = strtotime($oScreenshot->sSubmitTime);
|
|
|
|
|
|
|
|
|
|
// is this submission time older than the oldest queued time?
|
|
|
|
|
// if so this is the new oldest time
|
|
|
|
|
if($iSubmitTime < $iOldestQueuedEntryTime)
|
|
|
|
|
{
|
|
|
|
|
$iOldestQueuedEntryTime = $iSubmitTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if the oldest queue entry time is older than the time the maintainer
|
|
|
|
|
// signed up, use the maintainer signup time as the oldest time
|
|
|
|
|
if($iOldestQueuedEntryTime < $iMaintainerSignupTime)
|
|
|
|
|
$iOldestQueuedEntryTime = $iMaintainerSignupTime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if we found any queued screenshots add the screenshot queue processing link
|
|
|
|
|
// to the email
|
|
|
|
|
if(count($oQueuedEntries->aScreenshotIds) != 0)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: should use a function to generate these urls and use it here and
|
|
|
|
|
// in sidebar_maintainer.php and sidebar_admin.php
|
|
|
|
|
$sMsg .= 'Please visit <a href="'.BASE."objectManager.php?sClass=screenshot_queue&bIsQueue=true&sTitle=".
|
|
|
|
|
"Screenshot%20Queue".'">Screenshot queue</a> to process queued screenshots for versions you maintain.\r\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// queued screenshots
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
|
|
// compute the age in seconds of the oldest entry
|
|
|
|
|
$iAgeInSeconds = strtotime("now") - $iOldestQueuedEntryTime;
|
|
|
|
|
|
|
|
|
|
// compute the target warning level based on the age and the notification interval
|
|
|
|
|
// we divide the age by the number of seconds in a day multiplied by the days per notification interval
|
|
|
|
|
$iTargetLevel = (integer)($iAgeInSeconds / (iNotificationIntervalDays * 24 * 60 * 60));
|
|
|
|
|
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
{
|
|
|
|
|
echo "iOldestQueuedEntryTime is $iOldestQueuedEntryTime\n";
|
|
|
|
|
echo "iAgeInSeconds is $iAgeInSeconds\n";
|
|
|
|
|
echo "iNotificationIntervalDays is ".iNotificationIntervalDays."\n";
|
|
|
|
|
echo "strtotime(now) is ".strtotime("now")."\n";
|
|
|
|
|
echo "iTargetLevel is ".$iTargetLevel."\n";
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-21 23:49:36 +00:00
|
|
|
$oNotificationUpdate = new notificationUpdate($oUser->sEmail, $sSubject,
|
|
|
|
|
$sMsg, $iTargetLevel);
|
|
|
|
|
|
|
|
|
|
return $oNotificationUpdate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// level 0 is from 0 to iNotificationIntervalDays
|
|
|
|
|
// level 1 is from (iNotificationIntervalDays + 1) to (iNotificationIntervalDays * 2)
|
|
|
|
|
// level 2 is from (iNotificationIntervalDays * 2 + 1) to (iNotificationIntervalDays * 3)
|
|
|
|
|
// level 3 is beyond (iNotificationIntervalDays * 3)
|
|
|
|
|
function processNotificationUpdate($oNotificationUpdate)
|
|
|
|
|
{
|
|
|
|
|
$bDebugOutputEnabled = false;
|
|
|
|
|
|
2007-07-20 22:24:37 +00:00
|
|
|
// if the target level is less than the current level, adjust the current level
|
|
|
|
|
// This takes into account the entries in the users queue that may have been processed
|
2007-07-21 23:49:36 +00:00
|
|
|
if($oNotificationUpdate->iTargetLevel < $this->iNotificationLevel)
|
2007-07-20 22:24:37 +00:00
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
2007-07-21 23:49:36 +00:00
|
|
|
echo "Using iTargetLevel of $oNotificationUpdate->iTargetLevel\n";
|
|
|
|
|
$this->iNotificationLevel = $oNotificationUpdate->iTargetLevel;
|
2007-07-20 22:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if the target level is higher than the current level then adjust the
|
|
|
|
|
// current level up by 1
|
|
|
|
|
// NOTE: we adjust up by one because we want to ensure that we go through
|
|
|
|
|
// notification levels one at a time
|
2007-07-21 23:49:36 +00:00
|
|
|
if($oNotificationUpdate->iTargetLevel > $this->iNotificationLevel)
|
2007-07-20 22:24:37 +00:00
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "Increasing notification level of $this->iNotificationLevel by 1\n";
|
|
|
|
|
$this->iNotificationLevel++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch($this->iNotificationLevel)
|
|
|
|
|
{
|
|
|
|
|
case 0: // lowest level, no notification
|
|
|
|
|
// nothing to do here
|
|
|
|
|
break;
|
|
|
|
|
case 1: // send the first notification
|
|
|
|
|
// nothing to do here, the first notification is just a reminder
|
2007-07-21 23:49:36 +00:00
|
|
|
$oNotificationUpdate->sMsg.= "\n\nThanks,\n";
|
|
|
|
|
$oNotificationUpdate->sMsg.= "Appdb Admins";
|
2007-07-20 22:24:37 +00:00
|
|
|
break;
|
|
|
|
|
case 2: // send the second notification, notify them that if the queued entries aren't
|
|
|
|
|
// processed after another $iNotificationIntervalDays that
|
|
|
|
|
// we'll have to remove their maintainership for this application/version
|
|
|
|
|
// so a more active person can fill the spot
|
2007-07-21 23:49:36 +00:00
|
|
|
$oNotificationUpdate->sMsg.= "\nThis your second notification of queued entries. If the queued entries are";
|
|
|
|
|
$oNotificationUpdate->sMsg.= " not processed within the next ".iNotificationIntervalDays. "we will remove";
|
|
|
|
|
$oNotificationUpdate->sMsg.= " your maintainership for this application/version so a more active person";
|
|
|
|
|
$oNotificationUpdate->sMsg.= " can fill the spot.";
|
|
|
|
|
$oNotificationUpdate->sMsg.= "\n\nThanks,\n";
|
|
|
|
|
$oNotificationUpdate->sMsg.= "Appdb Admins";
|
2007-07-20 22:24:37 +00:00
|
|
|
break;
|
|
|
|
|
case 3: // remove their maintainership
|
|
|
|
|
$this->delete(); // delete ourselves from the database
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// save the notification level and notification time back into the database
|
|
|
|
|
$sQuery = "update appMaintainers set notificationLevel = '?', notificationTime = ?".
|
2007-07-21 23:49:36 +00:00
|
|
|
" where maintainerId = '?'";
|
2007-07-20 22:24:37 +00:00
|
|
|
query_parameters($sQuery, $this->iNotificationLevel, "NOW()", $this->iMaintainerId);
|
|
|
|
|
|
|
|
|
|
//TODO: we probably want to copy the mailing list on each of these emails
|
2007-07-21 23:49:36 +00:00
|
|
|
$oNotificationUpdate->sEmail.=" cmorgan@alum.wpi.edu"; // FIXME: for debug append my email address
|
2007-07-20 22:24:37 +00:00
|
|
|
|
|
|
|
|
if($this->iNotificationLevel == 0)
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
echo "At level 0, no warning issued to ".$oUser->sEmail."\n";
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
if($bDebugOutputEnabled)
|
|
|
|
|
{
|
2007-07-21 23:49:36 +00:00
|
|
|
echo "Email: ".$oNotificationUpdate->sEmail."\n";
|
|
|
|
|
echo "Subject: ".$oNotificationUpdate->sSubject."\n";
|
|
|
|
|
echo "Msg: ".$oNotificationUpdate->sMsg."\n\n";
|
2007-07-20 22:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-21 23:49:36 +00:00
|
|
|
mail_appdb($oNotificationUpdate->sEmail, $oNotificationUpdate->sSubject, $oNotificationUpdate->sMsg);
|
2007-07-20 22:24:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-21 23:49:36 +00:00
|
|
|
function notifyMaintainerOfQueuedData()
|
|
|
|
|
{
|
|
|
|
|
$oNotificationUpdate = $this->fetchNotificationUpdate();
|
|
|
|
|
|
|
|
|
|
// if we have a valid notificationUpdate then process it, otherwise skip it
|
|
|
|
|
if($oNotificationUpdate != NULL)
|
|
|
|
|
$this->processNotificationUpdate($oNotificationUpdate);
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-20 22:24:37 +00:00
|
|
|
// static method called by the cron maintenance script to notify
|
|
|
|
|
// maintainers of data pending for their applications and versions
|
2007-07-21 23:49:36 +00:00
|
|
|
//TODO: php5 make this static when we have php5
|
2007-07-20 22:24:37 +00:00
|
|
|
function notifyMaintainersOfQueuedData()
|
|
|
|
|
{
|
|
|
|
|
// retrieve all of the maintainers
|
|
|
|
|
$hResult = maintainer::objectGetEntries(false, false);
|
|
|
|
|
|
|
|
|
|
// echo "Processing ".mysql_num_rows($hResult)." maintainers\n";
|
|
|
|
|
|
2007-07-21 23:49:36 +00:00
|
|
|
// notify this user, the maintainer, of queued data, if any exists
|
2007-07-20 22:24:37 +00:00
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
$oMaintainer = new maintainer(null, $oRow);
|
2007-07-21 23:49:36 +00:00
|
|
|
$oMaintainer->notifyMaintainerOfQueuedData();
|
2007-07-20 22:24:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-03-04 23:22:57 +00:00
|
|
|
}
|
2004-12-10 00:18:01 +00:00
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
?>
|