protected function getPost($post_id, $params = array()) { list($discussions) = fn_get_discussions(array('post_id' => $post_id)); if (!$discussions) { return false; } $discussion = reset($discussions); if (!empty($params['object_type']) && $params['object_type'] != $discussion['object_type'] || !empty($params['object_id']) && $params['object_id'] != $discussion['object_id']) { return false; } return $discussion; }
$discussion_object_types = fn_get_discussion_objects(); if (empty($_REQUEST['object_type'])) { reset($discussion_object_types); $_REQUEST['object_type'] = key($discussion_object_types); // FIXME: bad style } $_url = fn_query_remove(Registry::get('config.current_url'), 'object_type', 'page'); foreach ($discussion_object_types as $obj_type => $obj) { if ($obj_type == 'E' && Registry::ifGet('addons.discussion.home_page_testimonials', 'D') == 'D') { continue; } $_name = $obj_type != 'E' ? __($obj) . ' ' . __('discussion_title_' . $obj) : __('discussion_title_' . $obj); // FIXME!!! Bad style Registry::set('navigation.tabs.' . $obj, array('title' => $_name, 'href' => $_url . '&object_type=' . $obj_type)); } list($posts, $search) = fn_get_discussions($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page')); if (!empty($posts)) { foreach ($posts as $k => $v) { $posts[$k]['object_data'] = fn_get_discussion_object_data($v['object_id'], $v['object_type'], DESCR_SL); } } Tygh::$app['view']->assign('posts', $posts); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->assign('discussion_object_type', $_REQUEST['object_type']); Tygh::$app['view']->assign('discussion_object_types', $discussion_object_types); } function fn_get_discussions($params, $items_per_page) { // Init filter $params = LastView::instance()->update('discussion', $params); // Set default values to input params
die('Access denied'); } if ($mode == 'manage') { $discussion_object_types = fn_get_discussion_objects(); if (empty($_REQUEST['object_type'])) { reset($discussion_object_types); $_REQUEST['object_type'] = key($discussion_object_types); // FIXME: bad style } $_url = fn_query_remove(Registry::get('config.current_url'), 'object_type'); foreach ($discussion_object_types as $obj_type => $obj) { $_name = $obj_type != 'E' ? fn_get_lang_var($obj) . ' ' . fn_get_lang_var('discussion_title_' . $obj) : fn_get_lang_var('discussion_title_' . $obj); // FIXME!!! Bad style Registry::set('navigation.tabs.' . $obj, array('title' => $_name, 'href' => $_url . '&object_type=' . $obj_type, 'ajax' => true)); } list($posts, $search) = fn_get_discussions($_REQUEST); if (!empty($posts)) { foreach ($posts as $k => $v) { $posts[$k]['object_data'] = fn_get_discussion_object_data($v['object_id'], $v['object_type'], DESCR_SL); } } $view->assign('posts', $posts); $view->assign('search', $search); if ($_REQUEST['object_type'] == 'E') { // FIXME!!! Bad style, must be reworked $is_enabled = db_get_field("SELECT type FROM ?:discussion WHERE object_id = '0' AND object_type = 'E'"); if (empty($is_enabled) || $is_enabled == 'D') { $view->assign('object_notice', fn_get_lang_var('text_enabled_testimonials_notice')); } else { $view->assign('but_text', fn_get_lang_var('add_new')); $view->assign('but_href', "discussion.update?discussion_type=E#add_new_post");