当前位置: 首页>>代码示例>>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;未经允许,请勿转载。