Ejemplo n.º 1
0
 public function actionDoadd()
 {
     $adminuser = new AdminUser();
     $adminuser->username = $_POST['username'];
     $adminuser->password = md5($_POST['password']);
     if ($adminuser->save()) {
         echo $this->success("添加成功", "index.php?r=user", '1');
     } else {
         echo $this->error("添加失败", "index.php?r=user", '1');
     }
 }
Ejemplo n.º 2
0
 /**
  * 后台验证登陆操作
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function check()
 {
     $username = Input::get('username', null);
     $password = Input::get('password', null);
     if ($username and $password) {
         $user = AdminUser::where('username', '=', $username)->first();
         if (count($user)) {
             if (sha1($password) == $user->password and $user->enable) {
                 Session::set('admin_user', $user->username);
                 Session::set('admin_id', $user->id);
                 Session::set('admin_level', $user->level);
                 if ($user->level == 1) {
                     return redirect('admin/orders/show');
                 } else {
                     return redirect('admin/promote/user/center');
                 }
             } else {
                 flash('密码错误或用户已禁用~');
                 return redirect()->back();
             }
         } else {
             flash('用户不存在~');
             return redirect()->back();
         }
     } else {
         flash('用户名或密码不能为空~');
         return redirect()->back();
     }
 }
Ejemplo n.º 3
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = AdminUser::findByUsername($this->username);
     }
     return $this->_user;
 }
Ejemplo n.º 4
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getAdminUser()
 {
     if ($this->_user === false) {
         $this->_user = AdminUser::findByUsername($this->username);
     }
     return $this->_user;
 }
Ejemplo n.º 5
0
 public static function sendMessageToAll($message)
 {
     $query = "";
     $users_id = AdminUser::getAllUserId();
     for ($i = 0; $i < count($users_id); $i++) {
         $query .= "INSERT INTO messages (id_user1, id_user2, text, date, id_who_delete) VALUES(-1, '{$users_id[$i]}', '{$message}', NOW(), -1);";
     }
     \Yii::$app->db->createCommand($query)->execute();
 }
Ejemplo n.º 6
0
 public function handle($request, Closure $next)
 {
     $uid = Session::get('admin_id');
     $level = Session::get('admin_level');
     if (AdminUser::find($uid ? $uid : 0) and $level == 1) {
         return $next($request);
     } else {
         Session::remove('admin_id');
         Session::remove('admin_user');
         Session::remove('admin_level');
         return redirect('admin/login');
     }
 }
Ejemplo n.º 7
0
                    <?php 
echo Html::a('Cập nhật', ['update', 'id' => $model->id, 'skill_id' => $model->skill_id], ['class' => 'btn btn-primary']);
?>
                    <?php 
echo Html::a('Xóa', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Bạn có chắc muốn xóa Quiz này?', 'method' => 'post']]);
?>
                </p>
            </div>
        </header>
        <div class="body">
            <?php 
$skillName = Skill::findOne($model->skill_id)->title;
if ($created_by = AdminUser::findOne($model->created_by)) {
    $created_by = $created_by->fullname != '' ? $created_by->fullname : $created_by->username;
}
if ($updated_by = AdminUser::findOne($model->updated_by)) {
    $updated_by = $updated_by->fullname != '' ? $updated_by->fullname : $updated_by->username;
}
switch ($model->difficulty) {
    case '0':
        $difficulty = '<span class="btn-success label">Dễ</span>';
        break;
    case '1':
        $difficulty = '<span class="btn-warning label">Trung bình</span>';
        break;
    default:
        $difficulty = '<span class="btn-danger label">Khó</span>';
        break;
}
?>
            <?php 
 /**
  * Filter the query by a related \App\Models\AdminUser object
  *
  * @param \App\Models\AdminUser|ObjectCollection $adminUser The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildAdminUserCredentialQuery The current query, for fluid interface
  */
 public function filterByAdminUser($adminUser, $comparison = null)
 {
     if ($adminUser instanceof \App\Models\AdminUser) {
         return $this->addUsingAlias(AdminUserCredentialTableMap::COL_ADMIN_USER_ID, $adminUser->getId(), $comparison);
     } elseif ($adminUser instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(AdminUserCredentialTableMap::COL_ADMIN_USER_ID, $adminUser->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByAdminUser() only accepts arguments of type \\App\\Models\\AdminUser or Collection');
     }
 }
 /**
  * @param ChildAdminUser $adminUser The ChildAdminUser object to add.
  */
 protected function doAddAdminUser(ChildAdminUser $adminUser)
 {
     $this->collAdminUsers[] = $adminUser;
     $adminUser->setTranslationLanguage($this);
 }
Ejemplo n.º 10
0
 /**
  * 商家首页
  *
  * @return $this
  */
 public function promote()
 {
     $data = [];
     $data['price'] = 0;
     $user = AdminUser::find(Session::get('admin_id'));
     if ($user->coupon) {
         $data['code'] = $user->coupon->coupon_code;
         $data['orders'] = PhoneOrder::where(['coupon_id' => $user->coupon->id, 'coupon_pay' => 0])->get();
     } else {
         $data['code'] = null;
         $data['orders'] = null;
     }
     if ($data['orders']) {
         foreach ($data['orders'] as $order) {
             if ($order->pay_type == 1) {
                 $data['price'] += 100;
             }
         }
     }
     return view('admin.promote.show')->with($data);
 }
Ejemplo n.º 11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if ($id) {
         $coupon = AdminCoupon::find($id);
         if ($coupon) {
             $user = AdminUser::where(['coupon_id' => $coupon->id])->first();
             if ($user) {
                 $user->coupon_id = 0;
                 $user->save();
             }
             $coupon->delete();
         }
     }
     return redirect()->back();
 }
Ejemplo n.º 12
0
 /**
  * Exclude object from result
  *
  * @param   ChildAdminUser $adminUser Object to remove from the list of results
  *
  * @return $this|ChildAdminUserQuery The current query, for fluid interface
  */
 public function prune($adminUser = null)
 {
     if ($adminUser) {
         $this->addUsingAlias(AdminUserTableMap::COL_ID, $adminUser->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 13
0
 /**
  * @param ChildAdminUser $adminUser The ChildAdminUser object to add.
  */
 protected function doAddAdminUser(ChildAdminUser $adminUser)
 {
     $this->collAdminUsers[] = $adminUser;
     $adminUser->setProfessor($this);
 }
 /**
  * Filter the query by a related \App\Models\AdminUser object
  *
  * @param \App\Models\AdminUser|ObjectCollection $adminUser the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildTranslationLanguageQuery The current query, for fluid interface
  */
 public function filterByAdminUser($adminUser, $comparison = null)
 {
     if ($adminUser instanceof \App\Models\AdminUser) {
         return $this->addUsingAlias(TranslationLanguageTableMap::COL_ID, $adminUser->getLanguageId(), $comparison);
     } elseif ($adminUser instanceof ObjectCollection) {
         return $this->useAdminUserQuery()->filterByPrimaryKeys($adminUser->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByAdminUser() only accepts arguments of type \\App\\Models\\AdminUser or Collection');
     }
 }
Ejemplo n.º 15
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aAdminCredential) {
         $this->aAdminCredential->removeAdminUserCredential($this);
     }
     if (null !== $this->aAdminUser) {
         $this->aAdminUser->removeAdminUserCredential($this);
     }
     $this->admin_user_id = null;
     $this->admin_credential_id = null;
     $this->perm_read = null;
     $this->perm_write = null;
     $this->perm_exec = null;
     $this->created_at = null;
     $this->updated_at = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->applyDefaultValues();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
Ejemplo n.º 16
0
 public function actionUnlockUser()
 {
     $post = Yii::$app->request->post();
     AdminUser::unlockedUser($post['user_id']);
 }
Ejemplo n.º 17
0
 /**
  * Finds the AdminUser model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AdminUser the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AdminUser::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 18
0
 /**
  * @param ChildAdminUser $adminUser The ChildAdminUser object to add.
  */
 protected function doAddAdminUser(ChildAdminUser $adminUser)
 {
     $this->collAdminUsers[] = $adminUser;
     $adminUser->setStudent($this);
 }
Ejemplo n.º 19
0
 public static function getGroupIdByUser($id)
 {
     // $query = Yii::$app->db->createCommand()->select('group_id')->from('usergroup_map')->where(['group_id'=>$id]);
     $query = AdminUser::find()->select(['usergroup_map.group_id'])->joinWith('usergroup_map')->where(['usergroup_map.userid' => $id]);
     return $query->one();
 }