* Yummie ? : syntax.
[lhc/web/wiklou.git] / includes / SpecialWatchlist.php
index 8b9f7db..e36cf7d 100644 (file)
@@ -15,7 +15,7 @@ require_once( 'WatchedItem.php' );
  * constructor
  */
 function wfSpecialWatchlist() {
-       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgRequest;
+       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgRequest, $wgContLang;;
        global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
        global $wgEnotif, $wgShowUpdatedMarker, $wgRCShowWatchingUsers;
        $fname = 'wfSpecialWatchlist';
@@ -27,8 +27,7 @@ function wfSpecialWatchlist() {
 
        $specialTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' );
 
-       $uid = $wgUser->getID();
-       if( $uid == 0 ) {
+       if( $wgUser->isAnon() ) {
                $wgOut->addWikiText( wfMsg( 'nowatchlist' ) );
                return;
        }
@@ -37,14 +36,28 @@ function wfSpecialWatchlist() {
        $days = $wgRequest->getVal( 'days' );
        $action = $wgRequest->getVal( 'action' );
        $remove = $wgRequest->getVal( 'remove' );
+       $hideOwn = $wgRequest->getVal( 'hideOwn' );             
        $id = $wgRequest->getArray( 'id' );
 
-       $wgOut->addWikiText( wfMsg( 'email_notification_infotext' ) );
+       if( $wgUser->getOption( 'enotifwatchlistpages' ) ) {
+               $wgOut->addHTML( "<div class='enotifinfo'>\n" );
+               
+               $wgOut->addWikiText( wfMsg( 'email_notification_infotext' ) );
+
+               $wgOut->addHTML( '<form action="' .
+                       $specialTitle->escapeLocalUrl( 'action=submit&magic=yes' ) .
+                       '" method="post"><input type="submit" name="dummy" value="' .
+                       htmlspecialchars( wfMsg( 'email_notification_reset' ) ) .
+                       '" /><input type="hidden" name="reset" value="all" /></form>' .
+                       "</div>\n\n" );
+       }
 
+       $uid = $wgUser->getID();
        if( $wgRequest->getVal( 'reset' ) == 'all' ) {
                $wgUser->clearAllNotifications( $uid );
        }
 
+
        if(($action == 'submit') && isset($remove) && is_array($id)) {
                $wgOut->addWikiText( wfMsg( 'removingchecked' ) );
                $wgOut->addHTML( '<p>' );
@@ -106,7 +119,7 @@ function wfSpecialWatchlist() {
        if ( $days <= 0 ) {
                $docutoff = '';
                $cutoff = false;
-               $npages = wfMsg( 'all' );
+               $npages = wfMsg( 'watchlistall1' );
        } else {
                $docutoff = "AND rev_timestamp > '" .
                  ( $cutoff = $dbr->timestamp( time() - intval( $days * 86400 ) ) )
@@ -117,6 +130,10 @@ function wfSpecialWatchlist() {
                $npages = $s->n;
 
        }
+       if ( is_null( $hideOwn ) ) {
+               # default is false (don't hide own edits)
+               $hideOwn = 0;
+       }
 
        if(isset($_REQUEST['magic'])) {
                $wgOut->addWikiText( wfMsg( 'watchlistcontains', $wgLang->formatNum( $nitems ) ) .
@@ -176,7 +193,12 @@ function wfSpecialWatchlist() {
                $z = 'wl_namespace=page_namespace';
        }
 
-
+       if ( 0 == $hideOwn )
+               $andHideOwn = '';
+       else
+               $andHideOwn = "AND (rev_user <> $uid)";
+               
+       
        $wgOut->addHTML( '<i>' . wfMsg( 'watchdetails',
                $wgLang->formatNum( $nitems ), $wgLang->formatNum( $npages ), $y,
                $specialTitle->escapeLocalUrl( 'magic=yes' ) ) . "</i><br />\n" );
@@ -187,6 +209,7 @@ function wfSpecialWatchlist() {
   rev_user,rev_user_text,rev_timestamp,rev_minor_edit,page_is_new,wl_notificationtimestamp
   FROM $watchlist,$page,$revision  $use_index
   WHERE wl_user=$uid
+  $andHideOwn
   AND $z
   AND wl_title=page_title
   AND page_latest=rev_id
@@ -205,7 +228,16 @@ function wfSpecialWatchlist() {
        $wgOut->addHTML( "\n<hr />\n{$note}\n<br />" );
        $note = wlCutoffLinks( $days );
        $wgOut->addHTML( "{$note}\n" );
-
+       
+       $sk = $wgUser->getSkin();
+       $s = $sk->makeKnownLink(
+               $wgContLang->specialPage( 'Watchlist' ),
+               (0 == $hideOwn) ? wfMsg( 'wlhide' ) : wfMsg( 'wlshow' ),        
+               'hideOwn=' . $wgLang->formatNum( 1-$hideOwn ) );
+               
+       $note = wfMsg( "wlhideshowown", $s );
+       $wgOut->addHTML( "\n<br />{$note}\n<br />" );
+       
        if ( $numRows == 0 ) {
                $wgOut->addHTML( '<p><i>' . wfMsg( 'watchnochange' ) . '</i></p>' );
                return;
@@ -265,7 +297,7 @@ function wlDaysLink( $d, $page ) {
        $sk = $wgUser->getSkin();
        $s = $sk->makeKnownLink(
          $wgContLang->specialPage( $page ),
-         ($d ? $wgLang->formatNum( $d ) : wfMsg( 'all' ) ), "days=$d" );
+         ($d ? $wgLang->formatNum( $d ) : wfMsg( 'watchlistall2' ) ), "days=$d" );
        return $s;
 }