Index: trunk/extensions/Configure/Configure.obj.php
===================================================================
--- trunk/extensions/Configure/Configure.obj.php (revision 44446)
+++ trunk/extensions/Configure/Configure.obj.php (revision 44447)
@@ -167,15 +167,16 @@
/** Recursive doohicky for normalising variables so we can compare them. */
public static function filterVar( $var ) {
- if (empty($var) && !$var) {
+ if ( empty( $var ) && !$var ) {
return null;
}
if ( is_array( $var ) ) {
return array_filter( array_map( array( __CLASS__, 'filterVar' ), $var ) );
}
-
- return trim($var);
+ if( is_object( $var ) )
+ throw new MWException( 'test' );
+ return trim( $var );
}
/**
Index: trunk/extensions/Configure/Configure.page.php
===================================================================
--- trunk/extensions/Configure/Configure.page.php (revision 44446)
+++ trunk/extensions/Configure/Configure.page.php (revision 44447)
@@ -4,7 +4,6 @@
/**
* Special page allows authorised users to configure the wiki
*
- * @file
* @ingroup Extensions
*/
abstract class ConfigurationPage extends SpecialPage {
@@ -612,6 +611,59 @@
}
$settings[$name] = $all;
+ break;
+ case 'promotion-conds':
+ $options = array( 'or' => '|', 'and' => '&', 'xor' => '^', 'not' => '!' );
+ $conds = array( APCOND_EDITCOUNT => 'int', APCOND_AGE => 'int', APCOND_EMAILCONFIRMED => 'bool', APCOND_INGROUPS => 'array' );
+
+ if ( isset( $_REQUEST['wp' . $name . '-vals'] ) ) {
+ $groups = explode( "\n", trim( $wgRequest->getText( 'wp' . $name . '-vals' ) ) );
+ foreach ( $groups as &$group ) {
+ // Our own Sanitizer::unescapeId() :)
+ $group = urldecode( str_replace( array( '.', "\r" ), array( '%', '' ),
+ substr( $group, strlen( $name ) + 3 ) ) );
+ }
+ unset( $group ); // Unset the reference, just in case
+ } else { // No javascript ?
+ $groups = array_keys( $this->getSettingValue( $name ) );
+ }
+
+ foreach( $groups as $group ) {
+ $op = $wgRequest->getText( 'wp' . $name . '-' . $group . '-opt' );
+ if( !isset( $options[$op] ) )
+ throw new MWException( "'{$op}' for group '{$group}' is not a valid operator for 'promotion-conds' type" );
+ $op = $options[$op];
+
+ $condsVal = array( $op );
+ foreach ( $conds as $condName => $condType ) {
+ switch( $condType ) {
+ case 'bool':
+ $val = $wgRequest->getCheck( 'wp' . $name . '-' . $group . '-cond-' . $condName );
+ if( $val )
+ $condsVal[] = array( $condName );
+ break;
+ case 'int':
+ $val = $wgRequest->getInt( 'wp' . $name . '-' . $group . '-cond-' . $condName );
+ if( $val )
+ $condsVal[] = array( $condName, $val );
+ break;
+ case 'array':
+ $val = trim( $wgRequest->getText( 'wp' . $name . '-' . $group . '-cond-' . $condName ) );
+ if( !$val )
+ break;
+ $val = array_map( 'trim', explode( "\n", $val ) );
+ $reqGroups = array();
+ foreach( $val as $reqGroup )
+ if( $reqGroup )
+ $reqGroups[] = $reqGroup;
+
+ if( count( $reqGroups ) )
+ $condsVal[] = array_merge( array( $condName ), $reqGroups );
+ }
+ $settings[$name][$group] = $condsVal;
+ }
+ }
+ break;
}
break;
case 'text':
@@ -698,14 +750,19 @@
$defaultValues = $wgConf->getDefaultsForWiki( $this->mWiki );
foreach ( $defaultValues as $name => $default ) {
## Normalise the two, to avoid false "changes"
- if (is_array($default))
- $default = WebConfiguration::filterVar( $default );
-
+ if ( is_array( $default ) ) {
+ try {
+ $default = WebConfiguration::filterVar( $default );
+ } catch( Exception $e ) {
+ throw new MWException( $name );
+ }
+ }
+
if ( isset( $settings[$name] ) ) {
$settingCompare = $settings[$name];
- if (is_array($settingCompare))
- $settingCompare = WebConfiguration::filterVar($settingCompare);
-
+ if ( is_array( $settingCompare ) )
+ $settingCompare = WebConfiguration::filterVar( $settingCompare );
+
if ( $settingCompare == $default ) {
unset( $settings[$name] );
} elseif ( $this->canBeMerged( $name, $default ) ) {
@@ -731,7 +788,7 @@
unset( $settings[$name][$group][$right] );
}
}
- if ( !count( $settings[$name][$group] ) )
+ if ( isset( $settings[$name][$group] ) && !count( $settings[$name][$group] ) )
unset( $settings[$name][$group] );
}
break;
@@ -980,16 +1037,16 @@
$keydesc = wfMsgExt( "configure-setting-$conf-key", 'parseinline' );
$valdesc = wfMsgExt( "configure-setting-$conf-value", 'parseinline' );
- if (wfEmptyMsg( "configure-setting-$conf-key", $keydesc ))
+ if ( wfEmptyMsg( "configure-setting-$conf-key", $keydesc ) )
$keydesc = wfMsgHtml( 'configure-desc-key' );
- if (wfEmptyMsg( "configure-setting-$conf-value", $valdesc ))
+ if ( wfEmptyMsg( "configure-setting-$conf-value", $valdesc ) )
$valdesc = wfMsgHtml( 'configure-desc-val' );
- $classes = array('configure-array-table', 'assoc');
+ $classes = array( 'configure-array-table', 'assoc' );
- if (!$allowed)
+ if ( !$allowed )
$classes[] = 'disabled';
- if (count($default) > 5)
+ if ( count( $default ) > 5 )
$classes[] = 'configure-biglist';
$text = Xml::openElement( 'table', array( 'class' => ( implode( ' ', $classes ) ),
@@ -1145,7 +1202,7 @@
$nsdesc = wfMsgHtml( 'configure-desc-ns' );
$valdesc = wfMsgExt( "configure-setting-$conf-value", 'parseinline' );
- if (wfEmptyMsg( "configure-setting-$conf-value", $valdesc ))
+ if ( wfEmptyMsg( "configure-setting-$conf-value", $valdesc ) )
$valdesc = wfMsgHtml( 'configure-desc-val' );
$text = "<table class='configure-array-table ns-text configure-biglist'>\n<tr><th>{$nsdesc}</th><th>{$valdesc}</th></tr>\n";
foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
@@ -1172,7 +1229,7 @@
$nsdesc = wfMsgHtml( 'configure-desc-ns' );
$valdesc = wfMsgExt( "configure-setting-$conf-value", 'parseinline' );
- if (wfEmptyMsg( "configure-setting-$conf-value", $valdesc ))
+ if ( wfEmptyMsg( "configure-setting-$conf-value", $valdesc ) )
$valdesc = wfMsgHtml( 'configure-desc-val' );
$text = "<table class='ns-array configure-biglist configure-array-table'>\n<tr><th>{$nsdesc}</th><th>{$valdesc}</th></tr>\n";
foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
@@ -1202,10 +1259,15 @@
}
if ( $type == 'group-bool' || $type == 'group-array' ) {
$all = array();
- $attr = ( !$allowed ) ? array( 'disabled' => 'disabled' ) : array();
if ( $type == 'group-bool' ) {
$all = User::getAllRights();
$iter = $default;
+ $allGroups = array_keys( $all );
+ $autopromote = array_keys( $this->getSettingValue( 'wgAutopromote' ) );
+ $newGroups = array_diff( $autopromote, $allGroups );
+ foreach( $newGroups as $newGroup ) {
+ $iter[$newGroup] = array();
+ }
} else {
$all = array_keys( $this->getSettingValue( 'wgGroupPermissions' ) );
$iter = array();
@@ -1218,35 +1280,149 @@
$groupdesc = wfMsgHtml( 'configure-desc-group' );
$valdesc = wfMsgExt( "configure-setting-$conf-value", 'parseinline' );
- if (wfEmptyMsg( "configure-setting-$conf-value", $valdesc ))
+ if ( wfEmptyMsg( "configure-setting-$conf-value", $valdesc ) )
$valdesc = wfMsgHtml( 'configure-desc-val' );
$encConf = htmlspecialchars( $conf );
- $text = "<table id= '{$encConf}' class='{$type} configure-array-table'>\n<tr><th>{$groupdesc}</th><th>{$valdesc}</th></tr>\n";
+ $classes = "{$type} configure-array-table" . ( $type == 'group-bool' ? ' ajax-group' : '' );
+ $text = "<table id=\"{$encConf}\" class=\"$classes\">\n";
+ $text .= "<tr class=\"configure-maintable-row\"><th>{$groupdesc}</th><th>{$valdesc}</th></tr>\n";
foreach ( $iter as $group => $levs ) {
- $row = '<div class="configure-biglist '.$type.'-element"><ul>';
- foreach ( $all as $right ) {
- if ( $type == 'group-bool' )
- $checked = ( isset( $levs[$right] ) && $levs[$right] );
- else
- $checked = in_array( $right, $levs );
- $id = Sanitizer::escapeId( 'wp' . $conf . '-' . $group . '-' . $right );
- if( $type == 'group-bool' )
- $desc = User::getRightDescription( $right ) . " (" .Xml::element( 'tt', array( 'class' => 'configure-right-id' ), $right ) . ")";
- else
- $desc = User::getGroupName( $right );
- $row .= '<li>' . Xml::check( $id, $checked, $attr + array( 'id' => $id ) ) . ' ' . Xml::tags( 'label', array( 'for' => $id ), $desc ) . "</li>\n";
- }
- $row .= '</ul></div>';
+ $row = self::buildGroupSettingRow( $conf, $type, $all, $allowed, $group, $levs );
$groupName = User::getGroupName( $group );
$encId = Sanitizer::escapeId( 'wp' . $conf . '-' . $group );
- $text .= "<tr id=\"{$encId}\">\n<td class=\"configure-grouparray-group\">{$groupName}</td>\n<td class=\"configure-grouparray-value\">{$row}</td>\n</tr>";
+ $text .= "<tr class=\"configure-maintable-row\" id=\"{$encId}\">\n<td class=\"configure-grouparray-group\">{$groupName}</td>\n<td class=\"configure-grouparray-value\">{$row}</td>\n</tr>";
}
$text .= '</table>';
return $text;
}
+ if ( $type == 'promotion-conds' ) {
+
+ $groupdesc = wfMsgHtml( 'configure-desc-group' );
+ $valdesc = wfMsgExt( "configure-setting-$conf-value", 'parseinline' );
+ if ( wfEmptyMsg( "configure-setting-$conf-value", $valdesc ) )
+ $valdesc = wfMsgHtml( 'configure-desc-val' );
+ $encConf = htmlspecialchars( $conf );
+ $text = "<table id= '{$encConf}' class='{$type} configure-array-table ajax-group'>\n";
+ $text .= "<tr class=\"configure-maintable-row\"><th>{$groupdesc}</th><th>{$valdesc}</th></tr>\n";
+
+ foreach ( $default as $group => $groupConds ) {
+ $row = self::buildPromotionCondsSettingRow( $conf, $allowed, $group, $groupConds );
+ $groupName = User::getGroupName( $group );
+ $encId = Sanitizer::escapeId( 'wp' . $conf . '-' . $group );
+ $text .= "<tr class=\"configure-maintable-row\" id=\"{$encId}\">\n<td class=\"configure-promotion-group\">{$groupName}</td>\n<td class=\"configure-promotion-value\">{$row}</td>\n</tr>";
+ }
+
+ $text .= '</table>';
+ return $text;
+ }
}
/**
+ * Build a row for promotion-conds array type, taken out of buildArrayInput()
+ * to called with ajax
+ * @param $conf String: setting name
+ * @param $allowed Boolean
+ * @param $group String: group name
+ * @param $groupConds Array: existing conditions for $group
+ * @return String: XHTML
+ */
+ public static function buildPromotionCondsSettingRow( $conf, $allowed, $group, $groupConds ){
+ static $options = array( 'or' => '|', 'and' => '&', 'xor' => '^', 'not' => '!' );
+ static $conds = array( APCOND_EDITCOUNT => 'int', APCOND_AGE => 'int', APCOND_EMAILCONFIRMED => 'bool', APCOND_INGROUPS => 'array' );
+
+ $row = '<div class="configure-biglist promotion-conds-element">';
+ $row .= wfMsgHtml( 'configure-condition-operator' ) . ' ';
+ $encConf = htmlspecialchars( $conf );
+ $encGroup = htmlspecialchars( $group );
+ $encId = 'wp'.$encConf.'-'.$encGroup;
+ $curOpt = array_shift( $groupConds );
+ $extra = $allowed ? array() : array( 'disabled' => 'disabled' );
+ foreach ( $options as $desc => $opt ) {
+ $row .= Xml::radioLabel( wfMsg( 'configure-condition-operator-'.$desc ), $encId.'-opt', $desc,
+ $encId.'-opt-'.$desc, $curOpt == $opt, $extra ) . "\n";
+ }
+ $row .= "<br />\n";
+
+ $condsVal = array();
+ foreach( $groupConds as $cond ){
+ if( !is_array( $cond ) ) {
+ $condsVal[$cond] = true;
+ continue;
+ }
+ $name = array_shift( $cond );
+ if ( count( $cond ) == 0 ) {
+ $condsVal[$name] = true;
+ } elseif( count( $cond ) == 1 ) {
+ $condsVal[$name] = array_shift( $cond );
+ } else {
+ $condsVal[$name] = $cond;
+ }
+ }
+
+ $row .= "<table class=\"configure-table-promotion\">\n";
+ $row .= '<tr><th>' . wfMsgHtml( 'configure-condition-name' ) . '</th><th>' . wfMsgHtml( 'configure-condition-requirement' ) . "</th></tr>\n";
+ foreach ( $conds as $condName => $condType ) {
+ $desc = wfMsgHtml( 'configure-condition-name-' . $condName );
+ $row .= "<tr><td><label for=\"{$encId}-cond-{$condName}\">{$desc}</label></td><td>";
+ switch( $condType ) {
+ case 'bool':
+ $row .= Xml::check( $encId.'-cond-'.$condName, isset( $condsVal[$condName] ) && $condsVal[$condName],
+ array( 'id' => $encId.'-cond-'.$condName ) + $extra ) . "<br />\n";
+ break;
+ case 'int':
+ $row .= Xml::input( $encId.'-cond-'.$condName, 20, isset( $condsVal[$condName] ) ? $condsVal[$condName] : 0, $extra ) . "<br />\n";
+ break;
+ case 'array':
+ $id = "{$encId}-cond-{$condName}";
+ if ( $allowed ) {
+ $row .= "<textarea id='{$id}' name='{$id}' cols='30' rows='4' style='width: 95%;'>";
+ if ( isset( $condsVal[$condName] ) && $condsVal[$condName] )
+ $row .= htmlspecialchars( implode( "\n", $condsVal[$condName] ) );
+ $row .= "</textarea>\n";
+ } else {
+ $row .= "<pre>";
+ if ( isset( $condsVal[$condName] ) && $condsVal[$condName] )
+ $row .= htmlspecialchars( implode( "\n", $condsVal[$condName] ) );
+ $row .= "</pre>\n";
+ }
+ }
+ $row .= "</td></tr>";
+ }
+ $row .= "</table></div>";
+ return $row;
+ }
+
+ /**
+ * Build a row for group-bool or group-array array type, taken out of
+ * buildArrayInput() to called with ajax
+ * @param $conf String: setting name
+ * @param $type String: array type
+ * @param $all Array: all avialable rights
+ * @param $allowed Boolean
+ * @param $group String: group name
+ * @param $levs Array: rights given to $group
+ * @return String: XHTML
+ */
+ public static function buildGroupSettingRow( $conf, $type, $all, $allowed, $group, $levs ){
+ $attr = ( !$allowed ) ? array( 'disabled' => 'disabled' ) : array();
+ $row = '<div class="configure-biglist '.$type.'-element"><ul>';
+ foreach ( $all as $right ) {
+ if ( $type == 'group-bool' )
+ $checked = ( isset( $levs[$right] ) && $levs[$right] );
+ else
+ $checked = in_array( $right, $levs );
+ $id = Sanitizer::escapeId( 'wp' . $conf . '-' . $group . '-' . $right );
+ if( $type == 'group-bool' )
+ $desc = User::getRightDescription( $right ) . " (" .Xml::element( 'tt', array( 'class' => 'configure-right-id' ), $right ) . ")";
+ else
+ $desc = User::getGroupName( $right );
+ $row .= '<li>' . Xml::check( $id, $checked, $attr + array( 'id' => $id ) ) . ' ' . Xml::tags( 'label', array( 'for' => $id ), $desc ) . "</li>\n";
+ }
+ $row .= '</ul></div>';
+ return $row;
+ }
+
+ /**
* Build a table row for $conf setting with $default as default value
*
* @param $conf String: name of the setting
@@ -1258,7 +1434,7 @@
$rowClasses = array();
- if ($params['customised'])
+ if ( $params['customised'] )
$rowClasses[] = 'configure-customised';
$msg = isset( $params['msg'] ) ? $params['msg'] : 'configure-setting-' . $conf;
@@ -1281,7 +1457,7 @@
else
$msgVal = "$msgVal ($link)";
- if ($params['customised'])
+ if ( $params['customised'] )
$msgVal = Xml::tags( 'p', null, $msgVal ).wfMsgExt( 'configure-customised', 'parse' );
$attribs['class'] = 'configure-left-column';
$td1 = Xml::tags( 'td', $attribs, $msgVal );
Index: trunk/extensions/Configure/Configure.settings.i18n.php
===================================================================
--- trunk/extensions/Configure/Configure.settings.i18n.php (revision 44446)
+++ trunk/extensions/Configure/Configure.settings.i18n.php (revision 44447)
@@ -152,6 +152,7 @@
'configure-setting-wgSpecialVersionShowHooks' => "Show the contents of \$wgHooks in Special:Version",
'configure-setting-wgUseNPPatrol' => "Use new pages patrolling to check for vandalism",
'configure-setting-wgAutopromote' => "Conditions of automatic promotion of user to specific groups",
+ 'configure-setting-wgAutopromote-value' => 'Conditions',
'configure-setting-wgAccountCreationThrottle' => "Number of accounts each IP address may create",
'configure-setting-wgAllowPageInfo' => "Allow the information action",
'configure-setting-wgAutoblockExpiry' => "Number of seconds before autoblock entries expire",
Index: trunk/extensions/Configure/CHANGELOG
===================================================================
--- trunk/extensions/Configure/CHANGELOG (revision 44446)
+++ trunk/extensions/Configure/CHANGELOG (revision 44447)
@@ -5,6 +5,7 @@
* efConfigureSetup() now delayed until cache objects are set with database
handler to avoid some issues with maintenance scripts.
* Removed $wgNullFile
+ * Added support for $wgAutopromote
THIS VERSION NOW REQUIRES MediaWiki 1.14 TO WORK.
Index: trunk/extensions/Configure/Configure.php
===================================================================
--- trunk/extensions/Configure/Configure.php (revision 44446)
+++ trunk/extensions/Configure/Configure.php (revision 44447)
@@ -148,7 +148,7 @@
/**
* Styles versions, you shouldn't change it
*/
-$wgConfigureStyleVersion = '18';
+$wgConfigureStyleVersion = '19';
# Adding new rights...
$wgAvailableRights[] = 'configure';
Index: trunk/extensions/Configure/Configure.i18n.php
===================================================================
--- trunk/extensions/Configure/Configure.i18n.php (revision 44446)
+++ trunk/extensions/Configure/Configure.i18n.php (revision 44447)
@@ -175,6 +175,18 @@
'configure-throttle-group' => 'Type',
'configure-throttle-limit' => 'Limit',
'configure-throttle-none' => 'No limit',
+
+ 'configure-condition-operator' => 'Operator:',
+ 'configure-condition-operator-or' => 'Or',
+ 'configure-condition-operator-and' => 'And',
+ 'configure-condition-operator-xor' => 'Xor',
+ 'configure-condition-operator-not' => 'Not',
+ 'configure-condition-name' => 'Condition',
+ 'configure-condition-requirement' => 'Requirement',
+ 'configure-condition-name-1' => 'Minimal edit count',
+ 'configure-condition-name-2' => 'Minimal age',
+ 'configure-condition-name-3' => 'Email confirmed',
+ 'configure-condition-name-4' => 'In groups',
);
/** Message documentation (Message documentation)
Index: trunk/extensions/Configure/SpecialExtensions.php
===================================================================
--- trunk/extensions/Configure/SpecialExtensions.php (revision 44446)
+++ trunk/extensions/Configure/SpecialExtensions.php (revision 44447)
@@ -94,7 +94,7 @@
foreach ( $this->mConfSettings->getAllExtensionsObjects() as $ext ) {
$settings = $ext->getSettings();
foreach ( $settings as $setting => $type ) {
- if ( !isset($GLOBALS[$setting]) && !isset($this->conf[$setting]) && file_exists($ext->getFile()) ) {
+ if ( !isset( $GLOBALS[$setting] ) && !isset( $this->conf[$setting] ) && file_exists( $ext->getFile() ) ) {
if ( !$globalDone ) {
extract( $GLOBALS, EXTR_REFS );
global $wgHooks;
Index: trunk/extensions/Configure/Configure.js
===================================================================
--- trunk/extensions/Configure/Configure.js (revision 44446)
+++ trunk/extensions/Configure/Configure.js (revision 44447)
@@ -172,15 +172,15 @@
addHandler( textbox, 'blur', createImageUrlCallback( textbox, img ) );
}
- // $wgGroupPermissions stuff, only if ajax is enabled
- // --------------------------------------------------
+ // $wgGroupPermissions and $wgAutopromote stuff, only if ajax is enabled
+ // ---------------------------------------------------------------------
if( wgConfigureUseAjax ){
- var tables = getElementsByClassName( configform, 'table', 'group-bool' );
+ var tables = getElementsByClassName( configform, 'table', 'ajax-group' );
for( var t = 0; t < tables.length ; t++ ){
table = tables[t];
// Button "remove this row"
- var trs = table.getElementsByTagName( 'tr' );
+ var trs = getElementsByClassName( table, 'tr', 'configure-maintable-row' );
for( var r = 0; r < trs.length; r++ ){
tr = trs[r];
if( r == 0 ){ // header
@@ -193,7 +193,7 @@
var button = document.createElement( 'input' );
button.type = 'button';
button.value = wgConfigureRemoveRow;
- button.onclick = removeGroupBoolCallback( table, r );
+ button.onclick = removeAjaxGroupCallback( table, r );
td.appendChild( button );
tr.appendChild( td );
}
@@ -203,17 +203,17 @@
button.type = 'button';
button.className = 'button-add';
button.value = wgConfigureAdd;
- button.onclick = createGroupBoolCallback( table );
+ button.onclick = createAjaxGroupCallback( table );
table.parentNode.appendChild( button );
}
document.getElementById( 'configure-form' ).onsubmit = function(){
- var tables = getElementsByClassName( configform, 'table', 'group-bool' );
+ var tables = getElementsByClassName( configform, 'table', 'ajax-group' );
for( var t = 0; t < tables.length ; t++ ){
var table = tables[t];
var id = table.id;
var cont = '';
- var trs = table.getElementsByTagName( 'tr' );
+ var trs = getElementsByClassName( table, 'tr', 'configure-maintable-row' );
for( var r = 1; r < trs.length; r++ ){
var tr = trs[r];
if( cont != '' ) cont += "\n";
@@ -365,7 +365,7 @@
var isType = function(type) { return elementType.indexOf( ' '+type+' ' ) !== -1; }
- if (isType('assoc') ) {
+ if ( isType('assoc') ) {
// If it's too big to display as an associative array, it's too big to display as a summary.
} else if ( isType( 'ns-bool' ) || isType( 'ns-simple' ) || isType( 'group-bool-element' ) || isType( 'group-array-element' ) ) {
var labels = div.getElementsByTagName( 'label' );
@@ -476,6 +476,7 @@
}
summary.appendChild( table );
+ } else if ( isType( 'promotion-conds-element' ) ) {
} else if ( isType( 'configure-rate-limits-action' ) ) {
} else {
summary.appendChild( document.createTextNode( 'Useless type:'+elementType ) );
@@ -611,7 +612,7 @@
}
// ----------------------
-// Group bool table stuff
+// Ajax group table stuff
// ----------------------
/**
@@ -620,9 +621,9 @@
*
* @param Dom object representing a table
*/
-function createGroupBoolCallback( table ){
+function createAjaxGroupCallback( table ){
return function(){
- addGroupBoolRow( table );
+ addAjaxGroupRow( table );
}
}
@@ -631,9 +632,9 @@
*
* @param Dom object representing a table
*/
-function removeGroupBoolCallback( table, r ){
+function removeAjaxGroupCallback( table, r ){
return function(){
- removeGroupBoolRow( table, r );
+ removeAjaxGroupRow( table, r );
}
}
@@ -642,8 +643,8 @@
*
* @param Dom object representing a table
*/
-function addGroupBoolRow( table ){
- r = table.getElementsByTagName( 'tr' ).length;
+function addAjaxGroupRow( table ){
+ r = getElementsByClassName( table, 'tr', 'configure-maintable-row' ).length;
startName = 'wp' + table.id;
var groupname = prompt( wgConfigurePromptGroup );
var tbody = table.getElementsByTagName( 'tbody' )[0];
@@ -651,6 +652,7 @@
return;
var tr = document.createElement( 'tr' );
+ tr.className = 'configure-maintable-row';
tr.id = startName + '-' + groupname;
var td1 = document.createElement( 'td' );
@@ -658,7 +660,7 @@
var td2 = document.createElement( 'td' );
error = false;
- sajax_do_call( 'efConfigureAjax', [ groupname ], function( x ){
+ sajax_do_call( 'efConfigureAjax', [ table.id, groupname ], function( x ){
var resp = x.responseText;
if( resp == '<err#>' || x.status != 200 )
error = true;
@@ -675,7 +677,7 @@
button.type = 'button';
button.className = 'button-add';
button.value = wgConfigureRemoveRow;
- button.onclick = removeAssocCallback( table, r );
+ button.onclick = removeAjaxGroupCallback( table, r );
td3.appendChild( button );
tr.appendChild( td1 );
@@ -685,13 +687,13 @@
}
/**
- * Remove a new row in a "group-bool" table
+ * Remove a new row in a "ajax-group" table
*
* @param Dom object representing a table
* @param integer
*/
-function removeGroupBoolRow( table, r ){
- var trs = table.getElementsByTagName( 'tr' );
+function removeAjaxGroupRow( table, r ){
+ var trs = getElementsByClassName( table, 'tr', 'configure-maintable-row' );
var tr = trs[r];
var tbody = table.getElementsByTagName( 'tbody' )[0];
tbody.removeChild( tr );
@@ -702,13 +704,13 @@
*
* @param Dom object representing a table
*/
-function fixAssocTable( table ){
+function fixAjaxGroupTable( table ){
var startName = 'wp' + table.id;
- var trs = table.getElementsByTagName( 'tr' );
+ var trs = getElementsByClassName( table, 'tr', 'configure-maintable-row' );
for( var r = 1; r < trs.length; r++ ){
var tr = trs[r];
var inputs = tr.getElementsByTagName( 'input' );
- inputs[inputs.length - 1].onclick = removeGroupBoolCallback( table, r );
+ inputs[inputs.length - 1].onclick = removeAjaxGroupCallback( table, r );
}
}
Index: trunk/extensions/Configure/Configure.settings-core.php
===================================================================
--- trunk/extensions/Configure/Configure.settings-core.php (revision 44446)
+++ trunk/extensions/Configure/Configure.settings-core.php (revision 44447)
@@ -754,7 +754,7 @@
# Interwiki
'wgImportSources' => 'simple',
# Access
- 'wgAutopromote' => 'array',
+ 'wgAutopromote' => 'promotion-conds',
'wgAddGroups' => 'group-array',
'wgDisabledActions' => 'simple',
'wgGroupPermissions' => 'group-bool',
Index: trunk/extensions/Configure/Configure.func.php
===================================================================
--- trunk/extensions/Configure/Configure.func.php (revision 44446)
+++ trunk/extensions/Configure/Configure.func.php (revision 44447)
@@ -11,33 +11,41 @@
*/
/**
- * Ajax function to create checkboxes for a new group in $wgGroupPermissions
+ * Ajax function to create row for a new group in $wgGroupPermissions or
+ * $wgAutopromote
*
+ * @param $setting String: setting name
* @param $group String: new group name
- * @return either <err#> if group already exist or html fragment
+ * @return either <err#> on error or html fragment
*/
-function efConfigureAjax( $group ) {
- global $wgUser, $wgGroupPermissions;
- if ( !$wgUser->isAllowed( 'configure-all' ) ) {
+function efConfigureAjax( $setting, $group ) {
+ global $wgUser;
+
+ $settings = ConfigurationSettings::singleton( CONF_SETTINGS_BOTH );
+ if ( $settings->getSettingType( $setting ) != 'array' )
return '<err#>';
- }
- if ( isset( $wgGroupPermissions[$group] ) ) {
- $html = '<err#>';
- } else {
- $all = User::getAllRights();
- $row = '<div style="-moz-column-count:2"><ul>';
- foreach ( $all as $right ) {
- $id = Sanitizer::escapeId( 'wpwgGroupPermissions-' . $group . '-' . $right );
- $desc = ( is_callable( array( 'User', 'getRightDescription' ) ) ) ?
- User::getRightDescription( $right ) : $right;
- $row .= '<li>' . Xml::checkLabel( $desc, $id, $id ) . "</li>\n";
- }
- $row .= '</ul></div>';
- $groupName = User::getGroupName( $group );
+ if ( in_array( $setting, $settings->getEditRestricted() ) && ( !$wgUser->isAllowed( 'configure-all' ) || !$wgUser->isAllowed( 'extensions-all' ) ) )
+ return '<err#>';
+
+ wfLoadExtensionMessages( 'Configure' );
+ $type = $settings->getArrayType( $setting );
+ switch( $type ) {
+ case 'group-bool':
+ if ( isset( $GLOBALS[$setting] ) && isset( $GLOBALS[$setting][$group] ) )
+ return '<err#>';
+
+ $row = ConfigurationPage::buildGroupSettingRow( $setting, $type, User::getAllRights(), true, $group, array() );
+
// Firefox seems to not like that :(
- $html = str_replace( ' ', ' ', $row );
+ return str_replace( ' ', ' ', $row );
+ case 'promotion-conds':
+ if ( isset( $GLOBALS[$setting] ) && isset( $GLOBALS[$setting][$group] ) )
+ return '<err#>';
+
+ return ConfigurationPage::buildPromotionCondsSettingRow( $setting, true, $group, array() );
+ default:
+ return '<err#>';
}
- return $html;
}
/**
@@ -54,7 +62,7 @@
global $wgConf, $wgConfigureFilesPath;
global $wgConfigureHandler;
- if (!$afterCache && $wgConfigureHandler == 'db') {
+ if ( !$afterCache && $wgConfigureHandler == 'db' ) {
// Defer to after caches are set up.
global $wgHooks;
$wgHooks['SetupAfterCache'][] = array( 'efConfigureSetupAfterCache', $wiki );
Index: trunk/extensions/Configure/Configure.css
===================================================================
--- trunk/extensions/Configure/Configure.css (revision 44446)
+++ trunk/extensions/Configure/Configure.css (revision 44447)
@@ -77,7 +77,8 @@
table.ns-array,
table.ns-text,
table.group-bool,
-table.group-array {
+table.group-array,
+table.promotion-conds {
border: 1px solid #777;
}
@@ -86,7 +87,8 @@
table.ns-array td,
table.ns-text td,
table.group-bool td,
-table.group-array td {
+table.group-array td,
+table.promotion-conds td {
padding: 6px;
margin: 0;
border-bottom: 1px solid #777;
@@ -97,7 +99,8 @@
table.ns-array td.button,
table.ns-text td.button,
table.group-bool td.button,
-table.group-array td.button {
+table.group-array td.button,
+table.promotion-conds td.button {
width: 10em;
}
@@ -106,7 +109,8 @@
table.ns-array th,
table.ns-text th,
table.group-bool th,
-table.group-array th {
+table.group-array th,
+table.promotion-conds th {
border-bottom: 1px solid #667;
background-color: #dde;
}
@@ -120,7 +124,8 @@
table.ns-array,
table.ns-text,
table.group-bool,
-table.group-array {
+table.group-array,
+table.promotion-conds {
border-spacing: 0;
width: 100%;
}