Move getAppsFromUserId() to user::getAppsMaintained(). Also implement a unit test for
user::getAppsMaintained()
This commit is contained in:
@@ -7,6 +7,7 @@ require_once(BASE."include/version.php");
|
||||
require_once(BASE."include/vendor.php");
|
||||
require_once(BASE."include/url.php");
|
||||
require_once(BASE."include/util.php");
|
||||
require_once(BASE."include/mail.php");
|
||||
|
||||
/**
|
||||
* Application class for handling applications.
|
||||
|
||||
@@ -3,29 +3,6 @@
|
||||
/* functions for maintainers */
|
||||
/*****************************/
|
||||
|
||||
/**
|
||||
* get the applications and versions that this userId maintains
|
||||
*/
|
||||
function getAppsFromUserId($userId)
|
||||
{
|
||||
/* 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 = '?' ORDER BY appName", $userId);
|
||||
if(!$hResult || mysql_num_rows($hResult) == 0)
|
||||
return;
|
||||
|
||||
$retval = array();
|
||||
$c = 0;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$retval[$c] = array($oRow->appId, $oRow->versionId, $oRow->superMaintainer);
|
||||
$c++;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* get the userIds of maintainers for a versionId
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@ function global_sidebar_login() {
|
||||
|
||||
/* if this user maintains any applications list them */
|
||||
/* in their sidebar */
|
||||
$apps_user_maintains = getAppsFromUserId($_SESSION['current']->iUserId);
|
||||
$apps_user_maintains = $_SESSION['current']->getAppsMaintained();
|
||||
if($apps_user_maintains)
|
||||
{
|
||||
$g->addmisc("");
|
||||
|
||||
@@ -296,6 +296,29 @@ class User {
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the applications and versions that this user maintains
|
||||
*/
|
||||
function getAppsMaintained()
|
||||
{
|
||||
/* 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 = '?' ORDER BY appName", $this->iUserId);
|
||||
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;
|
||||
}
|
||||
|
||||
function getMaintainerCount($bSuperMaintainer)
|
||||
{
|
||||
if(!$this->isLoggedIn()) return 0;
|
||||
|
||||
Reference in New Issue
Block a user