Ejemplo n.º 1
0
 /**
  * Create new forum
  */
 public function action_create()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Create new forum')));
     $forum = new Model_Forum();
     $get_all = Model_Forum::get_all();
     //get all forums to build forum parents in select
     $forum_parents = array();
     foreach ($get_all[0] as $parent) {
         $forum_parents[$parent['id']] = $parent['name'];
     }
     $this->template->content = View::factory('oc-panel/pages/forum/create', array('forum_parents' => $forum_parents));
     if ($_POST) {
         $forum->name = core::post('name');
         $forum->id_forum_parent = core::post('id_forum_parent');
         $forum->description = core::post('description');
         if (core::post('seoname') != "") {
             $forum->seoname = $forum->gen_seoname(core::post('name'));
         } else {
             $forum->seoname = $forum->gen_seoname(core::post('seoname'));
         }
         try {
             $forum->save();
             Core::delete_cache();
             Alert::set(Alert::SUCCESS, __('Forum is created.'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'forum', 'action' => 'index')));
     }
 }