модуль генерации пользователей

This commit is contained in:
Glambertessa
2019-11-14 17:21:34 +03:00
parent 601b62aa8d
commit f8222eb89c
19 changed files with 426 additions and 163 deletions

View File

@ -11,6 +11,13 @@ return [
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',
'modules' => [
'access' => [
'class' => 'frontend\modules\access\Access',
],
],
'components' => [
'request' => [
'csrfParam' => '_csrf-frontend',
@ -41,8 +48,7 @@ return [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
'rules' => [],
],
],

View File

@ -0,0 +1,24 @@
<?php
namespace frontend\modules\access;
/**
* access module definition class
*/
class Access extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'frontend\modules\access\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace frontend\modules\access\controllers;
use common\classes\Debug;
use common\models\Accesses;
use Yii;
use yii\web\Controller;
use yii\data\ActiveDataProvider;
class AccessController extends Controller
{
/**
* @return mixed
*/
public function actionIndex()
{
$id_user = Yii::$app->user->id;
$query = "SELECT accesses.name, accesses.access FROM `accesses`, `user_card`, `user_card_accesses` WHERE user_card.id_user =" . $id_user . " AND user_card_accesses.user_card_id = user_card.id AND accesses.id = user_card_accesses.accesses_id ";
$access = Accesses::findBySql($query);
$dataProvider = new ActiveDataProvider([
'query' => $access,
'pagination' => [
'pageSize' => 200,
],
]);
return $this->render('index', compact('dataProvider', $dataProvider));
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace frontend\modules\access\controllers;
use yii\web\Controller;
/**
* Default controller for the `access` module
*/
class DefaultController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
}

View File

@ -0,0 +1,13 @@
<?php
use yii\grid\GridView;
use yii\widgets\DetailView;
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'name',
'access',
],
]);

View File

@ -0,0 +1,12 @@
<div class="access-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>

View File

@ -15,6 +15,7 @@ AppAsset::register($this);
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@ -23,61 +24,64 @@ AppAsset::register($this);
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?php $this->beginBody() ?>
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = '<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>';
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
NavBar::end();
?>
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
['label' => 'Access', 'url' => ['/access/access/index']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = '<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>';
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
NavBar::end();
?>
<div class="container">
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= Alert::widget() ?>
<?= $content ?>
<div class="container">
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= Alert::widget() ?>
<?= $content ?>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-left">&copy; <?= Html::encode(Yii::$app->name) ?> <?= date('Y') ?></p>
<footer class="footer">
<div class="container">
<p class="pull-left">&copy; <?= Html::encode(Yii::$app->name) ?> <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<?php $this->endBody() ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
<?php $this->endPage() ?>