From eee9c290db512ef120de4dc70377c14d1e4f3b15 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 24 Apr 2008 11:36:47 +0000 Subject: [PATCH] Various final compatibility additions to work with global groups, which is ready for review --- docs/hooks.txt | 3 +++ includes/GlobalFunctions.php | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/docs/hooks.txt b/docs/hooks.txt index 06de42193e..46589c25db 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -612,6 +612,9 @@ $fileVersions: array of undeleted versions. Empty if all versions were restored $user: user who performed the undeletion $reason: reason +'GetAvailableRights': after calculating a list of all available rights +&$rights: Array of rights, which may be added to. + 'GetBlockedStatus': after loading blocking status of an user from the database $user: user (object) being checked diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4dcc087950..9983b2dacc 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2517,3 +2517,52 @@ function wfWaitForSlaves( $maxLag ) { return md5( mt_rand( 0, 0x7fffffff ) . $salt ); } + +/** + * Generate a list of all available rights. + * @todo Doesn't list any rights which aren't assigned to a group. + */ +function wfGetAvailableRights() { + global $wgGroupPermissions; + + $rights = array(); + + foreach( $wgGroupPermissions as $permissions ) { + $rights = array_merge( array_keys($permissions),$rights ); + } + + $rights = array_unique($rights); + + wfRunHooks( 'GetAvailableRights', array( &$rights ) ); + + return $rights; +} + +/** + * Generate a form (without the opening form element). + * Output DOES include a submit button. + * @param array $fields Associative array, key is message corresponding to a description for the field (colon is in the message), value is appropriate input. + * @param string $submitLable A message containing a label for the submit button. + * @return string HTML form. + */ +function wfBuildForm( $fields, $submitLabel ) { + $form = ''; + $form .= ""; + + foreach( $fields as $labelmsg => $input ) { + $id = "mw-gb-$labelmsg"; + $form .= Xml::openElement( 'tr', array( 'class' => $id ) ); + + $form .= Xml::element( 'td', array('valign' => 'top'), wfMsg( $labelmsg ) ); + + $form .= Xml::openElement( 'td' ) . $input . Xml::closeElement( 'td' ); + + $form .= Xml::closeElement( 'tr' ); + } + + $form .= "
"; + + $form .= wfSubmitButton( wfMsg($submitLabel) ); + + return $form; +} -- 2.20.1