ChangeSet ID: 30949 CVSROOT: /opt/cvs-commit Module name: appdb Changes by: wineowner@winehq.org 2007/03/10 15:21:10
Modified files: include : appData.php sidebar_admin.php sidebar_maintainer_admin.php user.php
Log message: Alexander Nicolaysen Sørnes alex@thehandofagony.com Add and use appData::objectGetEntriesCount()
Patch: http://cvs.winehq.org/patch.py?id=30949
Old revision New revision Changes Path 1.3 1.4 +76 -0 appdb/include/appData.php 1.27 1.28 +3 -3 appdb/include/sidebar_admin.php 1.1 1.2 +1 -1 appdb/include/sidebar_maintainer_admin.php 1.83 1.84 +1 -9 appdb/include/user.php
Index: appdb/include/appData.php diff -u -p appdb/include/appData.php:1.3 appdb/include/appData.php:1.4 --- appdb/include/appData.php:1.3 10 Mar 2007 21:21:10 -0000 +++ appdb/include/appData.php 10 Mar 2007 21:21:10 -0000 @@ -72,6 +72,82 @@ class appData
return $hResult; } + + function objectGetEntriesCount($sQueued, $sType = null) + { + if(($sQueued == "true" || $sQueued == "all") && !appData::canEdit($sType)) + return FALSE; + + if(($sQueued == "true" || $sQueued == "all") && + !$_SESSION['current']->hasPriv("admin")) + { + $sQuery = "SELECT COUNT(DISTINCT id) as count FROM appData, appMaintainers, + appVersion, appFamily + WHERE appMaintainers.userId = '?' AND + ((((appMaintainers.appId = appFamily.appId) OR appMaintainers.appId = + appVersion.appId) AND + appMaintainers.superMaintainer = '1' AND (appData.appId = + appMaintainers.appId OR (appData.versionId = appVersion.versionId + AND appVersion.appId = appMaintainers.appId)) + ) OR (appMaintainers.superMaintainer = '0' AND appMaintainers.versionId = + appVersion.versionId AND appMaintainers.versionId = appData.versionId)) + AND appVersion.queued = 'false' AND + appFamily.queued = 'false'"; + + if($sQueued == "true") + $sQuery .= " AND appData.queued = 'true'"; + + if($sType) + { + $sQuery = " AND type = '?'"; + $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, + $sType); + } else { + $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId); + } + } else + { + $sQuery = "SELECT COUNT(DISTINCT id) as count FROM appData, + appFamily, appVersion + WHERE ((appData.appId = appFamily.appId) OR (appData.versionId = + appVersion.versionId)) AND appVersion.queued = 'false' AND + appFamily.queued = 'false'"; + + if($sQueued == "true" || $sQueued == "false") + $sQuery .= " AND appData.queued = '$sQueued'"; + + if($sType) + { + $sQuery .= " AND type = '?'"; + $hResult = query_parameters($sQuery,$sType); + } else + $hResult = query_parameters($sQuery); + } + + if(!$hResult) + return FALSE; + + if(!$oRow = mysql_fetch_object($hResult)) + return FALSE; + + return $oRow->count; + } + + function canEdit($sType = null) + { + if($sType) + { + $oObject = new $sType(); + return $oObject->canEdit(); + } else + { + if($_SESSION['current']->hasPriv("admin") || + maintainer::isUserMaintainer($_SESSION['current'])) + return TRUE; + else + return FALSE; + } + } }
?> Index: appdb/include/sidebar_admin.php diff -u -p appdb/include/sidebar_admin.php:1.27 appdb/include/sidebar_admin.php:1.28 --- appdb/include/sidebar_admin.php:1.27 10 Mar 2007 21:21:10 -0000 +++ appdb/include/sidebar_admin.php 10 Mar 2007 21:21:10 -0000 @@ -8,14 +8,14 @@ require_once(BASE."include/distribution. function global_admin_menu() {
$g = new htmlmenu("Global Admin"); - + $g->add("Add Category", BASE."admin/addCategory.php"); $g->add("Add Vendor", BASE."objectManager.php?sClass=vendor&bQueue=". "false&sAction=add&sTitle=Add%20Vendor"); - + $g->addmisc(" "); $g->add("View App Queue (".$_SESSION['current']->getQueuedAppCount()."/".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php"); - $g->add("View App Data Queue (".$_SESSION['current']->getQueuedAppDataCount().")", + $g->add("View App Data Queue (".appData::objectGetEntriesCount("true").")", BASE."admin/adminAppDataQueue.php"); $g->add("View Maintainer Queue (".Maintainer::getQueuedMaintainerCount().")", BASE."objectManager.php?sClass=maintainer&bIsQueue=true&sTitle=Maintainer%20Queue"); Index: appdb/include/sidebar_maintainer_admin.php diff -u -p appdb/include/sidebar_maintainer_admin.php:1.1 appdb/include/sidebar_maintainer_admin.php:1.2 --- appdb/include/sidebar_maintainer_admin.php:1.1 10 Mar 2007 21:21:10 -0000 +++ appdb/include/sidebar_maintainer_admin.php 10 Mar 2007 21:21:10 -0000 @@ -8,7 +8,7 @@ function global_maintainer_admin_menu() $g = new htmlmenu("Maintainer Admin");
$g->add("View App Queue (".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php"); - $g->add("View App Data Queue (".$_SESSION['current']->getQueuedAppDataCount().")", BASE."admin/adminAppDataQueue.php"); + $g->add("View App Data Queue (".appData::objectGetEntriesCount("true").")", BASE."admin/adminAppDataQueue.php"); $g->done(); }
Index: appdb/include/user.php diff -u -p appdb/include/user.php:1.83 appdb/include/user.php:1.84 --- appdb/include/user.php:1.83 10 Mar 2007 21:21:11 -0000 +++ appdb/include/user.php 10 Mar 2007 21:21:11 -0000 @@ -299,15 +299,6 @@ class User { return $oRow->queued_versions - $this->getQueuedAppCount(); }
- - /* get the number of queued appdata */ - function getQueuedAppDataCount() - { - $hResult = $this->getAppDataQuery(0, true, false); - $oRow = mysql_fetch_object($hResult); - return $oRow->queued_appdata; - } - function addPriv($sPriv) { if(!$this->isLoggedIn() || !$sPriv) @@ -682,6 +673,7 @@ class User { function get_notify_email_address_list($iAppId = null, $iVersionId = null) { $aUserId = array(); + $sRetval = "";
/* * Retrieve version maintainers.