[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> bug_actiongroup_attach_tags_inc.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: bug_actiongroup_attach_tags_inc.php,v 1.1.2.2 2007-10-13 22:32:31 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      $t_core_path = config_get( 'core_path' );
  25      require_once( $t_core_path . 'tag_api.php' );
  26  
  27      /**
  28       * Prints the title for the custom action page.     
  29       */
  30  	function action_attach_tags_print_title() {
  31          echo '<tr class="form-title">';
  32          echo '<td colspan="2">';
  33          echo lang_get( 'tag_attach_long' );
  34          echo '</td></tr>';        
  35      }
  36  
  37      /**
  38       * Prints the table and form for the Attach Tags group action page.
  39       */
  40  	function action_attach_tags_print_fields() {
  41          echo '<tr ',helper_alternate_class(),'><td class="category">',lang_get('tag_attach_long'),'</td><td>';
  42          print_tag_input();
  43          echo '<input type="submit" class="button" value="' . lang_get( 'tag_attach' ) . ' " /></td></tr>';
  44      }
  45  
  46      /**
  47       * Validates the Attach Tags group action.
  48       * Gets called for every bug, but performs the real tag validation only
  49       * the first time.  Any invalid tags will be skipped, as there is no simple
  50       * or clean method of presenting these errors to the user.
  51       * @param integer Bug ID
  52       * @return boolean True
  53       */
  54  	function action_attach_tags_validate( $p_bug_id ) {
  55          global $g_action_attach_tags_valid;
  56          if ( !isset( $g_action_attach_tags_valid ) ) {
  57              $f_tag_string = gpc_get_string( 'tag_string' );
  58              $f_tag_select = gpc_get_string( 'tag_select' );
  59  
  60              global $g_action_attach_tags_attach, $g_action_attach_tags_create, $g_action_attach_tags_failed; 
  61              $g_action_attach_tags_attach = array();
  62              $g_action_attach_tags_create = array();
  63              $g_action_attach_tags_failed = array();
  64  
  65              $t_tags = tag_parse_string( $f_tag_string );
  66              $t_can_create = access_has_global_level( config_get( 'tag_create_threshold' ) );
  67  
  68              foreach ( $t_tags as $t_tag_row ) {
  69                  if ( -1 == $t_tag_row['id'] ) {
  70                      if ( $t_can_create ) {
  71                          $g_action_attach_tags_create[] = $t_tag_row;
  72                      } else {
  73                          $g_action_attach_tags_failed[] = $t_tag_row;
  74                      }
  75                  } elseif ( -2 == $t_tag_row['id'] ) {
  76                      $g_action_attach_tags_failed[] = $t_tag_row;
  77                  } else {
  78                      $g_action_attach_tags_attach[] = $t_tag_row;
  79                  }
  80              }
  81  
  82              if ( 0 < $f_tag_select && tag_exists( $f_tag_select ) ) {
  83                  $g_action_attach_tags_attach[] = tag_get( $f_tag_select );
  84              }
  85  
  86          }
  87  
  88          global $g_action_attach_tags_attach, $g_action_attach_tags_create, $g_action_attach_tags_failed; 
  89  
  90          return true;
  91      }
  92  
  93      /**
  94       * Attaches all the tags to each bug in the group action.
  95       * @param integer Bug ID
  96       * @return boolean True if all tags attach properly
  97       */
  98  	function action_attach_tags_process( $p_bug_id ) {
  99          global $g_action_attach_tags_attach, $g_action_attach_tags_create; 
 100  
 101          $t_user_id = auth_get_current_user_id();
 102  
 103          foreach( $g_action_attach_tags_create as $t_tag_row ) {
 104              $t_tag_row['id'] = tag_create( $t_tag_row['name'], $t_user_id );
 105              $g_action_attach_tags_attach[] = $t_tag_row;
 106          }
 107          $g_action_attach_tags_create = array();
 108  
 109          foreach( $g_action_attach_tags_attach as $t_tag_row ) {
 110              if ( ! tag_bug_is_attached( $t_tag_row['id'], $p_bug_id ) ) {
 111                  tag_bug_attach( $t_tag_row['id'], $p_bug_id, $t_user_id );
 112              }
 113          }
 114  
 115          return true;
 116      }


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