Exemplo n.º 1
0
 /**
  * Validates the password.
  * This method serves as the inline validation for password.
  *
  * @param string $attribute the attribute currently being validated
  * @param array $params the additional name-value pairs given in the rule
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $user = $this->getUser();
         if (!$user || !$user->validatePassword($this->password)) {
             $this->addError($attribute, Module::t('users', 'Incorrect username or password.'));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $user = new User(['scenario' => 'create']);
     $profile = new Profile();
     if ($user->load(Yii::$app->request->post()) && $profile->load(Yii::$app->request->post())) {
         if ($user->validate() && $profile->validate()) {
             //$user->populateRelation('profile', $profile);
             if ($user->save(false)) {
                 $user->link('profile', $profile);
                 Yii::$app->session->setFlash('success', Module::t('users', 'User has been successfully created.'));
                 return $this->redirect(['update', 'id' => $user->id]);
             } else {
                 Yii::$app->session->setFlash('danger', Module::t('users', 'User has not been saved. Please try again!'));
                 return $this->refresh();
             }
         }
     }
     return $this->render('create', ['user' => $user, 'profile' => $profile]);
 }
Exemplo n.º 3
0
 /**
  * @return array Statuses list
  */
 public static function getStatusesList()
 {
     return [self::STATUS_INACTIVE => Module::t('users', 'Inactive'), self::STATUS_ACTIVE => Module::t('users', 'Active'), self::STATUS_DELETED => Module::t('users', 'Deleted')];
 }
Exemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['first_name' => Module::t('users', 'First Name'), 'last_name' => Module::t('users', 'Last Name'), 'avatar_url' => Module::t('users', 'Avatar URL')];
 }
Exemplo n.º 5
0
<?php

use app\modules\users\Module;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $user app\modules\users\models\User */
/* @var $profile app\modules\users\models\Profile */
$this->title = Module::t('user', 'Users');
$this->params['subtitle'] = Module::t('users', 'User creation');
$this->params['breadcrumbs'] = [['label' => $this->title, 'url' => ['index']], $this->params['subtitle']];
?>

<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title"><?php 
echo $this->params['subtitle'];
?>
</h3>
        <div class="box-tools pull-right">
            <?php 
echo Html::a('<i class="fa fa-reply"></i>', ['index'], ['class' => 'btn btn-sm btn-default', 'title' => Module::t('module', 'Cancel')]);
?>
        </div>
    </div>
    <div class="box-body">
        <?php 
echo $this->render('_form', ['user' => $user, 'profile' => $profile]);
?>
    </div>
</div>
Exemplo n.º 6
0
use app\modules\formBuilder\widgets\FieldSet;
use app\modules\users\Module;
use app\themes\admin\widgets\Box;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model yii\base\DynamicModel */
/* @var $component im\config\components\ConfigurableInterface */
$this->title = Module::t('config', 'Settings');
$this->params['subtitle'] = $component->getConfigTitle() . ' ' . Module::t('config', 'settings');
$this->params['breadcrumbs'] = [['label' => $this->title, 'url' => ['index']], $this->params['subtitle']];
$boxButtons = ['{cancel}'];
$boxButtons = !empty($boxButtons) ? implode(' ', $boxButtons) : null;
?>
<div class="row">
    <div class="col-sm-12">
        <?php 
$box = Box::begin(['title' => $this->params['subtitle'], 'renderBody' => false, 'options' => ['class' => 'box-success'], 'buttonsTemplate' => $boxButtons]);
$form = ActiveForm::begin();
$box->beginBody();
echo FieldSet::widget(['form' => $form, 'model' => $model, 'fields' => ['option1' => ['fieldType' => 'input', 'inputOptions' => ['type' => 'text']], 'option5' => ['fieldType' => 'textarea']]]);
$box->endBody();
$box->beginFooter();
echo Html::submitButton(Module::t('config', 'Save'), ['class' => 'btn btn-success btn-large']);
$box->endFooter();
ActiveForm::end();
Box::end();
?>
    </div>
</div>
Exemplo n.º 7
0
if (Yii::$app->user->can('BackendDeleteUsers')) {
    $boxButtons[] = '{delete}';
}
$boxButtons = !empty($boxButtons) ? implode(' ', $boxButtons) : null;
?>

<div class="box box-success">
    <div class="box-header with-border">
        <h3 class="box-title"><?php 
echo $this->params['subtitle'];
?>
</h3>
        <div class="box-tools pull-right">
            <?php 
echo Html::a('<i class="fa fa-reply"></i>', ['index'], ['class' => 'btn btn-sm btn-default', 'title' => Module::t('module', 'Cancel')]);
?>
            <?php 
echo Html::a('<i class="fa fa-plus"></i>', ['create'], ['class' => 'btn btn-sm btn-default', 'title' => Module::t('module', 'Create')]);
?>
            <?php 
echo Html::a('<i class="fa fa-trash-o"></i>', ['delete', 'id' => $model->id], ['class' => 'btn btn-sm btn-default', 'title' => Module::t('module', 'Delete'), 'data-confirm' => Module::t('module', 'Are you sure you want to delete this item?'), 'data-method' => 'delete']);
?>
        </div>
    </div>
    <div class="box-body">
        <?php 
echo $this->render('_form', ['user' => $user, 'profile' => $profile]);
?>
    </div>
</div>
Exemplo n.º 8
0
$this->title = Module::t('users', 'Users');
$this->params['subtitle'] = Module::t('users', 'Users list');
$this->params['breadcrumbs'] = [$this->title];
$gridId = 'users-grid';
$gridConfig = ['id' => $gridId, 'tableOptions' => ['class' => 'table table-bordered table-hover'], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn'], 'id', ['attribute' => 'username', 'format' => 'html', 'value' => function ($model) {
    return Html::a($model['username'], ['update', 'id' => $model['id']], ['data-pjax' => 0]);
}], 'email:email', ['attribute' => 'first_name', 'value' => 'profile.first_name'], ['attribute' => 'last_name', 'value' => 'profile.last_name'], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === $model::STATUS_ACTIVE) {
        $class = 'label-success';
    } elseif ($model->status === $model::STATUS_INACTIVE) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->getStatus() . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', User::getStatusesList(), ['class' => 'form-control', 'prompt' => Module::t('users', 'Select status')])], ['attribute' => 'role', 'filter' => Html::activeDropDownList($searchModel, 'role', User::getRolesList(), ['class' => 'form-control', 'prompt' => Module::t('users', 'Select role')])], ['attribute' => 'created_at', 'format' => 'date', 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'created_at', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd.mm.yy']])], ['attribute' => 'updated_at', 'format' => 'date', 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'updated_at', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd.mm.yy']])]]];
$boxButtons = $actions = [];
$showActions = false;
if (Yii::$app->user->can('BackendCreateUsers')) {
    $boxButtons[] = '{create}';
}
if (Yii::$app->user->can('BackendUpdateUsers')) {
    $actions[] = '{update}';
    $showActions = $showActions || true;
}
if (Yii::$app->user->can('BackendDeleteUsers')) {
    $boxButtons[] = '{batch-delete}';
    $actions[] = '{delete}';
    $showActions = $showActions || true;
}
if ($showActions === true) {
Exemplo n.º 9
0
 public function behaviors()
 {
     return ['CustomControllerBehavior' => ['class' => CustomControllerBehavior::className(), 'module' => Module::className()]];
 }
Exemplo n.º 10
0
    <div class="header"><?php 
echo Html::encode($this->title);
?>
</div>
    <?php 
$form = ActiveForm::begin();
?>
    <div class="body bg-gray">
        <?php 
echo $form->field($model, 'username')->textInput(['placeholder' => $model->getAttributeLabel('username')])->label(false);
?>
        <?php 
echo $form->field($model, 'password')->passwordInput(['placeholder' => $model->getAttributeLabel('password')])->label(false);
?>
        <?php 
echo $form->field($model, 'rememberMe')->checkbox();
?>
    </div>
    <div class="footer">
        <?php 
echo Html::submitButton(Module::t('users', 'Sign In'), ['class' => 'btn bg-olive btn-block']);
?>
        <p><?php 
echo Html::a(Module::t('users', 'Recover password'), ['recovery']);
?>
</p>
    </div>
    <?php 
ActiveForm::end();
?>
</div>
Exemplo n.º 11
0
?>
    </div>
    <div class="col-sm-6">
        <?php 
echo $form->field($user, 'role')->dropDownList(User::getRolesList(), ['prompt' => Module::t('users', 'Select role')]);
?>
    </div>
</div>
<div class="row">
    <div class="col-sm-12">
<!--        --><?php 
//= $form->field($profile, 'avatar_url')->widget(Widget::className(),
//            [
//                'settings' => [
//                    'url' => ['fileapi-upload']
//                ],
//                'crop' => true,
//                'cropResizeWidth' => 100,
//                'cropResizeHeight' => 100
//            ]
//        )
?>
    </div>
</div>

<?php 
echo Html::submitButton($user->isNewRecord ? Module::t('users', 'Create') : Module::t('users', 'Update'), ['class' => $user->isNewRecord ? 'btn btn-primary btn-large' : 'btn btn-success btn-large']);
?>

<?php 
ActiveForm::end();