Skip to content

Commit

Permalink
Beautify the code with CodeSniffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajquick committed Mar 25, 2018
1 parent dca83f8 commit e1c916d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 41 deletions.
29 changes: 29 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!--
~ __ ___ ____ _ ___ _ __
~ / |/ /_ __/ / /_(_)___/ (_)___ ___ ___ ____ _____(_)___ ____ ____ _/ /
~ / /|_/ / / / / / __/ / __ / / __ `__ \/ _ \/ __ \/ ___/ / __ \/ __ \ / __ `/ /
~ / / / / /_/ / / /_/ / /_/ / / / / / / / __/ / / (__ ) / /_/ / / / // /_/ / /
~ /_/ /_/\__,_/_/\__/_/\__,_/_/_/ /_/ /_/\___/_/ /_/____/_/\____/_/ /_(_)__,_/_/
~
~ phpBB Auth: MediaWiki Authentication Extension
~ Copyright (c) Multidimension.al (http://multidimension.al)
~ Github : https://github.com/multidimension-al/phpbbauth
~
~ Licensed under The MIT License
~ For full copyright and license information, please see the LICENSE file
~ Redistributions of files must retain the above copyright notice.
~
~ @copyright Copyright © 2018 Multidimension.al (http://multidimension.al)
~ @link https://github.com/multidimension-al/phpbbauth phpBB Auth Github
~ @license http://www.opensource.org/licenses/mit-license.php MIT License
-->

<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
<file>.</file>
<exclude-pattern>extensions/*</exclude-pattern>
<arg name="bootstrap" value="./vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/>
<arg name="extensions" value="php,php5,inc"/>
<arg name="encoding" value="UTF-8"/>
</ruleset>
54 changes: 29 additions & 25 deletions PhpbbAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,52 @@
* / / / / /_/ / / /_/ / /_/ / / / / / / / __/ / / (__ ) / /_/ / / / // /_/ / /
* /_/ /_/\__,_/_/\__/_/\__,_/_/_/ /_/ /_/\___/_/ /_/____/_/\____/_/ /_(_)__,_/_/
*
* phpBB Auth: MediaWiki Authentication Extension
* Copyright (c) Multidimension.al (http://multidimension.al)
* Github : https://github.com/multidimension-al/phpbbauth
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE file
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright © 2018 Multidimension.al (http://multidimension.al)
* @link https://github.com/multidimension-al/phpbbauth phpBB Auth Github
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

if (!isset($wgPhpbbAuthForumDirectory))
{
$wgPhpbbAuthForumDirectory = './../phpBB3/';
if ( !isset( $wgPhpbbAuthForumDirectory ) ) {
$wgPhpbbAuthForumDirectory = './../phpBB3/';
}

define('PHPBB_ROOT_PATH', $wgPhpbbAuthForumDirectory);
define('IN_PHPBB', true);
define( 'PHPBB_ROOT_PATH', $wgPhpbbAuthForumDirectory );
define( 'IN_PHPBB', true );

$phpbb_root_path = PHPBB_ROOT_PATH;
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
$phpEx = substr( strrchr( __FILE__, '.' ), 1 );
require $phpbb_root_path . 'common.' . $phpEx;

// Start session management
$user->session_begin();
$auth->acl($user->data);
$auth->acl( $user->data );
$user->setup();
$request->enable_super_globals();

if ($user->data['user_id'] != ANONYMOUS) {

$wgAuthRemoteuserUserName = ucfirst(strtolower($user->data['username']));
$wgAuthRemoteuserUserPrefs = array(
'realname' => $user->data['username'],
'language' => 'en',
'disablemail' => 0
);
$wgAuthRemoteuserUserPrefsForced = array(
'email' => $user->data['user_email']
);
$wgDefaultUserOptions['disablemail'] = 0;
$wgHiddenPrefs[] = 'disablemail';

$wgAuthRemoteuserUserUrls = array(
'logout' => $wgPhpbbAuthForumDirectory . 'ucp.php?mode=logout&sid=' . $user->session_id
);
if ( $user->data['user_id'] != ANONYMOUS ) {

$wgAuthRemoteuserUserName = ucfirst( strtolower( $user->data['username'] ) );
$wgAuthRemoteuserUserPrefs = [
'realname' => $user->data['username'],
'language' => 'en',
'disablemail' => 0
];
$wgAuthRemoteuserUserPrefsForced = [
'email' => $user->data['user_email']
];
$wgDefaultUserOptions['disablemail'] = 0;
$wgHiddenPrefs[] = 'disablemail';

$wgAuthRemoteuserUserUrls = [
'logout' => $wgPhpbbAuthForumDirectory . 'ucp.php?mode=logout&sid=' . $user->session_id
];

}
33 changes: 17 additions & 16 deletions PhpbbAuthHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,33 @@
* / / / / /_/ / / /_/ / /_/ / / / / / / / __/ / / (__ ) / /_/ / / / // /_/ / /
* /_/ /_/\__,_/_/\__/_/\__,_/_/_/ /_/ /_/\___/_/ /_/____/_/\____/_/ /_(_)__,_/_/
*
* phpBB Auth: MediaWiki Authentication Extension
* Copyright (c) Multidimension.al (http://multidimension.al)
* Github : https://github.com/multidimension-al/phpbbauth
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE file
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright © 2018 Multidimension.al (http://multidimension.al)
* @link https://github.com/multidimension-al/phpbbauth phpBB Auth Github
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

class PhpbbAuthHooks
{

public function onPersonalUrls(array &$personal_urls, Title $title, SkinTemplate $skin)
{

global $wgPhpBBAuthForumDirectory;
class PhpbbAuthHooks {

if (array_key_exists('login', $personal_urls)) {
$personal_urls['login']['href'] = $wgPhpBBAuthForumDirectory . 'ucp.php?mode=login';
}
public function onPersonalUrls( array &$personal_urls, Title $title, SkinTemplate $skin ) {
global $wgPhpBBAuthForumDirectory;

if (array_key_exists('anonlogin', $personal_urls)) {
$personal_urls['anonlogin']['href'] = $wgPhpBBAuthForumDirectory . 'ucp.php?mode=login';
}
if ( array_key_exists( 'login', $personal_urls ) ) {
$personal_urls['login']['href'] = $wgPhpBBAuthForumDirectory . 'ucp.php?mode=login';
}

return true;
if ( array_key_exists( 'anonlogin', $personal_urls ) ) {
$personal_urls['anonlogin']['href'] = $wgPhpBBAuthForumDirectory . 'ucp.php?mode=login';
}

}
return true;
}

}
}
9 changes: 9 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@
"php": ">=5.4.0",
"composer/installers": "~1.0.1",
"mediawiki/auth-remoteuser": ">=2.0.0"
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "*"
},
"scripts": {
"test": [
"phpcs -p -s"
],
"fix": "phpcbf"
}
}

0 comments on commit e1c916d

Please sign in to comment.