| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 # MantisBT - A PHP based bugtracking system 3 4 # MantisBT is free software: you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published by 6 # the Free Software Foundation, either version 2 of the License, or 7 # (at your option) any later version. 8 # 9 # MantisBT is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Current User API 19 * 20 * @package CoreAPI 21 * @subpackage CurrentUserAPI 22 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 23 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 24 * @link http://www.mantisbt.org 25 * 26 * @uses authentication_api.php 27 * @uses constant_inc.php 28 * @uses filter_api.php 29 * @uses gpc_api.php 30 * @uses helper_api.php 31 * @uses tokens_api.php 32 * @uses user_api.php 33 * @uses user_pref_api.php 34 * @uses utility_api.php 35 */ 36 37 require_api( 'authentication_api.php' ); 38 require_api( 'constant_inc.php' ); 39 require_api( 'filter_api.php' ); 40 require_api( 'gpc_api.php' ); 41 require_api( 'helper_api.php' ); 42 require_api( 'tokens_api.php' ); 43 require_api( 'user_api.php' ); 44 require_api( 'user_pref_api.php' ); 45 require_api( 'utility_api.php' ); 46 47 # ## Current User API ### 48 # Wrappers around the User API that pass in the logged-in user for you 49 /** 50 * Returns the access level of the current user in the current project 51 * 52 * @return access level code 53 * @access public 54 */ 55 function current_user_get_access_level() { 56 return user_get_access_level( auth_get_current_user_id(), helper_get_current_project() ); 57 } 58 59 /** 60 * Returns the number of open issues that are assigned to the current user 61 * in the current project. 62 * 63 * @return Number of issues assigned to current user that are still open. 64 * @access public 65 */ 66 function current_user_get_assigned_open_bug_count() { 67 return user_get_assigned_open_bug_count( auth_get_current_user_id(), helper_get_current_project() ); 68 } 69 70 /** 71 * Returns the number of open reported bugs by the current user in 72 * the current project 73 * 74 * @return Number of issues reported by current user that are still open. 75 * @access public 76 */ 77 function current_user_get_reported_open_bug_count() { 78 return user_get_reported_open_bug_count( auth_get_current_user_id(), helper_get_current_project() ); 79 } 80 81 /** 82 * Returns the specified field of the currently logged in user 83 * 84 * @param field_name Name of user property as in the table definition. 85 * @return Get the value of the specified field for current user. 86 * @access public 87 */ 88 function current_user_get_field( $p_field_name ) { 89 return user_get_field( auth_get_current_user_id(), $p_field_name ); 90 } 91 92 /** 93 * Returns the specified field of the currently logged in user 94 * 95 * @param pref_name Name of user preference as in the preferences table 96 * definition. 97 * @return Get the value of the specified preference for current user. 98 * @access public 99 */ 100 function current_user_get_pref( $p_pref_name ) { 101 return user_pref_get_pref( auth_get_current_user_id(), $p_pref_name ); 102 } 103 104 /** 105 * Sets the specified preference for the current logged in user. 106 * 107 * @param pref_name The name of the preference as in the preferences table. 108 * @param pref_value The preference new value. 109 * @access public 110 */ 111 function current_user_set_pref( $p_pref_name, $p_pref_value ) { 112 return user_pref_set_pref( auth_get_current_user_id(), $p_pref_name, $p_pref_value ); 113 } 114 115 /** 116 * Return the specified field of the currently logged in user 117 * 118 * @param project_id The new default project id. 119 * @access public 120 */ 121 function current_user_set_default_project( $p_project_id ) { 122 return user_set_default_project( auth_get_current_user_id(), $p_project_id ); 123 } 124 125 /** 126 * Returns an array of projects that are accessible to the current logged in 127 * user. 128 * 129 * @param show_disabled Include disabled projects. 130 * @return an array of accessible project ids. 131 * @access public 132 */ 133 function current_user_get_accessible_projects( $p_show_disabled = false ) { 134 return user_get_accessible_projects( auth_get_current_user_id(), $p_show_disabled ); 135 } 136 137 /** 138 * Returns an array of subprojects of the specified project to which the 139 * currently logged in user has access to. 140 * 141 * @param project_id Parent project id. 142 * @param show_disabled Include disabled projects. 143 * @return an array of accessible sub-project ids. 144 * @access public 145 */ 146 function current_user_get_accessible_subprojects( $p_project_id, $p_show_disabled = false ) { 147 return user_get_accessible_subprojects( auth_get_current_user_id(), $p_project_id, $p_show_disabled ); 148 } 149 150 /** 151 * Returns an array of subprojects of the specified project to which the 152 * currently logged in user has access, including subprojects of subprojects 153 * 154 * @param project_id Parent project id. 155 * @return an array of accessible sub-project ids. 156 * @access public 157 */ 158 function current_user_get_all_accessible_subprojects( $p_project_id ) { 159 return user_get_all_accessible_subprojects( auth_get_current_user_id(), $p_project_id ); 160 } 161 162 /** 163 * Returns true if the currently logged in user is has a role of administrator 164 * or higher, false otherwise 165 * 166 * @return true: administrator; false: otherwise. 167 * @access public 168 */ 169 function current_user_is_administrator() { 170 return user_is_administrator( auth_get_current_user_id() ); 171 } 172 173 /** 174 * Returns true if the current user is a protected user, false otherwise. 175 * The $g_anonymous_account user is always considered protected. 176 * 177 * @return true: user is protected; false: otherwise. 178 * @access public 179 */ 180 function current_user_is_protected() { 181 return user_is_protected( auth_get_current_user_id() ); 182 } 183 184 /** 185 * Returns true if the current user is the anonymous user. 186 * 187 * @return true: user is anonymous; false: otherwise. 188 * @access public 189 */ 190 function current_user_is_anonymous() { 191 return user_is_anonymous( auth_get_current_user_id() ); 192 } 193 194 /** 195 * Triggers an ERROR if the current user account is protected. 196 * The $g_anonymous_account user is always considered protected. 197 * 198 * @access public 199 */ 200 function current_user_ensure_unprotected() { 201 user_ensure_unprotected( auth_get_current_user_id() ); 202 } 203 204 /** 205 * Returns the issue filter parameters for the current user 206 * 207 * @return Active issue filter for current user or false if no filter is currently defined. 208 * @access public 209 */ 210 function current_user_get_bug_filter( $p_project_id = null ) { 211 $f_filter_string = gpc_get_string( 'filter', '' ); 212 $t_view_all_cookie = ''; 213 $t_cookie_detail = ''; 214 $t_filter = ''; 215 216 if( !is_blank( $f_filter_string ) ) { 217 if( is_numeric( $f_filter_string ) ) { 218 $t_token = token_get_value( TOKEN_FILTER ); 219 if( null != $t_token ) { 220 $t_filter = unserialize( $t_token ); 221 } 222 } else { 223 $t_filter = unserialize( $f_filter_string ); 224 } 225 } else if( !filter_is_cookie_valid() ) { 226 return false; 227 } else { 228 $t_user_id = auth_get_current_user_id(); 229 $t_filter = user_get_bug_filter( $t_user_id, $p_project_id ); 230 } 231 232 $t_filter = filter_ensure_valid_filter( $t_filter ); 233 return $t_filter; 234 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |