コード例 #1
0
 public function actionSave()
 {
     $accountId = $this->getAccountId();
     $request = Yii::$app->request;
     $operatorId = $request->post('operatorId', '');
     $sampleId = $request->post('sampleId', '');
     $name = $request->post('name', '');
     $quantity = $request->post('quantity', '');
     $imgUrl = $request->post('imgUrl', '');
     $operator = User::find()->where(['_id' => $operatorId])->one();
     if ($operator === null) {
         return ['code' => 1309, 'msg' => 'not login'];
     }
     if ($name == '') {
         return ['code' => 1300, 'msg' => 'name not get'];
     }
     if ($quantity == '') {
         return ['code' => 1300, 'msg' => 'quantity not get'];
     }
     $sample = Sample::find()->where(['_id' => $sampleId])->one();
     if ($sampleId == '' || $sample == null) {
         $sample = new Sample();
         $sample->usedNumber = 0;
     }
     $sample->name = $name;
     $sample->quantity = $quantity;
     $sample->operator = $operator->name;
     $sample->imgUrl = $imgUrl;
     $sample->accountId = $accountId;
     $sample->save();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return ['code' => 200, 'msg' => 'OK'];
 }
コード例 #2
0
 public function actionStockPedidos($idComercio, $idRutaDiaria)
 {
     $rutaDiaria = RutaDiaria::find()->where(['id' => $idRutaDiaria])->one();
     $usuario = User::find()->where(['id' => $rutaDiaria->id_usuario])->one();
     $rutaDiariaComercio = $this->findRutaDiariaComercio($idComercio, $idRutaDiaria);
     $datosGrillaStock = [];
     $datosGrillaPedidos = [];
     $i = 0;
     if ($rutaDiariaComercio->getStocks()->count() > 0) {
         $datosStock = $this->findStockComercio($rutaDiariaComercio->id);
         foreach ($datosStock as $stock) {
             $nombreProducto = nombreProducto($stock->id_producto);
             $datosGrillaStock[$i] = ['tipo' => Yii::t('core', 'Stock'), 'producto' => $nombreProducto, 'cantidad' => $stock->cantidad];
             $i++;
         }
     }
     $i = 0;
     if ($rutaDiariaComercio->getPedidos()->count() > 0) {
         $datosPedidos = $this->findPedidosComercio($rutaDiariaComercio->id);
         foreach ($datosPedidos as $pedido) {
             $nombrePedido = nombreProducto($pedido->id_producto);
             $datosGrillaPedidos[$i] = ['tipo' => Yii::t('core', 'Order'), 'producto' => $nombrePedido, 'cantidad' => $pedido->cantidad];
             $i++;
         }
     }
     return $this->render('stockPedidos', ['model' => $rutaDiariaComercio, 'datosGrillaStock' => $datosGrillaStock, 'datosGrillaPedidos' => $datosGrillaPedidos, 'fecha' => $rutaDiaria->fecha, 'usuario' => $usuario->username, 'ruta' => $rutaDiaria->id]);
 }
コード例 #3
0
ファイル: LoginForm.php プロジェクト: buuug7/game4039
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->user === false) {
         $this->user = User::find()->andWhere(['or', ['username' => $this->username], ['email' => $this->username]])->one();
     }
     return $this->user;
 }
コード例 #4
0
 public function actionIndex()
 {
     $query = User::find();
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('registerTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render(Variable::$userMange_view, ['countries' => $countries, 'pagination' => $pagination]);
 }
コード例 #5
0
 public function actionShowTo()
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $id = $_POST['id'];
     $todoList = User::find()->where(['id' => $id])->with('todos')->asArray()->one();
     //print_r($done);
     return $todoList;
 }
コード例 #6
0
 /**
  * @return bool
  */
 public function isManager()
 {
     $model = User::find()->where(['username' => $this->username])->andWhere(['status' => 1])->one();
     $manager = Manager::find()->where(['user_id' => $model->id, 'status' => 1])->one();
     if ($manager) {
         return true;
     }
     return false;
 }
コード例 #7
0
ファイル: PassController.php プロジェクト: wuwenhan/huoqiwang
 public function actionUpdate()
 {
     $model = User::find()->where(['id' => \App::$app->user->identity->getId()])->One();
     $model->setScenario('admin-update');
     if ($model->load(\App::$app->request->post()) && $model->save()) {
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
コード例 #8
0
ファイル: UserController.php プロジェクト: wordnews/wei_shop
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (!$this->is_access('user/index')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $dataProvider = new ActiveDataProvider(['query' => User::find()->where(['<>', 'id', '1']), 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     Yii::$app->view->params['meta_title'] = '管理员列表';
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
コード例 #9
0
ファイル: UserSearch.php プロジェクト: mahmoodkhoeini/yii2cms
 public function search($params)
 {
     $query = User::find();
     $query->joinWith('authAssignment');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'username', $this->content])->andFilterWhere(['like', 'email', $this->status])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at])->andFilterWhere(['like', 'authAssignment.item_name', $this->item_name]);
     return $dataProvider;
 }
コード例 #10
0
ファイル: UserSearch.php プロジェクト: wuwenhan/huoqiwang
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'truename' => $this->truename, 'realcard' => $this->realcard, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'username', $this->truename])->andFilterWhere(['like', 'username', $this->realcard])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['>', 'created_at', strtotime($this->created_at)]);
     return $dataProvider;
 }
コード例 #11
0
ファイル: ApiController.php プロジェクト: Vlad9330/waiver
 public function actionLogin()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $username = Yii::$app->request->post('login');
     $password = Yii::$app->request->post('password');
     $model = User::find()->where(['username' => Yii::$app->request->post('login')])->one();
     if (!$model) {
         return ['status' => 'error', 'error' => array('login' => 'User with login ' . $username . ' is not registered.')];
     } elseif (!Yii::$app->security->validatePassword($password, $model->password_hash)) {
         return ['status' => 'error', 'error' => array('password' => 'Password incorrect.')];
     } else {
         return ['status' => 'success', 'data' => $model];
     }
 }
コード例 #12
0
ファイル: Users.php プロジェクト: jia253/centosYii2
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'create_time' => $this->create_time]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'pwd', $this->pwd]);
     return $dataProvider;
 }
コード例 #13
0
ファイル: UserSearch.php プロジェクト: quyettvq/luspel
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'dob' => $this->dob, 'gender' => $this->gender]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'image_path', $this->image_path]);
     return $dataProvider;
 }
コード例 #14
0
ファイル: MembershipChecker.php プロジェクト: xNok/membership
 public function onSwitch()
 {
     $id = post('user_id');
     $name = post('col');
     $value = !post($name);
     $profile = ProfileModel::where('user_id', $id)->get();
     //ensure that user always has a profile
     if (!$profile) {
         ProfileModel::getFromUser(UserModel::find($id));
         $profile = ProfileModel::where('user_id', $id)->get();
     }
     ProfileModel::where('user_id', $id)->update([$name => $value]);
     return ['value' => $value];
 }
コード例 #15
0
ファイル: UserSearch.php プロジェクト: Griff19/altbur
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'fullname', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
コード例 #16
0
ファイル: UserSearch.php プロジェクト: budipratama/admin_lte
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'first_update' => $this->first_update, 'last_update' => $this->last_update, 'active_date' => $this->active_date, 'rtries_count' => $this->rtries_count, 'rtries_count_use' => $this->rtries_count_use, 'change_pass_date' => $this->change_pass_date, 'passage1' => $this->passage1, 'passage2' => $this->passage2, 'flag_multiple' => $this->flag_multiple, 'last_action' => $this->last_action, 'flag_login' => $this->flag_login, 'superuser' => $this->superuser, 'lastvisit' => $this->lastvisit]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'first_user', $this->first_user])->andFilterWhere(['like', 'first_ip', $this->first_ip])->andFilterWhere(['like', 'last_user', $this->last_user])->andFilterWhere(['like', 'last_ip', $this->last_ip])->andFilterWhere(['like', 'usermode', $this->usermode])->andFilterWhere(['like', 'ip', $this->ip])->andFilterWhere(['like', 'accepted_ip', $this->accepted_ip]);
     return $dataProvider;
 }
コード例 #17
0
 /**
  * Execute the console command.
  * @return void
  */
 public function fire()
 {
     $base_path = base_path('');
     $this->info('Dependencies installing begins here! (plugin:install)');
     // DEPENDENCIES
     foreach (['RainLab.Translate', 'Flynsarmy.IdeHelper', 'BnB.ScaffoldTranslation', 'October.Drivers', 'RainLab.GoogleAnalytics', 'Genius.StorageClear'] as $required) {
         $this->info('Installing: ' . $required);
         Artisan::call("plugin:install", ['name' => $required]);
     }
     $this->info('Dependencies installed!');
     // THEME
     $this->info('Installing: oc-genius-theme');
     system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-theme themes/genius");
     Theme::setActiveTheme('genius');
     // ELIXIR
     $this->info('Installing: oc-genius-elixir');
     system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-elixir plugins/genius/elixir");
     // FORMS
     $this->info('Installing: oc-genius-forms');
     system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-forms plugins/genius/forms");
     // BACKUP
     $this->info('Installing: oc-genius-backup');
     system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-backup plugins/genius/backup");
     // GOOGLE ANALYTICS
     $this->info('Initial setup: AnalytcsSettings');
     if (!AnalytcsSettings::get('project_name')) {
         AnalytcsSettings::create(['project_name' => 'API Project', 'client_id' => '979078159189-8afk8nn2las4vk1krbv8t946qfk540up.apps.googleusercontent.com', 'app_email' => '*****@*****.**', 'profile_id' => '112409305', 'tracking_id' => 'UA-29856398-24', 'domain_name' => 'retrans.srv.br'])->gapi_key()->add(File::create(['data' => plugins_path('genius/base/assets/genius-analytics.p12')]));
     }
     // EMAIL
     $this->info('Initial setup: MailSettings');
     if (!MailSettings::get('mandrill_secret')) {
         MailSettings::create(['send_mode' => 'mandrill', 'sender_name' => 'Genius Soluções Web', 'sender_email' => '*****@*****.**', 'mandrill_secret' => 't27R2C15NPnZ8tzBrIIFTA']);
     }
     // BRAND
     $this->info('Initial setup: BrandSettings');
     if (!BrandSettings::get('app_init')) {
         BrandSettings::create(['app_name' => 'Genius Soluções Web', 'app_tagline' => 'powered by Genius', "primary_color_light" => "#e67e22", "primary_color_dark" => "#d35400", "secondary_color_light" => "#34495e", "secondary_color_dark" => "#2b3e50", "custom_css" => "", 'app_init' => true])->logo()->add(File::create(['data' => plugins_path('genius/base/assets/genius-logo.png')]));
     }
     // USUARIO BASE
     $this->info('Initial setup: User');
     $user = User::find(1);
     if (!$user->last_name) {
         $user->update(['first_name' => 'Genius', 'last_name' => 'Soluções Web', 'login' => 'genius', 'email' => '*****@*****.**', 'password' => 'genius', 'password_confirmation' => 'genius']);
         $user->avatar()->add(File::create(['data' => plugins_path('genius/base/assets/genius-avatar.jpg')]));
     }
     $this->info('Genius.Base is ready to rock!');
     $this->info('');
     $this->info('For Laravel Elixir setup run: php artisan elixir:init');
 }
コード例 #18
0
ファイル: User.php プロジェクト: jia253/centosYii2
 /**
  * Finds user by username
  *
  * @param  string      $username
  * @return static|null
  */
 public static function findByUsername($username)
 {
     $user = User::find()->where(['name' => $username])->asArray()->one();
     if ($user) {
         return new static($user);
     }
     return null;
     /*foreach (self::$users as $user) {
                 if (strcasecmp($user['username'], $username) === 0) {
                     return new static($user);
                 }
             }
     
             return null;*/
 }
コード例 #19
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
コード例 #20
0
ファイル: UserController.php プロジェクト: nizhuan1314/yii2
 public function actionIndex()
 {
     $model = new User();
     //分页
     $curPage = Yii::$app->request->get('page', 1);
     $pageSize = 3;
     //搜索
     $id = Yii::$app->request->get('id', '');
     $username = Yii::$app->request->get('username', '');
     $search = $id && $username ? ['like', $id, ['>=', 6]] : '';
     //查询语句
     $query = $model->find()->orderBy('created_at DESC');
     $data = $model->getPages($query, $curPage, $pageSize, $search);
     $pages = new Pagination(['totalCount' => $data['count'], 'pageSize' => $pageSize]);
     return $this->render('index', ['pages' => $pages, 'data' => $data, 'model' => $model]);
 }
コード例 #21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'telp' => $this->telp, 'jenis_kelamin' => $this->jenis_kelamin, 'type_user' => $this->type_user, 'newsletter' => $this->newsletter, 'activation_code' => $this->activation_code, 'status' => $this->status, 'last_login' => $this->last_login, 'role' => $this->role, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'user_create' => $this->user_create, 'user_update' => $this->user_update]);
     $query->andFilterWhere(['like', 'nama_depan', $this->nama_depan])->andFilterWhere(['like', 'nama_belakang', $this->nama_belakang])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'alamat', $this->alamat])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'deskripsi', $this->deskripsi])->andFilterWhere(['like', 'salt', $this->salt]);
     if (\Yii::$app->user->identity->role != 'superadmin') {
         $query->andWhere('role <> "superadmin"');
     }
     return $dataProvider;
 }
コード例 #22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'confirmed_at' => $this->confirmed_at, 'blocked_at' => $this->blocked_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'flags' => $this->flags, 'latitud' => $this->latitud, 'longitud' => $this->longitud]);
     if (strtolower($this->esActivo) == strtolower(Yii::t('core', 'Yes'))) {
         $query->andFilterWhere(['esActivo' => $this->esActivo == 0]);
     } else {
         if (strtolower($this->esActivo) == strtolower(Yii::t('core', 'No'))) {
             $query->andFilterWhere(['esActivo' => $this->esActivo == 1]);
         }
     }
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'unconfirmed_email', $this->unconfirmed_email])->andFilterWhere(['like', 'registration_ip', $this->registration_ip])->andFilterWhere(['like', 'direccion', $this->direccion]);
     return $dataProvider;
 }
コード例 #23
0
ファイル: UserSearch.php プロジェクト: NeroJz/admbackend
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $query->joinWith('pi');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     /* $query->andFilterWhere([
            'id' => $this->id,
            'pi_name' => $this->pi_id,
           // 'status' => $this->status,
           // 'online_status' => $this->online_status,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);
        */
     $query->andFilterWhere(['like', 'personal_information.pi_name', $this->pi])->andFilterWhere(['like', 'status', 10])->andFilterWhere(['like', 'username', $this->username]);
     return $dataProvider;
 }
コード例 #24
0
ファイル: _form.php プロジェクト: wuwenhan/huoqiwang
use yii\helpers\ArrayHelper;
use yii\web\View;
use xj\ueditor\Ueditor;
use kartik\file\FileInput;
/* @var $this yii\web\View */
/* @var $model backend\models\Article */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="article-form">
    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(\backend\models\User::find()->asArray()->all(), 'id', 'username'));
?>

    <?php 
echo '<label class="control-label">图片</label>';
echo FileInput::widget(['model' => $model, 'attribute' => 'logo', 'pluginOptions' => ['uploadExtraData' => ['album_id' => 20, 'cat_id' => 'Nature'], 'maxFileCount' => 10, 'initialCaption' => $model->logo, "showUpload" => false]]);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\backend\models\Category::get(0, \backend\models\Category::find()->asArray()->all()), 'id', 'str_label'));
?>
    <?php 
echo $form->field($model, 'status')->dropDownList(\backend\models\Article::getArrayStatus());
?>
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
コード例 #25
0
 /**
  * 系统初始化,创建管理员
  * 
  * */
 public function actionCreateAdmin()
 {
     $params = Yii::$app->request->post("CreateUser");
     $user_name = empty($params['username']) ? '' : $params['username'];
     $pwd = empty($params['password']) ? '' : $params['password'];
     $confirm_pwd = empty($params['confirmPassword']) ? '' : $params['confirmPassword'];
     $email = empty($params['email']) ? '' : $params['email'];
     $res = new Response();
     if ($pwd != $confirm_pwd) {
         $res->success = false;
         $res->message = '两次密码输入不一样';
     }
     $is_user = User::find()->all();
     //判断是否创建过管理员帐号
     if (!empty($is_user)) {
         $res->success = false;
         $res->message = '该系统已经创建过测试帐号';
     }
     $user = new User();
     $user->username = $user_name;
     $user->password_hash = $pwd;
     $user->email = $email;
     if ($user->validate() && $user->save()) {
         $res->success = true;
         $res->message = '创建系统管理员成功';
         //为超级管理员授权
         $auth = Yii::$app->authManager;
         // //创建管理员
         // $role = $auth->createRole('admin');
         // $role->description = '系统管理员';
         // $auth->add($role);
         // $auth->addChild($role, $privileges_manage);
         // $role = $auth->getRole( 'admin' );
         // $auth->assign($role, $user_id);
         if (!$auth->assign($role, $user->user_id)) {
             $res->success = false;
             $res->message = '创建系统管理员权限失败';
         }
     } else {
         $res->success = false;
         $res->message = '创建系统管理员失败';
     }
     $res->to_json();
 }
コード例 #26
0
ファイル: User.php プロジェクト: jaybril/www.mimgpotea.com
 public function getUserList()
 {
     $list = User::find()->orderBy('registerTime')->all();
 }
コード例 #27
0
 public static function getUsername()
 {
     $UsernameID = User::find()->all();
     $listData = ArrayHelper::map($UsernameID, 'username', 'username');
     return $listData;
 }
コード例 #28
0
ファイル: auth_assignment.php プロジェクト: vrigzalejo/YiiHey
<?php

/**
 * Created by PhpStorm.
 * User: vrigzlinuxmint13
 * Date: 9/6/15
 * Time: 4:06 PM
 */
use backend\models\AuthItem;
use backend\models\User;
// Find all users first, else it will stop the script
if (!empty($getAllUsers = User::find()->all())) {
    // Find all auth items first, else it will stop the script
    if (!empty($getAllAuthItems = AuthItem::find()->all())) {
        foreach ($getAllAuthItems as $authItems) {
            $allAuthItems[] = $authItems->name;
        }
    } else {
        exit("No 'auth item' data in '" . AuthItem::tableName() . "' table." . PHP_EOL);
    }
    // Check if 'admin' exists, else stop the script
    if (in_array('admin', $allAuthItems)) {
        $getAdminOnly = array_search('admin', $allAuthItems);
    } else {
        exit("Create an 'admin' first in " . AuthItem::tableName() . " table" . PHP_EOL);
    }
    // Random created/updated dates
    $created = $faker->dateTimeBetween('-7 days', 'now')->format('Y-m-d H:i:s');
    foreach ($getAllUsers as $user) {
        // Well, search me first before anything else :D
        if ($user->username === 'vrigzalejo') {
コード例 #29
0
ファイル: User.php プロジェクト: cindyming/yii-advance
 public function validateName($name)
 {
     $existUser = User::find()->where(['=', 'username', $this->username])->one();
     if ($existUser && $existUser->id != $this->id) {
         return false;
     } else {
         return true;
     }
 }
コード例 #30
0
ファイル: UserController.php プロジェクト: kuzma17/asu
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => User::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }