Inheritance: extends Core, implements yii\web\IdentityInterface, use trait skeeks\cms\models\behaviors\traits\HasRelatedPropertiesTrait
示例#1
0
 /**
  * Logs in a user using the provided username and password.
  *
  * @return boolean whether the user is logged in successfully
  */
 public function changePassword()
 {
     if ($this->validate() && $this->new_password == $this->new_password_confirm && $this->new_password) {
         $this->user->setPassword($this->new_password);
         return $this->user->save(false);
     } else {
         return false;
     }
 }
示例#2
0
 public function init()
 {
     $this->name = "Личный кабинет";
     $this->modelShowAttribute = "username";
     $this->modelClassName = User::className();
     parent::init();
 }
示例#3
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsernameOrEmail($this->identifier);
     }
     return $this->_user;
 }
示例#4
0
    /**
     * @inheritdoc
     */
    protected function renderDataCellContent($model, $key, $index)
    {
        $userId = (int) $model->{$this->attribute};
        $user = User::findOne($userId);
        if ($user) {
            if (!($srcImage = $user->getAvatarSrc())) {
                $srcImage = \Yii::$app->cms->moduleAdmin->noImage;
            }
            $this->grid->view->registerCss(<<<CSS
.sx-user-preview
{

}
.sx-user-preview .sx-user-preview-controll
{
    display: none;
}

.sx-user-preview:hover .sx-user-preview-controll
{
    display: inline;
}
CSS
);
            return "<div class='sx-user-preview'>" . Html::img($srcImage, ['width' => 25, 'style' => 'margin-right: 5px;']) . $user->getDisplayName() . "\n                <div class='sx-user-preview-controll'>" . Html::a("<i class='glyphicon glyphicon-pencil' title='Редактировать'></i>", UrlHelper::construct(['/cms/admin-user/update', 'pk' => $user->id])->enableAdmin()->toString(), ['class' => 'btn btn-xs btn-default', 'data-pjax' => 0]) . '</div></div>';
        } else {
            return null;
        }
    }
示例#5
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
示例#6
0
 public function init()
 {
     $this->name = "Управление пользователями";
     $this->modelShowAttribute = "username";
     $this->modelClassName = User::className();
     parent::init();
 }
示例#7
0
 public function actionResetPassword()
 {
     $this->view->title = \Yii::t('app', 'Password recovery');
     $this->layout = '@skeeks/cms/modules/admin/views/layouts/unauthorized.php';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $token = \Yii::$app->request->get('token');
     if (!$token) {
         return $this->goHome();
     }
     $user = User::findByPasswordResetToken($token);
     if ($user) {
         $password = \Yii::$app->getSecurity()->generateRandomString(10);
         $user->setPassword($password);
         $user->generatePasswordResetToken();
         if ($user->save(false)) {
             \Yii::$app->mailer->setViewPath(\Yii::$app->cms->moduleCms()->basePath . '/mail');
             \Yii::$app->mailer->compose('newPassword', ['user' => $user, 'password' => $password])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName])->setTo($user->email)->setSubject(\Yii::t('app', 'New password') . ' ' . \Yii::$app->cms->appName)->send();
             $message = \Yii::t('app', 'New password sent to your e-mail');
         }
     } else {
         $message = \Yii::t('app', 'Link outdated, try to request a password recovery again.');
     }
     return $this->render('reset-password', ['message' => $message]);
 }
示例#8
0
 /**
  * @inheritdoc
  */
 protected function renderDataCellContent($model, $key, $index)
 {
     $userId = (int) $model->{$this->attribute};
     $user = User::findOne($userId);
     if ($user) {
         if (!($srcImage = $user->getAvatarSrc())) {
             $srcImage = \Yii::$app->cms->moduleAdmin()->noImage;
         }
         return Html::img($srcImage, ['width' => 25, 'style' => 'margin-right: 5px;']) . $user->getDisplayName();
     } else {
         return null;
     }
 }
 public function safeUp()
 {
     if ($users = \skeeks\cms\models\User::find()->all()) {
         /**
          * @var $user \skeeks\cms\models\User
          */
         foreach ($users as $user) {
             if (!method_exists($user, 'getMainImageSrc')) {
                 continue;
             }
             //$user->getFiles()
             $imageSrc = $user->getMainImageSrc();
             if ($imageSrc) {
                 $storageFile = \skeeks\cms\models\CmsStorageFile::find()->where(['src' => $imageSrc])->one();
                 if ($storageFile) {
                     $user->image_id = $storageFile->id;
                     $user->save(false);
                 }
             }
         }
     }
 }
示例#10
0
 /**
  * Автоматическая генерация
  * @return $this
  */
 protected function initRootUser()
 {
     $this->stdout("Init root user \n", Console::BOLD);
     $root = User::findByUsername('root');
     $aManager = \Yii::$app->authManager;
     if ($root && $aManager->getRole(CmsManager::ROLE_ROOT)) {
         if (!$aManager->getAssignment(CmsManager::ROLE_ROOT, $root->primaryKey)) {
             $aManager->assign($aManager->getRole(CmsManager::ROLE_ROOT), $root->primaryKey);
         }
     }
     return $this;
 }
示例#11
0
文件: _form.php 项目: Liv1020/cms
?>
    <?php 
echo $form->field($model, 'value')->textInput(['maxlength' => 255]);
?>

    <?php 
if (\Yii::$app->request->get('user_id')) {
    ?>
        <?php 
    echo $form->field($model, 'user_id')->hiddenInput(['value' => \Yii::$app->request->get('user_id')])->label(false);
    ?>
    <?php 
} else {
    ?>
        <?php 
    echo $form->fieldSelect($model, 'user_id', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\User::find()->active()->all(), 'id', 'displayName'), ['allowDeselect' => true]);
    ?>
    <?php 
}
?>


    <?php 
echo $form->fieldRadioListBoolean($model, 'approved');
?>
    <?php 
echo $form->fieldRadioListBoolean($model, 'def');
?>

    <?php 
echo $form->buttonsCreateOrUpdate($model);
 public function actionRemove()
 {
     $component = $this->_component;
     $rr = new RequestResponse();
     if ($rr->isRequestAjaxPost()) {
         if (\Yii::$app->request->post('do') == 'all') {
             if ($settings = \skeeks\cms\models\CmsComponentSettings::baseQuery($component)->all()) {
                 /**
                  * @var $setting CmsComponentSettings
                  */
                 foreach ($settings as $setting) {
                     //TODO: добавить отладочную информацию.
                     if ($setting->delete()) {
                     }
                 }
                 $component->invalidateCache();
                 $rr->message = 'Настройки успешно удалены';
                 $rr->success = true;
             }
         } else {
             if (\Yii::$app->request->post('do') == 'default') {
                 if ($settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentDefault($component)) {
                     $settings->delete();
                     $component->invalidateCache();
                     $rr->message = 'Настройки успешно удалены';
                     $rr->success = true;
                 }
             } else {
                 if (\Yii::$app->request->post('do') == 'sites') {
                     if ($settings = \skeeks\cms\models\CmsComponentSettings::baseQuerySites($component)->all()) {
                         /**
                          * @var $setting CmsComponentSettings
                          */
                         foreach ($settings as $setting) {
                             //TODO: добавить отладочную информацию.
                             if ($setting->delete()) {
                             }
                         }
                         $component->invalidateCache();
                         $rr->message = 'Настройки успешно удалены';
                         $rr->success = true;
                     }
                 } else {
                     if (\Yii::$app->request->post('do') == 'users') {
                         if ($settings = \skeeks\cms\models\CmsComponentSettings::baseQueryUsers($component)->all()) {
                             /**
                              * @var $setting CmsComponentSettings
                              */
                             foreach ($settings as $setting) {
                                 //TODO: добавить отладочную информацию.
                                 if ($setting->delete()) {
                                 }
                             }
                             $component->invalidateCache();
                             $rr->message = 'Настройки успешно удалены';
                             $rr->success = true;
                         }
                     } else {
                         if (\Yii::$app->request->post('do') == 'site') {
                             $code = \Yii::$app->request->post('code');
                             $site = CmsSite::find()->where(['code' => $code])->one();
                             if ($site) {
                                 if ($settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentSite($component, $site)) {
                                     $settings->delete();
                                     $component->invalidateCache();
                                     $rr->message = 'Настройки успешно удалены';
                                     $rr->success = true;
                                 }
                             }
                         } else {
                             if (\Yii::$app->request->post('do') == 'user') {
                                 $id = \Yii::$app->request->post('id');
                                 $user = User::find()->where(['id' => $id])->one();
                                 if ($user) {
                                     if ($settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentUser($component, $user)) {
                                         $settings->delete();
                                         $component->invalidateCache();
                                         $rr->message = 'Настройки успешно удалены';
                                         $rr->success = true;
                                     }
                                 }
                             } else {
                                 $rr->message = 'Все настройки удалены';
                                 $rr->success = true;
                             }
                         }
                     }
                 }
             }
         }
         return (array) $rr;
     }
     return $this->render($this->action->id, ['component' => $component]);
 }
示例#13
0
文件: Cms.php 项目: Liv1020/cms
 /**
  * @return User
  * @throws Exception
  */
 public function getUserClassName()
 {
     /**
      * @var $userClassName User
      */
     $userClassName = \Yii::$app->user->identityClass;
     if (!class_exists($userClassName)) {
         throw new Exception("Не правильно сконфигурирован компонент user, класс пользователя не найден");
     }
     if (!is_subclass_of($userClassName, User::className())) {
         throw new Exception("Пользовательский класс должен быть наследован от базового skeeks cms класса: " . User::className());
     }
     return $userClassName;
 }
示例#14
0
文件: Core.php 项目: Liv1020/cms
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUpdatedBy()
 {
     return $this->hasOne(User::className(), ['id' => 'updated_by']);
 }
示例#15
0
 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     if ($user = User::findByEmail($this->email)) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName . ' robot'])->setTo($this->email)->setSubject(\Yii::t('app', 'Password reset for ') . \Yii::$app->cms->appName)->send();
         }
     }
     return false;
 }
示例#16
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }
示例#17
0
echo $form->field($model, 'user_phone')->textInput();
?>
    <?php 
echo $form->field($model, 'user_city')->textInput();
echo $form->fieldSetEnd();
?>

<?php 
echo $form->fieldSet(\Yii::t('skeeks/reviews2', 'Processing'));
?>
    <?php 
echo $form->fieldSelect($model, 'status', \skeeks\cms\reviews2\models\Reviews2Message::getStatuses());
?>

    <?php 
echo $form->fieldSelect($model, 'processed_by', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\User::find()->active()->all(), 'id', 'displayName'));
?>

    <?php 
echo $form->field($model, 'published_at')->widget(\kartik\datecontrol\DateControl::classname(), ['type' => \kartik\datecontrol\DateControl::FORMAT_DATETIME]);
?>


<?php 
echo $form->fieldSetEnd();
?>

<? if (!$model->isNewRecord) : ?>
    <?php 
echo $form->fieldSet(\Yii::t('skeeks/reviews2', 'Additional information'));
?>
示例#18
0
文件: index.php 项目: Liv1020/cms
%">
                        <span class="sr-only"><?php 
echo $freeSpacePercent;
?>
% Complete (success)</span>
                    </div>
                </div>
            </li>

        <li>
            <i class="icon-users"></i>
            <div class="number"><a href="<?php 
echo \skeeks\cms\helpers\UrlHelper::construct('/cms/admin-user')->enableAdmin()->toString();
?>
"><?php 
echo \skeeks\cms\models\User::find()->count();
?>
</a></div>
            <div class="title"><?php 
echo \Yii::t('app', 'Number of users');
?>
</div>

        </li>
    </ul>

<hr />
        <h2><?php 
echo \Yii::t('app', 'Read more');
?>
</h2>
示例#19
0
文件: users.php 项目: Liv1020/cms
            <button type="submit" class="btn btn-danger btn-xs" onclick="sx.ComponentSettings.Remove.removeUsers(); return false;">
                <i class="glyphicon glyphicon-remove"></i> <?php 
    echo \Yii::t('app', 'Reset settings for all users');
    ?>
            </button>
        <?php 
} else {
    ?>
            <small><?php 
    echo \Yii::t('app', 'Neither user does not have personal settings for this component');
    ?>
</small>
        <?php 
}
?>
    </div>

    <?php 
$search = new \skeeks\cms\models\Search(\skeeks\cms\models\User::className());
$search->search(\Yii::$app->request->get());
$search->getDataProvider()->query->andWhere(['active' => \skeeks\cms\components\Cms::BOOL_Y]);
?>
    <?php 
echo \skeeks\cms\modules\admin\widgets\GridViewHasSettings::widget(['dataProvider' => $search->getDataProvider(), 'filterModel' => $search->getLoadedModel(), 'columns' => [['class' => \yii\grid\DataColumn::className(), 'value' => function (\skeeks\cms\models\User $model, $key, $index, $this) {
    return \yii\helpers\Html::a('<i class="glyphicon glyphicon-cog"></i>', \skeeks\cms\helpers\UrlHelper::constructCurrent()->setRoute('cms/admin-component-settings/user')->set('user_id', $model->id)->toString(), ['class' => 'btn btn-default btn-xs', 'title' => \Yii::t('app', 'Customize')]);
}, 'format' => 'raw'], 'username', 'name', ['class' => \skeeks\cms\grid\ComponentSettingsColumn::className(), 'component' => $component]]]);
?>


<?php 
echo $this->render('_footer');
示例#20
0
 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     if ($user = User::findByEmail($this->email)) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             \Yii::$app->mailer->view->theme->pathMap = ArrayHelper::merge(\Yii::$app->mailer->view->theme->pathMap, ['@app/mail' => ['@skeeks/cms/mail']]);
             return \Yii::$app->mailer->compose('@app/mail/password-reset-token', ['user' => $user])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName . ' robot'])->setTo($this->email)->setSubject(\Yii::t('skeeks/cms', 'Password reset for ') . \Yii::$app->cms->appName)->send();
         }
     }
     return false;
 }
示例#21
0
文件: _form.php 项目: Liv1020/cms
echo $form->fieldSetEnd();
?>

    <?php 
echo $form->fieldSet(\Yii::t('app', 'Filtering'));
?>
        <?php 
echo $form->fieldSelect($model, 'active', \Yii::$app->cms->booleanFormat(), ['allowDeselect' => true]);
?>

        <?php 
echo $form->fieldSelect($model, 'enabledActiveTime', \Yii::$app->cms->booleanFormat())->hint(\Yii::t('app', "Will be considered time of beginning and end of the publication"));
?>

        <?php 
echo $form->fieldSelectMulti($model, 'createdBy', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\User::find()->active()->all(), 'id', 'name'));
?>

        <?php 
echo $form->fieldSelectMulti($model, 'content_ids', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsContent::find()->active()->all(), 'id', 'name'));
?>

        <?php 
echo $form->fieldRadioListBoolean($model, 'enabledCurrentTree', \Yii::$app->cms->booleanFormat());
?>
        <?php 
echo $form->fieldRadioListBoolean($model, 'enabledCurrentTreeChild', \Yii::$app->cms->booleanFormat());
?>
        <?php 
echo $form->fieldRadioListBoolean($model, 'enabledCurrentTreeChildAll', \Yii::$app->cms->booleanFormat());
?>
示例#22
0
echo \yii\widgets\DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'id', 'label' => \Yii::t('skeeks/form2/app', 'Post Number')], ['attribute' => 'created_at', 'value' => \Yii::$app->formatter->asDatetime($model->created_at, 'medium') . "(" . \Yii::$app->formatter->asRelativeTime($model->created_at) . ")"], ['format' => 'raw', 'label' => \Yii::t('skeeks/form2/app', 'Post Number'), 'value' => "<a href=\"{$model->site->url}\" target=\"_blank\" data-pjax=\"0\">{$model->site->name}</a>"], ['format' => 'raw', 'label' => \Yii::t('skeeks/form2/app', 'Submitted by'), 'value' => "{$model->createdBy->displayName}"], ['attribute' => 'ip', 'label' => \Yii::t('skeeks/form2/app', 'Ip address of the sender')], ['attribute' => 'page_url', 'format' => 'raw', 'label' => \Yii::t('skeeks/form2/app', 'Ip address of the sender'), 'value' => Html::a($model->page_url, $model->page_url, ['target' => '_blank', 'data-pjax' => 0])]]]);
?>

<?php 
echo $form->fieldSetEnd();
?>

<?php 
echo $form->fieldSet(\Yii::t('skeeks/form2/app', 'Control'));
?>
    <?php 
echo $form->fieldSelect($model, 'status', \skeeks\modules\cms\form2\models\Form2FormSend::getStatuses())->hint(\Yii::t('skeeks/form2/app', 'If you are treated with this message, change the status for convenience'));
?>

    <?php 
echo $form->fieldSelect($model, 'processed_by', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\User::find()->active()->all(), 'id', 'displayName'))->hint(\Yii::t('skeeks/form2/app', 'If you are treated with this message, change the status for convenience'));
?>

    <?php 
echo $form->field($model, 'comment')->textarea(['rows' => 5])->hint(\Yii::t('skeeks/form2/app', 'Short note, personal notes on this ship. Not necessary.'));
?>

<?php 
echo $form->fieldSetEnd();
?>

<?php 
echo $form->fieldSet(\Yii::t('skeeks/form2/app', 'For developers'));
?>

<div class="sx-block">