當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model_Ad::get_order方法代碼示例

本文整理匯總了PHP中Model_Ad::get_order方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Ad::get_order方法的具體用法?PHP Model_Ad::get_order怎麽用?PHP Model_Ad::get_order使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model_Ad的用法示例。


在下文中一共展示了Model_Ad::get_order方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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->is_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'"));
             }
             //expired but cannot reactivate option
             if (Core::config('advertisement.expire_reactivation') == FALSE and core::config('advertisement.expire_date') > 0 and Date::formatted_time($active_ad->published . '+' . core::config('advertisement.expire_date') . ' days') < Date::formatted_time()) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement can not be marked as “active”. It's expired."));
             }
             //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:kotsios5,項目名稱:openclassifieds2,代碼行數:62,代碼來源:myads.php


注:本文中的Model_Ad::get_order方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。