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


PHP Social::post_ad方法代码示例

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


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

示例1: new_ad

 /**
  * creates a new ad
  * @param  array $data 
  * @param  model_user $user 
  * @return array       
  */
 public static function new_ad($data, $user)
 {
     $return_message = '';
     $checkout_url = '';
     //akismet spam filter
     if (isset($data['title']) and isset($data['description']) and core::akismet($data['title'], $user->email, $data['description']) == TRUE) {
         // is user marked as spammer? Make him one :)
         if (core::config('general.black_list')) {
             $user->user_spam();
         }
         return array('error' => __('This post has been considered as spam! We are sorry but we can not publish this advertisement.'), 'error_type' => Alert::ALERT);
     }
     //akismet
     $ad = new Model_Ad();
     $ad->id_user = $user->id_user;
     $ad->values($data);
     $ad->seotitle = $ad->gen_seo_title($ad->title);
     $ad->created = Date::unix2mysql();
     try {
         $ad->save();
     } catch (ORM_Validation_Exception $e) {
         return array('validation_errors' => $e->errors('ad'));
     } catch (Exception $e) {
         return array('error' => $e->getMessage(), 'error_type' => Alert::ALERT);
     }
     /////////// NOTIFICATION Emails,messages to user and Status of the ad
     // depending on user flow (moderation mode), change usecase
     $moderation = core::config('general.moderation');
     //calculate how much he needs to pay in case we have payment on
     if (in_array($moderation, [Model_Ad::PAYMENT_ON, Model_Ad::PAYMENT_MODERATION])) {
         // check category price
         $amount = $ad->category->price > 0 ? $ad->category->price : $ad->category->parent->price;
         //swapping moderation since theres no price :(
         if ($amount == 0) {
             if ($moderation == Model_Ad::PAYMENT_MODERATION) {
                 $moderation = Model_Ad::MODERATION_ON;
             } else {
                 $moderation = Model_Ad::POST_DIRECTLY;
             }
         }
     }
     //where and what we say to the user depending ont he moderation
     switch ($moderation) {
         case Model_Ad::PAYMENT_ON:
         case Model_Ad::PAYMENT_MODERATION:
             $ad->status = Model_Ad::STATUS_NOPUBLISHED;
             $order = Model_Order::new_order($ad, $user, Model_Order::PRODUCT_CATEGORY, $amount, NULL, Model_Order::product_desc(Model_Order::PRODUCT_CATEGORY) . ' ' . $ad->category->name);
             // redirect to invoice
             $return_message = __('Please pay before we publish your advertisement.');
             $checkout_url = Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order));
             break;
         case Model_Ad::EMAIL_MODERATION:
         case Model_Ad::EMAIL_CONFIRMATION:
             $ad->status = Model_Ad::STATUS_UNCONFIRMED;
             $url_ql = $user->ql('oc-panel', array('controller' => 'myads', 'action' => 'confirm', 'id' => $ad->id_ad));
             $user->email('ads-confirm', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $ad->title));
             $return_message = __('Advertisement is posted but first you need to activate. Please check your email!');
             break;
         case Model_Ad::MODERATION_ON:
             $ad->status = Model_Ad::STATUS_NOPUBLISHED;
             $url_ql = $user->ql('oc-panel', array('controller' => 'myads', 'action' => 'update', 'id' => $ad->id_ad));
             $user->email('ads-notify', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $ad->title));
             // email to notify user of creating, but it is in moderation currently
             $return_message = __('Advertisement is received, but first administrator needs to validate. Thank you for being patient!');
             break;
         case Model_Ad::POST_DIRECTLY:
         default:
             $ad->status = Model_Ad::STATUS_PUBLISHED;
             $ad->published = $ad->created;
             $url_cont = $user->ql('contact');
             $url_ad = $user->ql('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
             $user->email('ads-user-check', array('[URL.CONTACT]' => $url_cont, '[URL.AD]' => $url_ad, '[AD.NAME]' => $ad->title));
             Model_Subscription::new_ad($ad->user);
             Model_Subscribe::notify($ad);
             $return_message = __('Advertisement is posted. Congratulations!');
             break;
     }
     //save the last changes on status
     $ad->save();
     // Post on social media
     Social::post_ad($ad);
     //notify admins new ad
     $ad->notify_admins();
     return array('message' => $return_message, 'checkout_url' => $checkout_url, 'ad' => $ad);
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:91,代码来源:ad.php

示例2: action_activate

 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     $id = $this->request->param('id');
     $id_ads = (isset($id) and is_numeric($id)) ? array($id) : Core::get('id_ads');
     $param_current_url = Core::get('current_url');
     if (is_array($id_ads)) {
         $ads = new Model_Ad();
         $ads = $ads->where('id_ad', 'in', $id_ads)->find_all();
         foreach ($ads as $ad) {
             //if theres subscription we need to check
             if (Core::config('general.subscriptions') == TRUE and $ad->user->subscription()->loaded() and $ad->user->subscription()->amount_ads_left <= 0 and $ad->user->subscription()->amount_ads_left != -1) {
                 Alert::set(Alert::WARNING, sprintf(__('The customer %s does not have more ads left to publish.'), $ad->user->email));
             } elseif ($ad->status != Model_Ad::STATUS_PUBLISHED) {
                 $ad->published = Date::unix2mysql();
                 $ad->status = Model_Ad::STATUS_PUBLISHED;
                 try {
                     $ad->save();
                     Model_Subscription::new_ad($ad->user);
                     Model_Subscribe::notify($ad);
                     // Post on social media
                     Social::post_ad($ad);
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
             }
         }
         $this->multiple_mails($id_ads);
         // sending many mails at the same time @TODO EMAIl
         Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     }
     if ($param_current_url == Model_Ad::STATUS_NOPUBLISHED and in_array(core::config('general.moderation'), Model_Ad::$moderation_status)) {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'moderate')));
     } elseif ($param_current_url == Model_Ad::STATUS_PUBLISHED) {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')));
     } else {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')) . '?status=' . $param_current_url);
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:41,代码来源:ad.php


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