Date/time fixes: try to ensure that timestamps are always kept in GMT, with conversio...
[lhc/web/wiklou.git] / includes / SpecialWatchlist.php
1 <?
2 global $IP;
3 include_once( "$IP/SpecialRecentchanges.php" );
4
5 function wfSpecialWatchlist()
6 {
7 global $wgUser, $wgOut, $wgLang, $wgTitle;
8 global $days, $limit, $target; # From query string
9 $fname = "wfSpecialWatchlist";
10
11 $wgOut->setPagetitle( wfMsg( "watchlist" ) );
12 $sub = str_replace( "$1", $wgUser->getName(), wfMsg( "watchlistsub" ) );
13 $wgOut->setSubtitle( $sub );
14 $wgOut->setRobotpolicy( "index,follow" );
15
16 if ( ! isset( $days ) ) {
17 $days = $wgUser->getOption( "rcdays" );
18 if ( ! $days ) { $days = 3; }
19 }
20 $days = (int)$days;
21 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
22
23 if ( $days <= 0 ) {
24 $docutoff = '';
25 } else {
26 $docutoff = "cur_timestamp > '" .
27 wfUnix2Timestamp( time() - ( $days * 86400 ) )
28 . "' AND";
29 }
30 if ( $limit == 0 ) {
31 $dolimit = "";
32 } else {
33 $dolimit = "LIMIT $limit";
34 }
35
36 $uid = $wgUser->getID();
37 if( $uid == 0 ) {
38 $wgOut->addHTML( wfMsg( "nowatchlist" ) );
39 return;
40 }
41
42 $sql = "SELECT DISTINCT
43 cur_id,cur_namespace,cur_title,cur_comment,
44 cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
45 FROM cur,watchlist
46 WHERE wl_user={$uid} AND wl_title=cur_title
47 AND (cur_namespace=wl_namespace OR cur_namespace=wl_namespace+1)
48 ORDER BY inverse_timestamp {$dolimit}";
49 $res = wfQuery( $sql, $fname );
50 if ( wfNumRows( $res ) == 0 ) {
51 $wgOut->addHTML( wfMsg( "nowatchlist" ) );
52 return;
53 }
54
55 $note = wfMsg( "rcnote", $limit, $days );
56 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
57 $note = rcDayLimitlinks( $days, $limit, "Watchlist", "", true );
58 $wgOut->addHTML( "{$note}\n" );
59
60 $sk = $wgUser->getSkin();
61 $s = $sk->beginRecentChangesList();
62
63 while ( $obj = wfFetchObject( $res ) ) {
64 $ts = $obj->cur_timestamp;
65 $u = $obj->cur_user;
66 $ut = $obj->cur_user_text;
67 $ns = $obj->cur_namespace;
68 $ttl = $obj->cur_title;
69 $com = $obj->cur_comment;
70 $me = ( $obj->cur_minor_edit > 0 );
71 $new = ( $obj->cur_is_new > 0 );
72 $watched = true;
73
74 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new, $watched );
75 }
76 $s .= $sk->endRecentChangesList();
77
78 wfFreeResult( $res );
79 $wgOut->addHTML( $s );
80 }
81
82 ?>