Initial revision
[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 if ( ! isset( $limit ) ) {
21 $limit = $wgUser->getOption( "rclimit" );
22 if ( ! $limit ) { $limit = 100; }
23 }
24 if ( $days == 0 ) {
25 $docutoff = '';
26 } else {
27 $docutoff = "cur_timestamp > '" .
28 date( "YmdHis", time() - ( $days * 86400 ) )
29 . "' AND";
30 }
31 if ( $limit == 0 ) {
32 $dolimit = "";
33 } else {
34 $dolimit = "LIMIT $limit";
35 }
36
37 $uid = $wgUser->getID();
38 if( $uid == 0 ) {
39 $wgOut->addHTML( wfMsg( "nowatchlist" ) );
40 return;
41 }
42
43 # $sql = "SELECT DISTINCT
44 # cur_id,cur_namespace,cur_title,cur_comment,
45 # cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
46 # FROM cur,watchlist
47 # WHERE wl_user={$uid} AND wl_namespace=cur_namespace & (~1) AND wl_title=cur_title
48 # ORDER BY cur_timestamp DESC {$dolimit}";
49 $sql = "SELECT DISTINCT
50 cur_id,cur_namespace,cur_title,cur_comment,
51 cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
52 FROM cur,watchlist
53 WHERE wl_user={$uid} AND wl_title=cur_title
54 AND (cur_namespace=wl_namespace OR cur_namespace=wl_namespace+1)
55 ORDER BY inverse_timestamp {$dolimit}";
56 $res = wfQuery( $sql, $fname );
57 if ( wfNumRows( $res ) == 0 ) {
58 $wgOut->addHTML( wfMsg( "nowatchlist" ) );
59 return;
60 }
61
62 $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
63 $note = str_replace( "$2", $days, $note );
64 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
65 $note = rcDayLimitlinks( $days, $limit, "Watchlist", "", true );
66 $wgOut->addHTML( "{$note}\n" );
67
68 $sk = $wgUser->getSkin();
69 $s = $sk->beginRecentChangesList();
70
71 while ( $obj = wfFetchObject( $res ) ) {
72 $ts = $obj->cur_timestamp;
73 $u = $obj->cur_user;
74 $ut = $obj->cur_user_text;
75 $ns = $obj->cur_namespace;
76 $ttl = $obj->cur_title;
77 $com = $obj->cur_comment;
78 $me = ( $obj->cur_minor_edit > 0 );
79 $new = ( $obj->cur_is_new > 0 );
80 $watched = true;
81
82 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new, $watched );
83 }
84 $s .= $sk->endRecentChangesList();
85
86 wfFreeResult( $res );
87 $wgOut->addHTML( $s );
88 }
89
90 ?>