@@ -24,6 +24,7 @@ class acp_profile
2424
2525 var $ edit_lang_id ;
2626 var $ lang_defs ;
27+ protected $ type_collection ;
2728
2829 function main ($ id , $ mode )
2930 {
@@ -50,6 +51,7 @@ function main($id, $mode)
5051 }
5152
5253 $ cp = $ phpbb_container ->get ('profilefields ' );
54+ $ this ->type_collection = $ phpbb_container ->get ('profilefields.type_collection ' );
5355
5456 // Build Language array
5557 // Based on this, we decide which elements need to be edited later and which language items are missing
@@ -341,7 +343,7 @@ function main($id, $mode)
341343 $ this ->edit_lang_id = $ field_row ['lang_id ' ];
342344 }
343345 $ field_type = $ field_row ['field_type ' ];
344- $ profile_field = $ phpbb_container -> get ( ' profilefields.type. ' . $ cp -> profile_types [$ field_type ]) ;
346+ $ profile_field = $ this -> type_collection [$ field_type ];
345347
346348 // Get language entries
347349 $ sql = 'SELECT *
@@ -365,14 +367,14 @@ function main($id, $mode)
365367 // We are adding a new field, define basic params
366368 $ lang_options = $ field_row = array ();
367369
368- $ field_type = request_var ('field_type ' , 0 );
370+ $ field_type = request_var ('field_type ' , '' );
369371
370- if (!$ field_type )
372+ if (!isset ( $ this -> type_collection [ $ field_type]) )
371373 {
372374 trigger_error ($ user ->lang ['NO_FIELD_TYPE ' ] . adm_back_link ($ this ->u_action ), E_USER_WARNING );
373375 }
374376
375- $ profile_field = $ phpbb_container -> get ( ' profilefields.type. ' . $ cp -> profile_types [$ field_type ]) ;
377+ $ profile_field = $ this -> type_collection [$ field_type ];
376378 $ field_row = array_merge ($ profile_field ->get_default_option_values (), array (
377379 'field_ident ' => str_replace (' ' , '_ ' , utf8_clean_string (request_var ('field_ident ' , '' , true ))),
378380 'field_required ' => 0 ,
@@ -623,7 +625,7 @@ function main($id, $mode)
623625 'S_FIELD_NO_VIEW ' => ($ cp ->vars ['field_no_view ' ]) ? true : false ,
624626
625627 'L_LANG_SPECIFIC ' => sprintf ($ user ->lang ['LANG_SPECIFIC_OPTIONS ' ], $ config ['default_lang ' ]),
626- 'FIELD_TYPE ' => $ user ->lang ['FIELD_ ' . strtoupper ($ cp -> profile_types [ $ field_type ] )],
628+ 'FIELD_TYPE ' => $ user ->lang ['FIELD_ ' . strtoupper ($ profile_field -> get_name () )],
627629 'FIELD_IDENT ' => $ cp ->vars ['field_ident ' ],
628630 'LANG_NAME ' => $ cp ->vars ['lang_name ' ],
629631 'LANG_EXPLAIN ' => $ cp ->vars ['lang_explain ' ],
@@ -707,9 +709,10 @@ function main($id, $mode)
707709 $ s_one_need_edit = true ;
708710 }
709711
712+ $ profile_field = $ this ->type_collection [$ row ['field_type ' ]];
710713 $ template ->assign_block_vars ('fields ' , array (
711714 'FIELD_IDENT ' => $ row ['field_ident ' ],
712- 'FIELD_TYPE ' => $ user ->lang ['FIELD_ ' . strtoupper ($ cp -> profile_types [ $ row [ ' field_type ' ]] )],
715+ 'FIELD_TYPE ' => $ user ->lang ['FIELD_ ' . strtoupper ($ profile_field -> get_name () )],
713716
714717 'L_ACTIVATE_DEACTIVATE ' => $ user ->lang [$ active_lang ],
715718 'U_ACTIVATE_DEACTIVATE ' => $ this ->u_action . "&action= $ active_value&field_id= $ id " ,
@@ -731,15 +734,15 @@ function main($id, $mode)
731734 }
732735
733736 $ s_select_type = '' ;
734- foreach ($ cp -> profile_types as $ key => $ value )
737+ foreach ($ this -> type_collection as $ key => $ profile_field )
735738 {
736- $ s_select_type .= '<option value=" ' . $ key . '"> ' . $ user ->lang ['FIELD_ ' . strtoupper ($ value )] . '</option> ' ;
739+ $ s_select_type .= '<option value=" ' . $ key . '"> ' . $ user ->lang ['FIELD_ ' . strtoupper ($ profile_field -> get_name () )] . '</option> ' ;
737740 }
738741
739742 $ template ->assign_vars (array (
740743 'U_ACTION ' => $ this ->u_action ,
741- 'S_TYPE_OPTIONS ' => $ s_select_type)
742- );
744+ 'S_TYPE_OPTIONS ' => $ s_select_type,
745+ )) ;
743746 }
744747
745748 /**
@@ -764,9 +767,8 @@ function build_language_options(&$cp, $field_type, $action = 'create')
764767 }
765768 $ db ->sql_freeresult ($ result );
766769
767- $ type_collection = $ phpbb_container ->get ('profilefields.type_collection ' );
768- $ profile_type = $ type_collection ['profilefields.type. ' . $ cp ->profile_types [$ field_type ]];
769- $ options = $ profile_type ->get_language_options ($ cp ->vars );
770+ $ profile_field = $ this ->type_collection [$ field_type ];
771+ $ options = $ profile_field ->get_language_options ($ cp ->vars );
770772
771773 $ lang_options = array ();
772774
@@ -906,16 +908,15 @@ function save_profile_field(&$cp, $field_type, $action = 'create')
906908 $ db ->sql_query ($ sql );
907909 }
908910
909- $ type_collection = $ phpbb_container ->get ('profilefields.type_collection ' );
910- $ profile_type = $ type_collection ['profilefields.type. ' . $ cp ->profile_types [$ field_type ]];
911+ $ profile_field = $ this ->type_collection [$ field_type ];
911912
912913 if ($ action == 'create ' )
913914 {
914915 $ field_ident = 'pf_ ' . $ field_ident ;
915916
916917 $ db_tools = $ phpbb_container ->get ('dbal.tools ' );
917918
918- list ($ sql_type , $ null ) = $ db_tools ->get_column_type ($ profile_type ->get_database_column_type ());
919+ list ($ sql_type , $ null ) = $ db_tools ->get_column_type ($ profile_field ->get_database_column_type ());
919920 $ profile_sql [] = $ this ->add_field_ident ($ field_ident , $ sql_type );
920921 }
921922
@@ -990,7 +991,7 @@ function save_profile_field(&$cp, $field_type, $action = 'create')
990991 foreach ($ cp ->vars ['lang_options ' ] as $ option_id => $ value )
991992 {
992993 $ sql_ary = array (
993- 'field_type ' => ( int ) $ field_type ,
994+ 'field_type ' => $ field_type ,
994995 'lang_value ' => $ value
995996 );
996997
@@ -1045,7 +1046,7 @@ function save_profile_field(&$cp, $field_type, $action = 'create')
10451046 'field_id ' => (int ) $ field_id ,
10461047 'lang_id ' => (int ) $ lang_id ,
10471048 'option_id ' => (int ) $ option_id ,
1048- 'field_type ' => ( int ) $ field_type ,
1049+ 'field_type ' => $ field_type ,
10491050 'lang_value ' => $ value
10501051 );
10511052 }
0 commit comments