function KB_know() { global $txt, $sourcedir, $smcFunc, $catname, $modSettings, $user_info, $scripturl, $context; $context['sub_template'] = 'kb_know'; $_GET['cat'] = (int) $_GET['cat']; $params = array('table' => 'kb_category', 'call' => 'name', 'where' => 'kbid = {int:cat}'); $data = array('cat' => (int) $_GET['cat']); $catname = KB_ListData($params, $data); $context['linktree'][] = array('url' => $scripturl . '?action=kb;area=cats;cat=' . $_GET['cat'] . '', 'name' => $catname['name']); $context['page_title'] = $catname['name']; KBisAllowedto($_GET['cat'], 'view'); $params1 = array('table' => 'kb_category', 'call' => 'kbid', 'where' => 'id_parent = {int:cat}'); $data1 = array('cat' => (int) $_GET['cat']); $kbid = KB_ListData($params1, $data1); if ($kbid['kbid']) { KB_subcat(); } $artperpage = !empty($modSettings['kb_app']) ? $modSettings['kb_app'] : 30; $list_options = array('id' => 'kb_know', 'title' => $catname['name'], 'items_per_page' => $artperpage, 'base_href' => $scripturl . '?action=kb;area=cats;cat=' . $_GET['cat'] . '', 'default_sort_col' => 'kbnid', 'get_items' => array('function' => create_function('$start, $items_per_page, $sort', ' global $user_info, $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT k.kbnid, k.title, k.views, k.date, k.id_cat, k.approved, k.id_member, m.real_name, k.rate, k.comments FROM {db_prefix}kb_articles AS k LEFT JOIN {db_prefix}members AS m ON (k.id_member = m.id_member) WHERE id_cat = {int:cat} AND approved = 1 ORDER BY {raw:sort} LIMIT {int:start}, {int:per_page}\', array( \'current_member\' => $user_info[\'id\'], \'cat\' => (int) $_GET[\'cat\'], \'sort\' => $sort, \'start\' => $start, \'per_page\' => $items_per_page, ) ); $kbcn = array(); while ($row = $smcFunc[\'db_fetch_assoc\']($request)) $kbcn[] = $row; $smcFunc[\'db_free_result\']($request); return $kbcn; ')), 'get_count' => array('function' => create_function('', ' global $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT COUNT(*) FROM {db_prefix}kb_articles WHERE id_cat = {int:cat} AND approved = 1\', array(\'cat\' => (int) $_GET[\'cat\'],)); list ($total_kbn) = $smcFunc[\'db_fetch_row\']($request); $smcFunc[\'db_free_result\']($request); return $total_kbn; ')), 'no_items_label' => $txt['knowledgebasenone'], 'columns' => array('kbnid' => array('header' => array('value' => '-'), 'data' => array('function' => create_function('$row', ' global $settings; if($row[\'views\'] >= 25){ return \'<img src="\'.$settings[\'images_url\'].\'/topic/veryhot_post.gif" alt="" align="middle" />\'; }elseif($row[\'views\'] >= 15){ return \'<img src="\'.$settings[\'images_url\'].\'/topic/hot_post.gif" alt="" align="middle" />\'; }else{ return \'<img src="\'.$settings[\'images_url\'].\'/topic/normal_post.gif" alt="" align="middle" />\'; } '), 'style' => 'width: 1%; text-align: left;'), 'sort' => array('default' => 'kbnid DESC', 'reverse' => 'kbnid')), 'title' => array('header' => array('value' => $txt['knowledgebasetitle']), 'data' => array('function' => create_function('$row', ' global $scripturl; return \'<a href="\'.$scripturl.\'?action=kb;area=article;cont=\'.$row[\'kbnid\'].\'">\'.$row[\'title\'].\'</a>\'; '), 'style' => 'width: 20%; text-align: left;'), 'sort' => array('default' => 'title DESC', 'reverse' => 'title')), 'author' => array('header' => array('value' => $txt['knowledgebaseauthor']), 'data' => array('function' => create_function('$row', ' global $scripturl; return \'\'.KB_profileLink($row[\'real_name\'], $row[\'id_member\']).\'\'; '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'real_name', 'reverse' => 'real_name DESC')), 'date' => array('header' => array('value' => $txt['knowledgebasecreated']), 'data' => array('function' => create_function('$row', ' return \'<div class="smalltext">\'.timeformat($row[\'date\']).\'</div>\'; '), 'style' => 'width: 10%; text-align: center;'), 'sort' => array('default' => 'date', 'reverse' => 'date DESC')), 'rate' => array('header' => array('value' => $txt['kb_pinfi2']), 'data' => array('function' => create_function('$row', ' return KB_Stars_Precent($row[\'rate\']); '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'rate', 'reverse' => 'rate DESC')), 'comments' => array('header' => array('value' => $txt['kb_ecom2']), 'data' => array('function' => create_function('$row', ' return $row[\'comments\']; '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'comments', 'reverse' => 'comments DESC')), 'views' => array('header' => array('value' => $txt['knowledgebaseviews']), 'data' => array('function' => create_function('$row', ' return $row[\'views\']; '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'views', 'reverse' => 'views DESC')))); if (empty($modSettings['kb_show_view'])) { unset($list_options['columns']['views']); } if (empty($modSettings['kb_eratings'])) { unset($list_options['columns']['rate']); } if (empty($modSettings['kb_ecom'])) { unset($list_options['columns']['comments']); } if (empty($modSettings['kb_salegend'])) { unset($list_options['columns']['icon']); } require_once $sourcedir . '/Subs-List.php'; createList($list_options); }
function KB_knowcont() { global $smcFunc, $txt, $scripturl, $sourcedir, $boardurl, $modSettings, $user_info, $context; $context['sub_template'] = 'kb_knowcont'; if (isset($_REQUEST['cont'])) { if (($listData = cache_get_data('kb_articles_listinfo' . $_GET['cont'] . '', 3600)) === null) { $params = array('table' => 'kb_articles AS a', 'call' => 'a.title,a.kbnid,a.id_cat,c.name', 'left_join' => '{db_prefix}kb_category AS c ON (a.id_cat = c.kbid)', 'where' => 'a.kbnid = {int:kbnid}'); $data = array('kbnid' => (int) $_GET['cont']); $listData = KB_ListData($params, $data); cache_put_data('kb_articles_listinfo' . $_GET['cont'] . '', $listData, 3600); } $artname = $listData['title']; $aid = $listData['kbnid']; $cid = $listData['id_cat']; $cname = $listData['name']; if (!$aid) { fatal_error('' . $txt['kb_pinfi7'] . ' <strong>' . $_GET['cont'] . '</strong> ' . $txt['kb_jumpgo1'] . '', false); } $context['linktree'][] = array('url' => $scripturl . '?action=kb;area=cats;cat=' . $cid . '', 'name' => $cname); $context['linktree'][] = array('url' => $scripturl . '?action=kb;area=article;cont=' . $_GET['cont'] . '', 'name' => $artname); if (($context['know'] = cache_get_data('kb_articles' . $_GET['cont'] . '', 3600)) === null) { $result = $smcFunc['db_query']('', ' SELECT k.kbnid,k.content, k.source, k.title,k.id_cat,k.date,k.id_member,m.real_name, k.views, k.rate, k.approved FROM {db_prefix}kb_articles AS k LEFT JOIN {db_prefix}members AS m ON (k.id_member = m.id_member) LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member) WHERE kbnid = {int:kbnid}', array('kbnid' => (int) $_GET['cont'])); $context['know'] = array(); while ($row = $smcFunc['db_fetch_assoc']($result)) { $context['know'][] = array('content' => KB_parseTags($row['content'], $row['kbnid'], 3), 'title' => parse_bbc($row['title']), 'source' => parse_bbc($row['source']), 'kbnid' => $row['kbnid'], 'approved' => $row['approved'], 'views' => $row['views'], 'rate' => $row['rate'], 'date' => date('D d M Y', $row['date']), 'id_cat' => $row['id_cat'], 'id_member' => $row['id_member'], 'real_name' => $row['real_name']); } $smcFunc['db_free_result']($result); cache_put_data('kb_articles' . $_GET['cont'] . '', $context['know'], 3600); } $context['page_title'] = $context['know'][0]['title']; if ($context['know'][0]['approved'] == 0 && $context['know'][0]['id_member'] != $user_info['id'] && !allowedTo('manage_kb')) { fatal_lang_error('kb_articlwnot_approved', false); } KBisAllowedto($context['know'][0]['id_cat'], 'view'); $context['kbimg'] = KB_getimages($_GET['cont']); if (!empty($modSettings['kb_ecom'])) { $context['kbcom'] = KB_getcomments($_GET['cont']); KB_showediter(!empty($_POST['description']) ? $_POST['description'] : '', 'description'); } KB_dojprint(); $query_params = array('table' => 'kb_articles', 'set' => 'views = views + 1', 'where' => 'kbnid = {int:kbnid}'); $query_data = array('kbnid' => (int) $_GET['cont']); kb_UpdateData($query_params, $query_data); } if ($user_info['is_guest']) { require_once $sourcedir . '/Subs-Editor.php'; $verificationOptions = array('id' => 'register'); $context['visual_verification'] = create_control_verification($verificationOptions); $context['visual_verification_id'] = $verificationOptions['id']; } //comment if (isset($_REQUEST['comment'])) { if ($user_info['is_guest']) { require_once $sourcedir . '/Subs-Editor.php'; $verificationOptions = array('id' => 'register'); $context['visual_verification'] = create_control_verification($verificationOptions, true); if (is_array($context['visual_verification'])) { loadLanguage('Errors'); foreach ($context['visual_verification'] as $error) { fatal_error($txt['error_' . $error]); } } } isAllowedTo('com_kb'); checkSession(); $_POST['description'] = $smcFunc['htmlspecialchars']($_POST['description'], ENT_QUOTES); $_GET['arid'] = (int) $_GET['arid']; if (empty($_POST['description'])) { fatal_lang_error('knowledgebase_emtydesc', false); } $approved = allowedTo('auto_approvecom_kb') ? 1 : 0; $mes = '' . $txt['kb_log_text4'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $_GET['arid'] . '">' . $context['know'][0]['title'] . '</a></strong>'; KB_log_actions('add_com', $_GET['arid'], $mes); $data = array('table' => 'kb_comments', 'cols' => array('id_article' => 'int', 'comment' => 'string', 'date' => 'int', 'id_member' => 'int', 'approved' => 'int')); $values = array($_GET['arid'], $_POST['description'], time(), $user_info['id'], $approved); $indexes = array('id_article'); KB_InsertData($data, $values, $indexes); KBrecountcomments(); KB_cleanCache(); redirectexit('action=kb;area=article;cont=' . $_GET['arid'] . ''); } if (isset($_REQUEST['commentdel'])) { isAllowedTo('comdel_kb'); $mes = '' . $txt['kb_log_text3'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $_GET['cont'] . '">' . $context['know'][0]['title'] . '</a></strong>'; KB_log_actions('del_com', $_GET['cont'], $mes); $query_params = array('table' => 'kb_comments', 'where' => 'id = {int:kbid}'); $query_data = array('kbid' => (int) $_GET['arid']); KB_DeleteData($query_params, $query_data); KB_cleanCache(); KBrecountcomments(); redirectexit('action=kb;area=article;cont=' . $_GET['cont'] . ''); } //approve if (isset($_REQUEST['approve'])) { checkSession('get'); $query_params = array('table' => 'kb_articles', 'set' => 'approved = {int:one}', 'where' => 'kbnid = {int:kbnid}'); $query_data = array('kbnid' => (int) $_REQUEST['aid'], 'one' => 1); kb_UpdateData($query_params, $query_data); $params = array('table' => 'kb_articles', 'call' => 'id_member, kbnid, title', 'where' => 'kbnid = {int:kbnid}'); $data = array('kbnid' => (int) $_GET['aid']); $listData = KB_ListData($params, $data); $nameid = $listData['id_member']; $kid = $listData['kbnid']; $title = $listData['title']; $kbmes = '' . $txt['kb_aapprove1'] . ' [url=' . $scripturl . '?action=kb;area=article;cont=' . $kid . ']' . $txt['kb_aapprove2'] . '[/url] ' . $txt['kb_aapprove3'] . ''; KB_sendpm($nameid, $txt['kb_aapprove6'], $kbmes); $mes = '' . $txt['kb_log_text2'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $kid . '">' . $title . '</a></strong>'; KB_log_actions('app_article', $kid, $mes); KBrecountItems(); KB_cleanCache(); redirectexit('action=kb;area=article;cont=' . $_REQUEST['aid'] . ''); } //unapprove if (isset($_REQUEST['unapprove']) && isset($_REQUEST['inap'])) { checkSession('get'); $query_params = array('table' => 'kb_articles', 'set' => 'approved = {int:one}', 'where' => 'kbnid = {int:kbnid}'); $query_data = array('kbnid' => (int) $_REQUEST['inap'], 'one' => 0); kb_UpdateData($query_params, $query_data); $params = array('table' => 'kb_articles', 'call' => 'id_member, kbnid, title', 'where' => 'kbnid = {int:kbnid}'); $data = array('kbnid' => (int) $_GET['inap']); $listData = KB_ListData($params, $data); $nameid = $listData['id_member']; $kid = $listData['kbnid']; $title = $listData['title']; $kbmes = '' . $txt['kb_aapprove4'] . ' [url=' . $scripturl . '?action=kb;area=article;cont=' . $kid . ']' . $txt['kb_aapprove2'] . '[/url] ' . $txt['kb_aapprove3'] . ''; KB_sendpm($nameid, $txt['kb_aapprove7'], $kbmes); $mes = '' . $txt['kb_log_text1'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $kid . '">' . $title . '</a></strong>'; KB_log_actions('unapp_article', $kid, $mes); KBrecountItems(); KB_cleanCache(); redirectexit('action=kb;area=article;cont=' . $_REQUEST['inap'] . ''); } }