Package Data | |
---|---|
Maintainer Username: | przemekperon |
Maintainer Contact: | huan@huan.pl (Przemyslaw Peron) |
Package Create Date: | 2013-01-31 |
Package Last Update: | 2019-09-15 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:14:42 |
Package Statistics | |
---|---|
Total Downloads: | 126 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 9 |
Total Watchers: | 4 |
Total Forks: | 8 |
Total Open Issues: | 1 |
Authentication for VBulletin users in Laravel 4. Tested with VBulletin 4.x.
Add pperon/vbauth
as a requirement to composer.json:
{
"require": {
"pperon/vbauth": "1.*"
}
}
Update your packages with composer update
or install with composer install
.
Once Composer has installed or updated your packages you need to register Vbauth with Laravel itself. Open app/config/app.php and find the providers key towards the bottom and add:
'providers' => array(
...
...
'Pperon\Vbauth\VbauthServiceProvider',
),
In order to use shorter class alias add it to alias sections in app/config/app.php:
'aliases' => array(
...
...
'Vbauth' => 'Pperon\Vbauth\Facades\Vbauth',
),
Default configuration file is located in vendor/pperon/vbauth/src/config/config.php but you should overwrite it with app/config/packages/pperon/vbauth/config.php
file.
Example usage in a controller:
if(Vbauth::isAdmin()){
// Show administrator page
View::make('admin.index');
} elseif (Vbauth::isLoggedin()) {
// Show user page
View::make('user.index');
} else {
// Show guest page
View::make('guest.index');
}
###Vbulletin User Variables
You may access user information directly by calling Vbauth::get('fieldname'). Fields are defined in config.php (select_columns).
Example:
if(Vbauth::isLoggedin()) {
$user_id = Vbauth::get('userid');
$username = Vbauth::get('username');
$email = Vbauth::get('email');
}
###isLoggedIn()
Checks for VBulletin user cookie and returns:
TRUE - user is logged in, FALSE - there is no vbulletin cookie (user not logged in)
###isAdmin()
Checks whether the user belongs to Admin usergroup. Usually this means the user belongs to usergroup with id = 6 but you can modify this in config.php file by changing admin group ids.
TRUE - user belongs to admin usergroup FALSE - user doesn't belong to admin usergroup
###is()
Checks whether the user belongs to specific usergroup. Default available groups: admin, moderator, user, banned, guest
. You can add more in config.php.
TRUE - user belongs to specific group
Example:
if(Vbauth::is('moderator')) {
View::make('moderator.panel');
}
###logoutUrl()
Returns URL to logout script in Vbulletin installation.
Example:
Redirect::to(Vbauth::logoutURL());
###getUserInfo()
Returns user data for any choosen forum user
Example:
$user_id = 8;
$user = Vbauth::getUserInfo($user_id);
echo $user['email']; // displays email for user with user_id = 8
echo $user['username']; // show username
###v1.1.2
Added support for separate database connection (when vbulletin forum database is located in different database than laravel):
Set the connection in app/config/database.php and add the connection name to config/packages/pperon/vbauth/config.php:
'db_connection' => 'vbconn', // vbconn is the connection name in database.php
###v1.0.7
Added getUserInfo()
method which returns user information for any forum user
Example:
$user_id = 8;
$user = Vbauth::getUserInfo($user_id);
echo $user['email']; // displays email for user with user_id = 8