[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> manage_config_email_page.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: manage_config_email_page.php,v 1.10.2.1 2007-10-13 22:33:23 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      require_once ( 'core.php' );
  25  
  26      $t_core_path = config_get( 'core_path' );
  27      require_once ( $t_core_path . 'email_api.php' );
  28  
  29      auth_reauthenticate();
  30  
  31  /**
  32   * array_merge_recursive2()
  33   *
  34   * Similar to array_merge_recursive but keyed-valued are always overwritten.
  35   * Priority goes to the 2nd array.
  36   *
  37   * @static yes
  38   * @public yes
  39   * @param $paArray1 array
  40   * @param $paArray2 array
  41   * @return array
  42   */
  43      function array_merge_recursive2($p_Array1, $p_Array2) {
  44          if (!is_array($p_Array1) or !is_array($p_Array2)) { 
  45              return $p_Array2; 
  46          }
  47          foreach ( $p_Array2 AS $t_Key2 => $t_Value2) {
  48              $p_Array1[$t_Key2] = array_merge_recursive2( @$p_Array1[$t_Key2], $t_Value2);
  49          }
  50          return $p_Array1;
  51      }
  52  
  53      # --------------------
  54      # get_notify_flag cloned from email_notify_flag
  55      # Get the value associated with the specific action and flag.
  56      # For example, you can get the value associated with notifying "admin"
  57      # on action "new", i.e. notify administrators on new bugs which can be
  58      # ON or OFF.
  59  	function get_notify_flag( $action, $flag ) {
  60          global $t_notify_flags, $t_default_notify_flags;
  61          
  62          $val = OFF;
  63          if ( isset ( $t_notify_flags[$action][$flag] ) ) {
  64              $val = $t_notify_flags[$action][$flag];
  65          } elseif ( isset ( $t_default_notify_flags[$flag] ) ) {
  66              $val = $t_default_notify_flags[$flag];
  67          } 
  68          return $val;
  69      }
  70      
  71      function colour_notify_flag ( $p_action, $p_flag ) {
  72          global $t_notify_flags, $t_global_notify_flags, $t_file_notify_flags, $t_colour_project, $t_colour_global;
  73          
  74          $t_file = isset( $t_file_notify_flags[$p_action][$p_flag] ) ? ( $t_file_notify_flags[$p_action][$p_flag] ? 1 : 0 ): -1;
  75          $t_global = isset( $t_global_notify_flags[$p_action][$p_flag] ) ? ( $t_global_notify_flags[$p_action][$p_flag]  ? 1 : 0 ): -1;
  76          $t_project = isset( $t_notify_flags[$p_action][$p_flag] ) ? ( $t_notify_flags[$p_action][$p_flag]  ? 1 : 0 ): -1;
  77             
  78          $t_colour = '';
  79          if ( $t_global >= 0 ) {
  80              if ( $t_global != $t_file ) {
  81                  $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
  82              }
  83          }
  84          if ( $t_project >= 0 ) {
  85              if ( $t_project != $t_global ) {
  86                  $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
  87              }
  88          } 
  89          return $t_colour;
  90      }
  91      
  92      
  93      # Get the value associated with the specific action and flag.
  94  	function show_notify_flag( $p_action, $p_flag ) {
  95          global $t_can_change_flags , $t_can_change_defaults;
  96          $t_flag = get_notify_flag( $p_action, $p_flag );
  97          if ( $t_can_change_flags || $t_can_change_defaults ) {
  98              $t_flag_name = $p_action . ':' . $p_flag;
  99              $t_set = $t_flag ? "CHECKED" : "";
 100              return "<input type=\"checkbox\" name=\"flag[]\" value=\"$t_flag_name\" $t_set />";
 101          } else {
 102              return ( $t_flag ? '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />' : '&nbsp;' );
 103          }
 104      }
 105  
 106      function colour_threshold_flag ( $p_access, $p_action ) {
 107          global $t_notify_flags, $t_global_notify_flags, $t_file_notify_flags, $t_colour_project, $t_colour_global;
 108          
 109          $t_file = ( $p_access >= $t_file_notify_flags[$p_action]['threshold_min'] )
 110                           && ( $p_access <= $t_file_notify_flags[$p_action]['threshold_max'] );
 111          $t_global = ( $p_access >= $t_global_notify_flags[$p_action]['threshold_min'] )
 112                           && ( $p_access <= $t_global_notify_flags[$p_action]['threshold_max'] );
 113          $t_project = ( $p_access >= $t_notify_flags[$p_action]['threshold_min'] )
 114                           && ( $p_access <= $t_notify_flags[$p_action]['threshold_max'] );
 115             
 116          $t_colour = '';
 117          if ( $t_global != $t_file ) {
 118              $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 119          }
 120          if ( $t_project != $t_global ) {
 121              $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 122          } 
 123          return $t_colour;
 124      }
 125      
 126  	function show_notify_threshold( $p_access, $p_action ) {
 127          global $t_can_change_flags , $t_can_change_defaults;
 128          $t_flag = ( $p_access >= get_notify_flag( $p_action, 'threshold_min' ) )
 129              && ( $p_access <= get_notify_flag( $p_action, 'threshold_max' ) );
 130          if ( $t_can_change_flags  || $t_can_change_defaults ) {
 131              $t_flag_name = $p_action . ':' . $p_access;
 132              $t_set = $t_flag ? "CHECKED" : "";
 133              return "<input type=\"checkbox\" name=\"flag_threshold[]\" value=\"$t_flag_name\" $t_set />";
 134          } else {
 135              return $t_flag ? '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />' : '&nbsp;';
 136          }
 137      }
 138  
 139  	function get_section_begin_for_email( $p_section_name ) {
 140          global $t_project;
 141          $t_access_levels = explode_enum_string( config_get( 'access_levels_enum_string' ) );
 142          echo '<table class="width100">';
 143          echo '<tr><td class="form-title" colspan="' . ( count( $t_access_levels ) + 7 ) . '">' . strtoupper( $p_section_name ) . '</td></tr>' . "\n";
 144          echo '<tr><td class="form-title" width="30%" rowspan="2">' . lang_get( 'message' ) . '</td>';
 145          echo'<td class="form-title" style="text-align:center" rowspan="2">&nbsp;' . lang_get( 'issue_reporter' ) . '&nbsp;</td>';
 146          echo '<td class="form-title" style="text-align:center" rowspan="2">&nbsp;' . lang_get( 'issue_handler' ) . '&nbsp;</td>';
 147          echo '<td class="form-title" style="text-align:center" rowspan="2">&nbsp;' . lang_get( 'users_monitoring_bug' ) . '&nbsp;</td>';
 148          echo '<td class="form-title" style="text-align:center" rowspan="2">&nbsp;' . lang_get( 'users_added_bugnote' ) . '&nbsp;</td>';
 149          echo '<td class="form-title" style="text-align:center" colspan="' . count( $t_access_levels ) . '">&nbsp;' . lang_get( 'access_levels' ) . '&nbsp;</td></tr><tr>';
 150          foreach( $t_access_levels as $t_access_level ) {
 151              $t_entry_array = explode_enum_arr( $t_access_level );
 152              echo '<td class="form-title" style="text-align:center">&nbsp;' . get_enum_to_string( lang_get( 'access_levels_enum_string' ), $t_entry_array[0] ) . '&nbsp;</td>';
 153          }
 154          echo '</tr>' . "\n";
 155      }
 156  
 157  	function get_capability_row_for_email( $p_caption, $p_message_type ) {
 158          $t_access_levels = explode_enum_string( config_get( 'access_levels_enum_string' ) );
 159  
 160          echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>';
 161          echo '<td class="center"' . colour_notify_flag( $p_message_type, 'reporter' ) . '>' . show_notify_flag( $p_message_type, 'reporter' )  . '</td>';
 162          echo '<td class="center"' . colour_notify_flag( $p_message_type, 'handler' ) . '>' . show_notify_flag( $p_message_type, 'handler' ) . '</td>';
 163          echo '<td class="center"' . colour_notify_flag( $p_message_type, 'monitor' ) . '>' . show_notify_flag( $p_message_type, 'monitor' ) . '</td>';
 164          echo '<td class="center"' . colour_notify_flag( $p_message_type, 'bugnotes' ) . '>' . show_notify_flag( $p_message_type, 'bugnotes' ) . '</td>';
 165  
 166          foreach( $t_access_levels as $t_access_level ) {
 167              $t_entry_array = explode_enum_arr( $t_access_level );
 168              echo '<td class="center"' . colour_threshold_flag( (int)$t_entry_array[0], $p_message_type ) . '>' . show_notify_threshold( (int)$t_entry_array[0], $p_message_type ) . '</td>';
 169          }
 170          echo '</tr>' . "\n";
 171      }
 172  
 173  	function get_section_end_for_email() {
 174          echo '</table><br />' . "\n";
 175      }
 176  
 177  
 178      html_page_top1( lang_get( 'manage_email_config' ) );
 179      html_page_top2();
 180  
 181      print_manage_menu( 'adm_permissions_report.php' );
 182      print_manage_config_menu( 'manage_config_email_page.php' );
 183  
 184      $t_access = current_user_get_access_level();
 185      $t_project = helper_get_current_project();
 186      
 187      $t_colour_project = config_get( 'colour_project');
 188      $t_colour_global = config_get( 'colour_global');
 189      
 190      # build a list of all of the actions
 191      $t_actions = array( 'owner', 'reopened', 'deleted', 'bugnote' );
 192      if( config_get( 'enable_sponsorship' ) == ON ) {
 193          $t_actions[] = 'sponsor';
 194      }
 195      if( config_get( 'enable_relationship' ) == ON ) {
 196          $t_actions[] = 'relationship';
 197      }
 198      $t_statuses = get_enum_to_array( config_get( 'status_enum_string' ) );
 199      foreach( $t_statuses as $t_status ) {
 200          $t_actions[] =  $t_status;
 201      }
 202      
 203      # build a composite of the status flags, exploding the defaults
 204      $t_global_default_notify_flags = config_get( 'default_notify_flags', null, null, ALL_PROJECTS );
 205      $t_global_notify_flags = array();
 206      foreach ( $t_global_default_notify_flags as $t_flag => $t_value ) {
 207         foreach ($t_actions as $t_action ) {
 208             $t_global_notify_flags[$t_action][$t_flag] = $t_value;
 209         }
 210      }
 211      $t_global_notify_flags = array_merge_recursive2( $t_global_notify_flags, config_get( 'notify_flags', null, null, ALL_PROJECTS ) );
 212  
 213      $t_file_default_notify_flags = config_get_global( 'default_notify_flags' );
 214      $t_file_notify_flags = array();
 215      foreach ( $t_file_default_notify_flags as $t_flag => $t_value ) {
 216         foreach ($t_actions as $t_action ) {
 217             $t_file_notify_flags[$t_action][$t_flag] = $t_value;
 218         }
 219      }
 220      $t_file_notify_flags = array_merge_recursive2( $t_file_notify_flags, config_get_global( 'notify_flags' ) );
 221      
 222      $t_default_notify_flags = config_get( 'default_notify_flags' );
 223      $t_notify_flags = array();
 224      foreach ( $t_default_notify_flags as $t_flag => $t_value ) {
 225         foreach ($t_actions as $t_action ) {
 226             $t_notify_flags[$t_action][$t_flag] = $t_value;
 227         }
 228      }
 229      $t_notify_flags = array_merge_recursive2( $t_notify_flags, config_get( 'notify_flags' ) );
 230  
 231      $t_can_change_flags = $t_access >= config_get_access( 'notify_flags' );
 232      $t_can_change_defaults = $t_access >= config_get_access( 'default_notify_flags' );
 233  
 234      echo '<br /><br />';
 235  
 236      # Email notifications
 237      if( config_get( 'enable_email_notification' ) == ON ) {
 238  
 239          if ( $t_can_change_flags  || $t_can_change_defaults ) {
 240              echo "<form name=\"mail_config_action\" method=\"post\" action=\"manage_config_email_set.php\">\n";
 241          }
 242  
 243          if ( ALL_PROJECTS == $t_project ) {
 244              $t_project_title = lang_get( 'config_all_projects' );
 245          } else {
 246              $t_project_title = sprintf( lang_get( 'config_project' ) , string_display( project_get_name( $t_project ) ) );
 247          }
 248          echo '<p class="bold">' . $t_project_title . '</p>' . "\n";
 249          echo '<p>' . lang_get( 'colour_coding' ) . '<br />';
 250          if ( ALL_PROJECTS <> $t_project ) {
 251              echo '<span style="background-color:' . $t_colour_project . '">' . lang_get( 'colour_project' ) .'</span><br />';
 252          }
 253          echo '<span style="background-color:' . $t_colour_global . '">' . lang_get( 'colour_global' ) . '</span></p>';
 254  
 255          get_section_begin_for_email( lang_get( 'email_notification' ) );
 256  #        get_capability_row_for_email( lang_get( 'email_on_new' ), 'new' );  # duplicate of status change to 'new'
 257          get_capability_row_for_email( lang_get( 'email_on_assigned' ), 'owner' );
 258          get_capability_row_for_email( lang_get( 'email_on_reopened' ), 'reopened' );
 259          get_capability_row_for_email( lang_get( 'email_on_deleted' ), 'deleted' );
 260          get_capability_row_for_email( lang_get( 'email_on_bugnote_added' ), 'bugnote' );
 261          if( config_get( 'enable_sponsorship' ) == ON ) {
 262              get_capability_row_for_email( lang_get( 'email_on_sponsorship_changed' ), 'sponsor' );
 263          }
 264          if( config_get( 'enable_relationship' ) == ON ) {
 265              get_capability_row_for_email( lang_get( 'email_on_relationship_changed' ), 'relationship' );
 266          }
 267          $t_statuses = explode_enum_string( config_get( 'status_enum_string' ) );
 268          foreach( $t_statuses as $t_status ) {
 269              list( $t_state, $t_label ) = explode_enum_arr( $t_status );
 270              get_capability_row_for_email( lang_get( 'status_changed_to' ) . ' \'' . get_enum_element( 'status', $t_state ) . '\'', $t_label );
 271          }
 272  
 273          get_section_end_for_email();
 274  
 275          if ( $t_can_change_flags  || $t_can_change_defaults ) {
 276              echo '<p>' . lang_get( 'notify_actions_change_access' ) . ':';
 277              echo '<select name="notify_actions_access">';
 278              print_enum_string_option_list( 'access_levels', config_get_access( 'notify_flags' ) );
 279              echo '</select> </p>';
 280  
 281              echo "<input type=\"submit\" class=\"button\" value=\"" . lang_get( 'change_configuration' ) . "\" />\n";
 282  
 283              echo "</form>\n";
 284              
 285              echo "<div class=\"right\"><form name=\"mail_config_action\" method=\"post\" action=\"manage_config_revert.php\">\n";
 286              echo "<input name=\"revert\" type=\"hidden\" value=\"notify_flags,default_notify_flags\"></input>";
 287              echo "<input name=\"project\" type=\"hidden\" value=\"$t_project\"></input>";
 288              echo "<input name=\"return\" type=\"hidden\" value=\"" . $_SERVER['PHP_SELF'] ."\"></input>";
 289              echo "<input type=\"submit\" class=\"button\" value=\"";
 290              if ( ALL_PROJECTS == $t_project ) {
 291                  echo lang_get( 'revert_to_system' );
 292              } else {
 293                  echo lang_get( 'revert_to_all_project' );
 294              } 
 295              echo "\" />\n";
 296              echo "</form></div>\n";
 297          }
 298  
 299      }
 300  
 301      html_page_bottom1( __FILE__ );
 302  ?>


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