/**
  * action: DELETE
  */
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $id = $this->request->param('id');
     $content = new Model_Content($id);
     if ($content->loaded()) {
         //deleting default locale emails is not allowed
         if ($content->type == 'email' and $content->locale == i18n::$locale_default) {
             Alert::set(Alert::INFO, sprintf(__('Sorry, deleting %s locale emails is not allowed'), i18n::$locale_default));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'list')) . '?type=' . $content->type . '&locale_select=' . $content->locale);
         } else {
             try {
                 $content->delete();
                 $this->template->content = 'OK';
             } catch (Exception $e) {
                 Alert::set(Alert::ERROR, $e->getMessage());
             }
         }
     }
 }
Example #2
0
 /**
  * action: DELETE
  */
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $id = $this->request->param('id');
     $content = new Model_Content($id);
     $type = $content->type;
     $locale = $content->locale;
     if ($content->loaded()) {
         try {
             $content->delete();
             Cache::instance()->delete_all();
             $this->template->content = 'OK';
             Alert::set(Alert::SUCCESS, __('Content is deleted'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
     } else {
         Alert::set(Alert::INFO, __('Content is not deleted'));
     }
     Request::current()->redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'list')) . '?type=' . $type . '&locale_select=' . $locale);
 }