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