Synchronizes Yii users with phpBB3 forum
Yii 1.1 or above
Disable a profile activation in your forum.
Add redirects from a forum to the site in forum/ucp.php:
case 'register': header('location: /site/registration'); exit(); break; case 'login': header('location: /site/login'); exit(); break; case 'logout': header('location: /site/logout'); exit(); break;
Rename class user to bbuser in forum sources forum/includes/session.php:
class user extends session { // ... function user() // ... }
to
class bbuser extends session { // ... function bbuser() // ... }
Replace in forum/common.php
// Instantiate some basic classes $user = new user();
to
// Instantiate some basic classes $user = new bbuser();
Remove input fields 'ICQ', 'AVATAR', etc. from forum templates ucp_profile_profile_info.html and ucp_profile_avatar.html.
Note: If you don't want to modify your forum core files, you can move login/logout/register redirects to .htaccess. But if your application contains class User, you must use namespaces or must rename your own class.
Configure protected/config/main.php
return array( 'modules'=>array( // ... 'phpbb', } 'components'=>array( // ... 'db'=>array( 'connectionString' => '...', ), 'forumDb'=>array( 'class'=>'CDbConnection', 'connectionString' => '...', 'tablePrefix' => 'phpbb_', 'charset' => 'utf8', ), 'phpBB'=>array( 'class'=>'phpbb.extensions.phpBB.phpBB', 'path'=>'webroot.forum', ), // Synchronize Login/Logout. See PhpBBWebUser for inheritance details 'user'=>array( 'class'=>'phpbb.components.PhpBBWebUser', 'allowAutoLogin'=>true, 'loginUrl'=>array('/site/login'), ), 'image'=>array( 'class'=>'ext.image.CImageHandler', ), 'file'=>array( 'class'=>'ext.file.CFile', ), ), );
Attach behavior and relation to your User model:
class User extends CActiveRecord { public function behaviors() { return array( 'PhpBBUserBehavior'=>array( 'class'=>'phpbb.components.PhpBBUserBehavior', 'usernameAttribute'=>'username', 'newPasswordAttribute'=>'new_password', 'emailAttribute'=>'email', 'avatarAttribute'=>'avatar', 'avatarPath'=>'webroot.upload.images.avatars', 'forumDbConnection'=>'forumDb', 'syncAttributes'=>array( 'site'=>'user_website', 'icq'=>'user_icq', 'from'=>'user_from', 'occ'=>'user_occ', 'interests'=>'user_interests', ) ), ); } public function relations() { Yii::import('phpbb.models.*'); return array( 'phpBbUser'=>array(self::HAS_ONE, 'PhpBBUser', array('username'=>'username')), ); } }
Access to forum userdata:
$model = User::model()->findByPk(Yii::app()->user->id); Private messages: <a href="/forum/ucp.php?i=pm&folder=inbox">New <?php echo $model->phpBbUser->user_unread_privmsg; </a>
Access to forum friends:
foreach ($model->phpBbUser->friends as $friend) { echo $friend->user->name . ' ' . $friend->user->lastname . ' ' . $friend->age; }
Total 2 comments
You can move login/logout/register redirects to .htaccess. But if your application contains class
User, you must use namespaces or rename your own class. Fixed readme.Sounds great! But what is happening if a new phpBB version released? If I use the automatic updater won't it be a problem that I edited some phpBB core files?
Leave a comment
Please login to leave your comment.