Esempio n. 1
0
 protected function user()
 {
     if (!isset($this->user)) {
         $user = new UserModel();
         $this->user = $user->getById($this->aAttributes['user_id']);
     }
     return $this->user;
 }
Esempio n. 2
0
 /**
  * 编辑用户信息
  */
 function edit()
 {
     //得到传来的ID得到用户信息
     $user_id = trim($_GET['id']);
     $users = new UserModel();
     $list = $users->getById($user_id);
     $this->assign('user_list', $list);
     $this->display();
 }
 public function getAllUsers()
 {
     $userModel = new UserModel();
     $database = new Database();
     $allId = $this->getAllId($database);
     $allUsers = array();
     foreach ($allId as $id) {
         array_push($allUsers, $userModel->getById($id));
     }
     return $allUsers;
 }
Esempio n. 4
0
 static function getById($id)
 {
     if (!$id) {
         return false;
     }
     $model = new UserModel();
     $result = $model->getById($id);
     if (!$result) {
         return false;
     }
     return $result[0];
 }
 public function isGranted($role)
 {
     $session = Request::getInstance()->getSession();
     $model = new UserModel();
     switch ($role) {
         case self::USER_IS_INACTIVE:
             $user = $model->getById($session->getInstance()->get('id'));
             if ($user) {
                 return !$user->getActive();
             }
             break;
         case self::USER_IS_ADMIN:
             if ($session->isConnected()) {
                 $user = $model->getById($session->get('id'));
                 return $user->getAccountLevel() == UserModel::ACCOUNT_LEVEL_ADMIN;
             }
             break;
         case self::USER_IS_CONNECTED:
             return $session->isConnected();
         case self::USER_IS_NOT_CONNECTED:
             return true;
     }
     return false;
 }
Esempio n. 6
0
 static function UserloginAddlog($id)
 {
     $userlogin = new UserLoginModel();
     $user = new UserModel();
     $udata = $user->getById($id);
     $data = array('uid' => $id, 'updated' => time(), 'updateip' => Tool_Fnc::realip(), 'fqy' => 1);
     if ($fqy = Member::LoginToday($id)) {
         if ($fqy['s'] == 1) {
             $data['fqy'] = $fqy['fqy'] + 1;
         } elseif ($fqy['s'] == 0) {
             $data['fqy'] = $fqy['fqy'];
         }
     }
     $userlogin->insert($data);
     //添加登陆日志
     $type = self::$type;
     if ($fqy) {
         if ($fqy['s'] == 1) {
             if ($data['fqy'] <= 10) {
                 $credit = $data['fqy'] * 10;
             } else {
                 $credit = 100;
             }
             self::AddCredit($id, $credit);
             self::AddLevelLog($id, 1, $credit, $data['fqy']);
         } elseif ($fqy['s'] == 0) {
             //同一天
             //$credit = 10;
         }
     } else {
         //第一次
         $credit = 10;
         self::AddCredit($id, $credit);
         self::AddLevelLog($id, 1, $credit, $data['fqy']);
     }
 }
Esempio n. 7
0
 public function addmoney()
 {
     $userid = I('id', NULL);
     $user = new UserModel();
     $data = $user->getById($userid);
     if (!empty($userid)) {
         $this->assign('data', $data);
         $this->display();
     } else {
         $this->message2('非法操作', __APP__ . '/Admin');
     }
 }