модуль генерации пользователей
This commit is contained in:
@ -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' => [],
|
||||
],
|
||||
|
||||
],
|
||||
|
24
frontend/modules/access/Access.php
Normal file
24
frontend/modules/access/Access.php
Normal 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
|
||||
}
|
||||
}
|
31
frontend/modules/access/controllers/AccessController.php
Normal file
31
frontend/modules/access/controllers/AccessController.php
Normal 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));
|
||||
}
|
||||
}
|
20
frontend/modules/access/controllers/DefaultController.php
Normal file
20
frontend/modules/access/controllers/DefaultController.php
Normal 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');
|
||||
}
|
||||
}
|
13
frontend/modules/access/views/access/index.php
Normal file
13
frontend/modules/access/views/access/index.php
Normal 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',
|
||||
],
|
||||
]);
|
12
frontend/modules/access/views/default/index.php
Normal file
12
frontend/modules/access/views/default/index.php
Normal 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>
|
@ -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">© <?= Html::encode(Yii::$app->name) ?> <?= date('Y') ?></p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="pull-left">© <?= 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() ?>
|
Reference in New Issue
Block a user