[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/ -> announcements.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  define("IN_MYBB", 1);
  13  define('THIS_SCRIPT', 'announcements.php');
  14  
  15  $templatelist = "announcement,postbit_groupimage,postbit_reputation,postbit_avatar,postbit_online,postbit_offline,postbit_away,postbit_find,postbit_pm,postbit_email,postbit_www,postbit_author_user,announcement_edit,announcement_quickdelete,postbit,postbit_classic,postbit_rep_button,postbit_author_guest,forumdisplay_password_wrongpass,forumdisplay_password";
  16  require_once  "./global.php";
  17  require_once  MYBB_ROOT."inc/functions_post.php";
  18  
  19  // Load global language phrases
  20  $lang->load("announcements");
  21  
  22  $aid = intval($mybb->input['aid']);
  23  
  24  $plugins->run_hooks("announcements_start");
  25  
  26  // Get announcement fid
  27  $query = $db->simple_select("announcements", "fid", "aid='$aid'");
  28  $announcement = $db->fetch_array($query);
  29  
  30  if(!$announcement)
  31  {
  32      error($lang->error_invalidannouncement);
  33  }
  34  
  35  // Get forum info
  36  $fid = $announcement['fid'];
  37  if($fid > 0)
  38  {
  39      $forum = get_forum($fid);
  40  
  41      if(!$forum)
  42      {
  43          error($lang->error_invalidforum);
  44      }
  45  
  46      // Make navigation
  47      build_forum_breadcrumb($forum['fid']);
  48  
  49      // Permissions
  50      $forumpermissions = forum_permissions($forum['fid']);
  51  
  52      if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
  53      {
  54          error_no_permission();
  55      }
  56      
  57      // Check if this forum is password protected and we have a valid password
  58      check_forum_password($forum['fid']);
  59  }
  60  add_breadcrumb($lang->nav_announcements);
  61  
  62  $archive_url = build_archive_link("announcement", $aid);
  63  
  64  // Get announcement info
  65  $time = TIME_NOW;
  66  
  67  $query = $db->query("
  68      SELECT u.*, u.username AS userusername, a.*, f.*
  69      FROM ".TABLE_PREFIX."announcements a
  70      LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
  71      LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
  72      WHERE a.startdate<='$time' AND (a.enddate>='$time' OR a.enddate='0') AND a.aid='$aid'
  73  ");
  74  
  75  $announcementarray = $db->fetch_array($query);
  76  
  77  if(!$announcementarray)
  78  {
  79      error($lang->error_invalidannouncement);
  80  }
  81  
  82  // Gather usergroup data from the cache
  83  // Field => Array Key
  84  $data_key = array(
  85      'title' => 'grouptitle',
  86      'usertitle' => 'groupusertitle',
  87      'stars' => 'groupstars',
  88      'starimage' => 'groupstarimage',
  89      'image' => 'groupimage',
  90      'namestyle' => 'namestyle',
  91      'usereputationsystem' => 'usereputationsystem'
  92  );
  93  
  94  foreach($data_key as $field => $key)
  95  {
  96      $announcementarray[$key] = $groupscache[$announcementarray['usergroup']][$field];
  97  }
  98  
  99  $announcementarray['dateline'] = $announcementarray['startdate'];
 100  $announcementarray['userusername'] = $announcementarray['username'];
 101  $announcement = build_postbit($announcementarray, 3);
 102  $announcementarray['subject'] = $parser->parse_badwords($announcementarray['subject']);
 103  $lang->forum_announcement = $lang->sprintf($lang->forum_announcement, htmlspecialchars_uni($announcementarray['subject']));
 104  
 105  if($announcementarray['startdate'] > $mybb->user['lastvisit'])
 106  {
 107      $setcookie = true;
 108      if($mybb->cookies['mybb']['announcements'])
 109      {
 110          $cookie = my_unserialize(stripslashes($mybb->cookies['mybb']['announcements']));
 111      
 112          if(isset($cookie[$announcementarray['aid']]))
 113          {
 114              $setcookie = false;
 115          }
 116      }
 117  
 118      if($setcookie)
 119      {
 120          my_set_array_cookie('announcements', $announcementarray['aid'], $announcementarray['startdate'], -1);
 121      }
 122  }
 123  
 124  $plugins->run_hooks("announcements_end");
 125  
 126  eval("\$forumannouncement = \"".$templates->get("announcement")."\";");
 127  output_page($forumannouncement);
 128  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1