application: Add support for filtering by app category

This commit is contained in:
Alexander Nicolaysen Sørnes
2008-06-12 23:39:04 +02:00
committed by Chris Morgan
parent f453c5d7a0
commit 7d0469978c
2 changed files with 43 additions and 1 deletions

View File

@@ -1010,8 +1010,18 @@ class Application {
public static function objectGetFilterInfo() public static function objectGetFilterInfo()
{ {
$oFilter = new FilterInterface(); $oFilter = new FilterInterface();
$aCategories = category::getOrderedList();
$aCatNames = array();
$aCatIds = array();
foreach($aCategories as $oCategory)
{
$aCatNames[] = $oCategory->sName;
$aCatIds[] = $oCategory->objectGetId();
}
$oFilter->AddFilterInfo('appVersion.rating', 'Rating', array(FILTER_EQUALS, FILTER_LESS_THAN, FILTER_GREATER_THAN), FILTER_VALUES_ENUM, array('Platinum', 'Gold', 'Silver', 'Bronze', 'Garbage')); $oFilter->AddFilterInfo('appVersion.rating', 'Rating', array(FILTER_EQUALS, FILTER_LESS_THAN, FILTER_GREATER_THAN), FILTER_VALUES_ENUM, array('Platinum', 'Gold', 'Silver', 'Bronze', 'Garbage'));
$oFilter->AddFilterInfo('appFamily.catId', 'Category', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aCatIds, $aCatNames);
return $oFilter; return $oFilter;
} }
@@ -1138,7 +1148,7 @@ class Application {
{ {
$sExtraTables = ',appVersion'; $sExtraTables = ',appVersion';
$sWhereFilter = " AND appVersion.appId = appFamily.appId AND $sWhereFilter"; $sWhereFilter = " AND appVersion.appId = appFamily.appId AND $sWhereFilter";
} }
if($sState != 'accepted' && !application::canEdit()) if($sState != 'accepted' && !application::canEdit())
{ {

View File

@@ -135,6 +135,38 @@ class Category {
return array(); return array();
} }
/* Get a category's subcategory objects. Names are indented according
to subcategory level */
function getSubCatList($iLevel)
{
$aOut = array();
$iId = $this->iCatId ? $this->iCatId : 0;
$sIndent = '';
for($i = 0; $i < $iLevel; $i++)
$sIndent .= '&nbsp; &nbsp;';
$hResult = query_parameters("SELECT * FROM appCategory WHERE catParent = '?'
ORDER BY catName", $iId);
while($oRow = mysql_fetch_object($hResult))
{
$oCat = new category($oRow->catId);
$oCat->sName = $sIndent.$oCat->sName;
$aOut[] = $oCat;
$aOut = array_merge($aOut, $oCat->getSubCatList($iLevel + 1));
}
return $aOut;
}
/* Get all category objects, ordered and with category names indented
according to subcategory level */
static function getOrderedList()
{
$oCat = new category();
return $oCat->getSubCatList(0);
}
function objectGetMail($sAction, $bMailSubmitter, $bParentAction) function objectGetMail($sAction, $bMailSubmitter, $bParentAction)
{ {
/* We don't send notification mails */ /* We don't send notification mails */