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


PHP Model_Ad::delete方法代碼示例

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


在下文中一共展示了Model_Ad::delete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: action_delete

 /**
  * Delete advertisement: Delete
  * @todo move to model ad
  */
 public function action_delete()
 {
     $id = $this->request->param('id');
     $format_id = explode('_', $id);
     $auth_user = Auth::instance();
     $nb_Ads_Deleted = 0;
     foreach ($format_id as $id) {
         if (isset($id) and $id !== '') {
             $ad = new Model_Ad($id);
             if ($ad->loaded()) {
                 try {
                     $ad->delete();
                     $nb_Ads_Deleted++;
                 } catch (Exception $e) {
                     Alert::set(Alert::ERROR, sprintf(__('Warning, something went wrong while deleting Ad with id %u'), $id) . ':<br>' . $e->getMessage());
                     //throw HTTP_Exception::factory(500,$e->getMessage());
                 }
             }
         }
     }
     $level_Alert = $nb_Ads_Deleted > 0 ? Alert::SUCCESS : Alert::INFO;
     if ($nb_Ads_Deleted == 1) {
         $nb_Ads_Deleted = __('Advertisement has been permanently deleted');
     } elseif ($nb_Ads_Deleted >= 2) {
         $nb_Ads_Deleted = sprintf(__('%u advertisements have been permanently deleted'), $nb_Ads_Deleted);
     } else {
         $nb_Ads_Deleted = __('None (0) advertisement has been deleted');
     }
     Alert::set($level_Alert, $nb_Ads_Deleted);
     $param_current_url = Core::get('current_url');
     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:kleitz,項目名稱:openclassifieds2,代碼行數:42,代碼來源:ad.php


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