Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#184 Fixed SQLite Migrations Issue #185

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
User management module for Yii 2
=====

This is a fork of [webvimark/user-management-module](https://github.com/webvimark/user-management) to further development for using SQLite
and NoSQL databases.

In addition, this extension is to be extended to use Bootstrap 4 Styles by given module setting.

[![Latest Stable Version](https://poser.pugx.org/wpler/module-user-management/v/stable)](https://packagist.org/packages/wpler/module-user-management)
[![Latest Unstable Version](https://poser.pugx.org/wpler/module-user-management/v/unstable)](https://packagist.org/packages/wpler/module-user-management)
[![Total Downloads](https://poser.pugx.org/wpler/module-user-management/downloads)](https://packagist.org/packages/wpler/module-user-management)


Perks
---

Expand All @@ -20,13 +30,13 @@ The preferred way to install this extension is through [composer](http://getcomp
Either run

```
composer require webvimark/module-user-management
composer require wpler/module-user-management
```

or add

```
"webvimark/module-user-management": "^1"
"wpler/module-user-management": "~1"
```

to the require section of your `composer.json` file.
Expand All @@ -40,18 +50,18 @@ Configuration

'components'=>[
'user' => [
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
'class' => 'wpler\modules\UserManagement\components\UserConfig',

// Comment this if you don't want to record user logins
'on afterLogin' => function($event) {
\webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
\wpler\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
}
],
],

'modules'=>[
'user-management' => [
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
'class' => 'wpler\modules\UserManagement\UserManagementModule',

// 'enableRegistration' => true,

Expand Down Expand Up @@ -96,8 +106,8 @@ To see full list of options check *UserManagementModule* file

'modules'=>[
'user-management' => [
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
'controllerNamespace'=>'vendor\webvimark\modules\UserManagement\controllers', // To prevent yii help from crashing
'class' => 'wpler\modules\UserManagement\UserManagementModule',
'controllerNamespace'=>'vendor\wpler\modules\UserManagement\controllers', // To prevent yii help from crashing
],
],

Expand All @@ -107,7 +117,7 @@ To see full list of options check *UserManagementModule* file

```php

./yii migrate --migrationPath=vendor/webvimark/module-user-management/migrations/
./yii migrate --migrationPath=vendor/wpler/module-user-management/migrations/

```

Expand All @@ -119,7 +129,7 @@ public function behaviors()
{
return [
'ghost-access'=> [
'class' => 'webvimark\modules\UserManagement\components\GhostAccessControl',
'class' => 'wpler\modules\UserManagement\components\GhostAccessControl',
],
];
}
Expand All @@ -132,8 +142,8 @@ Where you can go
```php

<?php
use webvimark\modules\UserManagement\components\GhostMenu;
use webvimark\modules\UserManagement\UserManagementModule;
use wpler\modules\UserManagement\components\GhostMenu;
use wpler\modules\UserManagement\UserManagementModule;

echo GhostMenu::widget([
'encodeLabels'=>false,
Expand Down Expand Up @@ -231,7 +241,7 @@ Events can be handled via config file like following

'modules'=>[
'user-management' => [
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
'class' => 'wpler\modules\UserManagement\UserManagementModule',
'on afterRegistration' => function(UserAuthEvent $event) {
// Here you can do your own stuff like assign roles, send emails and so on
},
Expand All @@ -247,21 +257,21 @@ FAQ

**Question**: Do you have API docs?

**Answer**: Check this one http://opensource.id5.com.br/webvimark/doc/index.html (Credits to [lukBarros](https://github.com/lukBarros))
**Answer**: Check this one on webvimark original module http://opensource.id5.com.br/webvimark/doc/index.html (Credits to [lukBarros](https://github.com/lukBarros))

**Question**: I want users to register and login with they e-mails! Mmmmm... And they should confirm it too!

**Answer**: See configuration properties *$useEmailAsLogin* and *$emailConfirmationRequired*

**Question**: I want to have profile for user with avatar, birthday and stuff. What should I do ?

**Answer**: Profiles are to project-specific, so you'll have to implement them yourself (but you can find example here - https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration). Here is how to do it without modifying this module
**Answer**: Profiles are to project-specific, so you'll have to implement them yourself (but you can find example here on webvimark original module - https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration). Here is how to do it without modifying this module

1) Create table and model for profile, that have user_id (connect with "user" table)

2) Check AuthController::actionRegistration() how it works (*you can skip this part*)

3) Define your layout for registration. Check example in *AuthHelper::layoutHandler()*. Now use theming to change registraion.php file
3) Define your layout for registration. Check example in *AuthHelper::layoutHandler()*. Now use theming to change registration.php file

4) Define your own UserManagementModule::$registrationFormClass. In this class you can do whatever you want like validating custom forms and saving profiles

Expand Down
30 changes: 26 additions & 4 deletions UserManagementModule.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<?php

namespace webvimark\modules\UserManagement;
namespace wpler\modules\UserManagement;

use wpler\modules\UserManagement\models\User;
use Yii;
use yii\helpers\ArrayHelper;

/**
* Class UserManagementModule
*
* @package wpler\modules\UserManagement
*/

class UserManagementModule extends \yii\base\Module
{
const SESSION_LAST_ATTEMPT = '_um_last_attempt';
Expand Down Expand Up @@ -68,7 +75,7 @@ class UserManagementModule extends \yii\base\Module
*
* @var string
*/
public $registrationFormClass = 'webvimark\modules\UserManagement\models\forms\RegistrationForm';
public $registrationFormClass = 'wpler\modules\UserManagement\models\forms\RegistrationForm';

/**
* After how many seconds confirmation token will be invalid
Expand Down Expand Up @@ -183,7 +190,7 @@ class UserManagementModule extends \yii\base\Module
public $auth_assignment_table = '{{%auth_assignment}}';
public $auth_rule_table = '{{%auth_rule}}';

public $controllerNamespace = 'webvimark\modules\UserManagement\controllers';
public $controllerNamespace = 'wpler\modules\UserManagement\controllers';

/**
* @p
Expand All @@ -202,13 +209,28 @@ public function init()
*/
public static function menuItems()
{
$menuItems=[];
if (User::hasPermission('viewUsers')) {
$menuItems[]=['label'=>'<i class="glyphicon glyphicon-circle-arrow-right"></i> '.UserManagementModule::t('back','Users'),'url'=>['/user-management/user/index']];
}
if (User::hasPermission('viewUserRoles')) {
$menuItems[]=['label'=>'<i class="glyphicon glyphicon-circle-arrow-right"></i> '.UserManagementModule::t('back','Roles'),'url'=>['/user-management/role/index']];
$menuItems[]=['label'=>'<i class="glyphicon glyphicon-circle-arrow-right"></i> '.UserManagementModule::t('back','Permissions'),'url'=>['/user-management/permission/index']];
$menuItems[]=['label'=>'<i class="glyphicon glyphicon-circle-arrow-right"></i> '.UserManagementModule::t('back','Permission groups'),'url'=>['/user-management/auth-item-group/index']];
}
if (User::hasPermission('viewVisitLog')) {
$menuItems[]=['label'=>'<i class="glyphicon glyphicon-circle-arrow-right"></i> '.UserManagementModule::t('back','Visit log'),'url'=>['/user-management/user-visit-log/index']];
}
return $menuItems;
/*
return [
['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Users'), 'url' => ['/user-management/user/index']],
['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Roles'), 'url' => ['/user-management/role/index']],
['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Permissions'), 'url' => ['/user-management/permission/index']],
['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Permission groups'), 'url' => ['/user-management/auth-item-group/index']],
['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Visit log'), 'url' => ['/user-management/user-visit-log/index']],
];
*/
}

/**
Expand All @@ -228,7 +250,7 @@ public static function t($category, $message, $params = [], $language = null)
Yii::$app->i18n->translations['modules/user-management/*'] = [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en',
'basePath' => '@vendor/webvimark/module-user-management/messages',
'basePath' => '@vendor/wpler/module-user-management/messages',
'fileMap' => [
'modules/user-management/back' => 'back.php',
'modules/user-management/front' => 'front.php',
Expand Down
2 changes: 1 addition & 1 deletion components/AbstractItemEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace webvimark\modules\UserManagement\components;
namespace wpler\modules\UserManagement\components;

use yii\base\Event;

Expand Down
Loading