function getPageHeader( ) {
return '';
}
+
+ /**
+ * Some special pages (for example SpecialListusers) might not return the
+ * current object formatted, but return the previous one instead.
+ * Setting this to return true, will call one more time wfFormatResult to
+ * be sure that the very last result is formatted and shown.
+ */
+ function tryLastResult( ) {
+ return false;
+ }
/**
* This is the actual workhorse. It does everything needed to make a
if ( $num > 0 ) {
$s = "<ol start='" . ( $offset + 1 ) . "' class='special'>";
+
# Only read at most $num rows, because $res may contain the whole 1000
for ( $i = 0; $i < $num && $obj = $dbr->fetchObject( $res ); $i++ ) {
$format = $this->formatResult( $sk, $obj );
$s .= "<li{$attr}>{$format}</li>\n";
}
}
+
+ if($this->tryLastResult()) {
+ // flush the very last result
+ $obj = null;
+ $format = $this->formatResult( $sk, $obj );
+ if( $format ) {
+ $s .= "<li{$attr}>{$format}</li>\n";
+ }
+ }
+
$dbr->freeResult( $res );
$s .= '</ol>';
$wgOut->addHTML( $s );
/**
*
*/
-require_once("QueryPage.php");
+require_once('QueryPage.php');
/**
* This class is used to get a list of user. The ones with specials
class ListUsersPage extends QueryPage {
var $requestedGroup = '';
var $requestedUser = '';
-
+ var $previousResult = false;
+ var $concatGroups = '';
+
function getName() {
- return "Listusers";
+ return 'Listusers';
}
function isSyndicated() { return false; }
// build the dropdown list menu using datas from the database
while($agroup = $dbr->fetchObject( $result )) {
- $selected = ($agroup->group_id == $this->requestedGroup) ? " selected " : "" ;
+ $selected = ($agroup->group_id == $this->requestedGroup) ? ' selected ' : '' ;
$out.= '<option value="'.$agroup->group_id.'" '.$selected.'>'.$agroup->group_name.'</option>';
}
$out .= '</select> ';
$userspace = Namespace::getUser();
$sql = "SELECT group_name as type, $userspace AS namespace, user_name AS title, user_name as value " .
- "FROM $user LEFT JOIN $user_groups ON user_id =ug_user " .
+ "FROM $user ".
+ "LEFT JOIN $user_groups ON user_id =ug_user " .
"LEFT JOIN $group ON ug_group = group_id ";
-
+
if($this->requestedGroup != '') {
$sql .= "WHERE group_id= '" . IntVal( $this->requestedGroup ) . "' ";
if($this->requestedUser != '') {
- $sql .= "AND user_name = " . $dbr->addQuotes( $this->requestedUser ) . " ";
+ $sql .= "AND user_name = " . $dbr->addQuotes( $this->requestedUser ) . ' ';
}
} else {
if($this->requestedUser !='') {
- $sql .= "WHERE user_name = " . $dbr->addQuotes( $this->requestedUser ) . " ";
+ $sql .= "WHERE user_name = " . $dbr->addQuotes( $this->requestedUser ) . ' ';
}
}
return $sql;
}
+ /**
+ * When calling formatResult we output the previous result instead of the
+ * current one. We need an additional step to flush out the last result.
+ */
+ function tryLastResult( ) {
+ return true;
+ }
+
function sortDescending() {
return false;
}
+ function appendGroups($group) {
+ $this->concatGroups .= $group.' ';
+ }
+
+ function clearGroups() {
+ $this->concatGroups = '';
+ }
+/*
+ var $previousResult = false;
+ var $concatGroups = '';
+*/
function formatResult( $skin, $result ) {
global $wgContLang;
- $name = $skin->makeLink( $wgContLang->getNsText($result->namespace) . ':' . $result->title, $result->title );
- if( '' != $result->type ) {
- $name .= ' (' .
- $skin->makeLink( wfMsgForContent( 'administrators' ), $result->type) .
- ')';
+ $name = false;
+
+ if($this->previousResult->title != $result->title && $this->previousResult != false) {
+ // Different username, give back name(group1,group2)
+ $name = $skin->makeLink( $wgContLang->getNsText($this->previousResult->namespace) . ':' . $this->previousResult->title, $this->previousResult->title );
+ $name .= $this->concatGroups ? '('.substr($this->concatGroups,0,-1).')' : '';
+ $this->clearGroups();
}
+
+ if($result->type != '') {
+ $this->appendGroups( $skin->makeLink( wfMsgForContent( 'administrators' ), $result->type ) );
+ }
+
+ $this->previousResult = $result;
return $name;
}
}