[ 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/ -> last_visited_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: last_visited_api.php,v 1.4.2.1 2007-10-13 22:35:33 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
  25  
  26      require_once ( $t_core_dir . 'tokens_api.php' );
  27  
  28      #---------------------------------
  29      # Determine if last visited feature is enabled
  30  	function last_visited_enabled() {
  31          return !( OFF == config_get( 'recently_visited' ) || current_user_is_anonymous() );
  32      }
  33  
  34      #---------------------------------
  35      # This method should be called from view, update, print pages for issues, mantisconnect.
  36  	function last_visited_issue( $p_issue_id, $p_user_id = null ) {
  37          if ( !last_visited_enabled() ) {
  38              return;
  39          }
  40  
  41          $c_issue_id = db_prepare_int( $p_issue_id );
  42  
  43          $t_value = token_get_value( TOKEN_LAST_VISITED, $p_user_id );
  44          if ( is_null( $t_value ) ) {
  45              $t_value = $c_issue_id;
  46          } else {
  47              $t_ids = explode( ',', $p_issue_id . ',' . $t_value );
  48              $t_ids = array_unique( $t_ids );
  49              $t_ids = array_slice( $t_ids, 0, config_get( 'recently_visited_count' ) );
  50              $t_value = implode( ',', $t_ids );
  51          }
  52          
  53          token_set( TOKEN_LAST_VISITED, $t_value, TOKEN_EXPIRY_LAST_VISITED, $p_user_id );
  54      }
  55      
  56      #---------------------------------
  57      # Get an array of the last visited bug ids.  We intentionally don't check if the ids still exists to avoid performance
  58      # degradation.
  59  	function last_visited_get_array( $p_user_id = null ) {
  60          $t_value = token_get_value( TOKEN_LAST_VISITED, $p_user_id );
  61  
  62          if ( is_null( $t_value ) ) {
  63              return array();
  64          }
  65  
  66          # we don't slice the array here to optimise for performance.  If the user reduces the number of recently
  67          # visited to track, then he/she will get the extra entries until visiting an issue.
  68          $t_ids = explode( ',', $t_value );
  69  
  70          return $t_ids;
  71      }
  72  ?>


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