本文整理匯總了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);
}
}