return Xml::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern );
}
+ public function beginLogEventList() {
+ return "<ul>\n";
+ }
+
+ public function endLogEventList() {
+ return "</ul>\n";
+ }
+
/**
* @param Row $row a single row from the result set
* @return string Formatted HTML list item
$action = LogPage::actionText( $row->log_type, $row->log_action, $title, $this->skin, $paramArray, true );
}
- return "<li>$del$time $userLink $action $comment $revert</li>";
+ return "<li>$del$time $userLink $action $comment $revert</li>\n";
}
/**
}
return "<tt>(<small>$del</small>)</tt>";
}
+
+ /**
+ * SQL clause to skip forbidden log types for this user
+ * @param Database $db
+ * @returns mixed (string or false)
+ */
+ public static function getExcludeClause( $db ) {
+ global $wgLogRestrictions, $wgUser;
+ // Reset the array, clears extra "where" clauses when $par is used
+ $hiddenLogs = array();
+ // Don't show private logs to unpriviledged users
+ foreach( $wgLogRestrictions as $logtype => $right ) {
+ if( !$wgUser->isAllowed($right) ) {
+ $safetype = $db->strencode( $logtype );
+ $hiddenLogs[] = "'$safetype'";
+ }
+ }
+ if( !empty($hiddenLogs) ) {
+ return 'log_type NOT IN(' . implode(',',$hiddenLogs) . ')';
+ }
+ return false;
+ }
}
# Insert list
$wgOut->addHTML(
$pager->getNavigationBar() .
- '<ul id="logevents">' . "\n" .
+ $loglist->beginLogEventList() .
$pager->getBody() .
- '</ul>' . "\n" .
+ $loglist->endLogEventList() .
$pager->getNavigationBar()
);
}
* @private
*/
private function limitType( $type ) {
- global $wgLogRestrictions, $wgUser;
- // Reset the array, clears extra "where" clauses when $par is used
- $hiddenLogs = array();
- // Nothing to show the user requested a log they can't see
- if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
- $this->mConds[] = "NULL";
- return false;
- }
// Don't show private logs to unpriviledged users
- foreach( $wgLogRestrictions as $logtype => $right ) {
- if( !$wgUser->isAllowed($right) || empty($type) ) {
- $safetype = $this->mDb->strencode( $logtype );
- $hiddenLogs[] = "'$safetype'";
- }
+ $hideLogs = LogEventList::getExcludeClause( $this->mDb );
+ if( $hideLogs !== false ) {
+ $this->mConds[] = $hideLogs;
}
- if( !empty($hiddenLogs) ) {
- $this->mConds[] = 'log_type NOT IN('.implode(',',$hiddenLogs).')';
- }
-
if( empty($type) ) {
return false;
}
list($tbl_logging, $tbl_page, $tbl_user) = $db->tableNamesN('logging', 'page', 'user');
+ $hideLogs = LogEventList::getExcludeClause($db);
+ if($hideLogs !== false)
+ $this->addWhere($hideLogs);
+
$this->addOption('STRAIGHT_JOIN');
$this->addTables("$tbl_logging LEFT OUTER JOIN $tbl_page ON " .
"log_namespace=page_namespace AND log_title=page_title " .