[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/core/ -> current_user_api.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: current_user_api.php,v 1.31.2.1 2007-10-13 22:35:21 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
  25  
  26      require_once ( $t_core_dir . 'filter_api.php' );
  27  
  28      ### Current User API ###
  29  
  30      # Wrappers around the User API that pass in the logged-in user for you
  31  
  32      # --------------------
  33      # Return the access level of the current user in the current project
  34  	function current_user_get_access_level() {
  35          return user_get_access_level( auth_get_current_user_id(),
  36                                          helper_get_current_project() );
  37      }
  38      # --------------------
  39      # Return the number of open assigned bugs to the current user in
  40      #  the current project
  41  	function current_user_get_assigned_open_bug_count() {
  42          return user_get_assigned_open_bug_count( auth_get_current_user_id(),
  43                                                      helper_get_current_project() );
  44      }
  45      # --------------------
  46      # Return the number of open reported bugs by the current user in
  47      #  the current project
  48  	function current_user_get_reported_open_bug_count() {
  49          return user_get_reported_open_bug_count( auth_get_current_user_id(),
  50                                                      helper_get_current_project() );
  51      }
  52      # --------------------
  53      # Return the specified field of the currently logged in user
  54  	function current_user_get_field( $p_field_name ) {
  55          return user_get_field( auth_get_current_user_id(),
  56                                  $p_field_name );
  57      }
  58      # --------------------
  59      # Return the specified field of the currently logged in user
  60  	function current_user_get_pref( $p_pref_name ) {
  61          return user_pref_get_pref( auth_get_current_user_id(), $p_pref_name );
  62      }
  63      # --------------------
  64      # Return the specified field of the currently logged in user
  65  	function current_user_set_pref( $p_pref_name, $p_pref_value ) {
  66          return user_pref_set_pref( auth_get_current_user_id(), $p_pref_name, $p_pref_value );
  67      }
  68      # --------------------
  69      # Return the specified field of the currently logged in user
  70  	function current_user_set_default_project( $p_project_id ) {
  71          return user_set_default_project( auth_get_current_user_id(), $p_project_id );
  72      }
  73      # --------------------
  74      # Return an array of projects to which the currently logged in user
  75      #  has access
  76  	function current_user_get_accessible_projects( $p_show_disabled = false ) {
  77          return user_get_accessible_projects( auth_get_current_user_id(), $p_show_disabled );
  78      }
  79      # --------------------
  80      # Return an array of subprojects of the specified project to which the
  81      # currently logged in user has access
  82  	function current_user_get_accessible_subprojects( $p_project_id, $p_show_disabled = false ) {
  83          return user_get_accessible_subprojects( auth_get_current_user_id(), $p_project_id, $p_show_disabled );
  84      }
  85      # --------------------
  86      # Return an array of subprojects of the specified project to which the
  87      # currently logged in user has access, including subprojects of subprojects
  88  	function current_user_get_all_accessible_subprojects( $p_project_id ) {
  89          return user_get_all_accessible_subprojects( auth_get_current_user_id(), $p_project_id );
  90      }
  91      # --------------------
  92      # Return true if the currently logged in user is has a role of administrator
  93      #  or higher, false otherwise
  94  	function current_user_is_administrator() {
  95          return user_is_administrator( auth_get_current_user_id() );
  96      }
  97      # --------------------
  98      # Return true if the currently logged in user protected, false otherwise
  99  	function current_user_is_protected() {
 100          return user_is_protected( auth_get_current_user_id() );
 101      }
 102      # --------------------
 103      # Return true if the currently user is the anonymous user
 104  	function current_user_is_anonymous() {
 105          if ( auth_is_user_authenticated() ) {
 106              return ( ( ON == config_get( 'allow_anonymous_login' ) ) &&
 107                       ( current_user_get_field( 'username' ) == config_get( 'anonymous_account' ) ) );
 108          }
 109          else {
 110              return false;
 111          }
 112      }
 113      # --------------------
 114      # Trigger an ERROR if the current user account is protected
 115  	function current_user_ensure_unprotected() {
 116          user_ensure_unprotected( auth_get_current_user_id() );
 117      }
 118      # --------------------
 119      # return the bug filter parameters for the current user
 120  	function current_user_get_bug_filter( $p_project_id = null ) {
 121          $f_filter_string    = gpc_get_string( 'filter', '' );
 122          $t_view_all_cookie    = '';
 123          $t_cookie_detail    = '';
 124          $t_filter            = '';
 125  
 126          if ( !is_blank( $f_filter_string ) ) {
 127              if( is_numeric( $f_filter_string ) ) {
 128                  $t_token = token_get_value( TOKEN_FILTER );
 129                  if ( null != $t_token ) {
 130                      $t_filter = unserialize( $t_token );
 131                  }
 132              } else {
 133                  $t_filter = unserialize( $f_filter_string );
 134              }
 135          } else if ( !filter_is_cookie_valid() ) {
 136              return false;
 137          } else {
 138              $t_user_id = auth_get_current_user_id();
 139              return user_get_bug_filter( $t_user_id, $p_project_id );
 140          }
 141  
 142          $t_filter = filter_ensure_valid_filter( $t_filter );
 143          return $t_filter;
 144      }
 145  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics