From 5c786caa0dba0cefabec870557e092a74f86d463 Mon Sep 17 00:00:00 2001 From: Chris Fitch Date: Fri, 25 Sep 2009 20:39:38 -0400 Subject: [PATCH] Convert boolean 'edit', 'delete', and 'make private' checks on bugnotes to thresholds diff --git a/bugnote_delete.php b/bugnote_delete.php index 03ddd08..6562952 100644 --- a/bugnote_delete.php +++ b/bugnote_delete.php @@ -48,7 +48,7 @@ $t_user_id = auth_get_current_user_id(); $t_reporter_id = bugnote_get_field( $f_bugnote_id, 'reporter_id' ); - if ( ( $t_user_id != $t_reporter_id ) || ( OFF == config_get( 'bugnote_allow_user_delete' ) ) ) { + if ( ( $t_user_id != $t_reporter_id ) || !( access_has_bugnote_level( config_get( 'bugnote_user_delete_threshold' ), $f_bugnote_id ) ) ) { access_ensure_bugnote_level( config_get( 'delete_bugnote_threshold' ), $f_bugnote_id ); } diff --git a/bugnote_edit_page.php b/bugnote_edit_page.php index d6a766e..9916ea2 100644 --- a/bugnote_edit_page.php +++ b/bugnote_edit_page.php @@ -57,7 +57,7 @@ $t_reporter_id = bugnote_get_field( $f_bugnote_id, 'reporter_id' ); if ( ( $t_user_id != $t_reporter_id ) || - ( OFF == config_get( 'bugnote_allow_user_edit' ) ) ) { + !( access_has_bugnote_level( config_get( 'bugnote_user_edit_threshold' ), $f_bugnote_id ) ) ) { access_ensure_bugnote_level( config_get( 'update_bugnote_threshold' ), $f_bugnote_id ); } diff --git a/bugnote_update.php b/bugnote_update.php index cdbfd26..ed4d361 100644 --- a/bugnote_update.php +++ b/bugnote_update.php @@ -41,7 +41,7 @@ $t_user_id = auth_get_current_user_id(); $t_reporter_id = bugnote_get_field( $f_bugnote_id, 'reporter_id' ); - if ( ( $t_user_id != $t_reporter_id ) || ( OFF == config_get( 'bugnote_allow_user_edit' ) )) { + if ( ( $t_user_id != $t_reporter_id ) || !( access_has_bugnote_level( config_get( 'bugnote_user_edit_threshold' ), $f_bugnote_id ) )) { access_ensure_bugnote_level( config_get( 'update_bugnote_threshold' ), $f_bugnote_id ); } diff --git a/bugnote_view_inc.php b/bugnote_view_inc.php index 4ca231c..6d4775b 100644 --- a/bugnote_view_inc.php +++ b/bugnote_view_inc.php @@ -142,13 +142,13 @@ $num_notes = count( $t_bugnotes ); # bugnote creator might be able to edit/delete this bugnote if ( $t_bugnote->reporter_id == $t_user_id ) { - if ( ON == config_get( 'bugnote_allow_user_edit' ) ) { + if ( access_has_bugnote_level( config_get( 'bugnote_user_edit_threshold' ), $t_bugnote->id ) ) { $t_can_edit_note = true; } - if ( ON == config_get( 'bugnote_allow_user_delete' ) ) { + if ( access_has_bugnote_level( config_get( 'bugnote_user_delete_threshold' ), $t_bugnote->id ) ) { $t_can_delete_note = true; } - if ( ON == config_get( 'bugnote_allow_user_make_priv' ) ) { + if ( access_has_bugnote_level( config_get( 'bugnote_user_make_priv_threshold' ), $t_bugnote->id ) ) { $t_can_make_note_priv = true; } } diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 5924b68..a97c221 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -2439,22 +2439,22 @@ $g_delete_bugnote_threshold = '%delete_bug_threshold%'; /** - * Are users allowed to change their own bugnotes? - * @global int $g_bugnote_allow_user_edit + * Threshold at which a user can edit his/her own bugnotes + * @global int $g_bugnote_user_edit_threshold */ - $g_bugnote_allow_user_edit = ON; + $g_bugnote_user_edit_threshold = REPORTER; /** - * Are users allowed to delete their own bugnotes? - * @global int $g_bugnote_allow_user_delete + * Threshold at which a user can delete his/her own bugnotes + * @global int $g_bugnote_user_delete_threshold */ - $g_bugnote_allow_user_delete = ON; + $g_bugnote_user_delete_threshold = REPORTER; /** - * Are users allowed to change the view status of their own bugnotes? - * @global int $g_bugnote_allow_user_make_priv + * Threshold at which a user can make his/her own bugnotes private + * @global int $g_bugnote_user_make_priv_threshold */ - $g_bugnote_allow_user_make_priv = ON; + $g_bugnote_user_make_priv_threshold = REPORTER; /** * Move bug threshold diff --git a/lang/strings_english.txt b/lang/strings_english.txt index 727502d..69412d7 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -846,9 +846,9 @@ $s_allow_close_immediate = 'Allow issue to be closed on Resolve'; $s_allow_reporter_close = 'Allow Reporter to close Issue'; $s_allow_reporter_reopen = 'Allow Reporter to re-open Issue'; $s_set_status_assigned = 'Set status on assignment of Handler'; -$s_allow_user_edit = 'Allow user to edit their own issue notes'; -$s_allow_user_delete = 'Allow user to delete their own issue notes'; -$s_allow_user_make_priv = 'Allow user to make their own issue notes private'; +$s_edit_user_notes = 'User can edit his/her own notes'; +$s_delete_user_notes = 'User can delete his/her own notes'; +$s_make_user_notes_priv = 'User can make his/her own notes private'; $s_limit_access = 'Limit reporter\'s access to their own issues'; $s_submit_status = 'Status to which a new issue is set'; $s_assigned_status = 'Status to set auto-assigned issues to'; diff --git a/manage_config_work_threshold_page.php b/manage_config_work_threshold_page.php index 3d95fa8..998e756 100644 --- a/manage_config_work_threshold_page.php +++ b/manage_config_work_threshold_page.php @@ -301,10 +301,10 @@ get_section_begin_mcwt( lang_get( 'notes' ) ); get_capability_row( lang_get( 'add_notes' ), 'add_bugnote_threshold' ); get_capability_row( lang_get( 'update_notes' ), 'update_bugnote_threshold' ); - get_capability_boolean( lang_get( 'allow_user_edit' ), 'bugnote_allow_user_edit' ); - get_capability_boolean( lang_get( 'allow_user_delete' ), 'bugnote_allow_user_delete' ); - get_capability_boolean( lang_get( 'allow_user_make_priv' ), 'bugnote_allow_user_make_priv' ); get_capability_row( lang_get( 'delete_note' ), 'delete_bugnote_threshold' ); + get_capability_row( lang_get( 'edit_user_notes' ), 'bugnote_user_edit_threshold' ); + get_capability_row( lang_get( 'delete_user_notes' ), 'bugnote_user_delete_threshold' ); + get_capability_row( lang_get( 'make_user_notes_priv' ), 'bugnote_user_make_priv_threshold' ); get_capability_row( lang_get( 'view_private_notes' ), 'private_bugnote_threshold' ); get_section_end(); diff --git a/manage_config_work_threshold_set.php b/manage_config_work_threshold_set.php index ef2f4e5..ffa9209 100644 --- a/manage_config_work_threshold_set.php +++ b/manage_config_work_threshold_set.php @@ -144,9 +144,9 @@ # Notes set_capability_row( 'add_bugnote_threshold' ); set_capability_row( 'update_bugnote_threshold' ); - set_capability_boolean( 'bugnote_allow_user_edit' ); - set_capability_boolean( 'bugnote_allow_user_delete' ); - set_capability_boolean( 'bugnote_allow_user_make_priv' ); + set_capability_row( 'bugnote_user_edit_threshold' ); + set_capability_row( 'bugnote_user_delete_threshold' ); + set_capability_row( 'bugnote_user_make_priv_threshold' ); set_capability_row( 'delete_bugnote_threshold' ); set_capability_row( 'private_bugnote_threshold' ); -- 1.6.0.4