8000 GitHub - jbellomy/yii2-comments: Yii 2 comments extension
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jbellomy/yii2-comments

 
 

Repository files navigation

Yii 2 Comments Module

License Latest Stable Version Latest Unstable Version Total Downloads

Code Status

Scrutinizer Code Quality Code Coverage Travis CI Build Status Dependency Status

Installation

Add in composer.json:

{
    "require": {
        "rmrevin/yii2-comments": "1.0.6"
    }
}

In config /protected/config/main.php

<?
return [
	// ...
	'modules' => [
		// ...
		'comments' => 'rmrevin\yii\module\Comments\Module',
	],
	// ...
];

In auth manager add rules:

use \yii\rbac\Role;
use \rmrevin\yii\module\Comments\Permission;
use \rmrevin\yii\module\Comments\rbac\ItsMyComment;

$AuthManager = \Yii::$app->getAuthManager();
$ItsMyCommentRule = new \rmrevin\yii\module\Comments\rbac\ItsMyComment();

$AuthManager->add($ItsMyCommentRule);

$AuthManager->add(new \yii\rbac\Role([
    'name' => Permission::CREATE,
    'description' => 'Can create own comments',
]));
$AuthManager->add(new \yii\rbac\Role([
    'name' => Permission::UPDATE,
    'description' => 'Can update all comments',
]));
$AuthManager->add(new \yii\rbac\Role([
    'name' => Permission::UPDATE_OWN,
    'ruleName' => $ItsMyCommentRule->name,
    'description' => 'Can update own comments',
]));
$AuthManager->add(new \yii\rbac\Role([
    'name' => Permission::DELETE,
    'description' => 'Can delete all comments',
]));
$AuthManager->add(new \yii\rbac\Role([
    'name' => Permission::DELETE_OWN,
    'ruleName' => $ItsMyCommentRule->name,
    'description' => 'Can delete own comments',
]));

Usage

In view

<?
// ...

echo \rmrevin\yii\module\Comments\widgets\CommentListWidget::widget([
    'entity' => (string) 'photo-15', // type and id
]);

About

Yii 2 comments extension

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 91.3%
  • JavaScript 5.0%
  • CSS 3.7%
0