本文整理汇总了PHP中Model_User::loaded方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_User::loaded方法的具体用法?PHP Model_User::loaded怎么用?PHP Model_User::loaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_User
的用法示例。
在下文中一共展示了Model_User::loaded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: action_get
/**
* Handle GET requests.
*/
public function action_get()
{
try {
if (is_numeric($id_user = $this->request->param('id'))) {
$user = new Model_User($id_user);
if ($user->loaded() and $user->status == Model_User::STATUS_ACTIVE) {
$res = $user->as_array();
$res['image'] = $user->get_profile_image();
//remove the hidden fields
foreach ($res as $key => $value) {
if (in_array($key, $this->_hidden_fields)) {
unset($res[$key]);
}
}
$this->rest_output(array('user' => $res));
} else {
$this->_error(__('User not found'), 404);
}
} else {
$this->_error(__('User not found'), 404);
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
return;
}
}
示例3: 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'));
}
}
示例4: action_delete
public function action_delete()
{
$user = new Model_User($this->request->param('id'));
if ($user->loaded()) {
$user->delete();
}
$this->redirect('admin/user/all');
}
示例5: action_profile_picture
public function action_profile_picture()
{
$id = $this->request->param('id');
$param = $this->request->param('param1');
$context_user = new Model_User($id);
if ($id == null || !$context_user->loaded() || empty($context_user->profile_pic_id)) {
$this->request->redirect("/assets/default/img/default-user.jpg");
}
$this->show_picture($context_user->profile_pic_id, $param);
}
示例6: is_favorite
/**
* is favorite?
* @param Model_User $user user
* @param Model_Ad $ad ad
* @return boolean
*/
public static function is_favorite(Model_User $user, Model_Ad $ad)
{
if ($user->loaded() and $ad->loaded()) {
$fav = new Model_Favorite();
$fav->where('id_user', '=', $user->id_user)->where('id_ad', '=', $ad->id_ad)->find();
if ($fav->loaded()) {
return TRUE;
}
}
return FALSE;
}
示例7: _return_user_element
/**
* Returns the information for a user in addition to the role.
* @param Model_User $user
* @return stdClass stdClass of all properties for this user.
* @throws Exception If User object is not valid.
*/
protected function _return_user_element($user)
{
$return_object = new stdClass();
if (!$user->loaded() or get_class($user) != "Model_User") {
throw new Exception("Invalid User.");
}
$return_object->id = $user->id;
$return_object->name = $user->name;
$return_object->email = $user->email;
$return_object->role = $this->_return_role_element($user->role);
$return_object->current_auth_expiration = $user->auth_expiration;
return $return_object;
}
示例8: get_affiliate
/**
* get the affiliate from the query or from the cookie
* @return Model_Affiliate
*/
public static function get_affiliate()
{
$id_affiliate = core::request('aff', Cookie::get(self::$_cookie_name));
$affiliate = new Model_User();
if (Core::config('affiliate.active') == 1 and is_numeric($id_affiliate) and Theme::get('premium') == 1) {
$affiliate = new Model_User($id_affiliate);
//the user exists so we set again the cookie, just in case it's a different user or to renew it
if ($affiliate->loaded()) {
Cookie::set(self::$_cookie_name, $id_affiliate, time() + 24 * 60 * 60 * Core::config('affiliate.cookie'));
}
}
return $affiliate;
}
示例9: 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));
}
示例10: generate
/**
* Generate new reflink code
*
* @param Model_User $user
* @param integer $type reflink type
* @param string $data string stored to reflink in database
* @return string
*/
public function generate(Model_User $user, $type, $data = NULL)
{
if (!$user->loaded()) {
throw new Reflink_Exception(' User not loaded ');
}
$type = URL::title($type, '_');
$reflink = $this->reset(FALSE)->where('user_id', '=', $user->id)->where('type', '=', $type)->where('created', '>', DB::expr('CURDATE() - INTERVAL 1 HOUR'))->find();
if (!$reflink->loaded()) {
$values = array('user_id' => (int) $user->id, 'code' => uniqid(TRUE) . sha1(microtime()), 'type' => $type, 'data' => $data);
$reflink = ORM::factory('user_reflink')->values($values, array_keys($values))->create();
} else {
$reflink->set('data', $data)->update();
}
return $reflink->code;
}
示例11: _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;
}
示例12: action_remove
public function action_remove()
{
if ($id = $this->request->param('id')) {
$user = new Model_User($id);
if ($user->loaded()) {
$user->status = Model_User::STATUS_ACTIVE;
try {
$user->save();
Alert::set(Alert::SUCCESS, sprintf(__('User %s has been removed from black list.'), $user->name));
$this->redirect(Route::url('oc-panel', array('controller' => 'pool', 'action' => 'index')));
} catch (Exception $e) {
}
}
$this->redirect(Route::url('oc-panel', array('controller' => 'pool', 'action' => 'index')));
}
}
示例13: action_get
/**
* Handle GET requests.
*/
public function action_get()
{
try {
if (is_numeric($id_user = $this->request->param('id'))) {
$user = new Model_User($id_user);
if ($user->loaded() and $user->status == Model_User::STATUS_ACTIVE) {
$this->rest_output(array('user' => self::get_user_array($user)));
} else {
$this->_error(__('User not found'), 404);
}
} else {
$this->_error(__('User not found'), 404);
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
}
}
示例14: action_create
public function action_create()
{
try {
if (!is_numeric(core::request('id_ad')) or !is_numeric(core::request('id_product')) or !is_numeric(core::request('id_user'))) {
$this->_error(__('Missing parameters'), 501);
} else {
$user = new Model_User(core::request('id_user'));
$ad = new Model_Ad(core::request('id_ad'));
if ($user->loaded() and $ad->loaded()) {
$id_product = core::request('id_product');
$amount = core::request('amount');
//in case not set by request
if (!is_numeric($amount)) {
//get original price for the product
switch ($id_product) {
case Model_Order::PRODUCT_CATEGORY:
$amount = $ad->category->price;
break;
case Model_Order::PRODUCT_TO_TOP:
$amount = core::config('payment.pay_to_go_on_top');
break;
case Model_Order::PRODUCT_TO_FEATURED:
$amount = Model_Order::get_featured_price(core::request('featured_days'));
break;
case Model_Order::PRODUCT_AD_SELL:
$amount = $ad->price;
break;
default:
$plan = new Model_Plan($id_product);
$amount = $plan->loaded() ? $plan->price : 0;
break;
}
}
$order = Model_Order::new_order($ad, $user, $id_product, $amount, core::request('currency'), Model_Order::product_desc(core::request('id_product')), core::request('featured_days'));
$order->confirm_payment(core::request('paymethod', 'API'), core::request('txn_id'));
$order->save();
$this->rest_output(array('order' => self::get_order_array($order)));
} else {
$this->_error(__('User or Ad not loaded'), 501);
}
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
}
}
示例15: action_pay
/**
*
* view affiliates and payments
*/
public function action_pay()
{
//create an order and mark it as paid to the user_id
if (is_numeric($this->request->param('id'))) {
//get the user
$user = new Model_User($this->request->param('id'));
if ($user->loaded()) {
//commissions due to pay
$query = DB::select(DB::expr('SUM(amount) total'))->from('affiliates')->where('id_user', '=', $user->id_user)->where('date_to_pay', '<', Date::unix2mysql())->where('status', '=', Model_Affiliate::STATUS_CREATED)->group_by('id_user')->execute();
$due_to_pay = $query->as_array();
$due_to_pay = isset($due_to_pay[0]['total']) ? $due_to_pay[0]['total'] : 0;
if ($due_to_pay > 0) {
//create the order
$order = new Model_Order();
$order->id_user = $user->id_user;
$order->amount = $due_to_pay * -1;
//we add the order as a negative, since we pay, we don't get paid.
$order->currency = 'USD';
$order->paymethod = 'paypal';
$order->pay_date = Date::unix2mysql();
$order->notes = 'Affiliate Commissions';
$order->status = Model_Order::STATUS_PAID;
try {
$order->save();
//update the commissions
DB::update('affiliates')->set(array('date_paid' => Date::unix2mysql(), 'status' => Model_Affiliate::STATUS_PAID, 'id_order_payment' => $order->id_order))->where('id_user', '=', $user->id_user)->where('date_to_pay', '<', Date::unix2mysql())->where('status', '=', Model_Affiliate::STATUS_CREATED)->execute();
Alert::set(Alert::SUCCESS, __('Commission Paid'));
} catch (Exception $e) {
}
}
}
}
$this->template->title = __('Affiliates Payments');
$query = DB::select(DB::expr('SUM(amount) total'))->select('id_user')->from('affiliates')->where('date_to_pay', '<', Date::unix2mysql())->where('status', '=', Model_Affiliate::STATUS_CREATED)->group_by('id_user')->having('total', '>=', core::config('affiliate.payment_min'))->execute();
$users_to_pay = $query->as_array('id_user');
$total_to_pay = 0;
foreach ($users_to_pay as $key => $value) {
$total_to_pay += $value['total'];
}
$users = new Model_User();
if (count($users_to_pay)) {
$users = $users->where('id_user', 'in', array_keys($users_to_pay))->where('status', '=', Model_User::STATUS_ACTIVE)->find_all();
}
$this->render('oc-panel/pages/affiliate/pay', array('users' => $users, 'total_to_pay' => $total_to_pay, 'users_to_pay' => $users_to_pay));
}