Skip to content

Commit 5277060

Browse files
committed
update
1 parent 0e1f9c1 commit 5277060

File tree

10 files changed

+25
-21
lines changed

10 files changed

+25
-21
lines changed

Module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function init()
3939
parent::init();
4040

4141
if (null === $this->userIdentityClass) {
42-
$this->userIdentityClass = Yii::$app->getUser()->identityClass;
42+
$this->userIdentityClass = ($this->params['commentsIdentityClass']) ? $this->params['commentsIdentityClass'] : Yii::$app->getUser()->identityClass;
4343
}
4444
}
4545
}

behaviors/BlameableBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace yii2mod\comments\behaviors;
3+
namespace coderseden\cmt\behaviors;
44

55
use Yii;
66
use yii\db\BaseActiveRecord;

models/CommentModel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use paulzi\adjacencyList\AdjacencyListBehavior;
66
use Yii;
7-
use yii\behaviors\BlameableBehavior;
7+
use coderseden\cmt\behaviors\BlameableBehavior;
88
use yii\behaviors\TimestampBehavior;
99
use yii\db\ActiveQuery;
1010
use yii\db\ActiveRecord;
@@ -220,6 +220,10 @@ public function saveComment()
220220
*/
221221
public function getAuthor()
222222
{
223+
if (app()->getModule('comment')->params['commentsIdentityPrimaryId']) {
224+
return $this->hasOne($this->getModule()->userIdentityClass, [app()->getModule('comment')->params['commentsIdentityPrimaryId'] => 'createdBy']);
225+
}
226+
223227
return $this->hasOne($this->getModule()->userIdentityClass, ['id' => 'createdBy']);
224228
}
225229

tests/CommentTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
22

3-
namespace yii2mod\comments\tests;
3+
namespace coderseden\cmt\tests;
44

55
use Yii;
66
use yii\base\Event;
77
use yii\helpers\Json;
8-
use yii2mod\comments\models\CommentModel;
9-
use yii2mod\comments\tests\data\DefaultController;
10-
use yii2mod\comments\tests\data\PostModel;
11-
use yii2mod\comments\tests\data\User;
8+
use coderseden\cmt\models\CommentModel;
9+
use coderseden\cmt\tests\data\DefaultController;
10+
use coderseden\cmt\tests\data\PostModel;
11+
use coderseden\cmt\tests\data\User;
1212
use yii2mod\moderation\enums\Status;
1313

1414
/**
1515
* Class CommentTest
1616
*
17-
* @package yii2mod\comments\tests
17+
* @package coderseden\cmt\tests
1818
*/
1919
class CommentTest extends TestCase
2020
{

tests/TestCase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace yii2mod\comments\tests;
3+
namespace coderseden\cmt\tests;
44

55
use Yii;
66
use yii\helpers\ArrayHelper;
@@ -49,7 +49,7 @@ protected function mockApplication($config = [], $appClass = '\yii\web\Applicati
4949
'scriptUrl' => 'index.php',
5050
],
5151
'user' => [
52-
'identityClass' => 'yii2mod\comments\tests\data\User',
52+
'identityClass' => 'coderseden\cmt\tests\data\User',
5353
],
5454
'i18n' => [
5555
'translations' => [
@@ -62,9 +62,9 @@ protected function mockApplication($config = [], $appClass = '\yii\web\Applicati
6262
],
6363
'modules' => [
6464
'comment' => [
65-
'class' => 'yii2mod\comments\Module',
65+
'class' => 'coderseden\cmt\Module',
6666
'userIdentityClass' => '',
67-
'controllerNamespace' => 'yii2mod\comments\tests\data',
67+
'controllerNamespace' => 'coderseden\cmt\tests\data',
6868
],
6969
],
7070
], $config));

tests/data/DefaultController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace yii2mod\comments\tests\data;
3+
namespace coderseden\cmt\tests\data;
44

55
/**
66
* Class DefaultController
77
*
8-
* @package yii2mod\comments\tests\data
8+
* @package coderseden\cmt\tests\data
99
*/
10-
class DefaultController extends \yii2mod\comments\controllers\DefaultController
10+
class DefaultController extends \coderseden\cmt\controllers\DefaultController
1111
{
1212
public function behaviors()
1313
{

tests/data/PostModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace yii2mod\comments\tests\data;
3+
namespace coderseden\cmt\tests\data;
44

55
use yii\db\ActiveRecord;
66

77
/**
88
* Class PostModel
99
*
10-
* @package yii2mod\comments\tests\data
10+
* @package coderseden\cmt\tests\data
1111
*/
1212
class PostModel extends ActiveRecord
1313
{

tests/data/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace yii2mod\comments\tests\data;
3+
namespace coderseden\cmt\tests\data;
44

55
use yii\db\ActiveRecord;
66
use yii\web\IdentityInterface;

widgets/views/_list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<?php if (Yii::$app->getUser()->can('admin')) : ?>
1919
<?php echo Html::a('<span class="glyphicon glyphicon-trash"></span> ' . Yii::t('yii2mod.comments', 'Delete'), '#', ['class' => 'delete-comment-btn', 'data' => ['action' => 'delete', 'url' => Url::to(['/comment/default/delete', 'id' => $model->id]), 'comment-id' => $model->id]]); ?>
2020
<?php endif; ?>
21-
<?php if (!Yii::$app->user->isGuest && ($model->level < $maxLevel || is_null($maxLevel))) : ?>
21+
<?php if (!Yii::$app->customer->isGuest && ($model->level < $maxLevel || is_null($maxLevel))) : ?>
2222
<?php echo Html::a("<span class='glyphicon glyphicon-share-alt'></span> " . Yii::t('yii2mod.comments', 'Reply'), '#', ['class' => 'reply-comment-btn', 'data' => ['action' => 'reply', 'comment-id' => $model->id]]); ?>
2323
<?php endif; ?>
2424
</div>

widgets/views/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
],
4343
$listViewConfig
4444
)); ?>
45-
<?php if (!Yii::$app->user->isGuest) : ?>
45+
<?php if (!Yii::$app->customer->isGuest) : ?>
4646
<?php echo $this->render('_form', [
4747
'commentModel' => $commentModel,
4848
'formId' => $formId,

0 commit comments

Comments
 (0)