Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3e35866d7862
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b997da939b18
Choose a head ref
  • 3 commits
  • 98 files changed
  • 1 contributor

Commits on Apr 11, 2013

  1. Fix typo spotted by atrol

    mantis committed Apr 11, 2013
    Copy the full SHA
    4ba772e View commit details
  2. misc fixes for 2.x

    mantis committed Apr 11, 2013
    Copy the full SHA
    db2c92b View commit details

Commits on Apr 19, 2013

  1. Initial work at adding MantisContext class concept

    Removal of bulk of current_user_* api
    mantis committed Apr 19, 2013
    Copy the full SHA
    b997da9 View commit details
Showing with 272 additions and 561 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. +2 −2 admin/install.php
  12. +4 −7 bug_actiongroup.php
  13. +2 −3 bug_actiongroup_ext.php
  14. +2 −6 bug_actiongroup_page.php
  15. +1 −5 bug_change_status_page.php
  16. +1 −5 bug_file_add.php
  17. +1 −5 bug_file_delete.php
  18. +2 −6 bug_monitor_add.php
  19. +1 −5 bug_monitor_delete.php
  20. +2 −5 bug_relationship_add.php
  21. +2 −5 bug_relationship_delete.php
  22. +1 −5 bug_relationship_graph.php
  23. +2 −5 bug_reminder.php
  24. +2 −5 bug_reminder_page.php
  25. +1 −1 bug_report_page.php
  26. +3 −8 bug_set_sponsorship.php
  27. +1 −3 bug_sponsorship_list_view_inc.php
  28. +1 −5 bug_stick.php
  29. +1 −3 bug_update.php
  30. +1 −5 bug_update_page.php
  31. +3 −8 bug_view_inc.php
  32. +4 −5 bugnote_add.php
  33. +4 −5 bugnote_delete.php
  34. +2 −5 bugnote_edit_page.php
  35. +2 −5 bugnote_set_view_state.php
  36. +1 −3 bugnote_view_inc.php
  37. +1 −1 config_defaults_inc.php
  38. +0 −2 core/access_api.php
  39. +10 −26 core/authentication_api.php
  40. +1 −1 core/bug_group_action_api.php
  41. +2 −2 core/category_api.php
  42. +63 −0 core/classes/MantisContext.class.php
  43. +16 −1 core/classes/MantisDatabaseDict/MantisDatabaseDict.class.php
  44. +1 −1 core/classes/MantisError.class.php
  45. +1 −3 core/collapse_api.php
  46. +1 −4 core/config_api.php
  47. +0 −191 core/current_user_api.php
  48. +1 −3 core/email_api.php
  49. +1 −1 core/filter_api.php
  50. +6 −18 core/helper_api.php
  51. +16 −16 core/html_api.php
  52. +1 −3 core/last_visited_api.php
  53. +2 −4 core/news_api.php
  54. +1 −1 core/php_api.php
  55. +2 −4 core/print_api.php
  56. +1 −1 core/project_api.php
  57. +1 −3 core/relationship_api.php
  58. +2 −4 core/rss_api.php
  59. +3 −3 core/string_api.php
  60. +2 −4 core/summary_api.php
  61. +25 −4 core/user_api.php
  62. +1 −0 core/user_pref_api.php
  63. +1 −3 login_page.php
  64. +3 −5 login_select_proj_page.php
  65. +4 −6 main_page.php
  66. +1 −3 manage/columns_copy.php
  67. +2 −4 manage/columns_inc.php
  68. +1 −3 manage/config_columns_set.php
  69. +1 −3 manage/config_email_page.php
  70. +1 −3 manage/config_email_set.php
  71. +1 −3 manage/config_work_threshold_set.php
  72. +0 −1 manage/config_workflow_graph_page.php
  73. +1 −3 manage/config_workflow_page.php
  74. +1 −3 manage/config_workflow_set.php
  75. +1 −3 manage/overview_page.php
  76. +1 −3 manage/proj_create.php
  77. +1 −3 manage/proj_create_page.php
  78. +1 −3 manage/proj_edit_page.php
  79. +1 −3 manage/proj_update_children.php
  80. +4 −4 manage/user_create.php
  81. +1 −2 manage/user_update.php
  82. +5 −7 my_view_page.php
  83. +1 −3 news_edit_page.php
  84. +1 −2 news_menu_page.php
  85. +1 −1 plugins/MantisGraph/pages/config.php
  86. +1 −1 plugins/MantisGraph/pages/config_edit.php
  87. +1 −3 print_all_bug_options_reset.php
  88. +2 −5 print_bug_page.php
  89. +1 −3 print_bugnote_inc.php
  90. +1 −2 proj_doc_page.php
  91. +1 −2 project_page.php
  92. +1 −1 return_dynamic_filters.php
  93. +1 −3 set_project.php
  94. +1 −2 summary_page.php
  95. +2 −4 view_all_bug_page.php
  96. +0 −2 view_all_inc.php
  97. +1 −1 view_filters_page.php
  98. +1 −1 view_user_page.php
6 changes: 2 additions & 4 deletions account_delete.php
Original file line number Diff line number Diff line change
@@ -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();
}
4 changes: 1 addition & 3 deletions account_manage_columns_page.php
Original file line number Diff line number Diff line change
@@ -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 );
6 changes: 2 additions & 4 deletions account_page.php
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions account_prefs_page.php
Original file line number Diff line number Diff line change
@@ -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' );
4 changes: 1 addition & 3 deletions account_prof_edit_page.php
Original file line number Diff line number Diff line change
@@ -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' );

4 changes: 1 addition & 3 deletions account_prof_menu_page.php
Original file line number Diff line number Diff line change
@@ -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' ) );
6 changes: 2 additions & 4 deletions account_prof_update.php
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 1 addition & 3 deletions account_sponsor_page.php
Original file line number Diff line number Diff line change
@@ -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();
}

4 changes: 1 addition & 3 deletions account_update.php
Original file line number Diff line number Diff line change
@@ -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', '' );
2 changes: 1 addition & 1 deletion admin/check/check_anonymous_inc.php
Original file line number Diff line number Diff line change
@@ -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.'
)
);
4 changes: 2 additions & 2 deletions admin/install.php
Original file line number Diff line number Diff line change
@@ -564,7 +564,7 @@ function InsertData( $p_table, $p_data ) {
print_test_result( GOOD );
$t_db_open = true;
} else {
$dict = new MantisDatabaseDict( $g_db );
$dict = MantisDatabaseDict::get_driver_instance($f_db_type);

$sqlarray = $dict->CreateDatabase( $f_database_name );
$ret = $dict->ExecuteSQLarray( $sqlarray );
@@ -676,7 +676,7 @@ function InsertData( $p_table, $p_data ) {
}

$g_db->SetPrefixes( 'mantis_', '_table' );
$dict = new MantisDatabaseDict( $g_db );
$dict = MantisDatabaseDict::get_driver_instance($f_db_type);
$t_sql = true;
$t_target = $upgrade[$i][1][0];
if( $upgrade[$i][0] == 'InsertData' ) {
11 changes: 4 additions & 7 deletions bug_actiongroup.php
Original file line number Diff line number Diff line change
@@ -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;

5 changes: 2 additions & 3 deletions bug_actiongroup_ext.php
Original file line number Diff line number Diff line change
@@ -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 ) {
8 changes: 2 additions & 6 deletions bug_actiongroup_page.php
Original file line number Diff line number Diff line change
@@ -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 );

6 changes: 1 addition & 5 deletions bug_change_status_page.php
Original file line number Diff line number Diff line change
@@ -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 );
6 changes: 1 addition & 5 deletions bug_file_add.php
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 1 addition & 5 deletions bug_file_delete.php
Original file line number Diff line number Diff line change
@@ -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 );

8 changes: 2 additions & 6 deletions bug_monitor_add.php
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@
$t_user_id = user_get_id_by_realname( $f_username );

if ( $t_user_id === false ) {
throw new MantisBT\Exception\User_By_Name_Not_Found( $f_username );
throw new MantisBT\Exception\User\UserNotFound( $f_username );
}
}
}
@@ -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 );
6 changes: 1 addition & 5 deletions bug_monitor_delete.php
Original file line number Diff line number Diff line change
@@ -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 );
Loading