Permalink
Browse files

Initial work at adding MantisContext class concept

Removal of bulk of current_user_* api
  • Loading branch information...
1 parent db2c92b commit b997da939b18c47840611c508e0cc2d5500cfe96 @grangeway grangeway committed Apr 19, 2013
Showing with 245 additions and 549 deletions.
  1. +2 −4 account_delete.php
  2. +1 −3 account_manage_columns_page.php
  3. +2 −4 account_page.php
  4. +1 −3 account_prefs_page.php
  5. +1 −3 account_prof_edit_page.php
  6. +1 −3 account_prof_menu_page.php
  7. +2 −4 account_prof_update.php
  8. +1 −3 account_sponsor_page.php
  9. +1 −3 account_update.php
  10. +1 −1 admin/check/check_anonymous_inc.php
  11. +4 −7 bug_actiongroup.php
  12. +2 −3 bug_actiongroup_ext.php
  13. +2 −6 bug_actiongroup_page.php
  14. +1 −5 bug_change_status_page.php
  15. +1 −5 bug_file_add.php
  16. +1 −5 bug_file_delete.php
  17. +1 −5 bug_monitor_add.php
  18. +1 −5 bug_monitor_delete.php
  19. +2 −5 bug_relationship_add.php
  20. +2 −5 bug_relationship_delete.php
  21. +1 −5 bug_relationship_graph.php
  22. +2 −5 bug_reminder.php
  23. +2 −5 bug_reminder_page.php
  24. +1 −1 bug_report_page.php
  25. +3 −8 bug_set_sponsorship.php
  26. +1 −3 bug_sponsorship_list_view_inc.php
  27. +1 −5 bug_stick.php
  28. +1 −3 bug_update.php
  29. +1 −5 bug_update_page.php
  30. +3 −8 bug_view_inc.php
  31. +4 −5 bugnote_add.php
  32. +4 −5 bugnote_delete.php
  33. +2 −5 bugnote_edit_page.php
  34. +2 −5 bugnote_set_view_state.php
  35. +1 −3 bugnote_view_inc.php
  36. +0 −2 core/access_api.php
  37. +10 −26 core/authentication_api.php
  38. +1 −1 core/bug_group_action_api.php
  39. +2 −2 core/category_api.php
  40. +63 −0 core/classes/MantisContext.class.php
  41. +1 −1 core/classes/MantisError.class.php
  42. +1 −3 core/collapse_api.php
  43. +1 −4 core/config_api.php
  44. +0 −191 core/current_user_api.php
  45. +1 −3 core/email_api.php
  46. +1 −1 core/filter_api.php
  47. +6 −18 core/helper_api.php
  48. +16 −16 core/html_api.php
  49. +1 −3 core/last_visited_api.php
  50. +2 −4 core/news_api.php
  51. +2 −4 core/print_api.php
  52. +1 −1 core/project_api.php
  53. +1 −3 core/relationship_api.php
  54. +2 −4 core/rss_api.php
  55. +3 −3 core/string_api.php
  56. +2 −4 core/summary_api.php
  57. +25 −4 core/user_api.php
  58. +1 −3 login_page.php
  59. +3 −5 login_select_proj_page.php
  60. +4 −6 main_page.php
  61. +1 −3 manage/columns_copy.php
  62. +2 −4 manage/columns_inc.php
  63. +1 −3 manage/config_columns_set.php
  64. +1 −3 manage/config_email_page.php
  65. +1 −3 manage/config_email_set.php
  66. +1 −3 manage/config_work_threshold_set.php
  67. +0 −1 manage/config_workflow_graph_page.php
  68. +1 −3 manage/config_workflow_page.php
  69. +1 −3 manage/config_workflow_set.php
  70. +1 −3 manage/overview_page.php
  71. +1 −3 manage/proj_create.php
  72. +1 −3 manage/proj_create_page.php
  73. +1 −3 manage/proj_edit_page.php
  74. +1 −3 manage/proj_update_children.php
  75. +5 −7 my_view_page.php
  76. +1 −3 news_edit_page.php
  77. +1 −2 news_menu_page.php
  78. +1 −1 plugins/MantisGraph/pages/config.php
  79. +1 −1 plugins/MantisGraph/pages/config_edit.php
  80. +1 −3 print_all_bug_options_reset.php
  81. +2 −5 print_bug_page.php
  82. +1 −3 print_bugnote_inc.php
  83. +1 −2 proj_doc_page.php
  84. +1 −2 project_page.php
  85. +1 −1 return_dynamic_filters.php
  86. +1 −3 set_project.php
  87. +1 −2 summary_page.php
  88. +2 −4 view_all_bug_page.php
  89. +0 −2 view_all_inc.php
  90. +1 −1 view_filters_page.php
  91. +1 −1 view_user_page.php
View
@@ -43,7 +43,6 @@
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
- * @uses current_user_api.php
* @uses form_api.php
* @uses helper_api.php
* @uses print_api.php
@@ -55,7 +54,6 @@
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
-require_api( 'current_user_api.php' );
require_api( 'form_api.php' );
require_api( 'helper_api.php' );
require_api( 'print_api.php' );
@@ -65,7 +63,7 @@
auth_ensure_user_authenticated();
-current_user_ensure_unprotected();
+user_ensure_unprotected();
# Only allow users to delete their own accounts if allow_account_delete = ON or
# the user has permission to manage user accounts.
@@ -76,7 +74,7 @@
# check that we are not deleting the last administrator account
$t_admin_threshold = config_get_global( 'admin_site_threshold' );
-if ( current_user_is_administrator() &&
+if ( user_is_administrator( auth_get_current_user_id() ) &&
user_count_level( $t_admin_threshold ) <= 1 ) {
throw new MantisBT\Exception\User\ProtectedLastAdministrator();
}
@@ -36,17 +36,15 @@
* @link http://www.mantisbt.org
*
* @uses core.php
- * @uses current_user_api.php
* @uses html_api.php
*/
require_once( 'core.php' );
-require_api( 'current_user_api.php' );
require_api( 'html_api.php' );
html_page_top( _( 'Manage Columns' ) );
-current_user_ensure_unprotected();
+user_ensure_unprotected();
# Define constant that will be checked by the include page.
define ( 'ACCOUNT_COLUMNS', true );
View
@@ -46,7 +46,6 @@
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
- * @uses current_user_api.php
* @uses form_api.php
* @uses helper_api.php
* @uses html_api.php
@@ -61,7 +60,6 @@
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
-require_api( 'current_user_api.php' );
require_api( 'form_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
@@ -74,7 +72,7 @@
#============ Permissions ============
auth_ensure_user_authenticated();
-current_user_ensure_unprotected();
+user_ensure_unprotected();
# extracts the user information for the currently logged in user
# and prefixes it with u_
@@ -188,7 +186,7 @@
</div>
<div class="field-container">
<span class="display-label"><span><?php echo _( 'Project Access Level' ) ?></span></span>
- <span class="input"><span class="field-value"><?php echo get_enum_element( 'access_levels', current_user_get_access_level() ); ?></span></span>
+ <span class="input"><span class="field-value"><?php echo get_enum_element( 'access_levels', user_get_access_level() ); ?></span></span>
<span class="label-style"></span>
</div>
<?php
View
@@ -41,13 +41,11 @@
*
* @uses core.php
* @uses authentication_api.php
- * @uses current_user_api.php
* @uses html_api.php
*/
require_once( 'core.php' );
require_api( 'authentication_api.php' );
-require_api( 'current_user_api.php' );
require_api( 'html_api.php' );
#============ Parameters ============
@@ -56,7 +54,7 @@
#============ Permissions ============
auth_ensure_user_authenticated();
-current_user_ensure_unprotected();
+user_ensure_unprotected();
define( 'ACCOUNT_PREFS_INC_ALLOW', true );
include( dirname( __FILE__ ) . '/account_prefs_inc.php' );
@@ -28,7 +28,6 @@
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
- * @uses current_user_api.php
* @uses form_api.php
* @uses gpc_api.php
* @uses html_api.php
@@ -41,7 +40,6 @@
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
-require_api( 'current_user_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
require_api( 'html_api.php' );
@@ -54,7 +52,7 @@
auth_ensure_user_authenticated();
-current_user_ensure_unprotected();
+user_ensure_unprotected();
$f_profile_id = gpc_get_int( 'profile_id' );
@@ -30,7 +30,6 @@
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
- * @uses current_user_api.php
* @uses form_api.php
* @uses html_api.php
* @uses print_api.php
@@ -42,7 +41,6 @@
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
-require_api( 'current_user_api.php' );
require_api( 'form_api.php' );
require_api( 'html_api.php' );
require_api( 'print_api.php' );
@@ -60,7 +58,7 @@
auth_ensure_user_authenticated();
-current_user_ensure_unprotected();
+user_ensure_unprotected();
if ( $g_global_profiles ) {
access_ensure_global_level( config_get( 'manage_global_profile_threshold' ) );
View
@@ -28,7 +28,6 @@
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
- * @uses current_user_api.php
* @uses form_api.php
* @uses gpc_api.php
* @uses print_api.php
@@ -40,7 +39,6 @@
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
-require_api( 'current_user_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
require_api( 'print_api.php' );
@@ -54,7 +52,7 @@
auth_ensure_user_authenticated();
-current_user_ensure_unprotected();
+user_ensure_unprotected();
$f_action = gpc_get_string('action');
@@ -129,7 +127,7 @@
case 'make_default':
$f_profile_id = gpc_get_int( 'profile_id' );
- current_user_set_pref( 'default_profile', $f_profile_id );
+ user_pref_set_pref( auth_get_current_user_id(), 'default_profile', $f_profile_id );
form_security_purge('profile_update');
print_header_redirect( 'account_prof_menu_page.php' );
break;
View
@@ -43,7 +43,6 @@
* @uses bug_api.php
* @uses config_api.php
* @uses constant_inc.php
- * @uses current_user_api.php
* @uses database_api.php
* @uses form_api.php
* @uses gpc_api.php
@@ -62,7 +61,6 @@
require_api( 'bug_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
-require_api( 'current_user_api.php' );
require_api( 'database_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
@@ -80,7 +78,7 @@
}
# anonymous users are not allowed to sponsor issues
-if ( current_user_is_anonymous() ) {
+if ( user_is_anonymous( auth_get_current_user_id() ) ) {
throw new MantisBT\Exception\Access\AccessDenied();
}
View
@@ -28,7 +28,6 @@
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
- * @uses current_user_api.php
* @uses email_api.php
* @uses form_api.php
* @uses gpc_api.php
@@ -43,7 +42,6 @@
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
-require_api( 'current_user_api.php' );
require_api( 'email_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
@@ -57,7 +55,7 @@
auth_ensure_user_authenticated();
-current_user_ensure_unprotected();
+user_ensure_unprotected();
$f_email = gpc_get_string( 'email', '' );
$f_realname = gpc_get_string( 'realname', '' );
@@ -87,7 +87,7 @@
'anonymous_account user does not have administrator permissions',
!user_is_administrator( $t_anonymous_user_id ),
array(
- true => 'The anonymous user account currently has an access level of: ' . htmlentities( get_enum_element( 'access_levels', user_get_access_level( $t_anonymous_user_id ) ) ),
+ true => 'The anonymous user account currently has an access level of: ' . htmlentities( get_enum_element( 'access_levels', user_get_access_level( $t_anonymous_user_id, ALL_PROJECTS ) ) ),
false => 'The anonymous user account should not have administrator level permissions.'
)
);
View
@@ -92,13 +92,10 @@
bug_ensure_exists( $t_bug_id );
$t_bug = bug_get( $t_bug_id, true );
- if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
- /** @todo (thraxisp) the next line goes away if the cache was smarter and used project */
- config_flush_cache(); # flush the config cache so that configs are refetched
- }
+ MantisContext::SetProject( $t_bug->project_id );
+ /** @todo (thraxisp) the next line goes away if the cache was smarter and used project */
+ // @TODO ?!!!?
+ config_flush_cache(); # flush the config cache so that configs are refetched
$t_status = $t_bug->status;
View
@@ -76,7 +76,7 @@
$t_failed_ids = array();
foreach( $t_projects_bugs as $t_project_id => $t_bugs ) {
- $g_project_override = $t_project_id;
+ MantisContext::SetProject( $t_project_id );
foreach( $t_bugs as $t_bug_id ) {
$t_fail_reason = bug_group_action_validate( $f_action, $t_bug_id );
if( $t_fail_reason !== null ) {
@@ -89,10 +89,9 @@
}
}
}
+ MantisContext::PopProject();
}
-$g_project_override = null;
-
form_security_purge( $t_form_name );
if ( count( $t_failed_ids ) > 0 ) {
View
@@ -88,12 +88,8 @@
$t_project_id = ALL_PROJECTS;
$t_projects[ALL_PROJECTS] = ALL_PROJECTS;
}
-# override the project if necessary
-if( $t_project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_project_id;
-}
+
+MantisContext::SetProject( $t_project_id );
define( 'BUG_ACTIONGROUP_INC_ALLOW', true );
@@ -70,11 +70,7 @@
$tpl_force_readonly = true;
$tpl_fields_config_option = 'bug_change_status_page_columns';
-if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
-}
+MantisContext::SetProject( $t_bug->project_id );
$f_new_status = gpc_get_int( 'new_status' );
$f_reopen_flag = gpc_get_int( 'reopen_flag', OFF );
View
@@ -60,11 +60,7 @@
form_security_validate( 'bug_file_add' );
$t_bug = bug_get( $f_bug_id, true );
-if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
-}
+MantisContext::SetProject( $t_bug->project_id );
if ( !file_allow_bug_upload( $t_bug ) ) {
throw new MantisBT\Exception\Access\AccessDenied();
View
@@ -51,11 +51,7 @@
$t_bug_id = file_get_field( $f_file_id, 'bug_id' );
$t_bug = bug_get( $t_bug_id, true );
-if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
-}
+MantisContext::SetProject( $t_bug->project_id );
access_ensure_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id );
View
@@ -76,11 +76,7 @@
bug_ensure_exists( $f_bug_id );
-if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
-}
+MantisContext::SetProject( $t_bug->project_id );
if ( $t_logged_in_user_id == $t_user_id ) {
access_ensure_bug_level( config_get( 'monitor_bug_threshold' ), $f_bug_id );
View
@@ -68,11 +68,7 @@
bug_ensure_exists( $f_bug_id );
-if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
-}
+MantisContext::SetProject( $t_bug->project_id );
if ( $t_logged_in_user_id == $t_user_id ) {
access_ensure_bug_level( config_get( 'monitor_bug_threshold' ), $f_bug_id );
View
@@ -85,11 +85,8 @@
}
$t_bug = bug_get( $f_src_bug_id, true );
- if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
- }
+
+ MantisContext::SetProject( $t_bug->project_id );
# check if there is other relationship between the bugs...
$t_old_id_relationship = relationship_same_type_exists( $f_src_bug_id, $f_dest_bug_id, $f_rel_type );
@@ -61,11 +61,8 @@
$f_bug_id = gpc_get_int( 'bug_id' );
$t_bug = bug_get( $f_bug_id, true );
-if( $t_bug->project_id != helper_get_current_project() ) {
- # in case the current project is not the same project of the bug we are viewing...
- # ... override the current project. This to avoid problems with categories and handlers lists etc.
- $g_project_override = $t_bug->project_id;
-}
+
+MantisContext::SetProject( $t_bug->project_id );
# user has access to update the bug...
access_ensure_bug_level( config_get( 'update_bug_threshold' ), $f_bug_id );
Oops, something went wrong.

0 comments on commit b997da9

Please sign in to comment.