add support for application maintainers
This commit is contained in:
committed by
Jeremy Newman
parent
073acaff01
commit
c81eebd949
@@ -66,8 +66,7 @@ function view_app_comment($ob)
|
||||
echo "</td></tr>\n";
|
||||
|
||||
// delete message button, for admins
|
||||
//TODO: application managers should also see this button
|
||||
if(havepriv("admin"))
|
||||
if(havepriv("admin") || isMaintainer($ob->appId, $ob->versionId))
|
||||
{
|
||||
echo "<tr>";
|
||||
echo '<td><form method=post name=message action="deletecomment.php"><input type=submit value="Delete" class=button> ',"\n";
|
||||
|
||||
47
include/maintainer.php
Normal file
47
include/maintainer.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* get the applications and versions that this userId maintains
|
||||
*/
|
||||
function getAppsFromUserId($userId)
|
||||
{
|
||||
$result = mysql_query("SELECT appId, versionId FROM ".
|
||||
"appMaintainers WHERE userId = '$userId'");
|
||||
if(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;
|
||||
}
|
||||
|
||||
/*
|
||||
* get the userIds of maintainers for this appId and versionId
|
||||
*/
|
||||
function getMaintainersUserIdsFromAppIdVersionId($appId, $versionId)
|
||||
{
|
||||
$query = "SELECT userId FROM ".
|
||||
"appMaintainers WHERE appId = '$appId' " .
|
||||
"AND versionId = '$versionId';";
|
||||
$result = mysql_query($query);
|
||||
if(mysql_num_rows($result) == 0)
|
||||
return; // no sub categories
|
||||
|
||||
$retval = array();
|
||||
$c = 0;
|
||||
while($row = mysql_fetch_object($result))
|
||||
{
|
||||
$retval[$c] = array($row->userId);
|
||||
$c++;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -10,7 +10,7 @@ class htmlmenu {
|
||||
|
||||
echo '
|
||||
<div align=left>
|
||||
<table width="150" border="0" cellspacing="0" cellpadding="0">
|
||||
<table width="160" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="topMenu">
|
||||
@@ -30,7 +30,7 @@ echo '
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="145" border="0" cellspacing="0" cellpadding="1">
|
||||
<table width="155" border="0" cellspacing="0" cellpadding="1">
|
||||
<tr class="topMenu"><td>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="5">
|
||||
';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
.<?
|
||||
|
||||
/*
|
||||
* sidebar_admin
|
||||
@@ -18,6 +18,7 @@ function global_admin_menu() {
|
||||
$g->addmisc(" ");
|
||||
$g->add("List Users", $apidb_root."admin/");
|
||||
$g->add("View App Queue (".getQueuedAppCount().")", $apidb_root."admin/adminAppQueue.php");
|
||||
$g->add("View Maintainer Queue (".getQueuedMaintainerCount().")", $apidb_root."admin/adminMaintainerQueue.php");
|
||||
|
||||
$g->done();
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?
|
||||
|
||||
require_once(BASE."include/"."maintainer.php");
|
||||
require_once(BASE."include/"."category.php");
|
||||
|
||||
/*
|
||||
* Login SideBar
|
||||
*
|
||||
@@ -13,8 +16,23 @@ function global_sidebar_login() {
|
||||
|
||||
if(loggedin())
|
||||
{
|
||||
global $current;
|
||||
|
||||
$g->add("Logout", $apidb_root."account.php?cmd=logout");
|
||||
$g->add("Preferences", $apidb_root."preferences.php");
|
||||
|
||||
/* if this user maintains any applications list them */
|
||||
/* in their sidebar */
|
||||
$apps_user_maintains = getAppsFromUserId($current->userid);
|
||||
if($apps_user_maintains)
|
||||
{
|
||||
$g->addmisc("");
|
||||
$g->addmisc("You maintain:\n");
|
||||
while(list($index, list($appId, $versionId)) = each($apps_user_maintains))
|
||||
{
|
||||
$g->addmisc("<a href='".$apidb_root."appview.php?appId=$appId&versionId=$versionId'>".appIdToName($appId).versionIdToName($versionId)."</a>", "center");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -46,11 +46,7 @@ class User {
|
||||
|
||||
function lookup_username($userid)
|
||||
{
|
||||
$result = mysql_query("SELECT username FROM user_list WHERE userid = $userid");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->username;
|
||||
return lookupUsername($userId);
|
||||
}
|
||||
|
||||
function lookup_userid($username)
|
||||
@@ -73,11 +69,7 @@ class User {
|
||||
|
||||
function lookup_email($userid)
|
||||
{
|
||||
$result = mysql_query("SELECT email FROM user_list WHERE userid = $userid");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->email;
|
||||
return lookupEmail($userid);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -183,14 +175,14 @@ class User {
|
||||
|
||||
function getpref($key, $def = null)
|
||||
{
|
||||
if(!$this->userid || !$key)
|
||||
if(!$this->userid || !$key)
|
||||
return $def;
|
||||
|
||||
$result = mysql_query("SELECT * FROM user_prefs WHERE userid = $this->userid AND name = '$key'", $this->link);
|
||||
if(!$result || mysql_num_rows($result) == 0)
|
||||
return $def;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->value;
|
||||
$result = mysql_query("SELECT * FROM user_prefs WHERE userid = $this->userid AND name = '$key'", $this->link);
|
||||
if(!$result || mysql_num_rows($result) == 0)
|
||||
return $def;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->value;
|
||||
}
|
||||
|
||||
function setpref($key, $value)
|
||||
@@ -220,6 +212,22 @@ class User {
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* check if this user is an maintainer of a given appId/versionId
|
||||
*/
|
||||
function is_maintainer($appId, $versionId)
|
||||
{
|
||||
global $current;
|
||||
if(!loggedin() || !$this->userid)
|
||||
return false;
|
||||
|
||||
$query = "SELECT * FROM appMaintainers WHERE userid = '$this->userid' AND appId = '$appId' AND versionId = '$versionId'";
|
||||
$result = mysql_query($query, $this->link);
|
||||
if(!$result)
|
||||
return 0;
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function addpriv($priv)
|
||||
{
|
||||
if(!$this->userid || !$priv)
|
||||
@@ -275,11 +283,21 @@ function havepriv($priv)
|
||||
global $current;
|
||||
|
||||
if(!loggedin())
|
||||
return false;
|
||||
return false;
|
||||
|
||||
return $current->checkpriv($priv);
|
||||
}
|
||||
|
||||
function isMaintainer($appId, $versionId)
|
||||
{
|
||||
global $current;
|
||||
|
||||
if(!loggedin())
|
||||
return false;
|
||||
|
||||
return $current->is_maintainer($appId, $versionId);
|
||||
}
|
||||
|
||||
function debugging()
|
||||
{
|
||||
global $current;
|
||||
@@ -315,4 +333,23 @@ function generate_passwd($pass_len = 10)
|
||||
return ($nps);
|
||||
}
|
||||
|
||||
function lookupUsername($userid)
|
||||
{
|
||||
$result = mysql_query("SELECT username FROM user_list WHERE userid = $userid");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->username;
|
||||
}
|
||||
|
||||
function lookupEmail($userid)
|
||||
{
|
||||
$result = mysql_query("SELECT email FROM user_list WHERE userid = $userid");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->email;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -180,4 +180,22 @@ function getQueuedAppCount()
|
||||
return $ob->queued_apps;
|
||||
}
|
||||
|
||||
/* get the number of applications in the appQueue table */
|
||||
function getQueuedAppCount()
|
||||
{
|
||||
$qstring = "SELECT count(*) as queued_apps FROM appQueue";
|
||||
$result = mysql_query($qstring);
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->queued_apps;
|
||||
}
|
||||
|
||||
/* get the number of applications in the appQueue table */
|
||||
function getQueuedMaintainerCount()
|
||||
{
|
||||
$qstring = "SELECT count(*) as queued_maintainers FROM appMaintainerQueue";
|
||||
$result = mysql_query($qstring);
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->queued_maintainers;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user