diff --git a/README.md b/README.md index b1be3183..14906a6d 100644 --- a/README.md +++ b/README.md @@ -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 --- @@ -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. @@ -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, @@ -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 ], ], @@ -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/ ``` @@ -119,7 +129,7 @@ public function behaviors() { return [ 'ghost-access'=> [ - 'class' => 'webvimark\modules\UserManagement\components\GhostAccessControl', + 'class' => 'wpler\modules\UserManagement\components\GhostAccessControl', ], ]; } @@ -132,8 +142,8 @@ Where you can go ```php false, @@ -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 }, @@ -247,7 +257,7 @@ 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! @@ -255,13 +265,13 @@ FAQ **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 diff --git a/UserManagementModule.php b/UserManagementModule.php index 75717919..c078da47 100644 --- a/UserManagementModule.php +++ b/UserManagementModule.php @@ -1,10 +1,17 @@ ' '.UserManagementModule::t('back','Users'),'url'=>['/user-management/user/index']]; + } + if (User::hasPermission('viewUserRoles')) { + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Roles'),'url'=>['/user-management/role/index']]; + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Permissions'),'url'=>['/user-management/permission/index']]; + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Permission groups'),'url'=>['/user-management/auth-item-group/index']]; + } + if (User::hasPermission('viewVisitLog')) { + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Visit log'),'url'=>['/user-management/user-visit-log/index']]; + } + return $menuItems; + /* return [ ['label' => ' ' . UserManagementModule::t('back', 'Users'), 'url' => ['/user-management/user/index']], ['label' => ' ' . UserManagementModule::t('back', 'Roles'), 'url' => ['/user-management/role/index']], @@ -209,6 +230,7 @@ public static function menuItems() ['label' => ' ' . UserManagementModule::t('back', 'Permission groups'), 'url' => ['/user-management/auth-item-group/index']], ['label' => ' ' . UserManagementModule::t('back', 'Visit log'), 'url' => ['/user-management/user-visit-log/index']], ]; + */ } /** @@ -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', diff --git a/components/AbstractItemEvent.php b/components/AbstractItemEvent.php index d5afecf1..808ac8f5 100644 --- a/components/AbstractItemEvent.php +++ b/components/AbstractItemEvent.php @@ -1,5 +1,5 @@ modelSearchClass ? new $this->modelSearchClass : null; + + if ( $searchModel ) + { + $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); + } + else + { + $modelClass = $this->modelClass; + $dataProvider = new ActiveDataProvider([ + 'query' => $modelClass::find(), + ]); + } + + return $this->renderIsAjax('index', compact('dataProvider', 'searchModel')); + } + + /** + * Displays a single model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->renderIsAjax('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new $this->modelClass; + + if ( $this->scenarioOnCreate ) + { + $model->scenario = $this->scenarioOnCreate; + } + + if ( $model->load(Yii::$app->request->post()) && $model->save() ) + { + $redirect = $this->getRedirectPage('create', $model); + + return $redirect === false ? '' : $this->redirect($redirect); + } + + return $this->renderIsAjax('create', compact('model')); + } + + /** + * Updates an existing model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ( $this->scenarioOnUpdate ) + { + $model->scenario = $this->scenarioOnUpdate; + } + + if ( $model->load(Yii::$app->request->post()) AND $model->save()) + { + $redirect = $this->getRedirectPage('update', $model); + + return $redirect === false ? '' : $this->redirect($redirect); + } + + return $this->renderIsAjax('update', compact('model')); + } + + /** + * Deletes an existing model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $model = $this->findModel($id); + $model->delete(); + + $redirect = $this->getRedirectPage('delete', $model); + + return $redirect === false ? '' : $this->redirect($redirect); + } + /** + * @param string $attribute + * @param int $id + */ + public function actionToggleAttribute($attribute, $id) + { + $model = $this->findModel($id); + $model->{$attribute} = ($model->{$attribute} == 1) ? 0 : 1; + $model->save(false); + } + + + /** + * Activate all selected grid items + */ + public function actionBulkActivate($attribute = 'active') + { + if ( Yii::$app->request->post('selection') ) + { + $modelClass = $this->modelClass; + + $modelClass::updateAll( + [$attribute=>1], + ['id'=>Yii::$app->request->post('selection', [])] + ); + } + } + + + /** + * Deactivate all selected grid items + */ + public function actionBulkDeactivate($attribute = 'active') + { + if ( Yii::$app->request->post('selection') ) + { + $modelClass = $this->modelClass; + + $modelClass::updateAll( + [$attribute=>0], + ['id'=>Yii::$app->request->post('selection', [])] + ); + } + } + + /** + * Deactivate all selected grid items + */ + public function actionBulkDelete() + { + if ( Yii::$app->request->post('selection') ) + { + $modelClass = $this->modelClass; + + foreach (Yii::$app->request->post('selection', []) as $id) + { + $model = $modelClass::findOne($id); + + if ( $model ) + $model->delete(); + } + } + } + + + /** + * Sorting items in grid + */ + public function actionGridSort() + { + if ( Yii::$app->request->post('sorter') ) + { + $sortArray = Yii::$app->request->post('sorter',[]); + + $modelClass = $this->modelClass; + + $models = $modelClass::findAll(array_keys($sortArray)); + + foreach ($models as $model) + { + $model->sorter = $sortArray[$model->id]; + $model->save(false); + } + + } + } + + + /** + * Set page size for grid + */ + public function actionGridPageSize() + { + if ( Yii::$app->request->post('grid-page-size') ) + { + $cookie = new Cookie([ + 'name' => '_grid_page_size', + 'value' => Yii::$app->request->post('grid-page-size'), + 'expire' => time() + 86400 * 365, // 1 year + ]); + + Yii::$app->response->cookies->add($cookie); + } + } + + /** + * Finds the model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param mixed $id + * + * @return ActiveRecord the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + $modelClass = $this->modelClass; + + if ( ($model = $modelClass::findOne($id)) !== null ) + { + return $model; + } + else + { + throw new NotFoundHttpException(Yii::t('yii', 'Page not found.')); + } + } + + + /** + * Define redirect page after update, create, delete, etc + * + * @param string $action + * @param ActiveRecord $model + * + * @return string|array + */ + protected function getRedirectPage($action, $model = null) + { + switch ($action) + { + case 'delete': + // Post and ajax request used in grid with pjax. To render normal page we have to redirect request to ['index'] + return Yii::$app->request->isAjax && !Yii::$app->request->isPost ? false : ['index']; + break; + case 'update': + return Yii::$app->request->isAjax ? false : ['view', 'id'=>$model->id]; + break; + case 'create': + return Yii::$app->request->isAjax ? false : ['view', 'id'=>$model->id]; + break; + default: + return ['index']; + } + } + + /** + * @inheritdoc + */ + public function beforeAction($action) + { + if ( parent::beforeAction($action) ) + { + if ( $this->enableOnlyActions !== [] AND in_array($action->id, $this->_implementedActions) AND !in_array($action->id, $this->enableOnlyActions) ) + { + throw new NotFoundHttpException('Page not found'); + } + + if ( in_array($action->id, $this->disabledActions) ) + { + throw new NotFoundHttpException('Page not found'); + } + + return true; + } + + return false; + + } +} \ No newline at end of file diff --git a/components/AuthHelper.php b/components/AuthHelper.php index 4ef8c1e2..967ec1ca 100644 --- a/components/AuthHelper.php +++ b/components/AuthHelper.php @@ -1,11 +1,11 @@ ['webvimark\modules\UserManagement\components\AuthHelper', 'layoutHandler'], + * 'on beforeAction'=>['wpler\modules\UserManagement\components\AuthHelper', 'layoutHandler'], * * @param \yii\base\ActionEvent $event */ diff --git a/components/BaseController.php b/components/BaseController.php new file mode 100644 index 00000000..fb0cf9fb --- /dev/null +++ b/components/BaseController.php @@ -0,0 +1,41 @@ + [ + 'class' => GhostAccessControl::className(), + ], + ]; + } + + /** + * Render ajax or usual depends on request + * + * @param string $view + * @param array $params + * + * @return string|\yii\web\Response + */ + protected function renderIsAjax($view, $params = []) + { + if ( Yii::$app->request->isAjax ) + { + return $this->renderAjax($view, $params); + } + else + { + return $this->render($view, $params); + } + } +} \ No newline at end of file diff --git a/components/GhostAccessControl.php b/components/GhostAccessControl.php index fd7d7e5b..5f5de13e 100644 --- a/components/GhostAccessControl.php +++ b/components/GhostAccessControl.php @@ -1,9 +1,9 @@ User::canRoute($item['url') will be added * - * @package webvimark\modules\UserManagement\components + * @package wpler\modules\UserManagement\components */ class GhostMenu extends Menu { diff --git a/components/GhostNav.php b/components/GhostNav.php index 2417705e..e3c1fc95 100644 --- a/components/GhostNav.php +++ b/components/GhostNav.php @@ -1,7 +1,7 @@ User::canRoute($item['url') will be added * - * @package webvimark\modules\UserManagement\components + * @package wpler\modules\UserManagement\components */ class GhostNav extends Nav { diff --git a/components/UserAuthEvent.php b/components/UserAuthEvent.php index c713a20e..16495399 100644 --- a/components/UserAuthEvent.php +++ b/components/UserAuthEvent.php @@ -1,10 +1,10 @@ '', 'Username' => '', 'You could not login from this IP' => '', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/de/back.php b/messages/de/back.php index 16965e3f..a236027e 100644 --- a/messages/de/back.php +++ b/messages/de/back.php @@ -19,7 +19,7 @@ return [ 'Active' => 'Aktiv', 'Are you sure you want to delete this user?' => 'Wollen Sie diesen Benutzer wirklich löschen?', - 'Banned' => '', + 'Banned' => 'Gebannt', 'Bind to IP' => 'An IP binden', 'Browser' => '', 'Change own password' => 'Eigenes Passwort ändern', @@ -29,7 +29,7 @@ 'Child permissions' => 'Kind-Berechtigungen', 'Child roles' => 'Kind-Rollen', 'Code' => '', - 'Confirmation Token' => '', + 'Confirmation Token' => 'Bestätigungs-Token', 'Create' => 'Erstellen', 'Created' => 'Erstellt', 'Creating permission group' => 'Erstelle Berechtigungs-Gruppe', @@ -39,7 +39,7 @@ 'Description' => 'Beschreibung', 'E-mail' => '', 'E-mail confirmed' => 'E-Mail bestätigt', - 'E-mail with activation link has been sent to {email}. This link will expire in {minutes} min.' => '', + 'E-mail with activation link has been sent to {email}. This link will expire in {minutes} min.' => 'Eine Email mit Aktivierungslink wurde an {email} gesendet. Der Link wird in {minutes} min. ablaufen.', 'Edit' => 'Bearbeiten', 'Editing' => 'Bearbeite', 'Editing permission group' => 'Bearbeite Berechtigungs-Gruppe', @@ -61,8 +61,8 @@ 'Permission groups' => 'Berechtigungs-Gruppen', 'Permissions' => 'Berechtigungen', 'Permissions for role:' => 'Berechtigungen für Rolle', - 'Refresh routes' => '', - 'Refresh routes (and delete unused)' => '', + 'Refresh routes' => 'Routen aktualisieren', + 'Refresh routes (and delete unused)' => 'Routen aktualisieren (& unbenutzte löschen)', 'Registration IP' => 'Registrierung IP', 'Repeat password' => 'Passwort wiederholen', 'Reset' => 'Zurücksetzen', @@ -70,15 +70,15 @@ 'Roles' => 'Rollen', 'Roles and permissions' => 'Rollen und Berechtigungen', 'Roles and permissions for user:' => 'Rollen und Berechtigungen von Benutzer:', - 'Routes that are not exists in this application will be deleted. Do not recommended for application with "advanced" structure, because frontend and backend have they own set of routes.' => '', + 'Routes that are not exists in this application will be deleted. Do not recommended for application with "advanced" structure, because frontend and backend have they own set of routes.' => 'Routen die nicht in der Anwendung benutzt werden, werden gelöscht. Dies ist nicht im Advanced-Template Struktur empfohlen, weil das Frontend sowie Backend seine eigenen Sets der Routen enthalten.', 'Rule' => 'Rolle', 'Save' => 'Speichern', 'Saved' => 'Gespeichert', 'Search' => 'Suchen', - 'Search route' => '', + 'Search route' => 'Route suchen', 'Settings for permission' => 'Einstellungen für Berechtigung', - 'Show all' => '', - 'Show only selected' => '', + 'Show all' => 'Zeige alle', + 'Show only selected' => 'Zeige nur markierte', 'Status' => '', 'Superadmin' => 'Super-Administrator', 'Token' => '', diff --git a/messages/de/front.php b/messages/de/front.php index d3e33b48..dbe0ce11 100644 --- a/messages/de/front.php +++ b/messages/de/front.php @@ -20,7 +20,7 @@ 'Captcha' => '', 'E-mail' => '', 'Login' => '', - 'Username' => '', + 'Username' => 'Benutzername', 'Authorization' => 'Autorisierung', 'Check your E-mail for further instructions' => 'Überprüfen Sie Ihre E-Mail-Adresse für weitere Anweisungen', 'Check your e-mail {email} for instructions to activate account' => 'Überprüfen Sie Ihre E-Mail-Adresse {email} für weitere Anweisungen zur Kontoaktivierung', @@ -49,4 +49,10 @@ 'Too many attempts' => 'Zu viele Versuche', 'Unable to send message for email provided' => 'Es war nicht möglich, die Nachricht an die angegebene E-Mail-Adresse zu senden', 'You could not login from this IP' => 'Sie können sich von dieser IP nicht anmelden', + 'Hello {username}, follow this link to confirm your E-mail address:' => 'Hallo {username}, folge den folgenden Link um deine E-Mail Adresse zu bestätigen:', + 'Confirm E-mail' => 'E-Mail bestätigen', + 'Hello {username}, follow this link to reset your password:' => 'Hallo {username}, folge den folgenden Link um dein Passwort zurückzusetzen:', + 'Reset password' => 'Passwort zurücksetzen', + 'Hello, you have been registered on {hostinfo}' => 'Hallo, Du wurdest auf {hostinfo} erfolgreich registriert.', + 'Follow this link to confirm your E-mail address and activate your account:' => 'Folge den folgenden Link um deine E-Mail Adresse zu bestätigen und dein Konto zu aktivieren:', ]; diff --git a/messages/es/front.php b/messages/es/front.php index 45c34b9c..18483147 100644 --- a/messages/es/front.php +++ b/messages/es/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Demasiados intentos', 'Unable to send message for email provided' => 'Deshabilitado para enviar mensaje por correo electrónico proveído', 'You could not login from this IP' => 'Usted no puede iniciar sesión desde esta dirección IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => 'Hola {username}, siga este enlace para confirmar su correo electrónico:', + 'Confirm E-mail' => 'Confirmar correo electrónico', + 'Hello {username}, follow this link to reset your password:' => 'Hola {username}, siga este enlace para restablecer su contraseña', + 'Reset password' => 'Restablecer contraseña', + 'Hello, you have been registered on {hostinfo}' => 'Hola, te has registrado en {hostinfo}.', + 'Follow this link to confirm your E-mail address and activate your account:' => 'Siga este enlace para confirmar su correo electrónico y activar su cuenta:', ]; diff --git a/messages/fr/front.php b/messages/fr/front.php index 935af0de..14186f08 100644 --- a/messages/fr/front.php +++ b/messages/fr/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Trop de tentatives', 'Unable to send message for email provided' => 'Impossible d\'envoyer le message pour l\'email fournit', 'You could not login from this IP' => 'Vous ne pouvez pas vous identifier à partir de cette adresse IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/ko-KR/front.php b/messages/ko-KR/front.php index 747b0827..d9fee166 100644 --- a/messages/ko-KR/front.php +++ b/messages/ko-KR/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => '너무 많은 시도를 했습니다', 'Unable to send message for email provided' => '제출된 주소로 메일을 보낼수 없습니다', 'You could not login from this IP' => '이 아이피로 로그인 할 수 없습니다', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/pl/front.php b/messages/pl/front.php index 1aad993f..f84835a9 100644 --- a/messages/pl/front.php +++ b/messages/pl/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Zbyt wiele prób', 'Unable to send message for email provided' => 'Nie udało się wysłać wiadomości na podany adres e-mail', 'You could not login from this IP' => 'Nie możesz się zalogować z tego IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/pt-BR/front.php b/messages/pt-BR/front.php index 5d4c7fe7..d47add56 100644 --- a/messages/pt-BR/front.php +++ b/messages/pt-BR/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Muitas tentativas', 'Unable to send message for email provided' => 'Não foi possível enviar mensagem para o e-mail informado', 'You could not login from this IP' => 'Você não pode logar a partir deste endereço IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/pt-PT/front.php b/messages/pt-PT/front.php index 7b57a575..f1349ff0 100644 --- a/messages/pt-PT/front.php +++ b/messages/pt-PT/front.php @@ -49,4 +49,10 @@ 'Unable to send message for email provided' => 'Não foi possível enviar mensagem para o e-mail indicado', 'Username' => 'Nome de Utilizador', 'You could not login from this IP' => 'Não é possível autenticar-se a partir deste endereço de IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/ru/front.php b/messages/ru/front.php index b4f9fd54..3bf81891 100644 --- a/messages/ru/front.php +++ b/messages/ru/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Лимит попыток превышен', 'Unable to send message for email provided' => 'Не удалось отправить письмо на указанный email', 'You could not login from this IP' => 'Вы не можете входить с этого IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/migrations/m140808_073114_create_auth_item_group_table.php b/migrations/m140808_073114_create_auth_item_group_table.php index 1d96d863..98163bc1 100644 --- a/migrations/m140808_073114_create_auth_item_group_table.php +++ b/migrations/m140808_073114_create_auth_item_group_table.php @@ -16,20 +16,28 @@ public function safeUp() $table_name = \Yii::$app->getModule('user-management')->auth_item_group_table; if (\Yii::$app->db->schema->getTableSchema($table_name) === null) { - // Create auth_item_group_table table - $this->createTable($table_name, [ - 'code' => 'varchar(64) NOT NULL', - 'name' => 'varchar(255) NOT NULL', - - 'created_at' => 'int', - 'updated_at' => 'int', - 'PRIMARY KEY (code)', - - ], $tableOptions); - - $this->addColumn(Yii::$app->getModule('user-management')->auth_item_table, 'group_code', 'varchar(64)'); - $this->addForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table, 'group_code', Yii::$app->getModule('user-management')->auth_item_group_table, 'code', 'SET NULL', 'CASCADE'); - } + // Columns + $columns=array( + 'code' => 'varchar(64) NOT NULL', + 'name' => 'varchar(255) NOT NULL', + 'created_at' => 'int', + 'updated_at' => 'int', + 'PRIMARY KEY (code)', + ); + if ( $this->db->driverName === 'sqlite' ) + { + $columns[]='FOREIGN KEY(code) REFERENCES '.\Yii::$app->getModule('user-management')->auth_item_table.'(group_code)'; + } + + // Create auth_item_group_table table + $this->createTable($table_name, $columns, $tableOptions); + + $this->addColumn(Yii::$app->getModule('user-management')->auth_item_table, 'group_code', 'varchar(64)'); + if ( $this->db->driverName !== 'sqlite' ) + { + $this->addForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table, 'group_code', Yii::$app->getModule('user-management')->auth_item_group_table, 'code', 'SET NULL', 'CASCADE'); + } + } if (Yii::$app->cache) { Yii::$app->cache->flush(); @@ -38,7 +46,9 @@ public function safeUp() public function safeDown() { - $this->dropForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table); + if ( $this->db->driverName !== 'sqlite' ) { + $this->dropForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table); + } $this->dropColumn(Yii::$app->getModule('user-management')->auth_item_table, 'group_code'); $this->dropTable(Yii::$app->getModule('user-management')->auth_item_group_table); diff --git a/migrations/m140809_072112_insert_superadmin_to_user.php b/migrations/m140809_072112_insert_superadmin_to_user.php index 77e331a7..d3bf1a9b 100644 --- a/migrations/m140809_072112_insert_superadmin_to_user.php +++ b/migrations/m140809_072112_insert_superadmin_to_user.php @@ -2,7 +2,7 @@ use yii\db\Schema; use yii\db\Migration; -use webvimark\modules\UserManagement\models\User; +use wpler\modules\UserManagement\models\User; class m140809_072112_insert_superadmin_to_user extends Migration { diff --git a/migrations/m140809_073114_insert_common_permisison_to_auth_item.php b/migrations/m140809_073114_insert_common_permisison_to_auth_item.php index 3563d580..071bc3c2 100644 --- a/migrations/m140809_073114_insert_common_permisison_to_auth_item.php +++ b/migrations/m140809_073114_insert_common_permisison_to_auth_item.php @@ -2,7 +2,7 @@ use yii\db\Schema; use yii\db\Migration; -use webvimark\modules\UserManagement\models\rbacDB\Permission; +use wpler\modules\UserManagement\models\rbacDB\Permission; class m140809_073114_insert_common_permisison_to_auth_item extends Migration { diff --git a/migrations/m141023_141535_create_user_visit_log.php b/migrations/m141023_141535_create_user_visit_log.php index c9e93b71..88a7a02c 100644 --- a/migrations/m141023_141535_create_user_visit_log.php +++ b/migrations/m141023_141535_create_user_visit_log.php @@ -22,7 +22,7 @@ public function safeUp() 'token' => 'string not null', 'ip' => 'varchar(15) not null', 'language' => 'char(2) not null', - 'browser_and_os' => 'string not null', + 'user_agent' => 'string not null', 'user_id' => 'int', 'visit_time' => 'int not null', 0 => 'FOREIGN KEY (user_id) REFERENCES '.Yii::$app->getModule('user-management')->user_table.' (id) ON DELETE SET NULL ON UPDATE CASCADE', diff --git a/migrations/m141121_194858_split_browser_and_os_column.php b/migrations/m141121_194858_split_browser_and_os_column.php index aa1a3cf4..0051af0a 100644 --- a/migrations/m141121_194858_split_browser_and_os_column.php +++ b/migrations/m141121_194858_split_browser_and_os_column.php @@ -8,9 +8,7 @@ public function safeUp() { $this->addColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser', 'varchar(30)'); $this->addColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'os', 'varchar(20)'); - $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser_and_os', 'user_agent'); - - if (Yii::$app->cache) { + if (Yii::$app->cache) { Yii::$app->cache->flush(); } } @@ -19,9 +17,7 @@ public function safeDown() { $this->dropColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'os'); $this->dropColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser'); - $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'user_agent', 'browser_and_os'); - - if (Yii::$app->cache) { + if (Yii::$app->cache) { Yii::$app->cache->flush(); } } diff --git a/migrations/m141207_001649_create_basic_user_permissions.php b/migrations/m141207_001649_create_basic_user_permissions.php index a9593ed3..d25ab3f9 100644 --- a/migrations/m141207_001649_create_basic_user_permissions.php +++ b/migrations/m141207_001649_create_basic_user_permissions.php @@ -1,9 +1,9 @@ 'webvimark\modules\UserManagement\models\User', + 'targetClass' => 'wpler\modules\UserManagement\models\User', 'targetAttribute' => 'username', ], diff --git a/models/rbacDB/AbstractItem.php b/models/rbacDB/AbstractItem.php index fae8ae59..954b1c05 100644 --- a/models/rbacDB/AbstractItem.php +++ b/models/rbacDB/AbstractItem.php @@ -1,9 +1,9 @@ user->isSuperAdmin OR $showAll) ? [] : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; - - $result = static::find()->andWhere($condition)->all(); + //$condition = (Yii::$app->user->isSuperadmin OR $showAll) ? [] : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; + $condition = (Yii::$app->user->isSuperadmin OR $showAll) ? false : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; + + if (false===$condition) { + $result = static::find()->all(); + } else { + $result = static::find()->andWhere($condition)->all(); + } return $asArray ? ArrayHelper::map($result, 'name', 'name') : $result; } diff --git a/models/rbacDB/Route.php b/models/rbacDB/Route.php index f410903a..9fc41127 100644 --- a/models/rbacDB/Route.php +++ b/models/rbacDB/Route.php @@ -1,7 +1,7 @@ diff --git a/views/auth-item-group/_search.php b/views/auth-item-group/_search.php index 48ec1d6f..0d546e05 100644 --- a/views/auth-item-group/_search.php +++ b/views/auth-item-group/_search.php @@ -5,7 +5,7 @@ /** * @var yii\web\View $this - * @var app\modules\merchant\models\search\AuthItemGroupSearch $model + * @var wpler\modules\UserManagement\models\rbacDB\search\AuthItemGroupSearch $model * @var yii\widgets\ActiveForm $form */ ?> diff --git a/views/auth-item-group/create.php b/views/auth-item-group/create.php index f1214c58..d3d2f204 100644 --- a/views/auth-item-group/create.php +++ b/views/auth-item-group/create.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('back', 'Creating permission group'); diff --git a/views/auth-item-group/index.php b/views/auth-item-group/index.php index 51a37134..60e9b5d4 100644 --- a/views/auth-item-group/index.php +++ b/views/auth-item-group/index.php @@ -1,19 +1,19 @@ title = UserManagementModule::t('back', 'Permission groups'); diff --git a/views/auth-item-group/update.php b/views/auth-item-group/update.php index 1d3520c7..8d7eb245 100644 --- a/views/auth-item-group/update.php +++ b/views/auth-item-group/update.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('back', 'Editing permission group') . ': ' . $model->name; diff --git a/views/auth-item-group/view.php b/views/auth-item-group/view.php index b3b289a3..390d9c7e 100644 --- a/views/auth-item-group/view.php +++ b/views/auth-item-group/view.php @@ -1,12 +1,12 @@ title = $model->name; diff --git a/views/auth/changeOwnPassword.php b/views/auth/changeOwnPassword.php index 9985fec8..7b1e6c33 100644 --- a/views/auth/changeOwnPassword.php +++ b/views/auth/changeOwnPassword.php @@ -1,12 +1,12 @@ title = UserManagementModule::t('back', 'Change own password'); diff --git a/views/auth/changeOwnPasswordSuccess.php b/views/auth/changeOwnPasswordSuccess.php index 88e0a4f9..5d9772ac 100644 --- a/views/auth/changeOwnPasswordSuccess.php +++ b/views/auth/changeOwnPasswordSuccess.php @@ -1,6 +1,6 @@ title = UserManagementModule::t('front', 'Confirm E-mail'); diff --git a/views/auth/confirmEmailSuccess.php b/views/auth/confirmEmailSuccess.php index 7bd4c0e7..6654111d 100644 --- a/views/auth/confirmEmailSuccess.php +++ b/views/auth/confirmEmailSuccess.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('front', 'E-mail confirmed'); diff --git a/views/auth/login.php b/views/auth/login.php index 25d7b088..1a3ee2ce 100644 --- a/views/auth/login.php +++ b/views/auth/login.php @@ -1,11 +1,11 @@ diff --git a/views/auth/passwordRecovery.php b/views/auth/passwordRecovery.php index b834c6d0..a3de02e4 100644 --- a/views/auth/passwordRecovery.php +++ b/views/auth/passwordRecovery.php @@ -1,13 +1,13 @@ title = UserManagementModule::t('front', 'Password recovery'); diff --git a/views/auth/passwordRecoverySuccess.php b/views/auth/passwordRecoverySuccess.php index bc7b678f..d18d22b2 100644 --- a/views/auth/passwordRecoverySuccess.php +++ b/views/auth/passwordRecoverySuccess.php @@ -1,6 +1,6 @@ title = UserManagementModule::t('front', 'Registration'); diff --git a/views/auth/registrationWaitForEmailConfirmation.php b/views/auth/registrationWaitForEmailConfirmation.php index 05805288..336b99b5 100644 --- a/views/auth/registrationWaitForEmailConfirmation.php +++ b/views/auth/registrationWaitForEmailConfirmation.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('front', 'Registration - confirm your e-mail'); diff --git a/views/layouts/loginLayout.php b/views/layouts/loginLayout.php index a728287d..ab539f57 100644 --- a/views/layouts/loginLayout.php +++ b/views/layouts/loginLayout.php @@ -1,6 +1,6 @@ urlManager->createAbsoluteUrl(['/user-management/auth/confirm-email-receive', 'token' => $user->confirmation_token]); ?> -Hello username) ?>, follow this link to confirm your email: +Html::encode($user->username))); ?> - \ No newline at end of file + \ No newline at end of file diff --git a/views/mail/passwordRecoveryMail.php b/views/mail/passwordRecoveryMail.php index ea49d85f..cdbd7f0c 100644 --- a/views/mail/passwordRecoveryMail.php +++ b/views/mail/passwordRecoveryMail.php @@ -1,15 +1,16 @@ urlManager->createAbsoluteUrl(['/user-management/auth/password-recovery-receive', 'token' => $user->confirmation_token]); ?> -Hello username) ?>, follow this link to reset your password: +Html::encode($user->username))); ?> - \ No newline at end of file + \ No newline at end of file diff --git a/views/mail/registrationEmailConfirmation.php b/views/mail/registrationEmailConfirmation.php index efc3beb6..d338a5df 100644 --- a/views/mail/registrationEmailConfirmation.php +++ b/views/mail/registrationEmailConfirmation.php @@ -1,9 +1,10 @@ urlManager->createAbsoluteUrl(['/user-management/auth/confirm-registration-email', 'token' => $user->confirmation_token, 'returnUrl'=>$returnUrl]); ?> -Hello, you have been registered on urlManager->hostInfo ?> +Yii::$app->urlManager->hostInfo)); ?>

-Follow this link to confirm your E-mail and activate account: + - \ No newline at end of file + \ No newline at end of file diff --git a/views/permission/_form.php b/views/permission/_form.php index 439c0923..3a88e588 100644 --- a/views/permission/_form.php +++ b/views/permission/_form.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('back', 'Permission creation'); $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Permissions'), 'url' => ['index']]; diff --git a/views/permission/index.php b/views/permission/index.php index 4f8796a2..1a7ecbd7 100644 --- a/views/permission/index.php +++ b/views/permission/index.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Permissions'); diff --git a/views/permission/update.php b/views/permission/update.php index b2736079..fa155f4c 100644 --- a/views/permission/update.php +++ b/views/permission/update.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Editing permission: ') . ' ' . $model->name; $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Permissions'), 'url' => ['index']]; diff --git a/views/permission/view.php b/views/permission/view.php index a28af200..e4b50cfd 100644 --- a/views/permission/view.php +++ b/views/permission/view.php @@ -9,8 +9,8 @@ * @var yii\rbac\Permission $item */ -use webvimark\modules\UserManagement\components\GhostHtml; -use webvimark\modules\UserManagement\UserManagementModule; +use wpler\modules\UserManagement\components\GhostHtml; +use wpler\modules\UserManagement\UserManagementModule; use yii\helpers\ArrayHelper; use yii\helpers\Html; diff --git a/views/role/_form.php b/views/role/_form.php index 764e92ff..d7e04579 100644 --- a/views/role/_form.php +++ b/views/role/_form.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Role creation'); $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Roles'), 'url' => ['index']]; diff --git a/views/role/index.php b/views/role/index.php index 6d09e1b3..b5f4168a 100644 --- a/views/role/index.php +++ b/views/role/index.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Roles'); diff --git a/views/role/update.php b/views/role/update.php index 8c28b7b1..15f83020 100644 --- a/views/role/update.php +++ b/views/role/update.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Editing role: ') . ' ' . $model->name; $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Roles'), 'url' => ['index']]; diff --git a/views/role/view.php b/views/role/view.php index 2754628e..ff64ada9 100644 --- a/views/role/view.php +++ b/views/role/view.php @@ -10,9 +10,9 @@ * @var yii\rbac\Role $role */ -use webvimark\modules\UserManagement\components\GhostHtml; -use webvimark\modules\UserManagement\models\rbacDB\Role; -use webvimark\modules\UserManagement\UserManagementModule; +use wpler\modules\UserManagement\components\GhostHtml; +use wpler\modules\UserManagement\models\rbacDB\Role; +use wpler\modules\UserManagement\UserManagementModule; use yii\helpers\ArrayHelper; use yii\helpers\Html; diff --git a/views/user-permission/set.php b/views/user-permission/set.php index 462a72d2..66f36521 100644 --- a/views/user-permission/set.php +++ b/views/user-permission/set.php @@ -2,12 +2,12 @@ /** * @var yii\web\View $this * @var array $permissionsByGroup - * @var webvimark\modules\UserManagement\models\User $user + * @var wpler\modules\UserManagement\models\User $user */ -use webvimark\modules\UserManagement\components\GhostHtml; -use webvimark\modules\UserManagement\models\rbacDB\Role; -use webvimark\modules\UserManagement\UserManagementModule; +use wpler\modules\UserManagement\components\GhostHtml; +use wpler\modules\UserManagement\models\rbacDB\Role; +use wpler\modules\UserManagement\UserManagementModule; use yii\bootstrap\BootstrapPluginAsset; use yii\helpers\ArrayHelper; use yii\helpers\Html; diff --git a/views/user-visit-log/index.php b/views/user-visit-log/index.php index 4d70a702..9b379eef 100644 --- a/views/user-visit-log/index.php +++ b/views/user-visit-log/index.php @@ -1,16 +1,16 @@ title = UserManagementModule::t('back', 'Visit log'); diff --git a/views/user-visit-log/view.php b/views/user-visit-log/view.php index ce7a0731..1d01122f 100644 --- a/views/user-visit-log/view.php +++ b/views/user-visit-log/view.php @@ -1,12 +1,12 @@ title = $model->id; diff --git a/views/user/_form.php b/views/user/_form.php index e828d60f..0d63cde6 100644 --- a/views/user/_form.php +++ b/views/user/_form.php @@ -1,14 +1,14 @@ diff --git a/views/user/_search.php b/views/user/_search.php index d5f0c455..7887d9e4 100644 --- a/views/user/_search.php +++ b/views/user/_search.php @@ -5,7 +5,7 @@ /** * @var yii\web\View $this - * @var webvimark\modules\UserManagement\models\search\UserSearch $model + * @var wpler\modules\UserManagement\models\search\UserSearch $model * @var yii\widgets\ActiveForm $form */ ?> diff --git a/views/user/changePassword.php b/views/user/changePassword.php index 1ec181c0..b5cbfe3d 100644 --- a/views/user/changePassword.php +++ b/views/user/changePassword.php @@ -1,12 +1,12 @@ title = UserManagementModule::t('back', 'Changing password for user: ') . ' ' . $model->username; diff --git a/views/user/create.php b/views/user/create.php index f890c518..3545ca33 100644 --- a/views/user/create.php +++ b/views/user/create.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('back', 'User creation'); diff --git a/views/user/index.php b/views/user/index.php index 2c5a6565..4e249dd8 100644 --- a/views/user/index.php +++ b/views/user/index.php @@ -1,21 +1,21 @@ title = UserManagementModule::t('back', 'Users'); @@ -73,7 +73,7 @@ ['class' => 'yii\grid\SerialColumn', 'options'=>['style'=>'width:10px'] ], [ - 'class'=>'webvimark\components\StatusColumn', + 'class'=>'\webvimark\components\StatusColumn', 'attribute'=>'superadmin', 'visible'=>Yii::$app->user->isSuperadmin, ], @@ -91,13 +91,13 @@ 'visible'=>User::hasPermission('viewUserEmail'), ], [ - 'class'=>'webvimark\components\StatusColumn', + 'class'=>'\webvimark\components\StatusColumn', 'attribute'=>'email_confirmed', 'visible'=>User::hasPermission('viewUserEmail'), ], [ 'attribute'=>'gridRoleSearch', - 'filter'=>ArrayHelper::map(Role::getAvailableRoles(Yii::$app->user->isSuperAdmin),'name', 'description'), + 'filter'=>ArrayHelper::map(Role::getAvailableRoles(Yii::$app->user->isSuperadmin),'name', 'description'), 'value'=>function(User $model){ return implode(', ', ArrayHelper::map($model->roles, 'name', 'description')); }, @@ -138,7 +138,7 @@ ], ], [ - 'class'=>'webvimark\components\StatusColumn', + 'class'=>'\webvimark\components\StatusColumn', 'attribute'=>'status', 'optionsArray'=>[ [User::STATUS_ACTIVE, UserManagementModule::t('back', 'Active'), 'success'], diff --git a/views/user/update.php b/views/user/update.php index 0a4ef0a1..9d4e4b79 100644 --- a/views/user/update.php +++ b/views/user/update.php @@ -1,14 +1,14 @@ title = UserManagementModule::t('back', 'Editing user: ') . ' ' . $model->username; diff --git a/views/user/view.php b/views/user/view.php index 5623a29b..733a9327 100644 --- a/views/user/view.php +++ b/views/user/view.php @@ -1,16 +1,16 @@ title = $model->username;