make_table_with_key_is_id function added to replace and use for like filling the category array, I guess it will be used in the future for a lot of different things

--HG--
branch : quitta-gsoc-2013
This commit is contained in:
Quitta 2013-07-09 16:34:43 +02:00
parent ba69c5939e
commit fca8eb1ced
2 changed files with 10 additions and 5 deletions

View file

@ -16,4 +16,13 @@ class Gui_Elements{
return $result; return $result;
} }
public static function make_table_with_key_is_id( $inputList, $funcArray, $idFunction){
$result = Array();
foreach($inputList as $element){
foreach($funcArray as $function){
$result[$element->$idFunction()] = $element->$function();
}
}
return $result;
}
} }

View file

@ -29,11 +29,7 @@ function createticket(){
//create array of category id & names //create array of category id & names
global $cfg; global $cfg;
$catArray = Ticket_Category::getAllCategories($cfg['db']['lib']); $catArray = Ticket_Category::getAllCategories($cfg['db']['lib']);
$result['category'] = Array(); $result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" );
foreach($catArray as $catObj){
$result['category'][$catObj->getTCategoryId()] = $catObj->getName();
}
return $result; return $result;
}else{ }else{