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


PHP Model_User::ql方法代码示例

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


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

示例1: action_activate

 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     $user = Auth::instance()->get_user();
     $id = $this->request->param('id');
     if (isset($id)) {
         $active_ad = new Model_Ad($id);
         if ($active_ad->loaded()) {
             $activate = FALSE;
             //admin whatever he wants
             if ($user->id_role == Model_Role::ROLE_ADMIN) {
                 $activate = TRUE;
             } elseif ($user->id_user == $active_ad->id_user and !in_array(core::config('general.moderation'), Model_Ad::$moderation_status)) {
                 $activate = TRUE;
             } else {
                 Alert::set(Alert::ALERT, __("This is not your advertisement."));
             }
             //its not published
             if ($active_ad->status == Model_Ad::STATUS_PUBLISHED) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement is already marked as 'active'"));
             }
             //pending payment
             if ($activate === TRUE and ($order = $active_ad->get_order()) !== FALSE and $order->status == Model_Order::STATUS_CREATED) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement can not be marked as “active”. There is a pending payment."));
             }
             //activate the ad
             if ($activate === TRUE) {
                 $active_ad->published = Date::unix2mysql(time());
                 $active_ad->status = Model_Ad::STATUS_PUBLISHED;
                 try {
                     $active_ad->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
             } else {
                 HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
             }
         } else {
             //throw 404
             throw HTTP_Exception::factory(404, __('Page not found'));
         }
     }
     // send confirmation email
     $cat = new Model_Category($active_ad->id_category);
     $usr = new Model_User($active_ad->id_user);
     if ($usr->loaded()) {
         //we get the QL, and force the regen of token for security
         $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $active_ad->seotitle), TRUE);
         $ret = $usr->email('ads-activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $active_ad->title));
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:57,代码来源:myads.php

示例2: new_order

 /**
  * creates an order
  * @param  Model_Ad $ad    
  * @param  Model_User $user          
  * @param  integer   $id_product  
  * @param  numeric   $amount      
  * @param  string   $currency    
  * @param  string   $description 
  * @return Model_Order                
  */
 public static function new_order(Model_Ad $ad, $user, $id_product, $amount, $currency = NULL, $description = NULL, $featured_days = NULL)
 {
     if ($currency === NULL) {
         $currency = core::config('payment.paypal_currency');
     }
     if ($description === NULL) {
         $description = Model_Order::product_desc($id_product);
     }
     //get if theres an unpaid order for this product and this ad
     $order = new Model_Order();
     $order->where('id_ad', '=', $ad->id_ad)->where('id_user', '=', $user->id_user)->where('status', '=', Model_Order::STATUS_CREATED)->where('id_product', '=', $id_product)->where('amount', '=', $amount)->where('currency', '=', $currency)->limit(1)->find();
     //if no unpaid create order
     if (!$order->loaded()) {
         //add coupon ID and discount only if not AD_SELL
         if (Model_Coupon::valid($id_product)) {
             $amount = Model_Coupon::price($id_product, $amount);
             $order->id_coupon = Model_Coupon::current()->id_coupon;
         }
         //create order
         $order = new Model_Order();
         $order->id_user = $user->id_user;
         $order->id_ad = $ad->id_ad;
         $order->id_product = $id_product;
         $order->currency = $currency;
         $order->amount = $amount;
         $order->description = $description;
         //store how many days the ad is featured
         if ($featured_days !== NULL and is_numeric($featured_days)) {
             $order->featured_days = $featured_days;
         }
         try {
             $order->save();
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         //send email to user with link to pay
         $url_checkout = $user->ql('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order));
         $replace = array('[ORDER.ID]' => $order->id_order, '[ORDER.DESC]' => $order->description, '[URL.CHECKOUT]' => $url_checkout);
         //$user->email('new-order',$replace);
     }
     return $order;
 }
开发者ID:zhangkom,项目名称:openclassifieds2,代码行数:52,代码来源:order.php

示例3: multiple_mails

 public function multiple_mails($receivers)
 {
     foreach ($receivers as $num => $receiver_id) {
         if (is_numeric($receiver_id)) {
             $ad = new Model_Ad($receiver_id);
             $cat = new Model_Category($ad->id_category);
             $usr = new Model_User($ad->id_user);
             if ($usr->loaded()) {
                 $edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $ad->id_ad;
                 $delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $ad->id_ad;
                 //we get the QL, and force the regen of token for security
                 $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $ad->seotitle), TRUE);
                 $ret = $usr->email('ads.activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
             }
         }
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:17,代码来源:ad.php

示例4: action_ticket

 public function action_ticket()
 {
     $this->template->scripts['footer'] = array('js/oc-panel/ticket.js');
     //after creating the reply we redirect to the ticket view
     $errors = NULL;
     $user = Auth::instance()->get_user();
     $ticket_id = $this->request->param('id', 0);
     //getting the parent ticket
     $ticket = new Model_Ticket();
     if (!$user->has_access('supportadmin')) {
         $ticket->where('id_user', '=', $user->id_user);
     }
     $ticket->where('id_ticket', '=', $ticket_id)->where('id_ticket_parent', 'IS', NULL)->limit(1)->find();
     if (!$ticket->loaded()) {
         Alert::set(Alert::ERROR, __('Not your ticket.'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index')));
     }
     //marking it as read if was not assign we assign an agent.
     if ($ticket->status == Model_Ticket::STATUS_CREATED and $user->has_access('supportadmin') and !is_numeric($ticket->id_user_support)) {
         //modify status of parent ticket
         $ticket->id_user_support = $user->id_user;
         $ticket->read_date = Date::unix2mysql();
         $ticket->status = Model_Ticket::STATUS_READ;
         $ticket->save();
     }
     //Change the agent assigned to this ticket
     if (core::post('agent') and $user->has_access('supportadmin')) {
         //modify ticket
         $ticket->id_user_support = core::post('agent');
         $ticket->status = Model_Ticket::STATUS_CREATED;
         $ticket->save();
         //send notification to agent
         $agent = new Model_User(core::post('agent'));
         $agent->email('assign-agent', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $ticket->description, '[URL.QL]' => $agent->ql('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
         Alert::set(Alert::SUCCESS, __('Agent assigned.'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index', 'id' => 'admin')));
     }
     //create new reply
     if ($this->request->post() and Form::token('reply_ticket', TRUE)) {
         $validation = Validation::factory($this->request->post())->rule('description', 'not_empty')->rule('description', 'min_length', array(':value', 5))->rule('description', 'max_length', array(':value', 1000));
         if ($validation->check()) {
             //creates the answer ticket
             $ticketr = new Model_Ticket();
             $ticketr->id_user = $user->id_user;
             $ticketr->id_order = $ticket->id_order;
             $ticketr->id_ticket_parent = $ticket->id_ticket;
             $ticketr->description = core::post('description');
             $ticketr->ip_address = ip2long(Request::$client_ip);
             $ticketr->save();
             unset($_POST['description']);
             //modify status of parent ticket
             $ticket->status = Model_Ticket::STATUS_CREATED;
             $ticket->save();
             //an admin answer so we send email to owner of ticket
             if ($user->has_access('supportadmin')) {
                 $ticket->id_user_support = $user->id_user;
                 $ticket->read_date = Date::unix2mysql();
                 $ticket->status = Model_Ticket::STATUS_HOLD;
                 $ticket->save();
                 //send email to creator of the ticket
                 $ticket->user->email('new-reply', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $user->signature, '[URL.QL]' => $ticket->user->ql('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
             } elseif (is_numeric($ticket->id_user_support)) {
                 //send notification to agent
                 $agent = new Model_User($ticket->id_user_support);
                 $agent->email('new-reply', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $ticketr->description, '[URL.QL]' => $agent->ql('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
             } elseif (core::config('email.new_sale_notify')) {
                 Email::content(core::config('email.notify_email'), NULL, NULL, NULL, 'new-reply', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $ticketr->description, '[URL.QL]' => Route::url('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
             }
             //set empty since they already replied
             Request::current()->post('description', '');
             Alert::set(Alert::SUCCESS, __('Reply created.'));
         } else {
             $errors = $validation->errors('ad');
         }
     }
     //getting all the ticket replies
     $replies = new Model_Ticket();
     $replies = $replies->where('id_ticket_parent', '=', $ticket->id_ticket)->order_by('created', 'asc')->find_all();
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Ticket')));
     $this->template->title = $ticket->title . ' - ' . __('Ticket');
     //loading agents/admins
     $users = NULL;
     if ($user->has_access('supportadmin')) {
         //getting the roles that have access to the supportadmin since are the agents ;)
         $support_roles = array(Model_Role::ROLE_ADMIN);
         $access = new Model_Access();
         $access = $access->where('access', '=', 'supportadmin.*')->find_all();
         foreach ($access as $a) {
             $support_roles[] = $a->id_role;
         }
         //getting agents ;)
         $users_db = DB::select('u.id_user')->select('u.name')->from(array('users', 'u'))->where('id_role', 'in', $support_roles)->as_object()->execute();
         foreach ($users_db as $key => $value) {
             $users[$value->id_user] = $value->name;
         }
     }
     $this->template->bind('content', $content);
     $this->template->content = View::factory('oc-panel/pages/support/ticket', array('replies' => $replies, 'ticket' => $ticket, 'users' => $users));
     $content->errors = $errors;
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:100,代码来源:support.php

示例5: action_activate

 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     $id = $this->request->param('id');
     if (isset($id)) {
         $active_ad = new Model_Ad($id);
         if ($active_ad->loaded()) {
             if (Auth::instance()->get_user()->id_user !== $active_ad->id_user or Auth::instance()->get_user()->id_role !== Model_Role::ROLE_ADMIN and Auth::instance()->get_user()->id_user == 1) {
                 Alert::set(Alert::ALERT, __("This is not your advertisement."));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
             } elseif ($active_ad->status != 1) {
                 $active_ad->published = Date::unix2mysql(time());
                 $active_ad->status = 1;
                 try {
                     $active_ad->save();
                 } catch (Exception $e) {
                     throw new HTTP_Exception_500($e->getMessage());
                 }
             } else {
                 Alert::set(Alert::ALERT, __("Advertisement is already marked as 'active'"));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
             }
         } else {
             //throw 404
             throw new HTTP_Exception_404();
         }
     }
     // send confirmation email
     $cat = new Model_Category($active_ad->id_category);
     $usr = new Model_User($active_ad->id_user);
     if ($usr->loaded()) {
         $edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $active_ad->id_ad;
         $delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $active_ad->id_ad;
         //we get the QL, and force the regen of token for security
         $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $active_ad->seotitle), TRUE);
         $ret = $usr->email('ads.activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $active_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
     }
     if (Core::config('sitemap.on_post') == TRUE) {
         Sitemap::generate();
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:45,代码来源:profile.php

示例6: confirm_payment

 /**
  * confirm payment for order
  *
  * @param string    $id_order [unique indentifier of order]
  * @param int       $id_user  [unique indentifier of user] 
  */
 public function confirm_payment($id_order, $moderation)
 {
     $orders = new self();
     $orders->where('id_order', '=', $id_order)->where('status', '=', 0)->limit(1)->find();
     $id_ad = $orders->id_ad;
     $product_find = new Model_Ad();
     $product_find = $product_find->where('id_ad', '=', $id_ad)->limit(1)->find();
     $categ = new Model_Category($product_find->id_category);
     $user = new Model_User($orders->id_user);
     // update orders
     if ($orders->loaded()) {
         $orders->status = 1;
         $orders->pay_date = Date::unix2mysql(time());
         try {
             $orders->save();
         } catch (Exception $e) {
             echo $e;
         }
     }
     // update product
     if ($orders->id_product == Paypal::category_product) {
         if ($moderation == Model_Ad::PAYMENT_ON) {
             $product_find->published = Date::unix2mysql(time());
             $product_find->status = 1;
             try {
                 $product_find->save();
                 //we get the QL, and force the regen of token for security
                 $url_cont = $user->ql('contact', array(), TRUE);
                 $url_ad = $user->ql('ad', array('category' => $product_find->id_category, 'seotitle' => $product_find->seotitle), TRUE);
                 $ret = $user->email('ads.user_check', array('[URL.CONTACT]' => $url_cont, '[URL.AD]' => $url_ad, '[AD.NAME]' => $product_find->title));
             } catch (Exception $e) {
                 echo $e;
             }
         } else {
             if ($moderation == Model_Ad::PAYMENT_MODERATION) {
                 $product_find->published = Date::unix2mysql(time());
                 try {
                     $product_find->save();
                     $edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $product_find->id_ad;
                     $delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $product_find->id_ad;
                     //we get the QL, and force the regen of token for security
                     $url_ql = $user->ql('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $orders->id_ad), TRUE);
                     $ret = $user->email('ads.notify', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $product_find->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
                 } catch (Exception $e) {
                 }
             }
         }
     } elseif ($orders->id_product == Paypal::to_top) {
         $product_find->published = Date::unix2mysql(time());
         try {
             $product_find->save();
         } catch (Exception $e) {
             echo $e;
         }
     } elseif ($orders->id_product == Paypal::to_featured) {
         $product_find->featured = Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60);
         try {
             $product_find->save();
         } catch (Exception $e) {
             echo $e;
         }
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:69,代码来源:order.php

示例7: action_userprofile_contact

 public function action_userprofile_contact()
 {
     $user = new Model_User($this->request->param('id'));
     //message to user
     if ($user->loaded() and $this->request->post()) {
         if (captcha::check('contact')) {
             //check if user is loged in
             if (Auth::instance()->logged_in()) {
                 $email_from = Auth::instance()->get_user()->email;
                 $name_from = Auth::instance()->get_user()->name;
             } else {
                 $email_from = core::post('email');
                 $name_from = core::post('name');
             }
             //akismet spam filter
             if (!core::akismet($name_from, $email_from, core::post('message'))) {
                 if (core::config('general.messaging')) {
                     $ret = Model_Message::send_user(core::post('message'), $this->user->id_user, $user->id_user);
                     if ($ret !== FALSE) {
                         $user->email('messaging-user-contact', array('[FROM.NAME]' => $this->user->name, '[TO.NAME]' => $user->name, '[DESCRIPTION]' => core::post('message'), '[URL.QL]' => $user->ql('oc-panel', array('controller' => 'messages', 'action' => 'message', 'id' => $ret->id_message))));
                     }
                 } else {
                     $ret = $user->email('user-profile-contact', array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => $name_from, '[EMAIL.SUBJECT]' => core::post('subject'), '[EMAIL.FROM]' => $email_from), $email_from, core::post('name'));
                 }
                 //if succesfully sent
                 if ($ret) {
                     Alert::set(Alert::SUCCESS, __('Your message has been sent'));
                 } else {
                     Alert::set(Alert::ERROR, __('Message not sent'));
                 }
             } else {
                 Alert::set(Alert::SUCCESS, __('This email has been considered as spam! We are sorry but we can not send this email.'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Captcha is not correct'));
         }
         HTTP::redirect(Route::url('profile', array('seoname' => $user->seoname)));
     }
 }
开发者ID:nick-catanchin-ie,项目名称:openclassifieds2,代码行数:39,代码来源:contact.php


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