Example #1
0
 /**
  * Update new forum
  */
 public function action_update()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Topic')));
     $topic = new Model_Topic($this->request->param('id'));
     $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/topic', array('topic' => $topic, 'forum_parents' => $forum_parents));
     if ($_POST) {
         $topic->title = core::post('title');
         $topic->id_forum = core::post('id_forum');
         $topic->description = core::post('description');
         if (core::post('seotitle') != $topic->seotitle) {
             $topic->seotitle = $topic->gen_seotitle(core::post('seotitle'));
         }
         if (core::post('status') == 'on') {
             $topic->status = 1;
         } else {
             $topic->status = 0;
         }
         try {
             $topic->save();
             Alert::set(Alert::SUCCESS, __('Topic is updated.'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'topic', 'action' => 'index')));
     }
 }
Example #2
0
 public function action_detail($id = 0)
 {
     $data["forum"] = Model_Forum::find($id);
     if ($data["forum"] == null) {
         Response::redirect("/teachers/forum/");
     }
     if (Input::get("del_id", null) != null) {
         $del_comment = Model_Comment::find(Input::get("del_id", 0));
         if ($del_comment->user_id == $this->user->id) {
             $del_comment->deleted_at = time();
             $del_comment->save();
         }
     }
     // add
     if (Input::post("body", "") != "" and Security::check_token()) {
         // save
         $comment = Model_Comment::forge();
         $comment->body = Input::post("body", "");
         $comment->forum_id = $id;
         $comment->user_id = $this->user->id;
         $comment->save();
     }
     $data["user"] = $this->user;
     $view = View::forge("teachers/forum/detail", $data);
     $this->template->content = $view;
 }
Example #3
0
 public function action_detail($id = 0)
 {
     $data['pasts'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
     $data["forum"] = Model_Forum::find($id);
     if ($data["forum"] == null) {
         Response::redirect("/students/forum/");
     }
     if (Input::get("del_id", null) != null) {
         $del_comment = Model_Comment::find(Input::get("del_id", 0));
         if ($del_comment->user_id == $this->user->id) {
             $del_comment->deleted_at = time();
             $del_comment->save();
         }
     }
     // add
     if (Input::post("body", "") != "" and Security::check_token()) {
         // save
         $comment = Model_Comment::forge();
         $comment->body = Input::post("body", "");
         $comment->forum_id = $id;
         $comment->user_id = $this->user->id;
         $comment->save();
     }
     $data["user"] = $this->user;
     $view = View::forge("students/forum/detail", $data);
     $this->template->content = $view;
 }
Example #4
0
 public function before()
 {
     parent::before();
     $param = $this->request->param('forum');
     $forum = Model_Forum::factory($param)->load();
     try {
         if (!$forum->loaded()) {
             throw new Kohana_Exception('Forumet :forum existerar inte.', array(':forum' => $param));
         }
         $roles = $forum->roles->as_array(NULL, 'name');
         if (!$this->auth->has_roles($roles)) {
             throw new Kohana_Exception('Du måste vara inloggad för att ha tillgång till forum/:forum.', array(':forum' => $forum->name));
         }
     } catch (Kohana_Exception $e) {
         $this->message_add($e->getMessage(), 'error');
         $this->request->redirect('forum');
     }
     // Save forum for later use
     $this->_forum = $forum;
     // REST-thingy
     switch (Request::$method) {
         case 'POST':
             $this->request->action = 'create';
             break;
         case 'DELETE':
             $this->request->action = 'delete';
             break;
     }
 }
Example #5
0
 /**
  * displays the form new topic
  * @return [type] [description]
  */
 public function action_new()
 {
     if (!Auth::instance()->logged_in()) {
         Alert::set(Alert::ALERT, __('Please login before posting'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'auth', 'action' => 'login')));
     }
     $forums = Model_Forum::get_forum_count();
     if (count($forums) == 0) {
         if (Auth::instance()->logged_in() and Auth::instance()->get_user()->id_role == Model_Role::ROLE_ADMIN) {
             Alert::set(Alert::INFO, __('Please, first create some Forums.'));
             $this->redirect(Route::url('oc-panel', array('controller' => 'forum', 'action' => 'index')));
         } else {
             Alert::set(Alert::INFO, __('New Topic is not available as a feature.'));
             $this->redirect('default');
         }
     }
     $errors = NULL;
     if ($this->request->post()) {
         //captcha check
         if (captcha::check('new-forum')) {
             $user = Auth::instance()->get_user();
             //akismet spam filter
             if (!core::akismet($user->name, $user->email, core::post('description'))) {
                 $validation = Validation::factory($this->request->post())->rule('description', 'not_empty')->rule('description', 'min_length', array(':value', 5))->rule('description', 'max_length', array(':value', 1000))->rule('title', 'not_empty')->rule('title', 'min_length', array(':value', 5))->rule('id_forum', 'numeric');
                 // Optional banned words validation
                 if (core::config('advertisement.validate_banned_words')) {
                     $validation = $validation->rule('title', 'no_banned_words');
                 }
                 if ($validation->check()) {
                     $topic = new Model_Post();
                     $topic->id_user = $user->id_user;
                     $topic->id_forum = core::post('id_forum');
                     $topic->title = Text::banned_words(core::post('title'));
                     $topic->seotitle = $topic->gen_seotitle($topic->title);
                     $topic->description = Text::banned_words(core::post('description'));
                     $topic->status = Model_Post::STATUS_ACTIVE;
                     $topic->ip_address = ip2long(Request::$client_ip);
                     $topic->save();
                     $this->redirect(Route::url('forum-topic', array('forum' => $topic->forum->seoname, 'seotitle' => $topic->seotitle)));
                 } else {
                     $errors = $validation->errors('ad');
                 }
             } else {
                 Alert::set(Alert::WARNING, __('This email has been considered as spam! We are sorry but we can not send this email.'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Check the form for errors'));
         }
     }
     //template header
     $this->template->title = __('New Forum Topic');
     $this->template->meta_description = $this->template->title;
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
     $this->template->styles = array('css/jquery.sceditor.default.theme.min.css' => 'screen');
     $this->template->scripts['footer'] = array('js/jquery.sceditor.bbcode.min.js', 'js/forum-new.js');
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/forum/new', array('forums' => $forums));
     $content->errors = $errors;
 }
Example #6
0
 /**
  * returns the current forum
  * @return Model_Forum
  */
 public static function current()
 {
     //we don't have so let's retrieve
     if (self::$_current === NULL) {
         self::$_current = new self();
         if (Request::current()->param('forum') != NULL) {
             self::$_current = self::$_current->where('seoname', '=', Request::current()->param('forum'))->limit(1)->cached()->find();
         }
     }
     return self::$_current;
 }
Example #7
0
 public function action_forum()
 {
     $this->auto_render = FALSE;
     $info = array('title' => 'RSS Forum ' . Core::config('general.site_name'), 'pubDate' => date("r"), 'description' => __('Latest post published'), 'generator' => 'Open Classifieds');
     $items = array();
     $topics = new Model_Topic();
     if (Model_Forum::current()->loaded()) {
         $topics->where('id_forum', '=', Model_Forum::current()->id_forum);
     } else {
         $topics->where('id_forum', '!=', NULL);
     }
     //any forum
     $topics = $topics->where('status', '=', Model_Topic::STATUS_ACTIVE)->where('id_post_parent', 'IS', NULL)->order_by('created', 'desc')->limit(Core::config('advertisement.feed_elements'))->cached()->find_all();
     foreach ($topics as $topic) {
         $url = Route::url('forum-topic', array('seotitle' => $topic->seotitle, 'forum' => $topic->forum->seoname));
         $items[] = array('title' => htmlspecialchars($topic->title, ENT_QUOTES), 'link' => $url, 'pubDate' => Date::mysql2unix($topic->created), 'description' => htmlspecialchars(Text::removebbcode($topic->description), ENT_QUOTES), 'guid' => $url);
     }
     $xml = Feed::create($info, $items);
     $this->response->headers('Content-type', 'text/xml');
     $this->response->body($xml);
 }
Example #8
0
    ?>
" href="<?php 
    echo Route::url('rss-forum');
    ?>
" />
  <?php 
    if (Model_Forum::current()->loaded()) {
        ?>
  <link rel="alternate" type="application/atom+xml" title="RSS Forum <?php 
        echo HTML::chars(Core::config('general.site_name'));
        ?>
 - <?php 
        echo Model_Forum::current()->name;
        ?>
" href="<?php 
        echo Route::url('rss-forum', array('forum' => Model_Forum::current()->seoname));
        ?>
" />
  <?php 
    }
}
if (Model_User::current() != NULL and Model_User::current()->loaded()) {
    ?>
  <link rel="alternate" type="application/atom+xml" title="RSS Profile - <?php 
    echo HTML::chars(Model_User::current()->name);
    ?>
" href="<?php 
    echo Route::url('rss-profile', array('seoname' => Model_User::current()->seoname));
    ?>
" />
  <?php 
Example #9
0
 public function threads_for_userAction()
 {
     $request = $this->getRequest();
     $this->setViewChange('index');
     $username = $request->getRequest('threads_for_user');
     $username = trim(mb_strtolower(urldecode($username), 'UTF-8'));
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Forum'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum')), array('name' => $username));
     $this->view->mainCategories = array();
     $this->view->mainCategories = Model_Forum::getAll();
     foreach ($this->view->mainCategories as $k => $v) {
         $this->view->mainCategories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=thread/' . $this->view->mainCategories[$k]['id'] . '/' . WM_Router::clearName($this->view->mainCategories[$k]['name']));
     }
     $this->view->mainCategories = array_merge(array(0 => array('name' => $this->translate('All Topics'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum'))), $this->view->mainCategories);
     $this->view->headline = $this->translate('All Topics');
     $this->view->sel_thread = -1;
     $this->view->headline = $this->translate('Threads') . ': ' . $username;
     $threads = Model_Forum::getThreadsByUser($username);
     $total_records = count($threads);
     if ($threads) {
         $model_images = new Model_Images();
         $page = (int) $request->getRequest('page', 1);
         if ($page < 1) {
             $page = 1;
         }
         $limit = JO_Registry::get('front_limit');
         if (JO_Session::get('msg_success')) {
             $this->view->msg_success = JO_Session::get('msg_success');
             JO_Session::clear('msg_success');
         }
         if (JO_Session::get('msg_error')) {
             $this->view->error = JO_Session::get('msg_error');
             $this->view->data = JO_Session::get('data');
             JO_Session::clear('msg_error');
             JO_Session::clear('data');
         }
         $total_records = count($threads);
         $start = $page * $limit - $limit;
         if ($start > $total_records) {
             $page = max(ceil($total_records / $limit), 1);
             $start = $page * $limit - $limit;
         } elseif ($start < 0) {
             $start = 0;
         }
         $threads = array_slice($threads, $start, $limit);
         foreach ($threads as $thread) {
             if ($thread['avatar']) {
                 $thread['avatar'] = $model_images->resize($thread['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
             } else {
                 $thread['avatar'] = 'data/themes/images/noavatar.png';
             }
             $thread['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'owner']));
             $thread_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=topic/' . $thread['id'] . '/' . WM_Router::clearName($thread['name']));
             $thread['threadhref'] = $thread_link;
             $thread['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=report/' . $thread['id']);
             $thread['badges'] = Helper_Author::userBadges($thread['badges']);
             $thread['first_date'] = WM_Date::format($thread['datetime'], 'dd M yy H:i');
             $last_page = ceil($thread['cnt'] / $limit);
             if (!empty($thread['lusername'])) {
                 if ($thread['lavatar']) {
                     $thread['lavatar'] = $model_images->resize($thread['lavatar'], 50, 50, true);
                 } else {
                     $thread['lavatar'] = 'data/themes/images/small_noavatar.png';
                 }
                 $thread['lasthref'] = $thread_link . ($last_page > 1 ? '/page/' . $last_page : '');
                 $thread['lhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'lusername']));
                 $thread['last_date'] = WM_Date::format($thread['last_post'], 'dd M yy H:i');
             }
             $this->view->threads[] = $thread;
         }
         $pagination = new Model_Pagination();
         $pagination->setLimit($limit);
         $pagination->setPage($page);
         $pagination->setText(array('text_prev' => $this->view->translate('Prev'), 'text_next' => $this->view->translate('Next')));
         $pagination->setTotal($total_records);
         $pagination->setUrl(WM_Router::create($request->getBaseUrl() . '?controller=forum&action=index&page={page}'));
         $this->view->pagination = $pagination->render();
         if (!empty($this->view->pagination)) {
             $this->view->pagination = str_replace('{of}', $this->view->translate('OF'), $this->view->pagination);
         }
     }
     $this->view->children = array();
     $this->view->children['rightside'] = 'forum/rightside';
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
Example #10
0
 public function post_delforum()
 {
     $code = 0;
     $message = "ok";
     if ($this->auth_status) {
         $forum = Model_Forum::find(Input::post("id", 0));
         if ($forum != null) {
             $forum->deleted_at = time();
             $forum->save();
         } else {
             $code = 404;
             $message = "Content not found.";
         }
     } else {
         $code = 500;
         $message = "Auth error.";
     }
     $this->response(array('code' => $code, 'message' => $message));
 }
Example #11
0
 /**
  * CRUD controller: DELETE
  */
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $forum = new Model_Forum($this->request->param('id'));
     //update the elements related to that ad
     if ($forum->loaded()) {
         try {
             $forum->delete();
             $this->template->content = 'OK';
             Core::delete_cache();
             Alert::set(Alert::SUCCESS, __('Forum deleted'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
     } else {
         Alert::set(Alert::ERROR, __('Forum not deleted'));
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'forum', 'action' => 'index')));
 }
Example #12
0
 private function getForm()
 {
     $request = $this->getRequest();
     $id = $request->getQuery('id');
     if ($id) {
         $info = Model_Forum::get($id);
     }
     if ($request->getPost('status')) {
         $this->view->status = $request->getPost('status');
     } elseif (isset($info)) {
         $this->view->status = $info['status'];
     } else {
         $this->view->status = 'false';
     }
     if ($request->getPost('name')) {
         $this->view->name = $request->getPost('name');
     } elseif (isset($info)) {
         $this->view->name = $info['name'];
     } else {
         $this->view->name = '';
     }
     if ($request->getPost('order_index')) {
         $this->view->order_index = $request->getPost('order_index');
     } elseif (isset($info)) {
         $this->view->order_index = $info['order_index'];
     } else {
         $this->view->order_index = Model_Forum::getMaxPosition();
     }
     $this->view->comments = Model_Forum::getReported();
 }
Example #13
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if ($this->getLayout()->meta_title) {
         $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . JO_Registry::get('meta_title'));
     } else {
         $this->getLayout()->placeholder('title', JO_Registry::get('meta_title'));
     }
     if ($this->getLayout()->meta_description) {
         $this->getLayout()->placeholder('description', $this->getLayout()->meta_description);
     } else {
         $this->getLayout()->placeholder('description', JO_Registry::get('meta_description'));
     }
     if ($this->getLayout()->meta_keywords) {
         $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords);
     } else {
         $this->getLayout()->placeholder('keywords', JO_Registry::get('meta_keywords'));
     }
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(JO_Registry::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads/' . JO_Registry::get('site_logo'))) {
         $this->view->site_logo = JO_Registry::get('site_logo');
     }
     $this->view->home_action = $request->getBaseUrl();
     $this->getCategories();
     $this->view->menuPages = Model_Pages::getPagesMenu();
     if (isset($this->view->menuPages[0])) {
         foreach ($this->view->menuPages[0] as $k => $v) {
             $this->view->menuPages[0][$k]['href'] = $v['url'] ? $v['url'] : WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name']));
             if (isset($this->view->menuPages[$v['id']])) {
                 foreach ($this->view->menuPages[$v['id']] as $r => $t) {
                     $this->view->menuPages[$v['id']][$r]['href'] = $t['url'] ? $t['url'] : WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $t['id'] . '&name=' . WM_Router::clearName($t['name']));
                 }
             }
         }
     }
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     }
     if (JO_Session::get('msg_error')) {
         $this->view->msg_error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     $this->view->recent_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=recent');
     $this->view->top_sellers_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=popular');
     $this->view->feature_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=featured');
     $this->view->collections_href = WM_Router::create($request->getBaseUrl() . '?controller=collections');
     $this->view->top_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=top');
     $this->view->all_authors_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=authors');
     $this->view->search = WM_Router::create($request->getBaseUrl() . '?controller=search');
     ////////// CURRENCY
     //autoupdate currency if set
     if (JO_Registry::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
         $currencies = WM_Currency::getCurrencies();
         $this->view->currencies = array();
         if ($currencies) {
             foreach ($currencies as $currency) {
                 $currency['active'] = $currency['code'] == WM_Currency::getCurrencyCode();
                 $this->view->currencies[] = $currency;
             }
         }
     }
     ///////// LANGUAGES
     $languages = WM_Locale::getLanguages();
     if ($languages && count($languages) > 1) {
         $this->view->languages = array();
         $config_language_id = JO_Registry::get('config_language_id');
         foreach ($languages as $language) {
             if ($language['language_id'] == $config_language_id) {
                 $this->view->current_language = array('name' => $language['name'], 'id' => $language['language_id'], 'image' => 'data/themes/images/flags/' . $language['image']);
             } else {
                 $this->view->languages[] = array('name' => $language['name'], 'id' => $language['language_id'], 'image' => 'data/themes/images/flags/' . $language['image']);
             }
         }
     }
     $username = JO_Session::get('username');
     if ($username) {
         $this->view->user = Model_Users::getUser(JO_Session::get('user_id'));
         $this->view->user['total'] = WM_Currency::format($this->view->user['total']);
         $ind = 0;
         $this->view->options = array(array('name' => $this->view->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('My Account'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Downloads'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=downloads'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Collections'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Deposit'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=deposit'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Dashboard'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=dashboard'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Upload'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=upload'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Earnings'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=earnings'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Statement'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=statement'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Withdrawal'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=withdrawal'), 'css' => 'icon-' . ++$ind));
         $this->view->user_logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
     } else {
         $this->view->user_registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=registration');
         $this->view->user_login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         $this->view->user_lost_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=lost_username');
         $this->view->user_reset_password = WM_Router::create($request->getBaseUrl() . '?controller=users&action=reset_password');
     }
     $threads = Model_Forum::getAll();
     if ($threads) {
         $this->view->forum_link = WM_Router::create($request->getBaseUrl() . '?controller=forum');
         $this->view->threads = array();
         foreach ($threads as $thread) {
             $this->view->threads[] = array('name' => $thread['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum&action=thread/' . $thread['id'] . '&name=' . WM_Router::clearName($thread['name'])));
         }
     }
     $facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret')));
     $this->view->facebook_link = $facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=callback_facebook'), 'req_perms' => JO_Registry::forceGet('facebook_req_perms'), 'scope' => JO_Registry::forceGet('facebook_req_perms')));
     $this->view->children = array();
     $this->view->children['extensions_top'] = 'extensions/top';
     //	$this->view->children['extensions_topmiddle'] = 'extensions/topmiddle';
 }