Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv19524/core Modified Files: access_api.php api.php config_defaults_inc.php constants_inc.php html_api.php Added Files: enum_api.php Log Message: - Added the home page (first page after login). - Refined the actions and added checks for the pages. - Implemented the access_denied() function. - Supporting enumerations (enum_api.php). - Added enumeration for access levels. --- NEW FILE: enum_api.php --- <?php # phpWebNotes - a php based note addition system # Copyright (C) 2000-2002 Webnotes Team - web...@so... # This program is distributed under the terms and conditions of the GPL # See the files README and LICENSE for details # -------------------------------------------------------- # $Id: enum_api.php,v 1.1 2002/09/18 12:33:31 vboctor Exp $ # -------------------------------------------------------- # -------------------- # Get the string associated with the $p_enum value function get_enum_to_string( $p_enum_string, $p_num ) { $t_arr = enum_explode_string( $p_enum_string ); $enum_count = count( $t_arr ); for ($i=0;$i<$enum_count;$i++) { $t_s = enum_explode_array( $t_arr[$i] ); if ( $t_s[0] == $p_num ) { return $t_s[1]; } } return '@null@'; } # -------------------- # Breaks up an enum string into num:value elements function enum_explode_string( $p_enum_string ) { return explode( ',', $p_enum_string ); } # -------------------- # Given one num:value pair it will return both in an array # num will be first (element 0) value second (element 1) function enum_explode_array( $p_enum_elem ) { return explode( ':', $p_enum_elem ); } # -------------------- # Given a enum string and num, return the appropriate string function enum_get_element( $p_enum_name, $p_val ) { $config_var = config_get( $p_enum_name.'_enum_string' ); $string_var = lang_get( $p_enum_name.'_enum_string' ); # use the global enum string to search $t_arr = enum_explode_string( $config_var ); $t_arr_count = count( $t_arr ); for ( $i=0;$i<$t_arr_count;$i++ ) { $elem_arr = enum_explode_array( $t_arr[$i] ); if ( $elem_arr[0] == $p_val ) { # now get the appropriate translation return get_enum_to_string( $string_var, $p_val ); } } return '@null@'; } ?> Index: access_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/access_api.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- access_api.php 18 Sep 2002 06:55:02 -0000 1.6 +++ access_api.php 18 Sep 2002 12:33:31 -0000 1.7 @@ -13,10 +13,27 @@ # he/she is not authorised to. This outputs an access denied message then # re-directs to the mainpage. function access_denied( $p_url = null ) { - echo '<div class="error">'; - echo 'Access Denied'; - # print_bracket_link( $p_url, lang_get( 'proceed' ) ); - print '</div>'; + if ( null === $p_url ) { + global $g_logout; + $p_url = $g_logout; + } + + print_html_top(); + print_head_top(); + print_title( config_get( 'window_title' ) ); + print_css( config_get( 'css_inc_file' ) ); + print_head_bottom(); + print_body_top(); + print_header( config_get( 'page_title' ) ); + print_top_page( config_get( 'top_page_inc' ) ); + echo '<div class="warning">'; + echo '<div align="center">Access Denied<br /><br />'; + print_bracket_link( $p_url, lang_get( 'proceed' ) ); + print '</div></div>'; + print_bottom_page( config_get( 'bottom_page_inc' ) ); + print_footer( __FILE__ ); + print_body_bottom(); + print_html_bottom(); exit; } # -------------------- Index: api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/api.php,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- api.php 17 Sep 2002 22:18:24 -0000 1.24 +++ api.php 18 Sep 2002 12:33:31 -0000 1.25 @@ -39,7 +39,9 @@ $g_admin_manage_users = $g_web_directory . 'admin_manage_users' . $g_ext; $g_admin_pending = $g_web_directory . 'admin_pending' . $g_ext; $g_admin_change_password = $g_web_directory . 'admin_change_password' . $g_ext; - $g_admin_page = $g_admin_pending; + + $g_user_home_page = $g_web_directory . 'user_home_page' . $g_ext; + $g_admin_page = $g_user_home_page; $g_css_inc_file = $g_absolute_directory . 'core' . DIRECTORY_SEPARATOR . 'css_inc' . $g_ext; $g_meta_inc_file = $g_absolute_directory . 'core' . DIRECTORY_SEPARATOR . 'meta_inc' . $g_ext; @@ -67,6 +69,7 @@ require_once( $t_path_core . 'util_api.php' ); require_once( $t_path_core . 'gpc_api.php' ); require_once( $t_path_core . 'email_api.php' ); + require_once( $t_path_core . 'enum_api.php' ); require_once( $t_path_main . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $g_theme . DIRECTORY_SEPARATOR . 'theme_api.php' ); Index: config_defaults_inc.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/config_defaults_inc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- config_defaults_inc.php 18 Sep 2002 06:55:03 -0000 1.2 +++ config_defaults_inc.php 18 Sep 2002 12:33:31 -0000 1.3 @@ -141,11 +141,15 @@ ACTION_NOTES_EDIT => MODERATOR, ACTION_NOTES_EDIT_OWN => REGISTERED, ACTION_NOTES_DELETE_OWN => REGISTERED, - ACTION_NOTES_ACCEPT => MODERATOR, - ACTION_NOTES_ARCHIVE => MODERATOR, - ACTION_USER_ADD => ADMINISTRATOR, - ACTION_USER_EDIT => ADMINISTRATOR, - ACTION_USER_DELETE => ADMINISTRATOR ); + ACTION_NOTES_MODERATE => MODERATOR, + ACTION_USERS_MANAGE => ADMINISTRATOR, + ACTION_USERS_ADD => ADMINISTRATOR, + ACTION_USERS_EDIT => ADMINISTRATOR, + ACTION_USERS_EDIT_OWN => REGISTERED, + ACTION_USERS_DELETE => ADMINISTRATOR, + ACTION_PAGES_MANAGE => ADMINISTRATOR, + ACTION_PAGES_ADD => ADMINISTRATOR, + ACTION_PAGES_DELETE => ADMINISTRATOR ); # This array specified for each action, the user types that can perform it. # This is more flexible than specifying a threshold. This is only used when @@ -156,11 +160,15 @@ ACTION_NOTES_EDIT => array(), ACTION_NOTES_EDIT_OWN => array(), ACTION_NOTES_DELETE_OWN => array(), - ACTION_NOTES_ACCEPT => array(), - ACTION_NOTES_ARCHIVE => array(), - ACTION_USER_ADD => array(), - ACTION_USER_EDIT => array(), - ACTION_USER_DELETE => array() ); + ACTION_NOTES_MODERATE => array(), + ACTION_USERS_MANAGE => array(), + ACTION_USERS_ADD => array(), + ACTION_USERS_EDIT => array(), + ACTION_USERS_EDIT_OWN => array(), + ACTION_USERS_DELETE => array(), + ACTION_PAGES_MANAGE => array(), + ACTION_PAGES_ADD => array(), + ACTION_PAGES_DELETE => array() ); ################### # EMAIL SETTINGS @@ -195,4 +203,13 @@ # If problems occur when sending mail through your server try turning this OFF # more here: http://pobox.com/~djb/docs/smtplf.html $g_mail_send_crlf = OFF; + + ########################## + # ENUMERATIONS SETTINGS + ########################## + + # --- enum strings ---------------- + # status from $g_status_index-1 to 79 are used for the onboard customization (if enabled) + # directly use Mantis to edit them. + $g_access_levels_enum_string = '10:anonymous,40:registered,70:moderator,90:administrator'; ?> Index: constants_inc.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/constants_inc.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- constants_inc.php 18 Sep 2002 06:55:03 -0000 1.5 +++ constants_inc.php 18 Sep 2002 12:33:31 -0000 1.6 @@ -34,9 +34,13 @@ define( 'ACTION_NOTES_EDIT_OWN', 4 ); define( 'ACTION_NOTES_DELETE', 5 ); define( 'ACTION_NOTES_DELETE_OWN', 6 ); - define( 'ACTION_NOTES_ACCEPT', 7 ); - define( 'ACTION_NOTES_ARCHIVE', 8 ); - define( 'ACTION_USER_ADD', 51 ); - define( 'ACTION_USER_EDIT', 52 ); - define( 'ACTION_USER_DELETE', 53 ); + define( 'ACTION_NOTES_MODERATE', 7 ); + define( 'ACTION_USERS_MANAGE', 101 ); + define( 'ACTION_USERS_ADD', 102 ); + define( 'ACTION_USERS_EDIT', 103 ); + define( 'ACTION_USERS_EDIT_OWN', 104 ); + define( 'ACTION_USERS_DELETE', 105 ); + define( 'ACTION_PAGES_MANAGE', 201 ); + define( 'ACTION_PAGES_ADD', 202 ); + define( 'ACTION_PAGES_DELETE', 203 ); ?> Index: html_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/html_api.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- html_api.php 14 Sep 2002 15:19:12 -0000 1.5 +++ html_api.php 18 Sep 2002 12:33:31 -0000 1.6 @@ -116,12 +116,13 @@ global $g_logout, $g_admin_index_files, $g_admin_pending, $g_admin_change_password, $g_admin_manage_notes, $g_admin_manage_users, $s_logout_link, $s_index_files, $s_view_queue, $s_change_password, - $s_manage_notes, $s_manage_users; + $s_manage_notes, $s_manage_users, $g_user_home_page; $queue_count = note_queue_count(); echo <<<EOT <div class="menu"> + <a href="$g_user_home_page">Home</a> | <a href="$g_admin_index_files">$s_index_files</a> | <a href="$g_admin_manage_notes">$s_manage_notes</a> | <a href="$g_admin_manage_users">$s_manage_users</a> | @@ -132,5 +133,15 @@ </div> <br /> EOT; + } + # -------------------- + # print the bracketed links used near the top + # if the $p_link is blank then the text is printed but no link is created + function print_bracket_link( $p_link, $p_url_text ) { + if ( empty( $p_link ) ) { + echo "[ $p_url_text ]"; + } else { + echo "[ <a href=\"$p_link\">$p_url_text</a> ]"; + } } ?> |