-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit de917f3
Showing
25 changed files
with
1,680 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.idea | ||
/vendor | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
build: | ||
environment: | ||
php: | ||
version: 5.5.12 | ||
dependencies: | ||
before: | ||
- sudo composer self-update && composer --version | ||
- composer global require "fxp/composer-asset-plugin:1.0.0-beta4" | ||
tests: | ||
override: | ||
- phpunit | ||
imports: | ||
- php | ||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
tools: | ||
php_sim: false | ||
php_cpd: false | ||
php_pdepend: true | ||
php_analyzer: true | ||
php_changetracking: true | ||
external_code_coverage: | ||
timeout: 2100 # Timeout in seconds. | ||
filter: | ||
excluded_paths: | ||
- tests/* | ||
- vendor/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
- hhvm-nightly | ||
|
||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- php: hhvm | ||
- php: hhvm-nightly | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- vendor | ||
|
||
install: | ||
- travis_retry composer self-update && composer --version | ||
- travis_retry composer global require "fxp/composer-asset-plugin:1.0.0-beta4" | ||
- export PATH="$HOME/.composer/vendor/bin:$PATH" | ||
- travis_retry composer install --prefer-dist --no-interaction | ||
|
||
script: | ||
- phpunit --verbose --coverage-clover=coverage/coverage.clover | ||
|
||
after_script: | ||
- travis_retry wget https://scrutinizer-ci.com/ocular.phar | ||
- php ocular.phar code-coverage:upload --format=php-clover coverage/coverage.clover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Revin Roman Borisovich | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Module.php | ||
* @author Revin Roman http://phptime.ru | ||
*/ | ||
|
||
namespace rmrevin\yii\module\Comments; | ||
|
||
/** | ||
* Class Module | ||
* @package rmrevin\yii\module\Comments | ||
*/ | ||
class Module extends \yii\base\Module | ||
{ | ||
|
||
/** @var string|null */ | ||
public $userIdentityClass = null; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
$AuthManager = \Yii::$app->getAuthManager(); | ||
$ItsMyCommentRule = new \rmrevin\yii\module\Comments\rbac\ItsMyComment(); | ||
|
||
$AuthManager->add($ItsMyCommentRule); | ||
|
||
$AuthManager->add(new \yii\rbac\Role(['name' => Permission::CREATE])); | ||
$AuthManager->add(new \yii\rbac\Role(['name' => Permission::UPDATE])); | ||
$AuthManager->add(new \yii\rbac\Role(['name' => Permission::UPDATE_OWN, 'ruleName' => $ItsMyCommentRule->name])); | ||
$AuthManager->add(new \yii\rbac\Role(['name' => Permission::DELETE])); | ||
$AuthManager->add(new \yii\rbac\Role(['name' => Permission::DELETE_OWN, 'ruleName' => $ItsMyCommentRule->name])); | ||
|
||
if ($this->userIdentityClass === null) { | ||
$this->userIdentityClass = \Yii::$app->getUser()->identityClass; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Permission.php | ||
* @author Revin Roman http://phptime.ru | ||
*/ | ||
|
||
namespace rmrevin\yii\module\Comments; | ||
|
||
/** | ||
* Class Permission | ||
* @package rmrevin\yii\module\Comments | ||
*/ | ||
class Permission | ||
{ | ||
|
||
const CREATE = 'comments.create'; | ||
const UPDATE = 'comments.update'; | ||
const UPDATE_OWN = 'comments.update.own'; | ||
const DELETE = 'comments.delete'; | ||
const DELETE_OWN = 'comments.delete.own'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Yii 2 Comments Module | ||
=============================== | ||
[![License](https://poser.pugx.org/rmrevin/yii2-comments/license.svg)](https://packagist.org/packages/rmrevin/yii2-comments) | ||
[![Latest Stable Version](https://poser.pugx.org/rmrevin/yii2-comments/v/stable.svg)](https://packagist.org/packages/rmrevin/yii2-comments) | ||
[![Latest Unstable Version](https://poser.pugx.org/rmrevin/yii2-comments/v/unstable.svg)](https://packagist.org/packages/rmrevin/yii2-comments) | ||
[![Total Downloads](https://poser.pugx.org/rmrevin/yii2-comments/downloads.svg)](https://packagist.org/packages/rmrevin/yii2-comments) | ||
|
||
Code Status | ||
----------- | ||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/rmrevin/yii2-comments/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/rmrevin/yii2-comments/?branch=master) | ||
[![Code Coverage](https://scrutinizer-ci.com/g/rmrevin/yii2-comments/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/rmrevin/yii2-comments/?branch=master) | ||
[![Travis CI Build Status](https://travis-ci.org/rmrevin/yii2-comments.svg)](https://travis-ci.org/rmrevin/yii2-comments) | ||
[![Dependency Status](https://www.versioneye.com/user/projects/54119b799e16229fe00000da/badge.svg)](https://www.versioneye.com/user/projects/54119b799e16229fe00000da) | ||
|
||
Installation | ||
------------ | ||
Add in `composer.json`: | ||
``` | ||
{ | ||
"require": { | ||
"rmrevin/yii2-comments": "*" | ||
} | ||
} | ||
``` | ||
|
||
In config `/protected/config/main.php` | ||
```php | ||
<? | ||
return [ | ||
// ... | ||
'modules' => [ | ||
// ... | ||
'comments' => 'rmrevin\yii\module\Comments\Module', | ||
], | ||
// ... | ||
]; | ||
``` | ||
|
||
In auth manager add rules: | ||
```php | ||
use \yii\rbac\Role; | ||
use \rmrevin\yii\module\Comments\Permission; | ||
use \rmrevin\yii\module\Comments\rbac\ItsMyComment; | ||
|
||
$AuthManager = \Yii::$app->getAuthManager(); | ||
$ItsMyCommentRule = new ItsMyComment(); | ||
|
||
// Rules | ||
$AuthManager->add($ItsMyCommentRule); | ||
|
||
// Permissions | ||
$AuthManager->add(new Role(['name' => Permission::CREATE])); | ||
$AuthManager->add(new Role(['name' => Permission::UPDATE])); | ||
$AuthManager->add(new Role(['name' => Permission::UPDATE_OWN, 'ruleName' => $ItsMyCommentRule->name])); | ||
$AuthManager->add(new Role(['name' => Permission::DELETE])); | ||
$AuthManager->add(new Role(['name' => Permission::DELETE_OWN, 'ruleName' => $ItsMyCommentRule->name])); | ||
``` | ||
|
||
Usage | ||
----- | ||
In view | ||
```php | ||
<? | ||
// ... | ||
|
||
echo \rmrevin\yii\module\Comments\widgets\CommentListWidget::widget([ | ||
'entity' => (string) 'photo-15', // type and id | ||
]); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "rmrevin/yii2-comments", | ||
"description": "Comments module for Yii2", | ||
"keywords": [ | ||
"yii", | ||
"comment", | ||
"widget", | ||
"module" | ||
], | ||
"type": "yii2-extension", | ||
"license": "MIT", | ||
"minimum-stability": "stable", | ||
"support": { | ||
"issues": "https://github.com/rmrevin/yii2-comments/issues", | ||
"source": "https://github.com/rmrevin/yii2-comments" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Roman Revin", | ||
"email": "[email protected]", | ||
"homepage": "http://rmrevin.ru/" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4.0", | ||
|
||
"yiisoft/yii2": "2.0.1", | ||
"rmrevin/yii2-fontawesome": "2.6.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"rmrevin\\yii\\module\\Comments\\": "" | ||
} | ||
} | ||
} |
Oops, something went wrong.