/
main_page.php
154 lines (134 loc) · 4.78 KB
/
main_page.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: main_page.php,v 1.32 2003-01-24 14:59:35 jlatour Exp $
# --------------------------------------------------------
?>
<?php
# This is the first page a user sees when they login to the bugtracker
# News is displayed which can notify users of any important changes
?>
<?php
require_once( 'core.php' );
require_once( $g_core_path . 'current_user_api.php' );
require_once( $g_core_path . 'news_api.php' );
?>
<?php login_cookie_check();
$f_offset = gpc_get_int( 'offset', 0 );
?>
<?php print_page_top1() ?>
<?php print_page_top2() ?>
<?php
if ( !current_user_is_anonymous() ) {
echo '<div class="quick-summary-left">';
echo lang_get( 'open_and_assigned_to_me' ) . ':';
echo '<a href="view_all_set.php?type=1&reporter_id=any&show_status=any&show_severity=any&show_category=any&handler_id=' . auth_get_current_user_id() . '&hide_closed=on">' . current_user_get_assigned_open_bug_count() . '</a>';
echo '</div>';
echo '<div class="quick-summary-right">';
echo lang_get( 'open_and_reported_to_me' ) . ':';
echo '<a href="view_all_set.php?type=1&reporter_id=' . auth_get_current_user_id() . '&show_status=any&show_severity=any&show_category=any&handler_id=any&hide_closed=on">' . current_user_get_reported_open_bug_count() . '</a>';
echo '</div>';
}
?>
<br />
<?php
$c_offset = db_prepare_int( $f_offset );
$t_project_id = helper_get_current_project();
# get news count (project plus sitewide posts)
$total_news_count = news_get_count( $t_project_id );
$t_news_table = config_get( 'mantis_news_table' );
$t_news_view_limit = config_get( 'news_view_limit' );
$t_news_view_limit_days = config_get( 'news_view_limit_days' );
switch ( config_get( 'news_limit_method' ) ) {
case 0 :
# Select the news posts
$query = "SELECT *, UNIX_TIMESTAMP(date_posted) as date_posted
FROM $t_news_table
WHERE project_id='$t_project_id' OR project_id=0
ORDER BY announcement DESC, id DESC
LIMIT $c_offset, $t_news_view_limit";
break;
case 1 :
# Select the news posts
$query = "SELECT *, UNIX_TIMESTAMP(date_posted) as date_posted
FROM $t_news_table
WHERE ( project_id='$t_project_id' OR project_id=0 ) AND
(TO_DAYS(NOW()) - TO_DAYS(date_posted) < '$t_news_view_limit_days')
ORDER BY announcement DESC, id DESC";
break;
} # end switch
$result = db_query( $query );
$news_count = db_num_rows( $result );
# Loop through results
for ($i=0;$i<$news_count;$i++) {
$row = db_fetch_array($result);
extract( $row, EXTR_PREFIX_ALL, 'v' );
$v_headline = string_display( $v_headline );
$v_body = string_display( $v_body );
$v_date_posted = date( config_get( 'normal_date_format' ), $v_date_posted );
# only show PRIVATE posts to configured threshold and above
if ( ( PRIVATE == $v_view_state ) &&
!access_level_check_greater_or_equal( config_get( 'private_news_threshold' ) ) ) {
continue;
}
## grab the username and email of the poster
$t_poster_name = user_get_name( $v_poster_id );
$t_poster_email = user_get_email( $v_poster_id );
if ( PRIVATE == $v_view_state ) {
$t_news_css = 'news-heading-private';
} else {
$t_news_css = 'news-heading-public';
}
?>
<br />
<div align="center">
<table class="width75" cellspacing="0">
<tr>
<td class="<?php echo $t_news_css ?>">
<span class="bold"><?php echo $v_headline ?></span> -
<span class="italic-small"><?php echo $v_date_posted ?></span> -
<a class="small" href="mailto:<?php echo $t_poster_email ?>"><?php echo $t_poster_name ?></a>
<span class='small'>
<?php
if ( 1 == $v_announcement ) {
PRINT '[' . lang_get( 'announcement' ) . ']';
}
?>
<?php
if ( PRIVATE == $v_view_state ) {
PRINT '[' . lang_get( 'private' ) . ']';
}
?>
</span>
</td>
</tr>
<tr>
<td class="news-body">
<?php echo $v_body ?>
</td>
</tr>
</table>
</div>
<?php
} # end for loop
?>
<?php # Print NEXT and PREV links if necessary ?>
<br />
<div align="center">
<?php
print_bracket_link( 'news_list_page.php', lang_get( 'archives' ) );
$f_offset_next = $f_offset + $t_news_view_limit;
$f_offset_prev = $f_offset - $t_news_view_limit;
if ( $f_offset_prev >= 0) {
print_bracket_link( 'main_page.php?offset=' . $f_offset_prev, lang_get( 'newer_news_link ' ) );
}
if ( $news_count == $t_news_view_limit ) {
print_bracket_link( 'main_page.php?offset=' . $f_offset_next, lang_get( 'older_news_link ' ) );
}
?>
</div>
<?php print_page_bot1( __FILE__ ) ?>