From: <vb...@us...> - 2002-10-01 03:38:31
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv6897/core Modified Files: enum_api.php html_api.php Log Message: - Fixed the access level option list in order not to disable ANYBODY / EVERYBODY. - Change the implementation of the access levels option list in order to make it depend on the enumeration, rather than hard coding it. - Changed the title of the add user to "Add User" rather than "Update User" Index: enum_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/enum_api.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- enum_api.php 18 Sep 2002 12:33:31 -0000 1.1 +++ enum_api.php 1 Oct 2002 03:38:28 -0000 1.2 @@ -50,4 +50,19 @@ } return '@null@'; } + # -------------------- + # Get enum ids (returns an array of all ids in an enumeration) + function enum_get_ids_array( $p_enum_name ) { + $config_var = config_get( $p_enum_name . '_enum_string' ); + + # use the global enum string to search + $ids = array(); + $t_arr = enum_explode_string( $config_var ); + for ( $i = 0; $i < count($t_arr); $i++ ) { + $elem_arr = enum_explode_array( $t_arr[$i] ); + $ids[] = $elem_arr[0]; + } + + return $ids; + } ?> Index: html_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/html_api.php,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- html_api.php 1 Oct 2002 03:06:22 -0000 1.14 +++ html_api.php 1 Oct 2002 03:38:28 -0000 1.15 @@ -165,24 +165,17 @@ } ### -------------------- function html_option_list_access_level( $p_access_level = '' ) { - echo '<option value="'.EVERYBODY.'" '; - check_selected( $p_access_level, EVERYBODY ); - echo '>everybody</option>'; - echo '<option value="'.ANONYMOUS.'" '; - check_selected( $p_access_level, ANONYMOUS ); - echo '>anonymous</option>'; - echo '<option value="'.REGISTERED.'" '; - check_selected( $p_access_level, REGISTERED ); - echo '>registered</option>'; - echo '<option value="'.MODERATOR.'" '; - check_selected( $p_access_level, MODERATOR ); - echo '>moderator</option>'; - echo '<option value="'.ADMINISTRATOR.'" '; - check_selected( $p_access_level, ADMINISTRATOR ); - echo '>administrator</option>'; - echo '<option value="'.NOBODY.'" '; - check_selected( $p_access_level, NOBODY ); - echo '>nobody</option>'; + $ids = enum_get_ids_array( 'access_levels' ); + + foreach ( $ids as $id ) { + if ( ( NOBODY == $id ) || ( EVERYBODY == $id ) ) { + continue; + } + + echo '<option value="' . $id . '" '; + check_selected( $p_access_level, $id ); + echo '>' . enum_get_element( 'access_levels', $id ) . '</option>'; + } } ### -------------------- ?> |