[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> issues_rss.php (source)

   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   *
  19   * GET PARAMETERS FOR THIS PAGE
  20   *
  21   * project_id: 0 - all projects, otherwise project id.
  22   * filter_id: The filter id to use for generating the rss.
  23   * sort: This parameter is ignore if filter_id is supplied and is not equal to 0.
  24   *        "update": issues ordered descending by last updated date.
  25   *       "submit": issues ordered descending by submit date (default).
  26   *
  27   * @package MantisBT
  28   * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
  29   * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  30   * @link http://www.mantisbt.org
  31   *
  32   * @uses core.php
  33   * @uses access_api.php
  34   * @uses bug_api.php
  35   * @uses category_api.php
  36   * @uses config_api.php
  37   * @uses constant_inc.php
  38   * @uses filter_api.php
  39   * @uses gpc_api.php
  40   * @uses lang_api.php
  41   * @uses project_api.php
  42   * @uses rss_api.php
  43   * @uses string_api.php
  44   * @uses user_api.php
  45   * @uses utility_api.php
  46   */
  47  
  48  /**
  49   * MantisBT Core API's
  50   */
  51  require_once ( 'core.php' );
  52  require_api( 'access_api.php' );
  53  require_api( 'bug_api.php' );
  54  require_api( 'category_api.php' );
  55  require_api( 'config_api.php' );
  56  require_api( 'constant_inc.php' );
  57  require_api( 'filter_api.php' );
  58  require_api( 'gpc_api.php' );
  59  require_api( 'lang_api.php' );
  60  require_api( 'project_api.php' );
  61  require_api( 'rss_api.php' );
  62  require_api( 'string_api.php' );
  63  require_api( 'user_api.php' );
  64  require_api( 'utility_api.php' );
  65  
  66  $f_project_id = gpc_get_int( 'project_id', ALL_PROJECTS );
  67  $f_filter_id = gpc_get_int( 'filter_id', 0 );
  68  $f_sort = gpc_get_string( 'sort', 'submit' );
  69  $f_username = gpc_get_string( 'username', null );
  70  $f_key = gpc_get_string( 'key', null );
  71  
  72  # make sure RSS syndication is enabled.
  73  if ( OFF == config_get( 'rss_enabled' ) ) {
  74      access_denied();
  75  }
  76  
  77  # authenticate the user
  78  if ( $f_username !== null ) {
  79      if ( !rss_login( $f_username, $f_key ) ) {
  80          access_denied();
  81      }
  82  } else {
  83      if ( OFF == config_get( 'allow_anonymous_login' ) ) {
  84          access_denied();
  85      }
  86  }
  87  
  88  # Make sure that the current user has access to the selected project (if not ALL PROJECTS).
  89  if ( $f_project_id != ALL_PROJECTS ) {
  90      access_ensure_project_level( VIEWER, $f_project_id );
  91  }
  92  
  93  if ( $f_sort === 'update' ) {
  94      $c_sort_field = 'last_updated';
  95  } else {
  96      $c_sort_field = 'date_submitted';
  97  }
  98  
  99  $t_path = config_get( 'path' );
 100  
 101  # construct rss file
 102  
 103  $encoding = 'utf-8';
 104  $about = $t_path;
 105  $title = config_get( 'window_title' );
 106  $image_link = $t_path . 'images/mantis_logo_button.gif';
 107  
 108  # only rss 2.0
 109  $category = project_get_name( $f_project_id );
 110  if ( $f_project_id !== 0 ) {
 111      $title .= ' - ' . $category;
 112  }
 113  
 114  $title .= ' - ' . lang_get( 'issues' );
 115  
 116  if ( $f_username !== null ) {
 117      $title .= " - ($f_username)";
 118  }
 119  
 120  if ( $f_filter_id !== 0 ) {
 121      $title .= ' (' . filter_get_field( $f_filter_id, 'name' ) . ')';
 122  }
 123  
 124  $description = $title;
 125  
 126  # in minutes (only rss 2.0)
 127  $cache = '10';
 128  
 129  $rssfile = new RSSBuilder(    $encoding, $about, $title, $description,
 130                  $image_link, $category, $cache);
 131  
 132  # person, an organization, or a service
 133  $publisher = '';
 134  
 135  # person, an organization, or a service
 136  $creator = '';
 137  
 138  $date = (string) date( 'r' );
 139  $language = lang_get( 'phpmailer_language' );
 140  $rights = '';
 141  
 142  # spatial location , temporal period or jurisdiction
 143  $coverage = (string) '';
 144  
 145  # person, an organization, or a service
 146  $contributor = (string) '';
 147  
 148  $rssfile->addDCdata( $publisher, $creator, $date, $language, $rights, $coverage, $contributor );
 149  
 150  # hourly / daily / weekly / ...
 151  $period = (string) 'hourly';
 152  
 153  # every X hours/days/...
 154  $frequency = (int) 1;
 155  
 156  $base = (string) date( 'Y-m-d\TH:i:sO' );
 157  
 158  # add missing : in the O part of the date.  PHP 5 supports a 'c' format which will output the format
 159  # exactly as we want it.
 160  # // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00
 161  $base = utf8_substr( $base, 0, 22 ) . ':' . utf8_substr( $base, -2 );
 162  
 163  $rssfile->addSYdata( $period, $frequency, $base );
 164  
 165  $t_page_number = 1;
 166  $t_issues_per_page = 25;
 167  $t_page_count = 0;
 168  $t_issues_count = 0;
 169  $t_project_id = $f_project_id;
 170  if ( $f_username !== null ) {
 171      $t_user_id = user_get_id_by_name( $f_username );
 172  } else {
 173      $t_user_id = user_get_id_by_name( config_get( 'anonymous_account' ) );
 174  }
 175  $t_show_sticky = null;
 176  
 177  if ( $f_filter_id == 0 ) {
 178      $t_custom_filter = filter_get_default();
 179      $t_custom_filter['sort'] = $c_sort_field;
 180  } else {
 181      # null will be returned if the user doesn't have access right to access the filter.
 182      $t_custom_filter = filter_db_get_filter( $f_filter_id, $t_user_id );
 183      if ( null === $t_custom_filter ) {
 184          access_denied();
 185      }
 186  
 187      $t_custom_filter = filter_deserialize( $t_custom_filter );
 188  }
 189  
 190  $t_issues = filter_get_bug_rows( $t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count,
 191                                   $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky );
 192  $t_issues_count = count( $t_issues );
 193  
 194  # Loop through results
 195  for ( $i = 0; $i < $t_issues_count; $i++ ) {
 196      $t_bug = $t_issues[$i];
 197  
 198      $about = $link = $t_path . "view.php?id=" . $t_bug->id;
 199      $title = bug_format_id( $t_bug->id ) . ': ' . $t_bug->summary;
 200  
 201      if ( $t_bug->view_state == VS_PRIVATE ) {
 202          $title .= ' [' . lang_get( 'private' ) . ']';
 203      }
 204  
 205      $description = string_rss_links( $t_bug->description );
 206  
 207      # subject is category.
 208      $subject = category_full_name( $t_bug->category_id, false );
 209  
 210      # optional DC value
 211      $date = $t_bug->last_updated;
 212  
 213      # author of item
 214      $author = '';
 215      if ( access_has_global_level( config_get( 'show_user_email_threshold' ) ) ) {
 216          $t_author_name = user_get_name( $t_bug->reporter_id );
 217          $t_author_email = user_get_field( $t_bug->reporter_id, 'email' );
 218  
 219          if ( !is_blank( $t_author_email ) ) {
 220              if ( !is_blank( $t_author_name ) ) {
 221                  $author = $t_author_name . ' <' . $t_author_email . '>';
 222              } else {
 223                  $author = $t_author_email;
 224              }
 225          }
 226      }
 227  
 228      # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1';    # url to comment page rss 2.0 value
 229      $comments = $t_path . 'view.php?id=' . $t_bug->id . '#bugnotes';
 230  
 231      # optional mod_im value for dispaying a different pic for every item
 232      $image = '';
 233  
 234      $rssfile->addRSSItem( $about, $title, $link, $description, $subject, $date,
 235                          $author, $comments, $image );
 236  }
 237  
 238  /** @todo consider making this a configuration option - 0.91 / 1.0 / 2.0 */
 239  $version = '2.0';
 240  
 241  $rssfile->outputRSS( $version );
 242  


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7