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


PHP Model_User::where方法代码示例

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


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

示例1: current

 /**
  * returns the current user used when navidating the site, not the current loged user!
  * @return Model_User
  */
 public static function current()
 {
     //we don't have so let's retrieve
     if (self::$_current === NULL and Request::current()->param('seoname') != NULL and strtolower(Request::current()->action()) == 'profile' and strtolower(Request::current()->controller()) == 'user') {
         self::$_current = new self();
         self::$_current = self::$_current->where('seoname', '=', Request::current()->param('seoname'))->where('status', '=', Model_User::STATUS_ACTIVE)->limit(1)->cached()->find();
     }
     return self::$_current;
 }
开发者ID:demoic,项目名称:openclassifieds2,代码行数:13,代码来源:user.php

示例2: action_index

 /**
  * Handle GET requests.
  */
 public function action_index()
 {
     try {
         if (is_numeric($this->request->param('id'))) {
             $this->action_get();
         } else {
             $output = array();
             $users = new Model_User();
             $users->where('status', '=', Model_User::STATUS_ACTIVE);
             //filter results by param, verify field exists and has a value and sort the results
             $users->api_filter($this->_filter_params)->api_sort($this->_sort);
             //how many? used in header X-Total-Count
             $count = $users->count_all();
             //pagination with headers
             $pagination = $users->api_pagination($count, $this->_params['items_per_page']);
             $users = $users->cached()->find_all();
             //as array
             foreach ($users as $user) {
                 $output[] = self::get_user_array($user);
             }
             $this->rest_output(array('users' => $output), 200, $count, $pagination !== FALSE ? $pagination : NULL);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
     }
 }
开发者ID:zhangkom,项目名称:openclassifieds2,代码行数:29,代码来源:users.php

示例3: action_profile

 public function action_profile()
 {
     $this->auto_render = FALSE;
     $xml = 'FALSE';
     $seoname = $this->request->param('seoname', NULL);
     if ($seoname !== NULL) {
         $user = new Model_User();
         $user->where('seoname', '=', $seoname)->where('status', '=', Model_User::STATUS_ACTIVE)->limit(1)->cached()->find();
         if ($user->loaded()) {
             $info = array('title' => 'RSS ' . $user->name, 'pubDate' => date("r"), 'description' => $user->name . ' - ' . $user->description, 'generator' => 'Open Classifieds');
             $items = array();
             //last ads, you can modify this value at: advertisement.feed_elements
             $ads = new Model_Ad();
             $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('id_user', '=', $user->id_user)->order_by('published', 'desc')->limit(Core::config('advertisement.feed_elements'));
             $ads = $ads->cached()->find_all();
             foreach ($ads as $a) {
                 $url = Route::url('ad', array('category' => $a->category->seoname, 'seotitle' => $a->seotitle));
                 $item = array('title' => htmlspecialchars($a->title, ENT_QUOTES), 'link' => $url, 'pubDate' => Date::mysql2unix($a->published), 'description' => htmlspecialchars(Text::removebbcode($a->description), ENT_QUOTES), 'guid' => $url);
                 if ($a->get_first_image() !== NULL) {
                     $item['description'] = '<img src="' . $a->get_first_image() . '" />' . $item['description'];
                 }
                 $items[] = $item;
             }
             $xml = Feed::create($info, $items);
         }
     }
     $this->response->headers('Content-type', 'text/xml');
     $this->response->body($xml);
 }
开发者ID:demoic,项目名称:openclassifieds2,代码行数:29,代码来源:feed.php

示例4: action_index

 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('User Profile')));
     $seoname = $this->request->param('seoname', NULL);
     if ($seoname !== NULL) {
         $user = new Model_User();
         $user->where('seoname', '=', $seoname)->limit(1)->cached()->find();
         if ($user->loaded()) {
             $this->template->title = __('User Profile') . ' - ' . $user->name;
             //$this->template->meta_description = $user->name;//@todo phpseo
             $this->template->bind('content', $content);
             $ads = new Model_Ad();
             $ads = $ads->where('id_user', '=', $user->id_user)->where('status', '=', Model_Ad::STATUS_PUBLISHED)->order_by('created', 'desc')->cached()->find_all();
             // case when user dont have any ads
             if ($ads->count() == 0) {
                 $profile_ads = NULL;
             }
             $this->template->content = View::factory('pages/userprofile', array('user' => $user, 'profile_ads' => $ads));
         } else {
             //throw 404
             throw HTTP_Exception::factory(404, __('Page not found'));
         }
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
开发者ID:nick-catanchin-ie,项目名称:openclassifieds2,代码行数:28,代码来源:user.php

示例5: before

 public function before()
 {
     $config = Kohana::$config->load('common');
     $this->template = $config->template_name;
     parent::before();
     if (Auth::instance()->logged_in()) {
         $user = new Model_User();
         $this->template->topbar = View::factory('profile/topbar')->set('users', $user->where('id', '=', Auth::instance()->get_user()->pk())->find())->set('users_levels', $user->get_level(Auth::instance()->get_user()->pk()));
     } else {
         $this->template->topbar = View::factory('login');
     }
     $this->template->stylesheets = $config->stylesheets;
     $this->template->site_name = $config->site_name;
     if (Auth::instance()->logged_in()) {
         $user_id = Auth::instance()->get_user()->pk();
         $roles = ORM::factory('Roles_User')->get_last_role_id($user_id);
         foreach ($roles as $role) {
             if ($role->role_id == 1) {
                 if ($this->request->directory() == 'dashboard') {
                     $this->request->redirect('');
                 }
                 if ($this->request->uri() == 'dashboard') {
                     $this->request->redirect('');
                 }
             }
         }
     } else {
         if ($this->request->directory() == 'dashboard') {
             $this->request->redirect('');
         }
         if ($this->request->uri() == 'dashboard') {
             $this->request->redirect('');
         }
     }
 }
开发者ID:reGative,项目名称:Phorumph,代码行数:35,代码来源:Template.php

示例6: output

 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $this->pluginTemplate = '/users/online.plug.html';
     $data = $data->fork();
     $users = new Model_User();
     $users->where('DATE_ADD(lastrequest, INTERVAL 30 MINUTE) > NOW()');
     $data->set('usersonline', $users->getTotal());
     parent::output($data, $stream);
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:9,代码来源:Online.php

示例7: registerAction

 public function registerAction()
 {
     if ($this->oAuth->isLoggedIn()) {
         $this->redirect('/');
         return;
     }
     $this->mTemplate->title = $this->getLang('title_registration');
     $this->mTemplate->sSectionTitle = $this->getLang('title_registration');
     $sUser = $this->post('user_name');
     $sPass = $this->post('user_pass');
     $sEmail = $this->post('user_email');
     $sAccount_name = $this->post('account_name');
     $oValidator = new Module_Validator();
     $oValidator->field('nick', $sUser, $this->getLang('user.nick'))->rules('required');
     $oValidator->field('password', $sPass, $this->getLang('user.password'))->rules('required|md5');
     $oValidator->field('email', $sEmail, $this->getLang('user.email'))->rules('required|email');
     $oValidator->field('account_name', $sAccount_name, $this->getLang('user.account_name'))->rules('required');
     if (isset($_POST['submit'])) {
         if ($oValidator->validate()) {
             // sprawdzamy czy nie ma juz takiego konta lub usera
             $oUser = new Model_User();
             $aRes = $oUser->where('email', $sEmail)->getRow();
             if (empty($aRes)) {
                 $oUser->reset();
                 $oAccount = new Model_Account();
                 $oAccount->name = $sAccount_name;
                 if ($iAccountId = $oAccount->save()) {
                     $oUser->name = $sUser;
                     $oUser->email = $sEmail;
                     $oUser->password = $sPass;
                     $oUser->role_id = 1;
                     $oUser->account_id = $iAccountId;
                     if ($oUser->save()) {
                         $this->redirect('/user/login/');
                     } else {
                         $error = $this->getLang('failed_creating_user');
                     }
                 } else {
                     $error = $this->getLang('failed_creating_account');
                 }
             } else {
                 $error = $this->getLang('user_already_exists');
             }
         } else {
             $error = 'Blad danych wejsciowych.';
             $aErrors = $oValidator->getError();
             foreach ($aErrors as $sField => $aError) {
                 $error .= '<br />' . $this->getLang($aError['msg'], $aError['field_name']);
             }
         }
     }
     // generate form
     $aData = array('label_user' => $this->getLang('user.nick'), 'label_pass' => $this->getLang('user.password'), 'label_email' => $this->getLang('user.email'), 'label_accountname' => $this->getLang('user.account_name'), 'user_name' => $sUser, 'user_pass' => '', 'user_email' => $sEmail, 'account_name' => $sAccount_name, 'submit' => $this->getLang('user.register'), 'error' => isset($error) ? $error : null);
     $this->mTemplate->content = View::factory('user/registration_form', $aData)->render();
 }
开发者ID:maxwroc,项目名称:PHP,代码行数:55,代码来源:User.php

示例8: action_index

 public function action_index()
 {
     //template header
     $this->template->title = __('Black list');
     $this->template->meta_description = __('Black list');
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     //find all tables
     $user = new Model_User();
     $black_list = $user->where('status', '=', Model_User::STATUS_SPAM)->order_by('id_user')->find_all();
     $this->template->content = View::factory('oc-panel/pages/black_list', array('black_list' => $black_list));
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:11,代码来源:pool.php

示例9: action_index

 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Newsletter')));
     $this->template->title = __('Newsletter');
     //count all users
     $user = new Model_User();
     $user->where('status', '=', Model_User::STATUS_ACTIVE);
     $count_all_users = $user->count_all();
     //count support expired
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where('status', '=', Model_Order::STATUS_PAID)->where('support_date', '<', Date::unix2mysql())->execute();
     $count_support_expired = $query->as_array();
     $count_support_expired = $count_support_expired[0]['count'];
     //count license expired
     $query = DB::select(DB::expr('COUNT(id_license) count'))->from('licenses')->where('valid_date', 'IS NOT', NULL)->where('valid_date', '<', Date::unix2mysql())->execute();
     $count_license_expired = $query->as_array();
     $count_license_expired = $count_license_expired[0]['count'];
     //orders per product, not accuarate since 1 user could buy more than 1 product but will do
     $query = DB::select(DB::expr('COUNT(id_order) count'))->select('p.title')->select('p.id_product')->from(array('products', 'p'))->join(array('orders', 'o'))->using('id_product')->where('o.status', '=', Model_Order::STATUS_PAID)->group_by('p.id_product')->execute();
     $products = $query->as_array();
     //post done sending newsletter
     if ($this->request->post() and Core::post('subject') != NULL) {
         $users = array();
         if (core::post('send_all') == 'on') {
             $query = DB::select('email')->select('name')->from('users')->where('status', '=', Model_User::STATUS_ACTIVE)->execute();
             $users = array_merge($users, $query->as_array());
         }
         if (Theme::get('premium') == 1) {
             if (core::post('send_expired_support') == 'on') {
                 $query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'))->using('id_user')->where('o.status', '=', Model_Order::STATUS_PAID)->where('o.support_date', '<', Date::unix2mysql())->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
             if (core::post('send_expired_license') == 'on') {
                 $query = DB::select('email')->select('name')->from(array('licenses', 'l'))->join(array('users', 'u'))->using('id_user')->where('l.valid_date', 'IS NOT', NULL)->where('l.valid_date', '<', Date::unix2mysql())->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
             if (is_numeric(core::post('send_product'))) {
                 $query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'))->using('id_user')->where('o.id_product', '=', core::post('send_product'))->where('o.status', '=', Model_Order::STATUS_PAID)->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
         }
         //NOTE $users may have duplicated emails, but phpmailer takes care of not sending the email 2 times to same recipient
         //sending!
         if (count($users) > 0) {
             if (!Email::send($users, '', Core::post('subject'), Kohana::$_POST_ORIG['description'], Core::post('from'), Core::post('from_email'))) {
                 Alert::set(Alert::ERROR, __('Error on mail delivery, not sent'));
             } else {
                 Alert::set(Alert::SUCCESS, __('Email sent'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Mail not sent'));
         }
     }
     $this->template->content = View::factory('oc-panel/pages/newsletter', array('count_all_users' => $count_all_users, 'count_support_expired' => $count_support_expired, 'count_license_expired' => $count_license_expired, 'products' => $products));
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:54,代码来源:newsletter.php

示例10: action_index

 public function action_index()
 {
     $email = Core::post('email_subscribe');
     if (Valid::email($email, TRUE)) {
         /* find user and compare emails */
         $obj_user = new Model_User();
         $user = $obj_user->where('email', '=', $email)->limit(1)->find();
         // case when user is not logged in.
         // We create new user if he doesn't exists in DB
         // and send him mail for ad created + new profile created
         if (!$user->loaded()) {
             $user = Model_User::create_email($email);
         }
         /* save this user to data base as subscriber */
         $arr_cat = Core::post('category_subscribe');
         // string in this case is returned as "int,int" so we need to format min/max price
         $price = Core::post('price_subscribe');
         if ($price = Core::post('price_subscribe')) {
             $min_price = substr($price, '0', stripos($price, ','));
             $max_price = substr($price, strrpos($price, ',') + 1);
         } else {
             //in case of mobile version
             // jquery mobile have different slider, so we need to get data differently
             $min_price = Core::post('price_subscribe-1');
             $max_price = Core::post('price_subscribe-2');
         }
         //if categry is not selected, subscribe them for al, set category to 0 thats all...
         if ($arr_cat === NULL) {
             $arr_cat[] = 0;
         }
         // create entry table subscriber for each category selected
         foreach ($arr_cat as $c => $id_value) {
             $obj_subscribe = new Model_Subscribe();
             $obj_subscribe->id_user = $user->id_user;
             $obj_subscribe->id_category = $id_value;
             $obj_subscribe->id_location = Core::post('location_subscribe');
             $obj_subscribe->min_price = $min_price;
             $obj_subscribe->max_price = $max_price;
             try {
                 $obj_subscribe->save();
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
         Alert::set(Alert::SUCCESS, __('Thank you for subscribing'));
         $this->redirect(Route::url('default'));
     } else {
         Alert::set(Alert::ALERT, __('Invalid Email'));
         $this->redirect(Route::url('default'));
     }
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:51,代码来源:subscribe.php

示例11: login

 /**
  * Log in the current user with the provided credentials.
  * @param string $usernameOrEmail User name or email of account
  * @param string $password
  * @param bool $cookie Use a cookie to store the login
  * @param string $use The field being used to identify the user (username, email, or either)
  * @return bool False if login failed
  */
 public function login($usernameOrEmail, $password, $cookie = false, $use = 'either')
 {
     switch ($use) {
         case 'username':
             $field = 'username';
             break;
         case 'email':
             $field = 'email';
             break;
         default:
             $field = 'username';
             if (preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $usernameOrEmail)) {
                 $field = 'email';
             }
             break;
     }
     $users = new Model_User();
     $users->where("{$field} = ?", $userNameOrEmail);
     if ($users->count() == 0) {
         Typeframe::Log("WARNING: {$usernameOrEmail} matches more than one {$field} in the user table.");
         //return false;
     }
     $row = $users->getFirst();
     // Did this even find a record?
     if (!$row) {
         Typeframe::Log("Login failed for {$usernameOrEmail} due to: no {$field} found");
         return false;
     }
     // Does the password not match?
     if (!self::CheckPassword($row, $password)) {
         Typeframe::Log("Login failed for {$usernameOrEmail} due to: incorrect password");
         return false;
     }
     //check to see if account is suspended.
     if ($row['confirmed'] == 0) {
         Typeframe::Log("Login failed for {$usernameOrEmail} due to: suspended account");
         return false;
     }
     // Whee, all the error checks must have passed!
     unset($row['salt']);
     unset($row['hashtype']);
     $_SESSION['typef_user'] = $row;
     if ($cookie) {
         // Store cookie
         // TODO: It might make more sense to store the user ID instead of the name.
         setcookie('typef_username', $row['username'], time() + 60 * 60 * 24 * 30, '/');
         setcookie('typef_passhash', $row['passhash'], time() + 60 * 60 * 24 * 30, '/');
     }
     Typeframe::Log("{$usernameOrEmail} logged in");
     return true;
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:59,代码来源:User.php

示例12: action_index

 /**
  *
  * Loads a basic list info
  * @param string $view template to render 
  */
 public function action_index($view = NULL)
 {
     $this->template->title = __('Orders');
     $this->template->styles = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen');
     $this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/oc-panel/crud/index.js', 'js/oc-panel/stats/dashboard.js');
     $orders = new Model_Order();
     $orders = $orders->where('status', '=', Model_Order::STATUS_PAID);
     //filter email
     if (core::request('email') !== NULL) {
         $user = new Model_User();
         $user->where('email', '=', core::request('email'))->limit(1)->find();
         if ($user->loaded()) {
             $orders = $orders->where('id_user', '=', $user->id_user);
         }
     }
     //filter date
     if (!empty(Core::request('from_date')) and !empty(Core::request('to_date'))) {
         //Getting the dates range
         $from_date = Core::request('from_date', strtotime('-1 month'));
         $to_date = Core::request('to_date', time());
         $orders = $orders->where('pay_date', 'between', array($from_date, $to_date));
     }
     //filter coupon
     if (is_numeric(core::request('id_coupon'))) {
         $orders = $orders->where('id_coupon', '=', core::request('id_coupon'));
     }
     //filter product
     if (is_numeric(core::request('id_product'))) {
         $orders = $orders->where('id_product', '=', core::request('id_product'));
     }
     //filter status
     if (is_numeric(core::request('status'))) {
         $orders = $orders->where('status', '=', core::request('status'));
     }
     //order by paid if we are filtering paid....
     if (core::request('status') == Model_Order::STATUS_PAID) {
         $orders->order_by('pay_date', 'desc');
     } else {
         $orders->order_by('id_order', 'desc');
     }
     $items_per_page = core::request('items_per_page', 10);
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $orders->count_all(), 'items_per_page' => $items_per_page))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     $pagination->title($this->template->title);
     $orders = $orders->limit($items_per_page)->offset($pagination->offset)->find_all();
     $pagination = $pagination->render();
     $products = new Model_Product();
     $products = $products->find_all();
     $this->render('oc-panel/pages/order/index', array('orders' => $orders, 'pagination' => $pagination, 'products' => $products));
 }
开发者ID:alirezadamash,项目名称:open-eshop,代码行数:54,代码来源:order.php

示例13: action_index

 /**
  *
  * Loads a basic list info
  * @param string $view template to render 
  */
 public function action_index($view = NULL)
 {
     $this->template->title = __($this->_orm_model);
     $this->template->scripts['footer'][] = 'js/oc-panel/crud/index.js';
     $users = new Model_User();
     // filter users by search value
     if ($q = $this->request->query('search')) {
         $users->where('email', 'like', '%' . $q . '%')->or_where('name', 'like', '%' . $q . '%');
     }
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $users->count_all()))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     $pagination->title($this->template->title);
     $users = $users->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     $pagination = $pagination->render();
     $this->render('oc-panel/crud/index', array('elements' => $users, 'pagination' => $pagination));
 }
开发者ID:nick-catanchin-ie,项目名称:common,代码行数:20,代码来源:user.php

示例14: _login

 /**
  * Logs a user in.
  *
  * @param   string   $username  Username
  * @param   string   $password  Password
  * @param   boolean  $remember  Enable autologin (not supported)
  * @return  boolean
  */
 protected function _login($username, $password, $remember)
 {
     if (is_string($password)) {
         // Create a hashed password
         $password = $this->hash($password);
     }
     $user = new Model_User();
     $user->where('username', '=', $username)->find();
     if ($user->loaded() and $user->password === $password) {
         // Complete the login
         return $this->complete_login($user);
     }
     // Login failed
     return FALSE;
 }
开发者ID:DavBfr,项目名称:BlogMVC,代码行数:23,代码来源:Auth.php

示例15: action_index

 /**
 Showing users on various status
 */
 public function action_index()
 {
     $ref = $this->request->param('id');
     if (empty($ref)) {
         $ref = 'APPLIED';
     }
     $this->_secondary_menu['APPLIED'] = new Model_Ui_Menuitem("Applied", "/admin/user/index/APPLIED");
     $this->_secondary_menu['ACTIVATED'] = new Model_Ui_Menuitem("Activated", "/admin/user/index/ACTIVATED");
     $this->_secondary_menu['BLOCKED'] = new Model_Ui_Menuitem("Blocked", "/admin/user/index/BLOCKED");
     $this->_secondary_menu[$ref]->active = true;
     if ($ref == 'APPLIED') {
         $this->_actions = array('activate' => "Activate");
     }
     $model = new Model_User();
     $elements = $model->where("user.status", "=", $ref)->find_all();
     return $this->render('index', array('elements' => $elements));
 }
开发者ID:kanikaN,项目名称:qload,代码行数:20,代码来源:user.php


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