当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_User类代码示例

本文整理汇总了PHP中Model_User的典型用法代码示例。如果您正苦于以下问题:PHP Model_User类的具体用法?PHP Model_User怎么用?PHP Model_User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Model_User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fetchDaysWithOrWoutGym

 public function fetchDaysWithOrWoutGym($date1, $date2, Model_User $user)
 {
     $select = "SELECT count(*) as total, date from `" . $this->_name . "`\r\n\t\t\t\t\t\tWHERE userId = " . $user->getId() . " \r\n\t\t\t\t\t\t\tAND\tdate between '" . $date1 . "' and '" . $date2 . "'\r\n\t\t\t\t\t\t\t\tGROUP BY date";
     $data = $this->_db->query($select)->fetchAll();
     $datesInBetween = array($date1);
     while (end($datesInBetween) < $date2) {
         $datesInBetween[] = date('Y-m-d', strtotime(end($datesInBetween) . ' +1 day'));
     }
     $final['datesInBetween'] = implode(', ', $datesInBetween);
     $final['daysWithGym'] = null;
     foreach ($datesInBetween as $dates) {
         foreach ($data as $date) {
             if (in_array($dates, $date)) {
                 $final['daysWithGym'][] = $date['date'];
             }
         }
         if (is_array($final['daysWithGym'])) {
             if (!in_array($dates, $final['daysWithGym'])) {
                 $final['daysWithoutGym'][] = $dates;
             }
         }
     }
     $final['countDaysWithGym'] = count($final['daysWithGym']);
     $final['countDaysWithoutGym'] = count($final['daysWithoutGym']);
     return $final;
 }
开发者ID:AlexanderMazaletskiy,项目名称:gym-Tracker-App,代码行数:26,代码来源:Exercises.php

示例2: get_notices

 /**
  * Возврващает все доступные уведомления для пользователя
  * @param Model_User $user
  * @return array
  */
 public function get_notices(Model_User $user)
 {
     $notices = array();
     $notice_config = Kohana::$config->load('notices_types');
     $notices_types = $notice_config['types'];
     $services = $user->get_user_services_ids();
     $selected_columns = $notice_config['selected_columns'];
     $query = DB::select()->from('notices')->select_array($selected_columns)->join(array('notices_services', 'notices_services'), 'left')->on('notices.id', '=', 'notices_services.notice_id')->join(array('notices_users', 'notices_users'), 'left')->on('notices.id', '=', 'notices_users.notice_id')->where('notices_users.user_id', '=', $user->id);
     if (!empty($services)) {
         $query->or_where('notices_services.service_id', 'in', $services);
     }
     $iteration = 0;
     foreach ($query->execute() as $q) {
         $config = $notices_types[$q['type']];
         if ($iteration == $q['id']) {
             $iteration++;
         }
         $id = $config['unique'] == false ? $q['id'] : $iteration;
         if (!isset($notices[$id])) {
             $notices[$id] = array('title' => $q['title'], 'text' => $q['text'], 'date' => $q[$config['date_column']], 'read' => $q[$config['read_column']]);
         }
         if ($config['for'] == 'service') {
             $service = DB::select(array('services.name', 'name'), array('org_type.name', 'org_type'))->from('services')->join(array('org_types', 'org_type'))->on('org_type.id', '=', 'services.org_type')->where('services.id', '=', $q['service_id'])->execute()->current();
             $notices[$id]['for'][] = $service['org_type'] . ' ' . '&laquo;' . $service['name'] . '&raquo;';
         }
         $iteration++;
     }
     usort($notices, array($this, 'sort_func'));
     return $notices;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:35,代码来源:notice.php

示例3: indexAction

 public function indexAction()
 {
     //$this->_redirect('/?cache');
     //desabilita layout
     //$this->_helper->layout()->disableLayout();
     //echo "teste";
     $this->cache = Zend_Registry::get('cache_FS');
     $devol = new Model_User();
     $user = $devol->getUserById(66);
     //var_dump('user: ', $user);
     echo "<br><br><br>";
     //var_dump('cache: ', $this->cache);
     $userCache = $this->cache->load('userCache');
     echo "<br><br><br>";
     //var_dump('userCache: ', $userCache);
     //recupera do cache
     if ($userCache == false) {
         //add fechall from db into cache
         $this->cache->save($user, 'userCache');
     }
     echo "<br><br>------------------------";
     $this->cache->save('conteudo variavel teste2 eh este!!', 'teste2');
     $this->cache->save('conteudo variavel teste3 eh este!!', 'teste3');
     echo "<br>teste2: " . $this->cache->load('teste2');
     echo "<br>teste3: " . $this->cache->load('teste3');
 }
开发者ID:Lazaro-Gallo,项目名称:psmn,代码行数:26,代码来源:CacheController.php

示例4: profile

 function profile()
 {
     $idu = isset($_SESSION['idu']) ? $_SESSION['idu'] : 0;
     $iduser = isset($_GET['id']) ? $_GET['id'] : 0;
     $this->stat->saveStat($idu, "users/profile [{$iduser}]");
     if (!empty($idu)) {
         if (!empty($iduser)) {
             $model = new Model_User();
             $profiles = $model->getUserProfile($idu, $iduser);
             if (count($profiles) > 0) {
                 $profile = $profiles[0];
             }
             if (!empty($profile)) {
                 $photos = $model->getPhotoList($iduser);
                 $this->template->vars('photos', $photos);
                 $this->template->vars('profile', $profile);
                 $this->template->view('index', $idu > 0);
             } else {
                 header('Location:' . WEB_APP);
             }
         } else {
             header('Location:' . WEB_APP);
         }
     } else {
         header('Location:' . WEB_APP . '/enter');
     }
 }
开发者ID:aliasnash,项目名称:flirt-web-p,代码行数:27,代码来源:users.php

示例5: _login

 /**
  * Logs a user in.
  *
  * @param   string   username
  * @param   string   password
  * @param   boolean  enable autologin
  * @return  boolean
  */
 protected function _login($user, $password, $remember)
 {
     if (!is_object($user)) {
         $username = $user;
         // Load the user
         $user = new Model_User($username);
     }
     // If the passwords match, perform a login
     if ($user->has('roles', 1) and $user->password === $password) {
         if ($remember === TRUE) {
             // Create a new autologin token
             $token = ORM::factory('user_token');
             // Set token data
             $token->user_id = $user->id;
             $token->expires = time() + $this->_config['lifetime'];
             $token->save();
             // Set the autologin cookie
             Cookie::set('authautologin', $token->token, $this->_config['lifetime']);
         }
         // Finish the login
         $this->complete_login($user);
         return TRUE;
     }
     // Login failed
     return FALSE;
 }
开发者ID:alle,项目名称:auto-modeler,代码行数:34,代码来源:orm.php

示例6: action_index

 public function action_index()
 {
     $count = ORM::factory('User')->count_all();
     if ($count === 0) {
         $this->template->content = View::factory('install/index');
         if ($this->request->method() === Request::POST) {
             if (!Security::check($this->request->param('id'))) {
                 throw new Exception("Bad token!");
             }
             $post = Validation::factory($_POST)->rule('username', 'not_empty')->rule('email', 'not_empty')->rule('email', 'email')->rule('password', 'not_empty')->rule('password', 'min_length', array(':value', '8'))->rule('password2x', 'not_empty')->rule('password', 'matches', array(':validation', 'password', 'password2x'));
             if ($post->check()) {
                 $user = new Model_User();
                 $post = $this->request->post();
                 $user->values($post)->save();
                 $adminRole = ORM::factory('Role')->where('name', '=', 'admin')->find();
                 $loginRole = ORM::factory('Role')->where('name', '=', 'login')->find();
                 $user->add('roles', $loginRole);
                 $user->add('roles', $adminRole);
                 $this->redirect('install/successful');
             } else {
                 $this->redirect('install/oops');
             }
         }
     } else {
         $this->redirect('');
     }
 }
开发者ID:reGative,项目名称:Phorumph,代码行数:27,代码来源:Install.php

示例7: indexAction

 public function indexAction()
 {
     $this->view->data = "hello";
     $muser = new Model_User();
     $q = $muser->listall2();
     print_r($q);
 }
开发者ID:backviet01,项目名称:zegome-main-web,代码行数:7,代码来源:IndexController.php

示例8: action_do

 public function action_do()
 {
     $user_id = $this->request->param('id');
     $hash = $this->request->param('id2');
     $password_recovery = new Model_Password_Recovery();
     $check_hash = $password_recovery->check($user_id, $hash);
     if ($check_hash !== true) {
         throw new Exception("This hash is not a password recovery request!");
     }
     $view = View::factory('forgot_password/recovery');
     if ($this->request->method() === Request::POST) {
         if (!Security::check($this->request->post('csrf_secure'))) {
             throw new Exception("Bad token!");
         }
         $password = $this->request->post('password');
         $confirm = $this->request->post('confirm');
         if ($password !== $confirm) {
             throw new Exception("Passwords did not match!");
         }
         $user = new Model_User();
         $password = crypt($password, 'generatedsalt');
         $change_password = $user->recover_password($password, $user_id);
         if (!$change_password) {
             throw new Exception("Error with changing a password!");
         }
         $chmod_attemp = $password_recovery->chmod_attemp($hash);
         if (!$chmod_attemp) {
             throw new Exception("False");
         }
         $this->redirect('');
     }
     $this->template->content = $view->render();
 }
开发者ID:reGative,项目名称:Phorumph,代码行数:33,代码来源:Password.php

示例9: actionSetup

 /**
  * 职位设置
  */
 public function actionSetup()
 {
     $this->_modelUser = $this->_getGlobalData('Model_User', 'object');
     $this->_setupFilePath = CACHE_DIR . '/program/position.cache.php';
     if (file_exists($this->_setupFilePath)) {
         $dataList = $this->_getGlobalData('program/position');
         foreach ($dataList as $key => &$list) {
             $list['url_del'] = Tools::url(CONTROL, 'SetupDel', array('zp' => 'Program', 'Id' => $key));
         }
     } else {
         $dataList = null;
     }
     if ($dataList !== null) {
         $users = $this->_modelUser->findByDepartment(self::DEPARTMENT_IT);
         foreach ($users as $user) {
             if (!$user['position_id']) {
                 continue;
             }
             if (array_key_exists($user['position_id'], $dataList)) {
                 if (!is_array($dataList[$user['position_id']]['users'])) {
                     $dataList[$user['position_id']]['users'] = array();
                 }
                 array_push($dataList[$user['position_id']]['users'], $user);
             }
         }
     }
     $this->_view->assign('dataList', $dataList);
     $this->_utilMsg->createPackageNavBar();
     $this->_view->display();
 }
开发者ID:huangwei2wei,项目名称:kfxt,代码行数:33,代码来源:ProgramUser.class.php

示例10: maskUserNamesAction

 /**
  * Maskuje nazwiska i adresy email uzytkownikow
  */
 public function maskUserNamesAction()
 {
     $oUser = new Model_User();
     $aUsers = $oUser->getAll();
     foreach ($aUsers as $aUser) {
         if (in_array($aUser['name'], array('Chodorowski', 'TestUser'))) {
             continue;
         }
         $oUser = new Model_User();
         $oUser->user_id = $aUser['user_id'];
         // pick random name
         $sName = chr(rand(65, 90));
         $sName .= chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122));
         $sName .= chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122));
         $oUser->name = $sName;
         $oUser->email = sprintf('%s.%s@catering.wsiz.wroc.pl', strtolower($aUser['fname']), strtolower($sName));
         // save
         if (!$oUser->save()) {
             break;
         }
         unset($oUser);
     }
     // foreach
     $this->indexAction('Maskowanie wykonane pomyslnie.');
 }
开发者ID:maxwroc,项目名称:PHP,代码行数:28,代码来源:Service.php

示例11: action_create

 public function action_create()
 {
     $this->template->page_title = 'Create Page';
     $user = new Model_User();
     $session = Session::instance()->get('user');
     $view = View::factory('cp/pages/create');
     $view->author = $user->get_user_by_session_id($session);
     if ($this->request->method() === Request::POST) {
         if (!Security::check($this->request->post('csrf_token'))) {
             throw new HTTP_Exception_401("Bad token!");
         }
         $post_title = $this->request->post('title');
         $post_content = $this->request->post('content');
         $post_author = $this->request->post('author');
         $post_date = time();
         if (empty($post_title) && empty($post_content) && empty($post_author) && empty($post_date)) {
             throw new Exception('Please don`t make empty fields!');
         }
         $page = new Model_Page();
         $data = array('title' => $post_title, 'content' => $post_content, 'author' => $post_author, 'date' => $date);
         $insert_page = $page->insert_page($data);
         if (!$insert_page) {
             throw new Exception('Check if you are connected to database!');
         }
         $this->request->redirect('cp/pages');
     }
     $this->template->content = $view->render();
 }
开发者ID:reGative,项目名称:Cosmoss,代码行数:28,代码来源:pages.php

示例12: login

 public function login(Model_User $user)
 {
     $select = $this->_db->select()->from(array('u' => 'users'))->where('email = ?', $user->email)->where('password = ?', $user->password);
     $data = (array) $this->_db->fetchRow($select);
     $user->setOptions($data);
     return $user;
 }
开发者ID:kminkov,项目名称:Blog,代码行数:7,代码来源:User.php

示例13: check

 /**
  * 检测用户是否对URI有访问权限的
  *
  * @param unknown_type $userid
  * @return boolean
  */
 public static function check($userid, $controller, $action)
 {
     // 非普通用户不查检权限
     if (QP_Session_Session::get('login_priv') != 1) {
         return true;
     }
     // 得到配置
     $privcfg = QP_Sys::config('privconfig');
     // 如果不使用权限则永远返回 true
     if (!$privcfg['enable']) {
         return true;
     }
     // 判断是否在全局访问的资源中
     $allRes = strtolower($controller . '_*');
     $currentRes = strtolower($controller . '_' . $action);
     if (in_array($currentRes, $privcfg['allow']) || in_array($allRes, $privcfg['allow'])) {
         return true;
     }
     // 得到用户所在的组的所有权限
     $userModel = new Model_User();
     $userInfo = $userModel->userinfo($userid);
     $privModel = new Model_Priv();
     $resourceArr = $privModel->getResource($userInfo['groupid']);
     // 判断是否在权限组中
     return in_array($currentRes, $resourceArr) || in_array($allRes, $resourceArr);
 }
开发者ID:laiello,项目名称:quickbug,代码行数:32,代码来源:Priv.php

示例14: deleteOrganisationById

 public function deleteOrganisationById($orgId)
 {
     $wepModel = new Model_Wep();
     // Delete Activities
     $actCollModel = new Model_ActivityCollection();
     $activities = $actCollModel->getActivityIdsByAccount($orgId);
     $activityModel = new Model_Activity();
     foreach ($activities as $activity) {
         $activityModel->deleteActivityById($activity['id']);
     }
     // Delete Defaults
     $wepModel->deleteRow('default_field_groups', 'account_id', $orgId);
     $wepModel->deleteRow('default_field_values', 'account_id', $orgId);
     // Delete registry info
     $regModel = new Model_RegistryInfo();
     $regModel->deleteRegistryInfo($orgId);
     // Delete Users
     $userModel = new Model_User();
     $users = $userModel->getAllUsersByAccountId($orgId);
     foreach ($users as $user) {
         $this->deleteUserById($user['user_id']);
     }
     // Delete account
     $wepModel->deleteRow('iati_activities', 'account_id', $orgId);
     $wepModel->deleteRow('account', 'id', $orgId);
 }
开发者ID:relyd,项目名称:aidstream,代码行数:26,代码来源:Admin.php

示例15: action_login

 public function action_login()
 {
     if ($this->logged === TRUE) {
         header('Location: /');
         exit;
     }
     $model_Auth = new Model_Auth();
     // obsluga formularza
     if (isset($_POST['send'])) {
         $valid = $model_Auth->loginValidation($_POST);
         if ($valid === TRUE) {
             $model_User = new Model_User();
             $userid = $model_User->getIdFromName($_POST['name']);
             // loguje użytkownika
             Auth::instance()->login($userid);
             // przekierowanie na glowna strone
             header('Location: /');
             exit;
         }
     }
     // wybieram widok
     $this->view = View::factory('template');
     // ustawiam dane w widoku
     $this->view->title = 'Zaloguj się';
     $this->view->content = View::factory('auth/login');
     $this->view->content->valid = $valid;
 }
开发者ID:adrianpl20,项目名称:oop,代码行数:27,代码来源:Auth.php


注:本文中的Model_User类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。