yii2-integration-phpBB3.1
This extension is intended to integrate the phpBB 3.1.x with the Yii2. Extension is intended for synchronization of a login, registration and editing of profile data, such as an e-mail address and password. An extension yii2-users-module was used as a users model, but you can connect and configure the behavior of your model., (*1)
Version: 0.3.7, (*2)
Authors: yiiframework.ru, Felix Manea, Äìèòðèé Åëèñååâ, Mefistophell Nill, (*3)
The preferred way to install this extension is through composer., (*4)
Either run, (*5)
php composer.phar require nill/forum "dev-master"
or add, (*6)
"nill/forum": "dev-master"
to the require section of your composer.json
file., (*7)
/vendor/nill/forum/
Github: yii2-integration-phpBB3.1, (*8)
Download and unpack files into created directory, (*9)
Add to extensions /vendor/yiisoft/extensions.php
:, (*10)
'nill/forum' => array ( 'name' => 'nill/forum', 'version' => '0.1.0.0', 'alias' => array ( '@nill/forum' => $vendorDir . '/nill/forum', ), ),
/common/config/main.php
'phpBB' => [ 'class' => 'nill\forum\phpBB', 'path' => dirname(dirname(__DIR__)). '\forum', ],
request
and change the user
in configuration of components:'user' => [ 'class' => 'nill\forum\PhpBBWebUser', 'loginUrl'=>['/login'], 'identityClass' => 'vova07\users\models\frontend\User', // enable cookie-based authentication // 'allowAutoLogin' => true, ], 'request' => [ 'baseUrl' => $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'] != $_SERVER['SCRIPT_FILENAME'] ? 'http://' . $_SERVER['HTTP_HOST'] : '', ],
get_container_filename()
into \forum\phpbb\di\container_builder.php
protected function get_container_filename() { // Change the line to synchronize with the site // $filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path); $filename = str_replace(array('\\', '/', '.'), array('slash', 'slash', 'dot'), $this->phpbb_root_path); return $this->phpbb_root_path . 'cache/container_' . $filename . '.' . $this->php_ext; }
frm_config
database field cookie_domain
to your domain:
example - domain.loc
CAUTION: This option also is in a cache file, clear your cache if will not work., (*11)
use nill\forum\behaviors\PhpBBUserBahavior;
, (*12)
and, (*13)
/** * The variables required for integration with the forum * @var string $password_reg - old password * @var string $password_new - new password */ public $password_reg; public $password_new;
getId
/** * Behavior PhpBBUserBahavior necessary for integration with the forum */ public function behaviors() { return [ 'PhpBBUserBahavior' => [ 'class' => PhpBBUserBahavior::className(), 'userAttr' => 'username', 'newpassAttr' => 'password_new', 'passAttr' => 'password', 'emailAttr' => 'email', ], ]; }
If you use yii2-start-users then do following instructions, (*14)
public function validatePassword($password) { $this->password_reg = $password; return Yii::$app->security->validatePassword($password, $this->password_hash); }
and, (*15)
public function password($password) { $this->password_new = $password; $this->setPassword($password); return $this->save(false); }
\vendor\vova07\users\models\frontend\PasswordForm.php
\vendor\vova07\users\models\frontend\Email.php
this string, (*16)
use vova07\users\models\User;
1. Create into the folder \forum
the file yiiapp.php
, (*17)
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../common/config/aliases.php'); $config = yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../common/config/main.php'), require(__DIR__ . '/../common/config/main-local.php'), require(__DIR__ . '/../frontend/config/main.php'), require(__DIR__ . '/../frontend/config/main-local.php') ); if ('YII_ENV_DEV') { $config['components']['assetManager']['basePath'] = '@app/web/assets'; } \Yii::setAlias('@app', '/../'); $application = new yii\web\Application($config);
2. Create into the folder \frontend\views\layouts\
the file forum.php
. This template forum., (*18)
<?= $content ?>
**3. Add to top of the file \forum\index.php
the following code:, (*19)
//************************ FORUM Yii ********************************** include "yiiapp.php"; $controller = new yii\web\Controller('7','forum'); \Yii::$app->controller = $controller; ob_start(); //************************ ********* **********************************
This code should be used to the all general pages of the forum, such as: viewforum.php, viewtopic.php..., (*20)
4. Add to the file \forum\includes\functions.php
the following code into the end of page_footer() function: (row:5310), (*21)
garbage_collection(); //************************ FORUM Yii ********************************** if (class_exists('Yii', false) && \Yii::$app->controller !== null) { $content = ob_get_clean(); echo \Yii::$app->controller->render('//layouts/forum', ['content' => $content]); } //************************ ********** ********************************** if ($exit_handler) { exit_handler(); }
If will not work then:, (*22)
In the file forum\phpbb\request\request.php
chang the following string:, (*23)
protected $super_globals_disabled = false;
on protected $super_globals_disabled = true;
(row:44), (*24)
Synchronization is necessary for a relation between the users of the site and the forum., (*25)
use nill\forum\models\phpBBUsers; public function getPhpbbuser() { return $this->hasOne(phpBBUsers::className(), ['username' => 'username']); }
Exemple view:, (*26)
<?php $models = User::findOne(Yii::$app->user->id); ?> Your Messages <a href="/forum/ucp.php?i=pm&folder=inbox">New: <?php if($models) echo $models->phpbbuser->user_unread_privmsg; ?></a>