Various final compatibility additions to work with global groups, which is ready...
authorAndrew Garrett <werdna@users.mediawiki.org>
Thu, 24 Apr 2008 11:36:47 +0000 (11:36 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Thu, 24 Apr 2008 11:36:47 +0000 (11:36 +0000)
docs/hooks.txt
includes/GlobalFunctions.php

index 06de421..46589c2 100644 (file)
@@ -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
 
index 4dcc087..9983b2d 100644 (file)
@@ -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 .= "<table><tbody>";
+
+       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 .= "</tbody></table>";
+
+       $form .= wfSubmitButton( wfMsg($submitLabel) );
+
+       return $form;
+}