Merge "Further tweaks to pipe trick documentation (follow-up Iaf365e31)"
[lhc/web/wiklou.git] / includes / logging / LogEventsList.php
index 6016641..1110249 100644 (file)
@@ -166,7 +166,7 @@ class LogEventsList extends ContextSource {
                        $query[$queryKey] = $hideVal;
 
                        $link = Linker::linkKnown(
-                               $this->getDisplayTitle(),
+                               $this->getTitle(),
                                $messages[$hideVal],
                                array(),
                                $query
@@ -351,9 +351,9 @@ class LogEventsList extends ContextSource {
                $user = $this->getUser();
                // Don't show useless checkbox to people who cannot hide log entries
                if( $user->isAllowed( 'deletedhistory' ) ) {
-                       if( $row->log_deleted || $user->isAllowed( 'deletelogentry' ) ) {
-                               $canHide = $user->isAllowed( 'deletelogentry' );
-                               if ( $this->flags & self::USE_REVDEL_CHECKBOXES ) { // Show checkboxes instead of links.
+                       $canHide = $user->isAllowed( 'deletelogentry' );
+                       if( $row->log_deleted || $canHide ) {
+                               if ( $canHide && $this->flags & self::USE_REVDEL_CHECKBOXES ) { // Show checkboxes instead of links.
                                        if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) { // If event was hidden from sysops
                                                $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
                                        } else {
@@ -575,23 +575,30 @@ class LogEventsList extends ContextSource {
         *
         * @param $db DatabaseBase
         * @param $audience string, public/user
+        * @param $user User object to check, or null to use $wgUser
         * @return Mixed: string or false
         */
-       public static function getExcludeClause( $db, $audience = 'public' ) {
-               global $wgLogRestrictions, $wgUser;
+       public static function getExcludeClause( $db, $audience = 'public', User $user = null ) {
+               global $wgLogRestrictions;
+
+               if ( $audience != 'public' && $user === null ) {
+                       global $wgUser;
+                       $user = $wgUser;
+               }
+
                // Reset the array, clears extra "where" clauses when $par is used
                $hiddenLogs = array();
+
                // Don't show private logs to unprivileged users
                foreach( $wgLogRestrictions as $logType => $right ) {
-                       if( $audience == 'public' || !$wgUser->isAllowed($right) ) {
-                               $safeType = $db->strencode( $logType );
-                               $hiddenLogs[] = $safeType;
+                       if( $audience == 'public' || !$user->isAllowed( $right ) ) {
+                               $hiddenLogs[] = $logType;
                        }
                }
-               if( count($hiddenLogs) == 1 ) {
+               if( count( $hiddenLogs ) == 1 ) {
                        return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
                } elseif( $hiddenLogs ) {
-                       return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
+                       return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) . ')';
                }
                return false;
        }