Merge "Error Msg for missing db username & password when installing"
[lhc/web/wiklou.git] / includes / specials / SpecialUserrights.php
index a6b3602..f8e5c84 100644 (file)
@@ -55,6 +55,7 @@ class UserrightsPage extends SpecialPage {
                if ( $user->getId() == 0 ) {
                        return false;
                }
+
                return !empty( $available['add'] )
                        || !empty( $available['remove'] )
                        || ( ( $this->isself || !$checkIfSelf ) &&
@@ -118,6 +119,7 @@ class UserrightsPage extends SpecialPage {
                                $out = $this->getOutput();
                                $out->wrapWikiMsg( "<div class=\"successbox\">\n$1\n</div>", 'userrights-removed-self' );
                                $out->returnToMain();
+
                                return;
                        }
 
@@ -148,6 +150,7 @@ class UserrightsPage extends SpecialPage {
                        $status = $this->fetchUser( $this->mTarget );
                        if ( !$status->isOK() ) {
                                $this->getOutput()->addWikiText( $status->getWikiText() );
+
                                return;
                        }
 
@@ -156,8 +159,9 @@ class UserrightsPage extends SpecialPage {
                                $targetUser->clearInstanceCache(); // bug 38989
                        }
 
-
-                       if ( $request->getVal( 'conflictcheck-originalgroups' ) !== implode( ',', $targetUser->getGroups() ) ) {
+                       if ( $request->getVal( 'conflictcheck-originalgroups' )
+                               !== implode( ',', $targetUser->getGroups() )
+                       ) {
                                $out->addWikiMsg( 'userrights-conflict' );
                        } else {
                                $this->saveUserGroups(
@@ -167,6 +171,7 @@ class UserrightsPage extends SpecialPage {
                                );
 
                                $out->redirect( $this->getSuccessURL() );
+
                                return;
                        }
                }
@@ -260,13 +265,14 @@ class UserrightsPage extends SpecialPage {
                // update groups in external authentication database
                $wgAuth->updateExternalDBGroups( $user, $add, $remove );
 
-               wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) );
-               wfDebug( 'newGroups: ' . print_r( $newGroups, true ) );
+               wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
+               wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
                wfRunHooks( 'UserRights', array( &$user, $add, $remove ) );
 
                if ( $newGroups != $oldGroups ) {
                        $this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
                }
+
                return array( $add, $remove );
        }
 
@@ -294,6 +300,7 @@ class UserrightsPage extends SpecialPage {
                $status = $this->fetchUser( $username );
                if ( !$status->isOK() ) {
                        $this->getOutput()->addWikiText( $status->getWikiText() );
+
                        return;
                } else {
                        $user = $status->value;
@@ -408,10 +415,25 @@ class UserrightsPage extends SpecialPage {
        function switchForm() {
                global $wgScript;
                $this->getOutput()->addHTML(
-                       Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1' ) ) .
+                       Html::openElement(
+                               'form',
+                               array(
+                                       'method' => 'get',
+                                       'action' => $wgScript,
+                                       'name' => 'uluser',
+                                       'id' => 'mw-userrights-form1'
+                               )
+                       ) .
                        Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
                        Xml::fieldset( $this->msg( 'userrights-lookup-user' )->text() ) .
-                       Xml::inputLabel( $this->msg( 'userrights-user-editname' )->text(), 'user', 'username', 30, str_replace( '_', ' ', $this->mTarget ), array( 'autofocus' => true ) ) . ' ' .
+                       Xml::inputLabel(
+                               $this->msg( 'userrights-user-editname' )->text(),
+                               'user',
+                               'username',
+                               30,
+                               str_replace( '_', ' ', $this->mTarget ),
+                               array( 'autofocus' => true )
+                       ) . ' ' .
                        Xml::submitButton( $this->msg( 'editusergroup' )->text() ) .
                        Html::closeElement( 'fieldset' ) .
                        Html::closeElement( 'form' ) . "\n"
@@ -480,27 +502,45 @@ class UserrightsPage extends SpecialPage {
                        $grouplist = $this->msg( 'userrights-groupsmember', $count, $user->getName() )->parse();
                        $grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
                }
+
                $count = count( $autoList );
                if ( $count > 0 ) {
-                       $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto', $count, $user->getName() )->parse();
+                       $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto', $count, $user->getName() )
+                               ->parse();
                        $grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
                }
 
                $userToolLinks = Linker::userToolLinks(
-                               $user->getId(),
-                               $user->getName(),
-                               false, /* default for redContribsWhenNoEdits */
-                               Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
+                       $user->getId(),
+                       $user->getName(),
+                       false, /* default for redContribsWhenNoEdits */
+                       Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
                );
 
                $this->getOutput()->addHTML(
-                       Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getPageTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2' ) ) .
+                       Xml::openElement(
+                               'form',
+                               array(
+                                       'method' => 'post',
+                                       'action' => $this->getPageTitle()->getLocalURL(),
+                                       'name' => 'editGroup',
+                                       'id' => 'mw-userrights-form2'
+                               )
+                       ) .
                        Html::hidden( 'user', $this->mTarget ) .
                        Html::hidden( 'wpEditToken', $this->getUser()->getEditToken( $this->mTarget ) ) .
-                       Html::hidden( 'conflictcheck-originalgroups', implode( ',', $user->getGroups() ) ) . // Conflict detection
+                       Html::hidden(
+                               'conflictcheck-originalgroups',
+                               implode( ',', $user->getGroups() )
+                       ) . // Conflict detection
                        Xml::openElement( 'fieldset' ) .
-                       Xml::element( 'legend', array(), $this->msg( 'userrights-editusergroup', $user->getName() )->text() ) .
-                       $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )->rawParams( $userToolLinks )->parse() .
+                       Xml::element(
+                               'legend',
+                               array(),
+                               $this->msg( 'userrights-editusergroup', $user->getName() )->text()
+                       ) .
+                       $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )
+                               ->rawParams( $userToolLinks )->parse() .
                        $this->msg( 'userrights-groups-help', $user->getName() )->parse() .
                        $grouplist .
                        Xml::tags( 'p', null, $this->groupCheckboxes( $groups, $user ) ) .
@@ -518,7 +558,9 @@ class UserrightsPage extends SpecialPage {
                                        <td></td>
                                        <td class='mw-submit'>" .
                                                Xml::submitButton( $this->msg( 'saveusergroups' )->text(),
-                                                       array( 'name' => 'saveusergroups' ) + Linker::tooltipAndAccesskeyAttribs( 'userrights-set' ) ) .
+                                                       array( 'name' => 'saveusergroups' ) +
+                                                               Linker::tooltipAndAccesskeyAttribs( 'userrights-set' )
+                                               ) .
                                        "</td>
                                </tr>" .
                        Xml::closeElement( 'table' ) . "\n" .
@@ -603,8 +645,13 @@ class UserrightsPage extends SpecialPage {
                                continue;
                        }
                        // Messages: userrights-changeable-col, userrights-unchangeable-col
-                       $ret .= Xml::element( 'th', null, $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text() );
+                       $ret .= Xml::element(
+                               'th',
+                               null,
+                               $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text()
+                       );
                }
+
                $ret .= "</tr>\n<tr>\n";
                foreach ( $columns as $column ) {
                        if ( $column === array() ) {
@@ -635,13 +682,17 @@ class UserrightsPage extends SpecialPage {
        }
 
        /**
-        * @param  $group String: the name of the group to check
+        * @param $group String: the name of the group to check
         * @return bool Can we remove the group?
         */
        private function canRemove( $group ) {
                // $this->changeableGroups()['remove'] doesn't work, of course. Thanks, PHP.
                $groups = $this->changeableGroups();
-               return in_array( $group, $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] ) );
+
+               return in_array(
+                       $group,
+                       $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] )
+               );
        }
 
        /**
@@ -650,13 +701,22 @@ class UserrightsPage extends SpecialPage {
         */
        private function canAdd( $group ) {
                $groups = $this->changeableGroups();
-               return in_array( $group, $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] ) );
+
+               return in_array(
+                       $group,
+                       $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] )
+               );
        }
 
        /**
         * Returns $this->getUser()->changeableGroups()
         *
-        * @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ), 'add-self' => array( addablegroups to self ), 'remove-self' => array( removable groups from self ) )
+        * @return array array(
+        *   'add' => array( addablegroups ),
+        *   'remove' => array( removablegroups ),
+        *   'add-self' => array( addablegroups to self ),
+        *   'remove-self' => array( removable groups from self )
+        *  )
         */
        function changeableGroups() {
                return $this->getUser()->changeableGroups();