*/
class HTMLForm {
/** name of our form. Used as prefix for labels */
- var $mName;
+ var $mName, $mRequest;
+
+ function HTMLForm( &$request ) {
+ $this->mRequest = $request;
+ }
/**
* @access private
* @param boolean $checked Set true to check the box (default False).
*/
function checkbox( $varname, $checked=false ) {
- $checked = isset( $_POST[$varname] ) && $_POST[$varname] ;
+ if ( $this->mRequest->wasPosted() && !is_null( $this->mRequest->getVal( $varname ) ) ) {
+ $checked = $this->mRequest->getCheck( $varname );
+ }
return "<div><input type='checkbox' value=\"1\" id=\"{$varname}\" name=\"wpOp{$varname}\"" .
( $checked ? ' checked="checked"' : '' ) .
" /><label for=\"{$varname}\">". wfMsg( $this->mName.'-'.$varname ) .
* @param integer $size Optional size of the textbox (default 20)
*/
function textbox( $varname, $value='', $size=20 ) {
- $value = isset( $_POST[$varname] ) ? $_POST[$varname] : $value;
+ if ( $this->mRequest->wasPosted() ) {
+ $value = $this->mRequest->getText( $varname, $value );
+ }
+ $value = htmlspecialchars( $value );
return "<div><label>". wfMsg( $this->mName.'-'.$varname ) .
"<input type='text' name=\"{$varname}\" value=\"{$value}\" size=\"{$size}\" /></label></div>\n";
}
* @param integer $size Optional size of the textarea (default 20)
*/
function textareabox ( $varname, $value='', $size=20 ) {
- $value = isset( $_POST[$varname] ) ? $_POST[$varname] : $value;
+ if ( $this->mRequest->wasPosted() ) {
+ $value = $this->mRequest->getText( $varname, $value );
+ }
+ $value = htmlspecialchars( $value );
return '<div><label>'.wfMsg( $this->mName.'-'.$varname ).
"<textarea name=\"{$varname}\" rows=\"5\" cols=\"{$size}\">$value</textarea></label></div>\n";
}
*/
function arraybox( $varname , $size=20 ) {
$s = '';
- if ( isset( $_POST[$varname] ) && is_array( $_POST[$varname] ) ) {
- foreach ( $_POST[$varname] as $index=>$element ) {
- $s .= $element."\n";
+ if ( $this->mRequest->wasPosted() ) {
+ $arr = $this->mRequest->getArray( $varname );
+ if ( is_array( $arr ) ) {
+ foreach ( $_POST[$varname] as $index=>$element ) {
+ $s .= htmlspecialchars( $element )."\n";
+ }
}
}
return "<div><label>".wfMsg( $this->mName.'-'.$varname ).
/** Build a select with all defined groups
* @param string $selectname Name of this element. Name of form is automaticly prefixed.
- * @param array $selected Array of element selected when posted. Multiples will only show them.
+ * @param array $selected Array of element selected when posted. Only multiples will show them.
* @param boolean $multiple A multiple elements select.
- * @param integer $size Number of element to be shown ignored for non multiple (default 6).
+ * @param integer $size Number of elements to be shown ignored for non-multiple (default 6).
* @param boolean $reverse If true, multiple select will hide selected elements (default false).
*/
function HTMLSelectGroups($selectname, $selectmsg, $selected=array(), $multiple=false, $size=6, $reverse=false) {
+ global $wgOut;
$groups =& Group::getAllGroups();
$out = wfMsg($selectmsg);
if($multiple) {
// for multiple will only show the things we want
if(in_array($id, $selected) xor $reverse) {
- $out .= '<option value="'.$id.'">'.$g->getExpandedName()."</option>\n";
+ $out .= '<option value="'.$id.'">'.$wgOut->parse( $g->getExpandedName() )."</option>\n";
}
} else {
$out .= '<option ';
if(in_array($id, $selected)) { $out .= 'selected="selected" '; }
- $out .= 'value="'.$id.'">'.$g->getExpandedName()."</option>\n";
+ $out .= 'value="'.$id.'">'.$wgOut->parse( $g->getExpandedName() )."</option>\n";
}
}
$out .= "</select>\n";
/** Constructor*/
function UserrightsForm ( &$request ) {
$this->mPosted = $request->wasPosted();
- $this->mRequest = $request;
+ $this->mRequest =& $request;
$this->mName = 'userrights';
$titleObj = Title::makeTitle( NS_SPECIAL, 'Userrights' );
}
/**
- * Manage forms to be shown according to posted datas.
- * Depending on the submit button used : Call a form or a saving function.
+ * Manage forms to be shown according to posted data.
+ * Depending on the submit button used, call a form or a save function.
*/
function execute() {
// show the general form
}
}
-// save things !!
/**
* Save user groups changes in the database.
* Datas comes from the editUserGroupsForm() form function
* @param array $removegroup id of groups to be removed.
* @param array $addgroup id of groups to be added.
*
- * @todo Log groupname instead of group id.
*/
function saveUserGroups($username,$removegroup,$addgroup) {
$u = User::NewFromName($username);
return;
}
- $groups = $u->getGroups();
+ $oldGroups = $u->getGroups();
+ $newGroups = $oldGroups;
$logcomment = ' ';
// remove then add groups
if(isset($removegroup)) {
- $groups = array_diff($groups, $removegroup);
- $logcomment .= implode( ' -', $removegroup);
- }
+ $newGroups = array_diff($newGroups, $removegroup);
+ }
if(isset($addgroup)) {
- $groups = array_merge($groups, $addgroup);
- $logcomment .= implode( ' +', $addgroup );
- }
+ $newGroups = array_merge($newGroups, $addgroup);
+ }
+ $newGroups = array_unique( $newGroups );
+
// save groups in user object and database
- $u->setGroups($groups);
+ $u->setGroups($newGroups);
$u->saveSettings();
$log = new LogPage( 'rights' );
- $log->addEntry( 'rights', Title::makeTitle( NS_USER, $u->getName() ), $logcomment );
+ $log->addEntry( 'rights', Title::makeTitle( NS_USER, $u->getName() ), '', array( $this->makeGroupNameList( $oldGroups ),
+ $this->makeGroupNameList( $newGroups ) ) );
+ }
+
+ function makeGroupNameList( $ids ) {
+ $s = '';
+ foreach( $ids as $id ) {
+ if ( $s != '' ) {
+ $s .= ', ';
+ }
+ $groupObj = Group::newFromId( $id );
+ $s .= $groupObj->getExpandedName();
+ }
+ return $s;
}
/**
global $wgOut;
$user = User::newFromName($username);
+ $encUser = htmlspecialchars( $username );
if(is_null($user)) {
- $wgOut->addHTML('<p>'.wfMsg('nosuchusershort',$username).'</p>');
+ $wgOut->addHTML('<p>'.wfMsg('nosuchusershort', $encUser).'</p>');
return;
}
if($user->getID() == 0) {
- $wgOut->addHTML('<p>'.wfMsg('nosuchusershort',$username).'</p>');
+ $wgOut->addHTML('<p>'.wfMsg('nosuchusershort', $encUser).'</p>');
return;
}
$groups = $user->getGroups();
$wgOut->addHTML( "<form name=\"editGroup\" action=\"$this->action\" method=\"post\">\n".
- '<input type="hidden" name="user-editname" value="'.$username.'" />');
+ '<input type="hidden" name="user-editname" value="'.$encUser.'" />');
$wgOut->addHTML( $this->fieldset( 'editusergroup',
wfMsg('editing', $this->mRequest->getVal('user-editname')).".<br />\n" .
'<table border="0" align="center"><tr><td>'.
'userrights-groupsavailable' => 'Available groups:',
'userrights-groupshelp' => 'Select groups you want the user to be removed from or added to.
Unselected groups will not be changed. You can deselect a group with CTRL + Left Click',
+'userrights-logcomment' => 'Changed group membership from $1 to $2',
# Default group names and descriptions
#
'email_notification_reset' => 'Reset all notification flags (set their status to "visited")',
'email_notification_newpagetext'=> 'This is a new page.',
'email_notification_to' => '$WATCHINGUSERNAME_QP <$WATCHINGUSEREMAILADDR>',
-'email_notification_subject' => '{{SITENAME}} page $PAGETITLE has been changed by $PAGEEDITOR',
+'changed' => 'changed',
+'created' => 'created',
+'email_notification_subject' => '{{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED by $PAGEEDITOR',
'email_notification_lastvisitedrevisiontext' => 'See {{SERVER}}{{localurl:$PAGETITLE_RAWURL|diff=0&oldid=$OLDID}} for all changes since your last visit.',
'email_notification_body' => 'Dear $WATCHINGUSERNAME,
-the {{SITENAME}} page $PAGETITLE has been changed on $PAGEEDITDATE by $PAGEEDITOR,
+the {{SITENAME}} page $PAGETITLE has been $CHANGEDORCREATED on $PAGEEDITDATE by $PAGEEDITOR,
see {{SERVER}}{{localurl:$PAGETITLE_RAWURL}} for the current version.
$NEWPAGE
Editor\'s summary: $PAGESUMMARY $PAGEMINOREDIT
+
Contact the editor:
mail {{SERVER}}{{localurl:Special:Emailuser|target=$PAGEEDITOR_RAWURL}}
wiki {{SERVER}}{{localurl:User:$PAGEEDITOR_RAWURL}}
'setbureaucratflag' => 'Set bureaucrat flag',
'bureaucratlog' => 'Bureaucrat_log',
'rightslogtext' => 'This is a log of changes to user rights.',
-'bureaucratlogentry' => "Rights for user \"$1\" set \"$2\"",
+'bureaucratlogentry' => "Changed group membership for $1 from $2 to $3",
'rights' => 'Rights:',
'set_user_rights' => 'Set user rights',
'user_rights_set' => "<b>User rights for \"$1\" updated</b>",