From 3dbf4a63ce505ebf33b1ef4f9f8dcff8eed2cc23 Mon Sep 17 00:00:00 2001 From: Quitta Date: Tue, 9 Jul 2013 16:34:43 +0200 Subject: [PATCH] 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 --- .../server/ryzom_ams/ams_lib/autoload/gui_elements.php | 9 +++++++++ .../tools/server/ryzom_ams/www/html/inc/createticket.php | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php index ced3a5870..e28e30531 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php @@ -16,4 +16,13 @@ class Gui_Elements{ 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; + } } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php index 4647bbfaf..56c83b458 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php @@ -29,11 +29,7 @@ function createticket(){ //create array of category id & names global $cfg; $catArray = Ticket_Category::getAllCategories($cfg['db']['lib']); - $result['category'] = Array(); - foreach($catArray as $catObj){ - $result['category'][$catObj->getTCategoryId()] = $catObj->getName(); - } - + $result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" ); return $result; }else{