From: <vb...@us...> - 2002-10-07 02:54:42
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv1320/core Modified Files: config_defaults_inc.php constants_inc.php html_api.php user_api.php Log Message: - Fixed a problem in the user add if the user was added as not enabled. - 0000079: Add support for protected accounts - Removing of some unnecessary code in user_api.php - User create was hard-coded to add users as enabled. - Changed the version back to 2.0.0-dev. Index: config_defaults_inc.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/config_defaults_inc.php,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- config_defaults_inc.php 6 Oct 2002 15:42:13 -0000 1.15 +++ config_defaults_inc.php 7 Oct 2002 02:54:39 -0000 1.16 @@ -12,7 +12,7 @@ # VERSION SETTINGS ##################### - $g_phpWebNotes_version = '2.0.0-pr1'; + $g_phpWebNotes_version = '2.0.0-dev'; ### Display phpWebNotes version on pages $g_show_version = ON; @@ -167,6 +167,7 @@ ACTION_USERS_ADD => ADMINISTRATOR, ACTION_USERS_EDIT => ADMINISTRATOR, ACTION_USERS_EDIT_OWN => REGISTERED, + ACTION_USERS_EDIT_OWN_PROTECTED => ADMINISTRATOR, ACTION_USERS_DELETE => ADMINISTRATOR, ACTION_PAGES_MANAGE => ADMINISTRATOR, ACTION_PAGES_ADD => ADMINISTRATOR, Index: constants_inc.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/constants_inc.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- constants_inc.php 19 Sep 2002 05:15:47 -0000 1.8 +++ constants_inc.php 7 Oct 2002 02:54:39 -0000 1.9 @@ -53,7 +53,8 @@ define( 'ACTION_USERS_ADD', 102 ); define( 'ACTION_USERS_EDIT', 103 ); define( 'ACTION_USERS_EDIT_OWN', 104 ); - define( 'ACTION_USERS_DELETE', 105 ); + define( 'ACTION_USERS_EDIT_OWN_PROTECTED', 105 ); + define( 'ACTION_USERS_DELETE', 106 ); define( 'ACTION_PAGES_MANAGE', 201 ); define( 'ACTION_PAGES_ADD', 202 ); Index: html_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/html_api.php,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- html_api.php 6 Oct 2002 15:23:36 -0000 1.20 +++ html_api.php 7 Oct 2002 02:54:39 -0000 1.21 @@ -126,7 +126,17 @@ if ( access_check_action( ACTION_USERS_MANAGE ) ) { echo "<a title=\"View/edit user information\" href=\"$g_admin_manage_users\">$s_manage_users</a> :: "; } - if ( access_check_action( ACTION_USERS_EDIT_OWN ) ) { + + $row = user_get_info( user_where_current() ); + extract( $row, EXTR_PREFIX_ALL, 'v' ); + + if ( 1 == $v_protected ) { + $t_action = ACTION_USERS_EDIT_OWN_PROTECTED; + } else { + $t_action = ACTION_USERS_EDIT_OWN; + } + + if ( access_check_action( $t_action ) ) { echo "<a title=\"Change your own password\" href=\"$g_admin_change_password\">$s_change_password</a> :: "; } Index: user_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/user_api.php,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- user_api.php 1 Oct 2002 02:20:43 -0000 1.14 +++ user_api.php 7 Oct 2002 02:54:39 -0000 1.15 @@ -13,7 +13,7 @@ ########################################################################### ### -------------------- - function user_create( $p_username, $p_password, $p_email, $p_access_level = null, $p_enabled = true ) { + function user_create( $p_username, $p_password, $p_email, $p_access_level = null, $p_enabled = true, $p_protected = false ) { if ( false !== user_get_info( user_where_username_equals( $p_username ) ) ) { echo "<p>Duplicate user.</p>"; return false; @@ -31,13 +31,15 @@ $c_username = db_prepare_string( $p_username ); $c_email = db_prepare_string( $p_email ); $c_encrypted_password = db_prepare_string( access_encrypt_password( $p_password ) ); + $c_enabled = db_prepare_int( $p_enabled ); + $c_protected = db_prepare_int( $p_protected ); $t_seed = $p_email . $p_username; $t_cookie_string = create_cookie_string( $t_seed ); $c_cookie_string = db_prepare_string( $t_cookie_string ); - $query = "INSERT INTO phpWN_user_table (username, password, email, cookie_string, access_level, enabled) - VALUES ('$c_username', '$c_encrypted_password', '$c_email', '$c_cookie_string', '$p_access_level', 1)"; + $query = "INSERT INTO phpWN_user_table (username, password, email, cookie_string, access_level, enabled, protected) + VALUES ('$c_username', '$c_encrypted_password', '$c_email', '$c_cookie_string', $p_access_level, $c_enabled, $c_protected)"; $result = mysql_query($query); return( false !== $result ); @@ -184,7 +186,7 @@ ### -------------------- # we assume that the password has been checked for accuracy # we assume that the enabled value is 0 or 1 - function user_update( $p_user_id, $p_email, $p_password, $p_access_level, $p_enabled ) { + function user_update( $p_user_id, $p_email, $p_password, $p_access_level, $p_enabled, $p_protected ) { global $g_phpWN_user_table; if ( empty( $p_password ) ) { @@ -194,24 +196,29 @@ $c_password = db_prepare_string( access_encrypt_password( $p_password ) ); } + $c_user_id = db_prepare_int( $p_user_id ); $c_email = db_prepare_string( $p_email ); $c_access_level = db_prepare_string( $p_access_level ); $c_enabled = db_prepare_string( $p_enabled ); + $c_protected = db_prepare_string( $p_protected ); $query = "UPDATE $g_phpWN_user_table SET email='$c_email', password='$c_password', - access_level='$c_access_level', - enabled='$p_enabled' - WHERE id='$p_user_id'"; + access_level=$c_access_level, + enabled=$c_enabled, + protected=$c_protected + WHERE id=$c_user_id"; return db_query( $query ); } ### -------------------- function user_delete( $p_user_id ) { global $g_phpWN_user_table; + $c_user_id = db_prepare_int( $p_user_id ); + $query = "DELETE FROM $g_phpWN_user_table - WHERE id='$p_user_id'"; + WHERE id=$c_user_id"; return db_query( $query ); } ### -------------------- |