Bootswatch, Summernote, and Captcheck mods for Mods for HESK (mods-for-hesk.com). In use at support.netsyms.com.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

manage_knowledgebase.php 106KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520
  1. <?php
  2. /**
  3. *
  4. * This file is part of HESK - PHP Help Desk Software.
  5. *
  6. * (c) Copyright Klemen Stirn. All rights reserved.
  7. * https://www.hesk.com
  8. *
  9. * For the full copyright and license agreement information visit
  10. * https://www.hesk.com/eula.php
  11. *
  12. */
  13. define('IN_SCRIPT',1);
  14. define('HESK_PATH','../');
  15. define('VALIDATOR', 1);
  16. define('PAGE_TITLE', 'ADMIN_KB');
  17. define('MFH_PAGE_LAYOUT', 'TOP_ONLY');
  18. /* Get all the required files and functions */
  19. require(HESK_PATH . 'hesk_settings.inc.php');
  20. require(HESK_PATH . 'inc/common.inc.php');
  21. require(HESK_PATH . 'inc/admin_functions.inc.php');
  22. require(HESK_PATH . 'inc/view_attachment_functions.inc.php');
  23. require(HESK_PATH . 'inc/mail_functions.inc.php');
  24. hesk_load_database_functions();
  25. // Check for POST requests larger than what the server can handle
  26. if ( $_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) && ! empty($_SERVER['CONTENT_LENGTH']) )
  27. {
  28. hesk_error($hesklang['maxpost']);
  29. }
  30. // For convenience allow adding at least 3 attachments at once in the KB
  31. if ($hesk_settings['attachments']['max_number'] < 3)
  32. {
  33. $hesk_settings['attachments']['max_number'] = 3;
  34. }
  35. hesk_session_start();
  36. hesk_dbConnect();
  37. hesk_isLoggedIn();
  38. $modsForHesk_settings = mfh_getSettings();
  39. /* Check permissions for this feature */
  40. if ( ! hesk_checkPermission('can_man_kb',0))
  41. {
  42. /* This person can't manage the knowledgebase, but can read it */
  43. header('Location: knowledgebase_private.php');
  44. exit();
  45. }
  46. /* Is Knowledgebase enabled? */
  47. if ( ! $hesk_settings['kb_enable'])
  48. {
  49. hesk_error($hesklang['kbdis']);
  50. }
  51. /* This will tell the header to include WYSIWYG editor Javascript */
  52. define('WYSIWYG',1);
  53. /* What should we do? */
  54. if ( $action = hesk_REQUEST('a') )
  55. {
  56. if ($action == 'add_article') {add_article();}
  57. elseif ($action == 'add_category') {add_category();}
  58. elseif ($action == 'manage_cat') {manage_category();}
  59. elseif ($action == 'edit_article') {edit_article();}
  60. elseif ($action == 'import_article') {import_article();}
  61. elseif ($action == 'list_private') {list_private();}
  62. elseif ($action == 'list_draft') {list_draft();}
  63. elseif ( defined('HESK_DEMO') ) {hesk_process_messages($hesklang['ddemo'], 'manage_knowledgebase.php', 'NOTICE');}
  64. elseif ($action == 'new_article') {new_article();}
  65. elseif ($action == 'new_category') {new_category();}
  66. elseif ($action == 'remove_article') {remove_article();}
  67. elseif ($action == 'save_article') {save_article();}
  68. elseif ($action == 'order_article') {order_article();}
  69. elseif ($action == 'order_cat') {order_category();}
  70. elseif ($action == 'edit_category') {edit_category();}
  71. elseif ($action == 'remove_kb_att') {remove_kb_att();}
  72. elseif ($action == 'sticky') {toggle_sticky();}
  73. elseif ($action == 'update_count') {update_count(1);}
  74. }
  75. // Part of a trick to prevent duplicate article submissions by reloading pages
  76. hesk_cleanSessionVars('article_submitted');
  77. /* Print header */
  78. require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
  79. /* Print main manage users page */
  80. require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
  81. ?>
  82. <?php
  83. /* This will handle error, success and notice messages */
  84. #hesk_handle_messages();
  85. // Total number of KB articles
  86. $total_articles = 0;
  87. // Get number of sub-categories for each parent category
  88. $parent = array(0 => 1);
  89. $result = hesk_dbQuery('SELECT `parent`, COUNT(*) AS `num` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_categories` GROUP BY `parent`');
  90. while ($row = hesk_dbFetchAssoc($result))
  91. {
  92. $parent[$row['parent']] = $row['num'];
  93. }
  94. $parent_copy = $parent;
  95. //print_r($parent);
  96. // Get Knowledgebase structure
  97. $kb_cat = array();
  98. $result = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_categories` ORDER BY `parent` ASC, `cat_order` ASC');
  99. while ($cat = hesk_dbFetchAssoc($result))
  100. {
  101. // Can this category be moved at all?
  102. if (
  103. $cat['id'] == 1 || // Main category cannot be moved
  104. ! isset($parent[$cat['parent']]) || // if the parent category isn't set
  105. $parent[$cat['parent']] < 2 // Less than 2 articles in category
  106. )
  107. {
  108. $cat['move_up'] = false;
  109. $cat['move_down'] = false;
  110. }
  111. else
  112. {
  113. $cat['move_up'] = true;
  114. $cat['move_down'] = true;
  115. }
  116. $kb_cat[] = $cat;
  117. }
  118. //print_r($kb_cat);
  119. /* Translate main category "Knowledgebase" if needed */
  120. $kb_cat[0]['name'] = $hesklang['kb_text'];
  121. require(HESK_PATH . 'inc/treemenu/TreeMenu.php');
  122. $icon = 'folder.gif';
  123. $expandedIcon = 'fa-folder-open" style="font-size:17px';
  124. $menu = new HTML_TreeMenu();
  125. $thislevel = array('0');
  126. $nextlevel = array();
  127. $i = 1;
  128. $j = 1;
  129. if (isset($_SESSION['KB_CATEGORY']))
  130. {
  131. $selected_catid = intval($_SESSION['KB_CATEGORY']);
  132. }
  133. else
  134. {
  135. $selected_catid = 0;
  136. }
  137. while (count($kb_cat) > 0)
  138. {
  139. foreach ($kb_cat as $k=>$cat)
  140. {
  141. if (in_array($cat['parent'],$thislevel))
  142. {
  143. $arrow = ($i - 2) % 10;
  144. $arrow = $arrow == 0 ? '' : $arrow;
  145. $up = $cat['parent'];
  146. $my = $cat['id'];
  147. $type = $cat['type'] ? '*' : '';
  148. $selected = ($selected_catid == $my) ? 1 : 0;
  149. $cls = (isset($_SESSION['newcat']) && $_SESSION['newcat'] == $my) ? ' class="kbCatListON"' : '';
  150. $text = str_replace('\\','\\\\','<span id="c_'.$my.'"'.$cls.'><a href="manage_knowledgebase.php?a=manage_cat&catid='.$my.'">'.$cat['name'].'</a>').$type.'</span> (<span class="kb_published">'.$cat['articles'].'</span>, <span class="kb_private">'.$cat['articles_private'].'</span>, <span class="kb_draft">'.$cat['articles_draft'].'</span>) '; /* ' */
  151. $text_short = $cat['name'].$type.' ('.$cat['articles'].', '.$cat['articles_private'].', '.$cat['articles_draft'].')';
  152. $total_articles += $cat['articles'];
  153. // Generate KB menu icons
  154. $menu_icons =
  155. '<a href="manage_knowledgebase.php?a=add_article&amp;catid='.$my.'" onclick="document.getElementById(\'option'.$j.'\').selected=true;return true;"><i class="fa fa-plus font-size-16p green" ></i></a> '
  156. .'<a href="manage_knowledgebase.php?a=add_category&amp;parent='.$my.'" onclick="document.getElementById(\'option'.$j.'_2\').selected=true;return true;"><i class="fa fa-caret-right font-size-16p blue"></i></a> '
  157. .'<a href="manage_knowledgebase.php?a=manage_cat&amp;catid='.$my.'"><i class="fa fa-gear font-size-16p gray"></i></a> '
  158. ;
  159. // Can this category be moved up?
  160. if ($cat['move_up'] == false || ($cat['move_up'] && $parent_copy[$cat['parent']] == $parent[$cat['parent']]) )
  161. {
  162. $menu_icons .= '<img src="../img/blank.gif" width="16" height="16" alt="" class="optionWhiteNbOFF" /> ';
  163. }
  164. else
  165. {
  166. $menu_icons .= '<a href="manage_knowledgebase.php?a=order_cat&amp;catid='.$my.'&amp;move=-15&amp;token=' . hesk_token_echo(0) . '"><i class="fa fa-arrow-up font-size-16p green"></i></a> ';
  167. }
  168. // Can this category be moved down?
  169. if ($cat['move_down'] == false || ($cat['move_down'] && $parent_copy[$cat['parent']] == 1) )
  170. {
  171. $menu_icons .= '<img src="../img/blank.gif" width="16" height="16" alt="" class="optionWhiteNbOFF" /> ';
  172. }
  173. else
  174. {
  175. $menu_icons .= '<a href="manage_knowledgebase.php?a=order_cat&amp;catid='.$my.'&amp;move=15&amp;token=' . hesk_token_echo(0) . '"><i class="fa fa-arrow-down font-size-16p green"></i></a> ';
  176. }
  177. if (isset($node[$up]))
  178. {
  179. $node[$my] = &$node[$up]->addItem(new HTML_TreeNode(array('hesk_selected' => $selected, 'text' => $text, 'text_short' => $text_short, 'menu_icons' => $menu_icons, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option'.$j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true)));
  180. }
  181. else
  182. {
  183. $node[$my] = new HTML_TreeNode(array('hesk_selected' => $selected, 'text' => $text, 'text_short' => $text_short, 'menu_icons' => $menu_icons, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option'.$j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true));
  184. }
  185. $nextlevel[] = $cat['id'];
  186. $parent_copy[$cat['parent']]--;
  187. $j++;
  188. unset($kb_cat[$k]);
  189. }
  190. }
  191. $thislevel = $nextlevel;
  192. $nextlevel = array();
  193. /* Break after 20 recursions to avoid hang-ups in case of any problems */
  194. if ($i > 20)
  195. {
  196. break;
  197. }
  198. $i++;
  199. }
  200. $menu->addItem($node[1]);
  201. // Create the presentation class
  202. $treeMenu = & ref_new(new HTML_TreeMenu_DHTML($menu, array('images' => '../img', 'defaultClass' => 'treeMenuDefault', 'isDynamic' => true)));
  203. $listBox = & ref_new(new HTML_TreeMenu_Listbox($menu));
  204. /* Hide new article and new category forms by default */
  205. if (!isset($_SESSION['hide']))
  206. {
  207. $_SESSION['hide'] = array(
  208. //'treemenu' => 1,
  209. 'new_article' => 1,
  210. 'new_category' => 1,
  211. );
  212. }
  213. echo '';
  214. /* Hide tree menu? */
  215. if (!isset($_SESSION['hide']['treemenu']))
  216. {
  217. ?>
  218. <div class="content-wrapper">
  219. <section class="content">
  220. <h2>
  221. <?php echo $hesklang['kb']; ?>
  222. <a href="javascript:void(0)" onclick="javascript:alert('<?php echo hesk_makeJsString($hesklang['kb_intro']); ?>')">
  223. <i class="fa fa-question-circle settingsquestionmark"></i>
  224. </a>
  225. </h2>
  226. <?php
  227. show_subnav();
  228. // Show a notice if total public articles is less than 5
  229. if ($total_articles < 5)
  230. {
  231. hesk_show_notice($hesklang['nkba']);
  232. }
  233. ?>
  234. <div class="row">
  235. <div class="col-md-8">
  236. <?php show_treeMenu(); ?>
  237. </div>
  238. <div class="col-md-4">
  239. <div class="box">
  240. <div class="box-header with-border">
  241. <h1 class="box-title">
  242. <?php echo $hesklang['ktool']; ?>
  243. </h1>
  244. <div class="box-tools pull-right">
  245. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  246. <i class="fa fa-minus"></i>
  247. </button>
  248. </div>
  249. </div>
  250. <div class="box-body">
  251. <ul class="list-unstyled">
  252. <li><i class="fa fa-search"></i> <a href="manage_knowledgebase.php?a=list_private"><?php echo $hesklang['listp']; ?></a></li>
  253. <li><i class="fa fa-search"></i> <a href="manage_knowledgebase.php?a=list_draft"><?php echo $hesklang['listd']; ?></a></li>
  254. <li><i class="fa fa-gear font-size-16p gray"></i> <a href="manage_knowledgebase.php?a=update_count"><?php echo $hesklang['uac']; ?></a></li>
  255. <li><i class="fa fa-globe font-size-16p"></i> <a href="http://support.mozilla.com/en-US/kb/how-to-write-knowledge-base-articles" rel="nofollow" target="_blank"><?php echo $hesklang['goodkb']; ?></a></li>
  256. </ul>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. </section>
  262. </div>
  263. <?php
  264. } // END hide treemenu
  265. /* Hide article form? */
  266. if (!isset($_SESSION['hide']['new_article']))
  267. {
  268. if (isset($_SESSION['new_article']))
  269. {
  270. $_SESSION['new_article'] = hesk_stripArray($_SESSION['new_article']);
  271. }
  272. elseif ( isset($_GET['type']) )
  273. {
  274. $_SESSION['new_article']['type'] = intval( hesk_GET('type') );
  275. if ($_SESSION['new_article']['type'] != 1 && $_SESSION['new_article']['type'] != 2)
  276. {
  277. $_SESSION['new_article']['type'] = 0;
  278. }
  279. }
  280. ?>
  281. <ol class="breadcrumb">
  282. <li><a href="manage_knowledgebase.php"><?php echo $hesklang['kb']; ?></a></li>
  283. <li class="active"><?php echo $hesklang['new_kb_art']; ?></li>
  284. </ol>
  285. <?php
  286. if ($hesk_settings['kb_wysiwyg'])
  287. {
  288. ?>
  289. <script type="text/javascript">
  290. tinyMCE.init({
  291. mode : "exact",
  292. elements : "content",
  293. theme : "advanced",
  294. convert_urls : false,
  295. gecko_spellcheck: true,
  296. plugins: "autolink",
  297. theme_advanced_buttons1 : "cut,copy,paste,|,undo,redo,|,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
  298. theme_advanced_buttons2 : "sub,sup,|,charmap,|,bullist,numlist,|,outdent,indent,insertdate,inserttime,preview,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,link,unlink,anchor,image,cleanup,code",
  299. theme_advanced_buttons3 : "",
  300. theme_advanced_toolbar_location : "top",
  301. theme_advanced_toolbar_align : "left",
  302. theme_advanced_statusbar_location : "bottom",
  303. theme_advanced_resizing : true
  304. });
  305. </script>
  306. <?php
  307. }
  308. ?>
  309. <div class="content-wrapper">
  310. <section class="content">
  311. <?php
  312. $catid = show_subnav('newa');
  313. $onsubmit = '';
  314. if ($hesk_settings['kb_wysiwyg']) {
  315. $onsubmit = 'onsubmit="return validateRichText(\'content-help-block\', \'content-group\', \'content\', \''.addslashes($hesklang['kb_e_cont']).'\')"';
  316. }
  317. ?>
  318. <form action="manage_knowledgebase.php" role="form" method="post" name="form1" enctype="multipart/form-data" data-toggle="validator" <?php echo $onsubmit; ?>>
  319. <div class="box">
  320. <div class="box-header with-border">
  321. <h1 class="box-title">
  322. <a name="new_article"></a><?php echo $hesklang['new_kb_art']; ?>
  323. </h1>
  324. <div class="box-tools pull-right">
  325. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  326. <i class="fa fa-minus"></i>
  327. </button>
  328. </div>
  329. </div>
  330. <div class="box-body">
  331. <?php
  332. $displayType = $hesk_settings['kb_wysiwyg'] ? 'none' : 'block';
  333. $displayWarn = 'none';
  334. ?>
  335. <span id="contentType" style="display:<?php echo $displayType; ?>">
  336. <label><input type="radio" name="html" value="0" <?php if (!isset($_SESSION['new_article']['html']) || (isset($_SESSION['new_article']['html']) && $_SESSION['new_article']['html'] == 0) ) {echo 'checked="checked"';} ?> onclick="javascript:document.getElementById('kblinks').style.display = 'none'" /> <?php echo $hesklang['kb_dhtml']; ?></label><br />
  337. <label><input type="radio" name="html" value="1" <?php $display = 'none'; if (isset($_SESSION['new_article']['html']) && $_SESSION['new_article']['html'] == 1) {echo 'checked="checked"'; $displayWarn = 'block';} ?> onclick="javascript:document.getElementById('kblinks').style.display = 'block'" /> <?php echo $hesklang['kb_ehtml']; ?></label><br />
  338. <span id="kblinks" style="display:<?php echo $displayWarn; ?>"><i><?php echo $hesklang['kb_links']; ?></i></span>
  339. </span>
  340. <div class="form-group">
  341. <label for="subject" class="control-label"><?php echo $hesklang['kb_subject']; ?></label>
  342. <input type="text" class="form-control" placeholder="<?php echo htmlspecialchars($hesklang['kb_subject']); ?>" data-error="<?php echo htmlspecialchars($hesklang['kb_e_subj']); ?>"
  343. name="subject" size="70" maxlength="255" <?php if (isset($_SESSION['new_article']['subject'])) {echo 'value="'.$_SESSION['new_article']['subject'].'"';} ?> required>
  344. <div class="help-block with-errors"></div>
  345. </div>
  346. <div class="form-group" id="content-group">
  347. <textarea class="form-control" id="content" name="content" rows="25" cols="70" data-error="<?php echo htmlspecialchars($hesklang['kb_e_cont']); ?>" id="content" required><?php if (isset($_SESSION['new_article']['content'])) {echo $_SESSION['new_article']['content'];} ?></textarea>
  348. <div class="help-block with-errors" id="content-help-block"></div>
  349. </div>
  350. </div>
  351. </div>
  352. <div class="box">
  353. <div class="box-header with-border">
  354. <h1 class="box-title">
  355. <?php echo $hesklang['information']; ?>
  356. </h1>
  357. <div class="box-tools pull-right">
  358. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  359. <i class="fa fa-minus"></i>
  360. </button>
  361. </div>
  362. </div>
  363. <div class="box-body">
  364. <div class="row">
  365. <div class="col-md-6">
  366. <div class="form-group">
  367. <label for="catid" class="control-label"><?php echo $hesklang['kb_cat']; ?></label>
  368. <select name="catid" class="form-control"><?php $listBox->printMenu(); ?></select>
  369. </div>
  370. <div class="form-group">
  371. <label for="type" class="control-label"><?php echo $hesklang['kb_type']; ?></label>
  372. <?php
  373. if (isset($_SESSION['new_article']['type']))
  374. {
  375. $selectedIndex = -1;
  376. } else
  377. {
  378. $modsForHesk_settings = mfh_getSettings();
  379. $selectedIndex = $modsForHesk_settings['new_kb_article_visibility'];
  380. }
  381. ?>
  382. <div class="radio">
  383. <label><input type="radio" name="type" value="0" <?php if ((isset($_SESSION['new_article']['type']) && $_SESSION['new_article']['type'] == 0) || $selectedIndex == 0) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['kb_published']; ?> &nbsp;<a href="javascript:void(0)" onclick="javascript:alert('<?php echo $hesklang['kb_published2']; ?>')"><i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  384. </div>
  385. <div class="radio">
  386. <label><input type="radio" name="type" value="1" <?php if ((isset($_SESSION['new_article']['type']) && $_SESSION['new_article']['type'] == 1) || $selectedIndex == 1) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['kb_private']; ?>&nbsp;<a href="javascript:void(0)" onclick="javascript:alert('<?php echo $hesklang['kb_private2']; ?>')"><i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  387. </div>
  388. <div class="radio">
  389. <label><input type="radio" name="type" value="2" <?php if ((isset($_SESSION['new_article']['type']) && $_SESSION['new_article']['type'] == 2) || $selectedIndex == 2) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['kb_draft']; ?>&nbsp;<a href="javascript:void(0)" onclick="javascript:alert('<?php echo $hesklang['kb_draft2']; ?>')"><i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  390. </div>
  391. </div>
  392. <div class="form-group">
  393. <label for="sticky" class="control-label"><?php echo $hesklang['opt']; ?></label>
  394. <div class="checkbox">
  395. <label><input type="checkbox" name="sticky" value="Y" <?php if ( ! empty($_SESSION['new_article']['sticky'])) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['sticky']; ?> <a href="javascript:void(0)" onclick="javascript:alert('<?php echo hesk_makeJsString($hesklang['saa']); ?>')"><i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  396. </div>
  397. </div>
  398. </div>
  399. <div class="col-md-6">
  400. <div class="form-group">
  401. <label for="keywords" class="control-label"><?php echo $hesklang['kw']; ?></label>
  402. <p class="font-size-90 form-control-static"><?php echo $hesklang['kw1']; ?></p><br/>
  403. <textarea name="keywords" class="form-control" rows="3" cols="70" id="keywords"><?php if (isset($_SESSION['new_article']['keywords'])) {echo $_SESSION['new_article']['keywords'];} ?></textarea>
  404. </div>
  405. <?php if ($hesk_settings['attachments']['use']): ?>
  406. <div class="form-group">
  407. <label for="attachments" class="control-label"><?php echo $hesklang['attachments']; ?> (<a href="Javascript:void(0)" onclick="Javascript:hesk_window('../file_limits.php',250,500);return false;"><?php echo $hesklang['ful']; ?></a>)</label>
  408. <?php build_dropzone_markup(true); ?>
  409. </div>
  410. <?php
  411. display_dropzone_field(HESK_PATH . 'internal-api/admin/knowledgebase/upload-attachment.php');
  412. endif; // End attachments
  413. ?>
  414. </div>
  415. </div>
  416. </div>
  417. <div class="box-footer">
  418. <div class="form-group">
  419. <input type="hidden" name="a" value="new_article">
  420. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>">
  421. <div class="btn-group">
  422. <input type="submit" value="<?php echo $hesklang['kb_save']; ?>" class="btn btn-primary">
  423. <a class="btn btn-default" href="manage_knowledgebase.php?a=manage_cat&amp;catid=<?php echo $catid; ?>"><?php echo $hesklang['cancel']; ?></a>
  424. </div>
  425. </div>
  426. </div>
  427. </div>
  428. </form>
  429. </section>
  430. </div>
  431. <?php
  432. } // END hide article
  433. /* Hide new category form? */
  434. if (!isset($_SESSION['hide']['new_category']))
  435. {
  436. if (isset($_SESSION['new_category']))
  437. {
  438. $_SESSION['new_category'] = hesk_stripArray($_SESSION['new_category']);
  439. }
  440. ?>
  441. <div class="content-wrapper">
  442. <ol class="breadcrumb">
  443. <li><a href="manage_knowledgebase.php"><?php echo $hesklang['kb']; ?></a></li>
  444. <li class="active"><?php echo $hesklang['kb_cat_new']; ?></li>
  445. </ol>
  446. <section class="content">
  447. <?php show_subnav('newc'); ?>
  448. <div class="row">
  449. <div class="col-md-5">
  450. <?php
  451. /* Show the treemenu? */
  452. if (isset($_SESSION['hide']['cat_treemenu']))
  453. {
  454. show_treeMenu();
  455. }
  456. ?>
  457. </div>
  458. <div class="col-md-7">
  459. <form action="manage_knowledgebase.php" class="form-horizontal" method="post" role="form" name="form2" data-toggle="validator">
  460. <div class="box">
  461. <div class="box-header with-border">
  462. <h1 class="box-title">
  463. <a name="new_category"></a><?php echo $hesklang['kb_cat_new']; ?>
  464. </h1>
  465. <div class="box-tools pull-right">
  466. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  467. <i class="fa fa-minus"></i>
  468. </button>
  469. </div>
  470. </div>
  471. <div class="box-body">
  472. <div class="form-group">
  473. <label for="title" class="col-sm-3 control-label"><?php echo $hesklang['kb_cat_title']; ?></label>
  474. <div class="col-sm-9">
  475. <input type="text" class="form-control" name="title" size="70" maxlength="255" data-error="<?php echo htmlspecialchars($hesklang['kb_cat_e_title']); ?>" required>
  476. <div class="help-block with-errors"></div>
  477. </div>
  478. </div>
  479. <div class="form-group">
  480. <label for="parent" class="col-sm-3 control-label"><?php echo $hesklang['kb_cat_parent']; ?>:</label>
  481. <div class="col-sm-9">
  482. <select class="form-control" name="parent"><?php $listBox->printMenu()?></select>
  483. </div>
  484. </div>
  485. <div class="form-group">
  486. <label for="type" class="col-sm-3 control-label"><?php echo $hesklang['kb_type']; ?>:</label>
  487. <div class="col-sm-9">
  488. <div class="radio">
  489. <label><input type="radio" name="type" value="0" <?php if (!isset($_SESSION['new_category']['type']) || (isset($_SESSION['new_category']['type']) && $_SESSION['new_category']['type'] == 0) ) {echo 'checked="checked"';} ?> /> <b><i><?php echo $hesklang['kb_published']; ?></i></b></label>
  490. <p class="form-static-content"><?php echo $hesklang['kb_cat_published']; ?></p>
  491. </div>
  492. <div class="radio">
  493. <label><input type="radio" name="type" value="1" <?php if (isset($_SESSION['new_category']['type']) && $_SESSION['new_category']['type'] == 1) {echo 'checked="checked"';} ?> /> <b><i><?php echo $hesklang['kb_private']; ?></i></b></label>
  494. <p class="form-static-content"><?php echo $hesklang['kb_cat_private']; ?></p>
  495. </div>
  496. </div>
  497. </div>
  498. <div class="form-group">
  499. <div class="col-sm-9 col-sm-offset-3">
  500. <input type="hidden" name="a" value="new_category" />
  501. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>" />
  502. <div class="btn-group">
  503. <input type="submit" value="<?php echo $hesklang['kb_cat_add']; ?>" class="btn btn-primary" />
  504. <a class="btn btn-default" href="manage_knowledgebase.php"><?php echo $hesklang['cancel']; ?></a>
  505. </div>
  506. </div>
  507. </div>
  508. </div>
  509. </div>
  510. </form>
  511. </div>
  512. </div>
  513. </section>
  514. </div>
  515. <?php
  516. } // END hide new category form
  517. /* Clean unneeded session variables */
  518. hesk_cleanSessionVars(array('hide','new_article','new_category','KB_CATEGORY','manage_cat','edit_article','newcat'));
  519. ?>
  520. <?php
  521. require_once(HESK_PATH . 'inc/footer.inc.php');
  522. exit();
  523. /*** START FUNCTIONS ***/
  524. function list_draft() {
  525. global $hesk_settings, $hesklang;
  526. $catid = 1;
  527. $kb_cat = hesk_getCategoriesArray(1);
  528. /* Translate main category "Knowledgebase" if needed */
  529. $kb_cat[0]['name'] = $hesklang['kb_text'];
  530. /* Print header */
  531. require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
  532. /* Print main manage users page */
  533. require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
  534. ?>
  535. <div class="content-wrapper">
  536. <ol class="breadcrumb">
  537. <li><a href="manage_knowledgebase.php"><?php echo $hesklang['kb']; ?></a></li>
  538. <li class="active"><?php echo $hesklang['kb_cat_man']; ?></li>
  539. </ol>
  540. <section class="content">
  541. <?php
  542. show_subnav('',$catid);
  543. $res = hesk_dbQuery("SELECT * FROM `". hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `type`='2' ORDER BY `catid` ASC, `id` ASC");
  544. $num = hesk_dbNumRows($res);
  545. ?>
  546. <div class="box">
  547. <div class="box-header with-border">
  548. <h1 class="box-title">
  549. <?php echo $hesklang['artd']; ?>
  550. </h1>
  551. <div class="box-tools pull-right">
  552. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  553. <i class="fa fa-minus"></i>
  554. </button>
  555. </div>
  556. </div>
  557. <div class="box-body">
  558. <?php
  559. if ($num == 0)
  560. {
  561. echo $hesklang['kb_no_dart'];
  562. }
  563. else
  564. {
  565. ?>
  566. <table class="table table-striped">
  567. <thead>
  568. <tr>
  569. <th>&nbsp;</th>
  570. <th><?php echo $hesklang['kb_subject']; ?></th>
  571. <th><?php echo $hesklang['kb_cat']; ?></th>
  572. <th><?php echo $hesklang['opt']; ?></th>
  573. </tr>
  574. </thead>
  575. <?php
  576. $j=1;
  577. while ($article = hesk_dbFetchAssoc($res))
  578. {
  579. if (isset($_SESSION['artord']) && $article['id'] == $_SESSION['artord'])
  580. {
  581. unset($_SESSION['artord']);
  582. }
  583. // Check for articles with no existing parent category
  584. if ( ! isset($kb_cat[$article['catid']]) )
  585. {
  586. $article['catid'] = hesk_stray_article($article['id']);
  587. }
  588. ?>
  589. <tr>
  590. <td><?php echo $j; ?>.</td>
  591. <td><?php echo $article['subject']; ?></td>
  592. <td><?php echo $kb_cat[$article['catid']]; ?></td>
  593. <td style="white-space:nowrap;">
  594. <a href="knowledgebase_private.php?article=<?php echo $article['id']; ?>&amp;back=1<?php if ($article['type'] == 2) {echo '&amp;draft=1';} ?>" target="_blank"><i class="fa fa-file-o" data-toggle="tooltip" title="<?php echo $hesklang['viewart']; ?>"></i></a>
  595. <a href="manage_knowledgebase.php?a=edit_article&amp;id=<?php echo $article['id']; ?>&amp;from=draft"><i class="fa fa-pencil icon-link orange" data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i></a>
  596. <a href="manage_knowledgebase.php?a=remove_article&amp;id=<?php echo $article['id']; ?>&amp;token=<?php hesk_token_echo(); ?>&amp;from=draft" onclick="return hesk_confirmExecute('<?php echo hesk_makeJsString($hesklang['del_art']); ?>');"><i class="fa fa-times icon-link red" data-toggle="tooltip" title="<?php echo $hesklang['delete']; ?>"></i></a></td>
  597. </tr>
  598. <?php
  599. $j++;
  600. } // End while
  601. ?>
  602. </table>
  603. <?php
  604. }
  605. ?>
  606. </div>
  607. <div class="box-footer">
  608. <a class="btn btn-success" href="manage_knowledgebase.php?a=add_article&amp;catid=<?php echo $catid; ?>&amp;type=2">
  609. <i class="fa fa-plus"></i>
  610. <?php echo $hesklang['kb_i_art2']; ?>
  611. </a>
  612. </div>
  613. </div>
  614. </section>
  615. </div>
  616. <?php
  617. /* Clean unneeded session variables */
  618. hesk_cleanSessionVars(array('hide','manage_cat','edit_article'));
  619. require_once(HESK_PATH . 'inc/footer.inc.php');
  620. exit();
  621. } // END list_draft()
  622. function list_private() {
  623. global $hesk_settings, $hesklang;
  624. $catid = 1;
  625. $kb_cat = hesk_getCategoriesArray(1);
  626. /* Translate main category "Knowledgebase" if needed */
  627. $kb_cat[0]['name'] = $hesklang['kb_text'];
  628. /* Get list of private categories */
  629. $private_categories = array();
  630. $res = hesk_dbQuery("SELECT `id` FROM `". hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` WHERE `type`='1'");
  631. $num = hesk_dbNumRows($res);
  632. if ($num)
  633. {
  634. while ($row = hesk_dbFetchAssoc($res))
  635. {
  636. $private_categories[] = intval($row['id']);
  637. }
  638. }
  639. /* Print header */
  640. require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
  641. /* Print main manage users page */
  642. require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
  643. $res = hesk_dbQuery("SELECT * FROM `". hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `type`='1' " . (count($private_categories) ? " OR `catid` IN('" . implode("','", $private_categories) . "') " : '') . " ORDER BY `catid` ASC, `id` ASC");
  644. $num = hesk_dbNumRows($res);
  645. ?>
  646. <div class="content-wrapper">
  647. <ol class="breadcrumb">
  648. <li><a href="manage_knowledgebase.php"><?php echo $hesklang['kb']; ?></a></li>
  649. <li class="active"><?php echo $hesklang['kb_cat_man']; ?></li>
  650. </ol>
  651. <section class="content">
  652. <?php show_subnav('',$catid); ?>
  653. <div class="box">
  654. <div class="box-header with-border">
  655. <h1 class="box-title">
  656. <?php echo $hesklang['artp']; ?>
  657. </h1>
  658. <div class="box-tools pull-right">
  659. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  660. <i class="fa fa-minus"></i>
  661. </button>
  662. </div>
  663. </div>
  664. <div class="box-body">
  665. <?php
  666. if ($num == 0)
  667. {
  668. echo '<p>'.$hesklang['kb_no_part'].'</p>';
  669. }
  670. else
  671. {
  672. ?>
  673. <table class="table table-striped">
  674. <thead>
  675. <tr>
  676. <th>&nbsp;</th>
  677. <th><?php echo $hesklang['kb_subject']; ?></th>
  678. <th><?php echo $hesklang['kb_cat']; ?></th>
  679. <th><?php echo $hesklang['views']; ?></th>
  680. <?php
  681. if ($hesk_settings['kb_rating'])
  682. {
  683. ?>
  684. <th style="white-space:nowrap" nowrap="nowrap" width="130"><?php echo $hesklang['rating'].' ('.$hesklang['votes'].')'; ?></th>
  685. <?php
  686. }
  687. ?>
  688. <th style="width:120px"><?php echo $hesklang['opt']; ?></th>
  689. </tr>
  690. </thead>
  691. <?php
  692. $i=1;
  693. $j=1;
  694. while ($article = hesk_dbFetchAssoc($res))
  695. {
  696. if (isset($_SESSION['artord']) && $article['id'] == $_SESSION['artord'])
  697. {
  698. unset($_SESSION['artord']);
  699. }
  700. // Check for articles with no existing parent category
  701. if ( ! isset($kb_cat[$article['catid']]) )
  702. {
  703. $article['catid'] = hesk_stray_article($article['id']);
  704. }
  705. $tmp = $i ? 'White' : 'Blue';
  706. $i = $i ? 0 : 1;
  707. if ($hesk_settings['kb_rating'])
  708. {
  709. $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
  710. $rat = '<td><span data-toggle="tooltip" title="' . $alt . '">' . mfh_get_stars(hesk_round_to_half($article['rating'])) . '</span> (' . $article['votes'] . ')</td>';
  711. }
  712. else
  713. {
  714. $rat = '';
  715. }
  716. ?>
  717. <tr>
  718. <td><?php echo $j; ?>.</td>
  719. <td><?php echo $article['subject']; ?></td>
  720. <td><?php echo $kb_cat[$article['catid']]; ?></td>
  721. <td><?php echo $article['views']; ?></td>
  722. <?php echo $rat; ?>
  723. <td class="text-center">
  724. <a href="knowledgebase_private.php?article=<?php echo $article['id']; ?>&amp;back=1<?php if ($article['type'] == 2) {echo '&amp;draft=1';} ?>" target="_blank"><i class="fa fa-file-o icon-link" data-toggle="tooltip" title="<?php echo $hesklang['viewart']; ?>"></i></a>
  725. <a href="manage_knowledgebase.php?a=edit_article&amp;id=<?php echo $article['id']; ?>&amp;from=private"><i class="fa fa-pencil icon-link orange" data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i></a>
  726. <a href="manage_knowledgebase.php?a=remove_article&amp;id=<?php echo $article['id']; ?>&amp;token=<?php hesk_token_echo(); ?>&amp;from=private" onclick="return hesk_confirmExecute('<?php echo hesk_makeJsString($hesklang['del_art']); ?>');"><i class="fa fa-times red icon-link" data-toggle="tooltip" title="<?php echo $hesklang['delete']; ?>"></i></a>&nbsp;</td>
  727. </tr>
  728. <?php
  729. $j++;
  730. } // End while
  731. ?>
  732. </table>
  733. <?php
  734. }
  735. ?>
  736. </div>
  737. <div class="box-footer">
  738. <a class="btn btn-success" href="manage_knowledgebase.php?a=add_article&amp;catid=<?php echo $catid; ?>&amp;type=1">
  739. <i class="fa fa-plus"></i>
  740. <?php echo $hesklang['kb_i_art2']; ?>
  741. </a>
  742. </div>
  743. </div>
  744. </section>
  745. </div>
  746. <?php
  747. /* Clean unneeded session variables */
  748. hesk_cleanSessionVars(array('hide','manage_cat','edit_article'));
  749. require_once(HESK_PATH . 'inc/footer.inc.php');
  750. exit();
  751. } // END list_private()
  752. function import_article()
  753. {
  754. global $hesk_settings, $hesklang, $listBox;
  755. $_SESSION['hide'] = array(
  756. 'treemenu' => 1,
  757. //'new_article' => 1,
  758. 'new_category' => 1,
  759. );
  760. $_SESSION['KB_CATEGORY'] = 1;
  761. // Get ticket ID
  762. $trackingID = hesk_cleanID();
  763. if (empty($trackingID))
  764. {
  765. return false;
  766. }
  767. // Get ticket info
  768. $res = hesk_dbQuery("SELECT `id`,`category`,`subject`,`message`,`owner` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `trackid`='".hesk_dbEscape($trackingID)."' LIMIT 1");
  769. if (hesk_dbNumRows($res) != 1)
  770. {
  771. return false;
  772. }
  773. $ticket = hesk_dbFetchAssoc($res);
  774. // Permission to view this ticket?
  775. if ($ticket['owner'] && $ticket['owner'] != $_SESSION['id'] && ! hesk_checkPermission('can_view_ass_others',0))
  776. {
  777. return false;
  778. }
  779. if ( ! $ticket['owner'] && ! hesk_checkPermission('can_view_unassigned',0))
  780. {
  781. return false;
  782. }
  783. // Is this user allowed to view tickets inside this category?
  784. if ( ! hesk_okCategory($ticket['category'],0))
  785. {
  786. return false;
  787. }
  788. // Set article contents
  789. if ($hesk_settings['kb_wysiwyg'])
  790. {
  791. // With WYSIWYG editor
  792. $_SESSION['new_article'] = array(
  793. 'html' => 1,
  794. 'subject' => $ticket['subject'],
  795. 'content' => hesk_htmlspecialchars($ticket['message']),
  796. );
  797. }
  798. else
  799. {
  800. // Without WYSIWYG editor *
  801. $_SESSION['new_article'] = array(
  802. 'html' => 0,
  803. 'subject' => $ticket['subject'],
  804. 'content' => hesk_msgToPlain($ticket['message']),
  805. );
  806. }
  807. // Get messages from replies to the ticket
  808. $res = hesk_dbQuery("SELECT `message` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` WHERE `replyto`='".intval($ticket['id'])."' ORDER BY `id` ASC");
  809. while ($reply=hesk_dbFetchAssoc($res))
  810. {
  811. if ($hesk_settings['kb_wysiwyg'])
  812. {
  813. $_SESSION['new_article']['content'] .= "<br /><br />" . hesk_htmlspecialchars($reply['message']);
  814. }
  815. else
  816. {
  817. $_SESSION['new_article']['content'] .= "\n\n" . hesk_msgToPlain($reply['message']);
  818. }
  819. }
  820. hesk_process_messages($hesklang['import'],'NOREDIRECT','NOTICE');
  821. } // END add_article()
  822. function add_article()
  823. {
  824. global $hesk_settings, $hesklang;
  825. $_SESSION['hide'] = array(
  826. 'treemenu' => 1,
  827. //'new_article' => 1,
  828. 'new_category' => 1,
  829. );
  830. $_SESSION['KB_CATEGORY'] = intval( hesk_GET('catid', 1) );
  831. } // END add_article()
  832. function add_category()
  833. {
  834. global $hesk_settings, $hesklang;
  835. $_SESSION['hide'] = array(
  836. 'treemenu' => 1,
  837. 'new_article' => 1,
  838. //'new_category' => 1,
  839. 'cat_treemenu' => 1,
  840. );
  841. $_SESSION['KB_CATEGORY'] = intval( hesk_GET('parent', 1) );
  842. } // END add_category()
  843. function remove_kb_att()
  844. {
  845. global $hesk_settings, $hesklang;
  846. // A security check
  847. hesk_token_check();
  848. $att_id = intval( hesk_GET('kb_att') ) or hesk_error($hesklang['inv_att_id']);
  849. $id = intval( hesk_GET('id', 1) );
  850. // Get attachment details
  851. $res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` WHERE `att_id`='".intval($att_id)."'");
  852. // Does the attachment exist?
  853. if ( hesk_dbNumRows($res) != 1 )
  854. {
  855. hesk_process_messages($hesklang['inv_att_id'], 'manage_knowledgebase.php');
  856. }
  857. $att = hesk_dbFetchAssoc($res);
  858. // Delete the file if it exists
  859. hesk_unlink(HESK_PATH.$hesk_settings['attach_dir'].'/'.$att['saved_name']);
  860. hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` WHERE `att_id`='".intval($att_id)."'");
  861. $res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `id`='".intval($id)."'");
  862. $art = hesk_dbFetchAssoc($res);
  863. // Make log entry
  864. $revision = sprintf($hesklang['thist12'],hesk_date(),$att['real_name'],$_SESSION['name'].' ('.$_SESSION['user'].')');
  865. // Remove attachment from article
  866. $art['attachments'] = str_replace($att_id.'#'.$att['real_name'].',','',$art['attachments']);
  867. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `attachments`='".hesk_dbEscape($art['attachments'])."', `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') WHERE `id`='".intval($id)."'");
  868. hesk_process_messages($hesklang['kb_att_rem'],'manage_knowledgebase.php?a=edit_article&id='.$id,'SUCCESS');
  869. } // END remove_kb_att()
  870. function edit_category()
  871. {
  872. global $hesk_settings, $hesklang;
  873. /* A security check */
  874. hesk_token_check('POST');
  875. $_SESSION['hide'] = array(
  876. 'article_list' => 1,
  877. );
  878. $hesk_error_buffer = array();
  879. $catid = intval( hesk_POST('catid') ) or hesk_error($hesklang['kb_cat_inv']);
  880. $title = hesk_input( hesk_POST('title') ) or $hesk_error_buffer[] = $hesklang['kb_cat_e_title'];
  881. $parent = intval( hesk_POST('parent', 1) );
  882. $type = empty($_POST['type']) ? 0 : 1;
  883. /* Category can't be it's own parent */
  884. if ($parent == $catid)
  885. {
  886. $hesk_error_buffer[] = $hesklang['kb_spar'];
  887. }
  888. /* Any errors? */
  889. if (count($hesk_error_buffer))
  890. {
  891. $_SESSION['manage_cat'] = array(
  892. 'type' => $type,
  893. 'parent' => $parent,
  894. 'title' => $title,
  895. );
  896. $tmp = '';
  897. foreach ($hesk_error_buffer as $error)
  898. {
  899. $tmp .= "<li>$error</li>\n";
  900. }
  901. $hesk_error_buffer = $tmp;
  902. $hesk_error_buffer = $hesklang['rfm'].'<br /><br /><ul>'.$hesk_error_buffer.'</ul>';
  903. hesk_process_messages($hesk_error_buffer,'./manage_knowledgebase.php?a=manage_cat&catid='.$catid);
  904. }
  905. /* Delete category or just update it? */
  906. if ( hesk_POST('dodelete')=='Y')
  907. {
  908. // Delete contents
  909. if ( hesk_POST('movearticles') == 'N')
  910. {
  911. // Delete all articles and all subcategories
  912. delete_category_recursive($catid);
  913. }
  914. // Move contents
  915. else
  916. {
  917. // -> Update category of articles in the category we are deleting
  918. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `catid`=".intval($parent)." WHERE `catid`='".intval($catid)."'");
  919. // -> Update parent category of subcategories
  920. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `parent`=".intval($parent)." WHERE `parent`='".intval($catid)."'");
  921. // -> Update article counts to make sure they are correct
  922. update_count();
  923. }
  924. // Now delete the category
  925. hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` WHERE `id`='".intval($catid)."'");
  926. // Clear KB cache
  927. hesk_purge_cache('kb');
  928. $_SESSION['hide'] = array(
  929. //'treemenu' => 1,
  930. 'new_article' => 1,
  931. 'new_category' => 1,
  932. );
  933. hesk_process_messages($hesklang['kb_cat_dlt'],'./manage_knowledgebase.php','SUCCESS');
  934. }
  935. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `name`='".hesk_dbEscape($title)."',`parent`=".intval($parent).",`type`='".intval($type)."' WHERE `id`='".intval($catid)."'");
  936. unset($_SESSION['hide']);
  937. hesk_process_messages($hesklang['your_cat_mod'],'./manage_knowledgebase.php?a=manage_cat&catid='.$catid,'SUCCESS');
  938. } // END edit_category()
  939. function save_article()
  940. {
  941. global $hesk_settings, $hesklang, $hesk_error_buffer;
  942. /* A security check */
  943. hesk_token_check('POST');
  944. $hesk_error_buffer = array();
  945. $id = intval( hesk_POST('id') ) or hesk_error($hesklang['kb_art_id']);
  946. $catid = intval( hesk_POST('catid', 1) );
  947. $type = intval( hesk_POST('type') );
  948. $type = ($type < 0 || $type > 2) ? 0 : $type;
  949. $html = $hesk_settings['kb_wysiwyg'] ? 1 : (empty($_POST['html']) ? 0 : 1);
  950. $now = hesk_date();
  951. $old_catid = intval( hesk_POST('old_catid') );
  952. $old_type = intval( hesk_POST('old_type') );
  953. $old_type = ($old_type < 0 || $old_type > 2) ? 0 : $old_type;
  954. $from = hesk_POST('from');
  955. $subject = hesk_input( hesk_POST('subject') ) or $hesk_error_buffer[] = $hesklang['kb_e_subj'];
  956. if ($html)
  957. {
  958. if (empty($_POST['content']))
  959. {
  960. $hesk_error_buffer[] = $hesklang['kb_e_cont'];
  961. }
  962. $content = hesk_getHTML( hesk_POST('content') );
  963. // Clean the HTML code
  964. require(HESK_PATH . 'inc/htmlpurifier/HeskHTMLPurifier.php');
  965. $purifier = new HeskHTMLPurifier($hesk_settings['cache_dir']);
  966. $content = $purifier->heskPurify($content);
  967. }
  968. else
  969. {
  970. $content = hesk_input( hesk_POST('content') ) or $hesk_error_buffer[] = $hesklang['kb_e_cont'];
  971. $content = nl2br($content);
  972. $content = hesk_makeURL($content);
  973. }
  974. $sticky = isset($_POST['sticky']) ? 1 : 0;
  975. $keywords = hesk_input( hesk_POST('keywords') );
  976. $extra_sql = '';
  977. if ( hesk_POST('resetviews')=='Y')
  978. {
  979. $extra_sql .= ',`views`=0 ';
  980. }
  981. if (hesk_POST('resetvotes')=='Y')
  982. {
  983. $extra_sql .= ',`votes`=0, `rating`=0 ';
  984. }
  985. /* Article attachments */
  986. define('KB',1);
  987. require_once(HESK_PATH . 'inc/posting_functions.inc.php');
  988. $attachments = array();
  989. $use_legacy_attachments = hesk_POST('use-legacy-attachments', 0);
  990. $myattachments='';
  991. if ($hesk_settings['attachments']['use']) {
  992. require_once(HESK_PATH . 'inc/attachments.inc.php');
  993. if ($use_legacy_attachments) {
  994. for ($i=1; $i<=$hesk_settings['attachments']['max_number']; $i++)
  995. {
  996. $att = hesk_uploadFile($i);
  997. if ( ! empty($att))
  998. {
  999. $attachments[$i] = $att;
  1000. }
  1001. }
  1002. } else {
  1003. // The user used the new drag-and-drop system.
  1004. $temp_attachment_ids = hesk_POST_array('attachment-ids');
  1005. foreach ($temp_attachment_ids as $temp_attachment_id) {
  1006. // Simply get the temp info and move it to the attachments table
  1007. $temp_attachment = mfh_getTemporaryAttachment($temp_attachment_id);
  1008. $attachments[] = $temp_attachment;
  1009. mfh_deleteTemporaryAttachment($temp_attachment_id);
  1010. }
  1011. }
  1012. }
  1013. /* Any errors? */
  1014. if (count($hesk_error_buffer))
  1015. {
  1016. // Remove any successfully uploaded attachments
  1017. if ($hesk_settings['attachments']['use'])
  1018. {
  1019. hesk_removeAttachments($attachments);
  1020. }
  1021. $_SESSION['edit_article'] = array(
  1022. 'type' => $type,
  1023. 'html' => $html,
  1024. 'subject' => $subject,
  1025. 'content' => hesk_input( hesk_POST('content') ),
  1026. 'keywords' => $keywords,
  1027. 'catid' => $catid,
  1028. 'sticky' => $sticky,
  1029. 'resetviews' => (isset($_POST['resetviews']) ? 'Y' : 0),
  1030. 'resetvotes' => (isset($_POST['resetvotes']) ? 'Y' : 0),
  1031. );
  1032. $tmp = '';
  1033. foreach ($hesk_error_buffer as $error)
  1034. {
  1035. $tmp .= "<li>$error</li>\n";
  1036. }
  1037. $hesk_error_buffer = $tmp;
  1038. $hesk_error_buffer = $hesklang['rfm'].'<br /><br /><ul>'.$hesk_error_buffer.'</ul>';
  1039. hesk_process_messages($hesk_error_buffer,'./manage_knowledgebase.php?a=edit_article&id='.$id.'&from='.$from);
  1040. }
  1041. /* Add to database */
  1042. if (!empty($attachments))
  1043. {
  1044. foreach ($attachments as $myatt)
  1045. {
  1046. hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` (`saved_name`,`real_name`,`size`) VALUES ('".hesk_dbEscape($myatt['saved_name'])."', '".hesk_dbEscape($myatt['real_name'])."', '".intval($myatt['size'])."')");
  1047. $myattachments .= hesk_dbInsertID() . '#' . $myatt['real_name'] .',';
  1048. }
  1049. $extra_sql .= ", `attachments` = CONCAT(`attachments`, '".$myattachments."') ";
  1050. }
  1051. /* Update article in the database */
  1052. $revision = sprintf($hesklang['revision2'],$now,$_SESSION['name'].' ('.$_SESSION['user'].')');
  1053. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET
  1054. `catid`=".intval($catid).",
  1055. `subject`='".hesk_dbEscape($subject)."',
  1056. `content`='".hesk_dbEscape($content)."',
  1057. `keywords`='".hesk_dbEscape($keywords)."' $extra_sql ,
  1058. `type`='".intval($type)."',
  1059. `html`='".intval($html)."',
  1060. `sticky`='".intval($sticky)."',
  1061. `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."')
  1062. WHERE `id`='".intval($id)."'");
  1063. $_SESSION['artord'] = $id;
  1064. // Update proper category article count
  1065. // (just do them all to be sure, don't compliate...)
  1066. update_count();
  1067. // Update article order
  1068. update_article_order($catid);
  1069. // Clear KB cache
  1070. hesk_purge_cache('kb');
  1071. // Redirect to the correct page
  1072. switch ($from) {
  1073. case 'draft':
  1074. $redirect_action = 'a=list_draft';
  1075. break;
  1076. case 'private':
  1077. $redirect_action = 'a=list_private';
  1078. break;
  1079. default:
  1080. $redirect_action = 'a=manage_cat&catid='.$catid;
  1081. break;
  1082. }
  1083. hesk_process_messages($hesklang['your_kb_mod'],'./manage_knowledgebase.php?'.$redirect_action,'SUCCESS');
  1084. } // END save_article()
  1085. function edit_article()
  1086. {
  1087. global $hesk_settings, $hesklang, $listBox;
  1088. $hesk_error_buffer = array();
  1089. $id = intval( hesk_GET('id') ) or hesk_process_messages($hesklang['kb_art_id'],'./manage_knowledgebase.php');
  1090. /* Get article details */
  1091. $result = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `id`='".intval($id)."' LIMIT 1");
  1092. if (hesk_dbNumRows($result) != 1)
  1093. {
  1094. hesk_process_messages($hesklang['kb_art_id'],'./manage_knowledgebase.php');
  1095. }
  1096. $article = hesk_dbFetchAssoc($result);
  1097. if ($hesk_settings['kb_wysiwyg'] || $article['html'])
  1098. {
  1099. $article['content'] = hesk_htmlspecialchars($article['content']);
  1100. }
  1101. else
  1102. {
  1103. $article['content'] = hesk_msgToPlain($article['content']);
  1104. }
  1105. $catid = $article['catid'];
  1106. $from = hesk_GET('from');
  1107. if (isset($_SESSION['edit_article']))
  1108. {
  1109. $_SESSION['edit_article'] = hesk_stripArray($_SESSION['edit_article']);
  1110. $article['type'] = $_SESSION['edit_article']['type'];
  1111. $article['html'] = $_SESSION['edit_article']['html'];
  1112. $article['subject'] = $_SESSION['edit_article']['subject'];
  1113. $article['content'] = $_SESSION['edit_article']['content'];
  1114. $article['keywords'] = $_SESSION['edit_article']['keywords'];
  1115. $article['catid'] = $_SESSION['edit_article']['catid'];
  1116. $article['sticky'] = $_SESSION['edit_article']['sticky'];
  1117. }
  1118. /* Get categories */
  1119. $result = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_categories` ORDER BY `parent` ASC, `cat_order` ASC');
  1120. $kb_cat = array();
  1121. while ($cat = hesk_dbFetchAssoc($result))
  1122. {
  1123. $kb_cat[] = $cat;
  1124. if ($cat['id'] == $article['catid'])
  1125. {
  1126. $this_cat = $cat;
  1127. $this_cat['parent'] = $article['catid'];
  1128. }
  1129. }
  1130. /* Translate main category "Knowledgebase" if needed */
  1131. $kb_cat[0]['name'] = $hesklang['kb_text'];
  1132. require(HESK_PATH . 'inc/treemenu/TreeMenu.php');
  1133. $icon = HESK_PATH . 'img/folder.gif';
  1134. $expandedIcon = 'fa-folder-open" style="font-size:17px';
  1135. $menu = new HTML_TreeMenu();
  1136. $thislevel = array('0');
  1137. $nextlevel = array();
  1138. $i = 1;
  1139. $j = 1;
  1140. while (count($kb_cat) > 0)
  1141. {
  1142. foreach ($kb_cat as $k=>$cat)
  1143. {
  1144. if (in_array($cat['parent'],$thislevel))
  1145. {
  1146. $up = $cat['parent'];
  1147. $my = $cat['id'];
  1148. $type = $cat['type'] ? '*' : '';
  1149. $text_short = $cat['name'].$type.' ('.$cat['articles'].', '.$cat['articles_private'].', '.$cat['articles_draft'].')';
  1150. if (isset($node[$up]))
  1151. {
  1152. $node[$my] = &$node[$up]->addItem(new HTML_TreeNode(array('hesk_parent' => $this_cat['parent'], 'text' => 'Text', 'text_short' => $text_short, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option'.$j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true)));
  1153. }
  1154. else
  1155. {
  1156. $node[$my] = new HTML_TreeNode(array('hesk_parent' => $this_cat['parent'], 'text' => 'Text', 'text_short' => $text_short, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option'.$j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true));
  1157. }
  1158. $nextlevel[] = $cat['id'];
  1159. $j++;
  1160. unset($kb_cat[$k]);
  1161. }
  1162. }
  1163. $thislevel = $nextlevel;
  1164. $nextlevel = array();
  1165. /* Break after 20 recursions to avoid hang-ups in case of any problems */
  1166. if ($i > 20)
  1167. {
  1168. break;
  1169. }
  1170. $i++;
  1171. }
  1172. $menu->addItem($node[1]);
  1173. // Create the presentation class
  1174. $listBox = & ref_new(new HTML_TreeMenu_Listbox($menu));
  1175. /* Print header */
  1176. require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
  1177. /* Print main manage users page */
  1178. require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
  1179. ?>
  1180. <ol class="breadcrumb">
  1181. <li><a href="manage_knowledgebase.php"><?php echo $hesklang['kb']; ?></a></li>
  1182. <li><a href="manage_knowledgebase.php?a=manage_cat&amp;catid=<?php echo $catid; ?>"><?php echo $hesklang['kb_cat_man']; ?></a></li>
  1183. <li class="active"><?php echo $hesklang['kb_art_edit']; ?></li>
  1184. </ol>
  1185. <h3 class="move-right-10"><?php echo $hesklang['kb_art_edit']; ?></h3>
  1186. <div class="footerWithBorder blankSpace move-right-10 move-left-10"></div>
  1187. <?php
  1188. $onsubmit = '';
  1189. if ($hesk_settings['kb_wysiwyg']) {
  1190. $onsubmit = 'onsubmit="return validateRichText(\'content-help-block\', \'content-group\', \'content\', \''.addslashes($hesklang['kb_e_cont']).'\')"';
  1191. }
  1192. ?>
  1193. <form action="manage_knowledgebase.php" role="form" method="post" name="form1" enctype="multipart/form-data" data-toggle="validator" <?php echo $onsubmit; ?>>
  1194. <div class="row">
  1195. <div class="col-md-3">
  1196. <div class="panel panel-default move-right-10">
  1197. <div class="panel-heading"><?php echo $hesklang['information']; ?></div>
  1198. <div class="panel-body">
  1199. <div class="form-group">
  1200. <label for="catid" class="control-label"><?php echo $hesklang['kb_cat']; ?></label>
  1201. <select class="form-control" name="catid"><?php $listBox->printMenu()?></select>
  1202. </div>
  1203. <div class="form-group">
  1204. <label for="type" class="control-label"><?php echo $hesklang['kb_type']; ?></label>
  1205. <div class="radio">
  1206. <label><input type="radio" name="type" value="0" <?php if ($article['type']==0) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['kb_published']; ?><a href="javascript:void(0)" onclick="javascript:alert('<?php echo $hesklang['kb_published2']; ?>')">&nbsp;<i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  1207. </div>
  1208. <div class="radio">
  1209. <label><input type="radio" name="type" value="1" <?php if ($article['type']==1) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['kb_private']; ?><a href="javascript:void(0)" onclick="javascript:alert('<?php echo $hesklang['kb_private2']; ?>')">&nbsp;<i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  1210. </div>
  1211. <div class="radio">
  1212. <label><input type="radio" name="type" value="2" <?php if ($article['type']==2) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['kb_draft']; ?><a href="javascript:void(0)" onclick="javascript:alert('<?php echo $hesklang['kb_draft2']; ?>')">&nbsp;<i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  1213. </div>
  1214. </div>
  1215. <div class="form-group">
  1216. <label for="options" class="control-label"><?php echo $hesklang['opt']; ?></label>
  1217. <div class="checkbox">
  1218. <label><input type="checkbox" name="sticky" value="Y" <?php if ($article['sticky']) {echo 'checked="checked"';} ?> /> <?php echo $hesklang['sticky']; ?> <a href="javascript:void(0)" onclick="javascript:alert('<?php echo hesk_makeJsString($hesklang['saa']); ?>')"><i class="fa fa-question-circle settingsquestionmark"></i></a></label>
  1219. </div>
  1220. <div class="checkbox">
  1221. <label><input type="checkbox" name="resetviews" value="Y" <?php if (isset($_SESSION['edit_article']['resetviews']) && $_SESSION['edit_article']['resetviews'] == 'Y') {echo 'checked="checked"';} ?> /> <?php echo $hesklang['rv']; ?></label>
  1222. </div>
  1223. <div class="checkbox">
  1224. <label><input type="checkbox" name="resetvotes" value="Y" <?php if (isset($_SESSION['edit_article']['resetvotes']) && $_SESSION['edit_article']['resetvotes'] == 'Y') {echo 'checked="checked"';} ?> /> <?php echo $hesklang['rr']; ?></label>
  1225. </div>
  1226. </div>
  1227. </div>
  1228. </div>
  1229. </div>
  1230. <div class="col-md-6">
  1231. <?php
  1232. /* This will handle error, success and notice messages */
  1233. hesk_handle_messages();
  1234. if ($hesk_settings['kb_wysiwyg'])
  1235. {
  1236. ?>
  1237. <script type="text/javascript">
  1238. tinyMCE.init({
  1239. mode : "exact",
  1240. elements : "content",
  1241. theme : "advanced",
  1242. convert_urls : false,
  1243. gecko_spellcheck: true,
  1244. plugins: "autolink",
  1245. theme_advanced_buttons1 : "cut,copy,paste,|,undo,redo,|,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
  1246. theme_advanced_buttons2 : "sub,sup,|,charmap,|,bullist,numlist,|,outdent,indent,insertdate,inserttime,preview,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,link,unlink,anchor,image,cleanup,code",
  1247. theme_advanced_buttons3 : "",
  1248. theme_advanced_toolbar_location : "top",
  1249. theme_advanced_toolbar_align : "left",
  1250. theme_advanced_statusbar_location : "bottom",
  1251. theme_advanced_resizing : true
  1252. });
  1253. </script>
  1254. <?php
  1255. }
  1256. $displayType = $hesk_settings['kb_wysiwyg'] ? 'none' : 'block';
  1257. $displayWarn = $article['html'] ? 'block' : 'none';
  1258. ?>
  1259. <span id="contentType" style="display:<?php echo $displayType; ?>">
  1260. <label><input type="radio" name="html" value="0" <?php if (!$article['html']) {echo 'checked="checked"';} ?> onclick="javascript:document.getElementById('kblinks').style.display = 'none'" /> <?php echo $hesklang['kb_dhtml']; ?></label><br />
  1261. <label><input type="radio" name="html" value="1" <?php if ($article['html']) {echo 'checked="checked"';} ?> onclick="javascript:document.getElementById('kblinks').style.display = 'block'" /> <?php echo $hesklang['kb_ehtml']; ?></label>
  1262. <span id="kblinks" style="display:<?php echo $displayWarn; ?>"><i><?php echo $hesklang['kb_links']; ?></i></span>
  1263. </span>
  1264. <div class="form-group">
  1265. <label for="subject" class="control-label"><?php echo $hesklang['kb_subject']; ?></label>
  1266. <input type="text" data-error="<?php echo htmlspecialchars($hesklang['kb_e_subj']); ?>" class="form-control"
  1267. placeholder="<?php echo htmlspecialchars($hesklang['kb_subject']); ?>" name="subject" size="70" maxlength="255" value="<?php echo $article['subject']; ?>" required>
  1268. <div class="help-block with-errors"></div>
  1269. </div>
  1270. <div class="form-group" id="content-group">
  1271. <textarea name="content" class="form-control" data-error="<?php echo htmlspecialchars($hesklang['kb_e_cont']); ?>" id="content"
  1272. placeholder="<?php echo htmlspecialchars($hesklang['kb_content']); ?>" rows="25" cols="70" id="content" required><?php echo $article['content']; ?></textarea>
  1273. <div class="help-block with-errors" id="content-help-block"></div>
  1274. </div>
  1275. </div>
  1276. <div class="col-md-3">
  1277. <div class="panel panel-default move-left-10">
  1278. <div class="panel-body">
  1279. <div class="form-group">
  1280. <label for="keywords" class="control-label"><?php echo $hesklang['kw']; ?></label>
  1281. <p class="font-size-90 form-control-static"><?php echo $hesklang['kw1']; ?></p><br>
  1282. <textarea name="keywords" class="form-control" placeholder="<?php echo htmlspecialchars($hesklang['kw']); ?>" rows="3" cols="70" id="keywords"><?php echo $article['keywords']; ?></textarea>
  1283. </div>
  1284. <?php if ( ! empty($article['attachments']) || $hesk_settings['attachments']['use']): ?>
  1285. <div class="form-group">
  1286. <label for="attachments" class="control-label"><?php echo $hesklang['attachments']; ?> (<a href="Javascript:void(0)" onclick="Javascript:hesk_window('../file_limits.php',250,500);return false;"><?php echo $hesklang['ful']; ?></a>)</label>
  1287. <?php
  1288. if ( ! empty($article['attachments']) )
  1289. {
  1290. $att=explode(',',substr($article['attachments'], 0, -1));
  1291. foreach ($att as $myatt)
  1292. {
  1293. list($att_id, $att_name) = explode('#', $myatt);
  1294. $tmp = 'White';
  1295. $style = 'class="option'.$tmp.'OFF" onmouseover="this.className=\'option'.$tmp.'ON\'" onmouseout="this.className=\'option'.$tmp.'OFF\'"';
  1296. echo '<a href="manage_knowledgebase.php?a=remove_kb_att&amp;id='.$id.'&amp;kb_att='.$att_id.'&amp;token='.hesk_token_echo(0).'" onclick="return hesk_confirmExecute(\''.hesk_makeJsString($hesklang['delatt']).'\');"><img src="../img/delete.png" width="16" height="16" alt="'.$hesklang['dela'].'" title="'.$hesklang['dela'].'" '.$style.' /></a> ';
  1297. echo '<a href="../download_attachment.php?kb_att='.$att_id.'"><img src="../img/clip.png" width="16" height="16" alt="'.$hesklang['dnl'].' '.$att_name.'" title="'.$hesklang['dnl'].' '.$att_name.'" '.$style.' /></a> ';
  1298. echo '<a href="../download_attachment.php?kb_att='.$att_id.'">'.$att_name.'</a><br />';
  1299. }
  1300. echo '<br />';
  1301. }
  1302. ?>
  1303. <?php
  1304. build_dropzone_markup(true);
  1305. display_dropzone_field(HESK_PATH . 'internal-api/admin/knowledgebase/upload-attachment.php');
  1306. ?>
  1307. </div>
  1308. <?php endif; //End attachments ?>
  1309. <div class="form-group">
  1310. <input type="hidden" name="a" value="save_article">
  1311. <input type="hidden" name="id" value="<?php echo $id; ?>">
  1312. <input type="hidden" name="old_type" value="<?php echo $article['type']; ?>">
  1313. <input type="hidden" name="old_catid" value="<?php echo $catid; ?>">
  1314. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>">
  1315. <div class="btn-group-vertical full-width">
  1316. <input type="submit" value="<?php echo $hesklang['kb_save']; ?>" class="btn btn-primary" />
  1317. <a class="btn btn-default" href="manage_knowledgebase.php?a=manage_cat&amp;catid=<?php echo $catid; ?>"><?php echo $hesklang['cancel']; ?></a>
  1318. <a class="btn btn-danger" href="manage_knowledgebase.php?a=remove_article&amp;id=<?php echo $article['id']; ?>&amp;token=<?php hesk_token_echo(); ?>" onclick="return hesk_confirmExecute('<?php echo hesk_makeJsString($hesklang['del_art']); ?>');"><?php echo $hesklang['del_kbaa']; ?></a>
  1319. </div>
  1320. </div>
  1321. </div>
  1322. </div>
  1323. </div>
  1324. </div>
  1325. </form>
  1326. <div class="row">
  1327. <div class="col-md-12 move-left-10 move-right-10">
  1328. <h3><?php echo $hesklang['revhist']; ?></h3>
  1329. <div class="footerWithBorder blankSpace"></div>
  1330. <ul><?php echo $article['history']; ?></ul>
  1331. </div>
  1332. </div>
  1333. <?php
  1334. /* Clean unneeded session variables */
  1335. hesk_cleanSessionVars('edit_article');
  1336. require_once(HESK_PATH . 'inc/footer.inc.php');
  1337. exit();
  1338. } // END edit_article()
  1339. function manage_category() {
  1340. global $hesk_settings, $hesklang;
  1341. $catid = intval( hesk_GET('catid') ) or hesk_error($hesklang['kb_cat_inv']);
  1342. $result = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_categories` ORDER BY `parent` ASC, `cat_order` ASC');
  1343. $kb_cat = array();
  1344. while ($cat = hesk_dbFetchAssoc($result))
  1345. {
  1346. $kb_cat[] = $cat;
  1347. if ($cat['id'] == $catid)
  1348. {
  1349. $this_cat = $cat;
  1350. }
  1351. }
  1352. if (isset($_SESSION['manage_cat']))
  1353. {
  1354. $_SESSION['manage_cat'] = hesk_stripArray($_SESSION['manage_cat']);
  1355. $this_cat['type'] = $_SESSION['manage_cat']['type'];
  1356. $this_cat['parent'] = $_SESSION['manage_cat']['parent'];
  1357. $this_cat['name'] = $_SESSION['manage_cat']['title'];
  1358. }
  1359. /* Translate main category "Knowledgebase" if needed */
  1360. $kb_cat[0]['name'] = $hesklang['kb_text'];
  1361. require(HESK_PATH . 'inc/treemenu/TreeMenu.php');
  1362. $icon = HESK_PATH . 'img/folder.gif';
  1363. $expandedIcon = 'fa-folder-open style="color:orange;font-size:17px';
  1364. $menu = new HTML_TreeMenu();
  1365. $thislevel = array('0');
  1366. $nextlevel = array();
  1367. $i = 1;
  1368. $j = 1;
  1369. while (count($kb_cat) > 0)
  1370. {
  1371. foreach ($kb_cat as $k=>$cat)
  1372. {
  1373. if (in_array($cat['parent'],$thislevel))
  1374. {
  1375. $up = $cat['parent'];
  1376. $my = $cat['id'];
  1377. $type = $cat['type'] ? '*' : '';
  1378. $text_short = $cat['name'].$type.' ('.$cat['articles'].', '.$cat['articles_private'].', '.$cat['articles_draft'].')';
  1379. if (isset($node[$up]))
  1380. {
  1381. $node[$my] = &$node[$up]->addItem(new HTML_TreeNode(array('hesk_parent' => $this_cat['parent'], 'text' => 'Text', 'text_short' => $text_short, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option'.$j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true)));
  1382. }
  1383. else
  1384. {
  1385. $node[$my] = new HTML_TreeNode(array('hesk_parent' => $this_cat['parent'], 'text' => 'Text', 'text_short' => $text_short, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option'.$j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true));
  1386. }
  1387. $nextlevel[] = $cat['id'];
  1388. $j++;
  1389. unset($kb_cat[$k]);
  1390. }
  1391. }
  1392. $thislevel = $nextlevel;
  1393. $nextlevel = array();
  1394. /* Break after 20 recursions to avoid hang-ups in case of any problems */
  1395. if ($i > 20)
  1396. {
  1397. break;
  1398. }
  1399. $i++;
  1400. }
  1401. $menu->addItem($node[1]);
  1402. // Create the presentation class
  1403. $listBox = & ref_new(new HTML_TreeMenu_Listbox($menu));
  1404. /* Print header */
  1405. require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
  1406. /* Print main manage users page */
  1407. require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
  1408. ?>
  1409. <div class="content-wrapper">
  1410. <ol class="breadcrumb">
  1411. <li><a href="manage_knowledgebase.php"><?php echo $hesklang['kb']; ?></a></li>
  1412. <li class="active"><?php echo $hesklang['kb_cat_man']; ?></li>
  1413. </ol>
  1414. <section class="content">
  1415. <?php
  1416. show_subnav('',$catid);
  1417. $result = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}' ORDER BY `sticky` DESC, `art_order` ASC");
  1418. $num = hesk_dbNumRows($result);
  1419. $secondCol = $catid == 1 ? 'col-md-12' : 'col-md-8';
  1420. if ( ! isset($_SESSION['hide']['article_list'])):
  1421. ?>
  1422. <div class="row">
  1423. <?php if ($catid != 1): ?>
  1424. <div class="col-md-4">
  1425. <div class="box">
  1426. <div class="box-header with-border">
  1427. <h1 class="box-title">
  1428. <?php echo $hesklang['catset']; ?>
  1429. </h1>
  1430. <div class="box-tools pull-right">
  1431. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  1432. <i class="fa fa-minus"></i>
  1433. </button>
  1434. </div>
  1435. </div>
  1436. <div class="box-body">
  1437. <form action="manage_knowledgebase.php" method="post" role="form" name="form1" data-toggle="validator"
  1438. onsubmit="Javascript:return hesk_deleteIfSelected('dodelete','<?php echo hesk_makeJsString($hesklang['kb_delcat']); ?>')">
  1439. <div class="form-group">
  1440. <label for="title" class="control-label"><?php echo $hesklang['kb_cat_title']; ?></label>
  1441. <input type="text" class="form-control" name="title" size="70" maxlength="255" value="<?php echo $this_cat['name']; ?>"
  1442. data-error="<?php echo htmlspecialchars($hesklang['kb_cat_e_title']); ?>" required>
  1443. <div class="help-block with-errors"></div>
  1444. </div>
  1445. <div class="form-group">
  1446. <label for="parent" class="control-label"><?php echo $hesklang['kb_cat_parent']; ?></label>
  1447. <select name="parent" class="form-control"><?php $listBox->printMenu(); ?></select>
  1448. </div>
  1449. <div class="form-group">
  1450. <label for="type" class="control-label"><?php echo $hesklang['kb_type']; ?></label>
  1451. <div class="radio">
  1452. <label><input type="radio" name="type" value="0" <?php if (!$this_cat['type']) {echo 'checked="checked"';} ?> /> <b><i><?php echo $hesklang['kb_published']; ?></i></b></label>
  1453. <p class="form-static-content"><?php echo $hesklang['kb_cat_published']; ?></p>
  1454. </div>
  1455. <div class="radio">
  1456. <label><input type="radio" name="type" value="1" <?php if ($this_cat['type']) {echo 'checked="checked"';} ?> /> <b><i><?php echo $hesklang['kb_private']; ?></i></b></label>
  1457. <p class="form-static-content"><?php echo $hesklang['kb_cat_private']; ?></p>
  1458. </div>
  1459. </div>
  1460. <div class="form-group">
  1461. <label for="dodelete" class="control-label"><?php echo $hesklang['opt']; ?></label>
  1462. <div class="checkbox">
  1463. <label><input type="checkbox" name="dodelete" id="dodelete" value="Y" onclick="Javascript:hesk_toggleLayerDisplay('deleteoptions')" /><?php echo $hesklang['delcat']; ?></label>
  1464. </div>
  1465. </div>
  1466. <div id="deleteoptions" style="display: none;">
  1467. <div class="form-group">
  1468. <div class="radio">
  1469. <label><input type="radio" name="movearticles" value="Y" checked="checked" /> <?php echo $hesklang['move1']; ?></label>
  1470. </div>
  1471. <div class="radio">
  1472. <label><input type="radio" name="movearticles" value="N" /> <?php echo $hesklang['move2']; ?></label>
  1473. </div>
  1474. </div>
  1475. </div>
  1476. <div class="form-group">
  1477. <input type="hidden" name="a" value="edit_category" />
  1478. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>" />
  1479. <input type="hidden" name="catid" value="<?php echo $catid; ?>" />
  1480. <div class="btn-group">
  1481. <input type="submit" value="<?php echo $hesklang['save_changes']; ?>" class="btn btn-primary" />
  1482. <a class="btn btn-default" href="manage_knowledgebase.php?a=add_category&amp;parent='.$catid.'"><?php echo $hesklang['kb_i_cat2']; ?></a>
  1483. </div>
  1484. </div>
  1485. </form>
  1486. </div>
  1487. </div>
  1488. </div>
  1489. <?php endif; ?>
  1490. <div class="<?php echo $secondCol; ?>">
  1491. <div class="box">
  1492. <div class="box-header with-border">
  1493. <h1 class="box-title">
  1494. <?php echo sprintf($hesklang['articles_in_category_x'], '<strong>'.$this_cat['name']).'</strong>'; ?>
  1495. </h1>
  1496. <div class="box-tools pull-right">
  1497. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  1498. <i class="fa fa-minus"></i>
  1499. </button>
  1500. </div>
  1501. </div>
  1502. <div class="box-body">
  1503. <?php
  1504. if ($num == 0)
  1505. {
  1506. echo '<p>'.$hesklang['kb_no_art'].'</p>';
  1507. }
  1508. else
  1509. {
  1510. /* Get number of sticky articles */
  1511. $res2 = hesk_dbQuery("SELECT COUNT(*) FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}' AND `sticky` = '1' ");
  1512. $num_sticky = hesk_dbResult($res2);
  1513. $num_nosticky = $num - $num_sticky;
  1514. ?>
  1515. <table class="table table-striped">
  1516. <thead>
  1517. <tr>
  1518. <th>&nbsp;</th>
  1519. <th><?php echo $hesklang['kb_subject']; ?></th>
  1520. <th><?php echo $hesklang['kb_type']; ?></th>
  1521. <th><?php echo $hesklang['views']; ?></th>
  1522. <?php
  1523. if ($hesk_settings['kb_rating'])
  1524. {
  1525. ?>
  1526. <th><?php echo $hesklang['rating'].' ('.$hesklang['votes'].')'; ?></th>
  1527. <?php
  1528. }
  1529. ?>
  1530. <th>&nbsp;<?php echo $hesklang['opt']; ?>&nbsp;</th>
  1531. </tr>
  1532. </thead>
  1533. <?php
  1534. $i=1;
  1535. $j=1;
  1536. $k=1;
  1537. $previous_sticky=1;
  1538. $num = $num_sticky;
  1539. while ($article=hesk_dbFetchAssoc($result))
  1540. {
  1541. if ($previous_sticky != $article['sticky'])
  1542. {
  1543. $k = 1;
  1544. $num = $num_nosticky;
  1545. $previous_sticky = $article['sticky'];
  1546. }
  1547. if (isset($_SESSION['artord']) && $article['id'] == $_SESSION['artord'])
  1548. {
  1549. unset($_SESSION['artord']);
  1550. }
  1551. $tmp = $i ? 'White' : 'Blue';
  1552. $i = $i ? 0 : 1;
  1553. switch ($article['type'])
  1554. {
  1555. case '1':
  1556. $type = '<span class="kb_private">' . $hesklang['kb_private'] . '</span>';
  1557. break;
  1558. case '2':
  1559. $type = '<span class="kb_draft">' . $hesklang['kb_draft'] . '</span>';
  1560. break;
  1561. default:
  1562. $type = '<span class="kb_published">' . $hesklang['kb_published'] . '</span>';
  1563. }
  1564. if ($hesk_settings['kb_rating'])
  1565. {
  1566. $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
  1567. $rat = '<td><span data-toggle="tooltip" title="' . $alt . '">' . mfh_get_stars(hesk_round_to_half($article['rating'])) . '</span> (' . $article['votes'] . ')</td>';
  1568. }
  1569. else
  1570. {
  1571. $rat = '';
  1572. }
  1573. ?>
  1574. <tr>
  1575. <td><?php echo $j; ?>.</td>
  1576. <td><?php echo $article['subject']; ?></td>
  1577. <td><?php echo $type; ?></td>
  1578. <td><?php echo $article['views']; ?></td>
  1579. <?php echo $rat; ?>
  1580. <td>
  1581. <?php
  1582. if ($num > 1)
  1583. {
  1584. if ($k == 1)
  1585. {
  1586. ?>
  1587. <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />
  1588. <a href="manage_knowledgebase.php?a=order_article&amp;id=<?php echo $article['id']; ?>&amp;catid=<?php echo $catid; ?>&amp;move=15&amp;token=<?php hesk_token_echo(); ?>"><i class="fa fa-arrow-down icon-link green" data-toggle="tooltip" data-placement="top" title="<?php echo $hesklang['move_dn']; ?>"></i></a>
  1589. <?php
  1590. }
  1591. elseif ($k == $num)
  1592. {
  1593. ?>
  1594. <a href="manage_knowledgebase.php?a=order_article&amp;id=<?php echo $article['id']; ?>&amp;catid=<?php echo $catid; ?>&amp;move=-15&amp;token=<?php hesk_token_echo(); ?>"><i class="fa fa-arrow-up icon-link green" data-toggle="tooltip" data-placement="top" title="<?php echo $hesklang['move_up']; ?>"></i></a>
  1595. <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />
  1596. <?php
  1597. }
  1598. else
  1599. {
  1600. ?>
  1601. <a href="manage_knowledgebase.php?a=order_article&amp;id=<?php echo $article['id']; ?>&amp;catid=<?php echo $catid; ?>&amp;move=-15&amp;token=<?php hesk_token_echo(); ?>"><i class="fa fa-arrow-up icon-link green" data-toggle="tooltip" data-placement="top" title="<?php echo $hesklang['move_up']; ?>"></i></a>
  1602. <a href="manage_knowledgebase.php?a=order_article&amp;id=<?php echo $article['id']; ?>&amp;catid=<?php echo $catid; ?>&amp;move=15&amp;token=<?php hesk_token_echo(); ?>"><i class="fa fa-arrow-down icon-link green" data-toggle="tooltip" data-placement="top" title="<?php echo $hesklang['move_dn'] ?>"></i></a>
  1603. <?php
  1604. }
  1605. }
  1606. elseif ( $num_sticky > 1 || $num_nosticky > 1 )
  1607. {
  1608. echo '<img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;vertical-align:text-bottom;" /> <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;vertical-align:text-bottom;" />';
  1609. }
  1610. ?>
  1611. <a href="manage_knowledgebase.php?a=sticky&amp;s=<?php echo $article['sticky'] ? 0 : 1 ?>&amp;id=<?php echo $article['id']; ?>&amp;catid=<?php echo $catid; ?>&amp;token=<?php hesk_token_echo(); ?>"><i class="glyphicon glyphicon-pushpin icon-link" style="color:<?php if ( ! $article['sticky']) {echo 'gray';} else {echo 'red';} ?>" data-toggle="tooltip" data-placement="top" title="<?php if (!$article['sticky']) {echo $hesklang['stickyon'];} else {echo $hesklang['stickyoff'];} ?>"></i></a>
  1612. <a href="knowledgebase_private.php?article=<?php echo $article['id']; ?>&amp;back=1<?php if ($article['type'] == 2) {echo '&amp;draft=1';} ?>" target="_blank"><i class="fa fa-file-o icon-link" data-toggle="tooltip" data-placement="top" title="<?php echo $hesklang['viewart'] ?>"></i></a>
  1613. <a href="manage_knowledgebase.php?a=edit_article&amp;id=<?php echo $article['id']; ?>"><i class="fa fa-pencil" style="color:orange;font-size:16px" data-toggle="tooltip" data-placement="top" title="<?php echo $hesklang['edit'] ?>"></i></a>
  1614. <a href="manage_knowledgebase.php?a=remove_article&amp;id=<?php echo $article['id']; ?>&amp;token=<?php hesk_token_echo(); ?>" onclick="return hesk_confirmExecute('<?php echo hesk_makeJsString($hesklang['del_art']); ?>');"><i class="fa fa-times icon-link red" data-toggle="tooltip" data-placement="top" title="<?php echo $hesklang['delete'] ?>"></i></a>&nbsp;</td>
  1615. </tr>
  1616. <?php
  1617. $j++;
  1618. $k++;
  1619. } // End while
  1620. ?>
  1621. </table>
  1622. <?php
  1623. } ?>
  1624. </div>
  1625. <div class="box-footer">
  1626. <a href="manage_knowledgebase.php?a=add_article&amp;catid=<?php echo $catid; ?>" class="btn btn-success">
  1627. <i class="fa fa-plus"></i>
  1628. <?php echo $hesklang['kb_i_art2']; ?>
  1629. </a>
  1630. </div>
  1631. </div>
  1632. </div>
  1633. </div>
  1634. <?php endif; ?>
  1635. </section>
  1636. </div>
  1637. <?php
  1638. /* Clean unneeded session variables */
  1639. hesk_cleanSessionVars(array('hide','manage_cat','edit_article'));
  1640. require_once(HESK_PATH . 'inc/footer.inc.php');
  1641. exit();
  1642. } // END manage_category()
  1643. function new_category() {
  1644. global $hesk_settings, $hesklang;
  1645. /* A security check */
  1646. hesk_token_check('POST');
  1647. $_SESSION['hide'] = array(
  1648. 'treemenu' => 1,
  1649. 'new_article' => 1,
  1650. //'new_category' => 1,
  1651. );
  1652. $parent = intval( hesk_POST('parent', 1) );
  1653. $type = empty($_POST['type']) ? 0 : 1;
  1654. $_SESSION['KB_CATEGORY'] = $parent;
  1655. $_SERVER['PHP_SELF'] = 'manage_knowledgebase.php';
  1656. /* Check that title is valid */
  1657. $title = hesk_input( hesk_POST('title') );
  1658. if (!strlen($title))
  1659. {
  1660. $_SESSION['new_category'] = array(
  1661. 'type' => $type,
  1662. );
  1663. hesk_process_messages($hesklang['kb_cat_e_title'],$_SERVER['PHP_SELF']);
  1664. }
  1665. /* Get the latest reply_order */
  1666. $res = hesk_dbQuery('SELECT `cat_order` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_categories` ORDER BY `cat_order` DESC LIMIT 1');
  1667. $row = hesk_dbFetchRow($res);
  1668. $my_order = $row[0]+10;
  1669. $result = hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` (`name`,`parent`,`cat_order`,`type`) VALUES ('".hesk_dbEscape($title)."','".intval($parent)."','".intval($my_order)."','".intval($type)."')");
  1670. $_SESSION['newcat'] = hesk_dbInsertID();
  1671. $_SESSION['hide'] = array(
  1672. 'treemenu' => 1,
  1673. 'new_article' => 1,
  1674. //'new_category' => 1,
  1675. 'cat_treemenu' => 1,
  1676. );
  1677. hesk_process_messages($hesklang['kb_cat_added2'],$_SERVER['PHP_SELF'],'SUCCESS');
  1678. } // End new_category()
  1679. function new_article()
  1680. {
  1681. global $hesk_settings, $hesklang, $listBox;
  1682. global $hesk_error_buffer;
  1683. /* A security check */
  1684. # hesk_token_check('POST');
  1685. $_SESSION['hide'] = array(
  1686. 'treemenu' => 1,
  1687. //'new_article' => 1,
  1688. 'new_category' => 1,
  1689. );
  1690. $hesk_error_buffer = array();
  1691. $catid = intval( hesk_POST('catid', 1) );
  1692. $type = empty($_POST['type']) ? 0 : (hesk_POST('type') == 2 ? 2 : 1);
  1693. $html = $hesk_settings['kb_wysiwyg'] ? 1 : (empty($_POST['html']) ? 0 : 1);
  1694. $now = hesk_date();
  1695. // Prevent submitting duplicate articles by reloading manage_knowledgebase.php page
  1696. if (isset($_SESSION['article_submitted']))
  1697. {
  1698. header('Location:manage_knowledgebase.php?a=manage_cat&catid=' . $catid);
  1699. exit();
  1700. }
  1701. $_SESSION['KB_CATEGORY'] = $catid;
  1702. $subject = hesk_input( hesk_POST('subject') ) or $hesk_error_buffer[] = $hesklang['kb_e_subj'];
  1703. if ($html)
  1704. {
  1705. if (empty($_POST['content']))
  1706. {
  1707. $hesk_error_buffer[] = $hesklang['kb_e_cont'];
  1708. }
  1709. $content = hesk_getHTML( hesk_POST('content') );
  1710. // Clean the HTML code
  1711. require(HESK_PATH . 'inc/htmlpurifier/HeskHTMLPurifier.php');
  1712. $purifier = new HeskHTMLPurifier($hesk_settings['cache_dir']);
  1713. $content = $purifier->heskPurify($content);
  1714. }
  1715. else
  1716. {
  1717. $content = hesk_input( hesk_POST('content') ) or $hesk_error_buffer[] = $hesklang['kb_e_cont'];
  1718. $content = nl2br($content);
  1719. $content = hesk_makeURL($content);
  1720. }
  1721. $sticky = isset($_POST['sticky']) ? 1 : 0;
  1722. $keywords = hesk_input( hesk_POST('keywords') );
  1723. /* Article attachments */
  1724. define('KB',1);
  1725. require_once(HESK_PATH . 'inc/posting_functions.inc.php');
  1726. $attachments = array();
  1727. $use_legacy_attachments = hesk_POST('use-legacy-attachments', 0);
  1728. $myattachments='';
  1729. if ($hesk_settings['attachments']['use']) {
  1730. require_once(HESK_PATH . 'inc/attachments.inc.php');
  1731. if ($use_legacy_attachments) {
  1732. for ($i=1; $i<=$hesk_settings['attachments']['max_number']; $i++)
  1733. {
  1734. $att = hesk_uploadFile($i);
  1735. if ( ! empty($att))
  1736. {
  1737. $attachments[$i] = $att;
  1738. }
  1739. }
  1740. } else {
  1741. // The user used the new drag-and-drop system.
  1742. $temp_attachment_ids = hesk_POST_array('attachment-ids');
  1743. foreach ($temp_attachment_ids as $temp_attachment_id) {
  1744. // Simply get the temp info and move it to the attachments table
  1745. $temp_attachment = mfh_getTemporaryAttachment($temp_attachment_id);
  1746. $attachments[] = $temp_attachment;
  1747. mfh_deleteTemporaryAttachment($temp_attachment_id);
  1748. }
  1749. }
  1750. }
  1751. /* Any errors? */
  1752. if (count($hesk_error_buffer))
  1753. {
  1754. // Remove any successfully uploaded attachments
  1755. if ($hesk_settings['attachments']['use'])
  1756. {
  1757. hesk_removeAttachments($attachments);
  1758. }
  1759. $_SESSION['new_article'] = array(
  1760. 'type' => $type,
  1761. 'html' => $html,
  1762. 'subject' => $subject,
  1763. 'content' => hesk_input( hesk_POST('content') ),
  1764. 'keywords' => $keywords,
  1765. 'sticky' => $sticky,
  1766. );
  1767. $tmp = '';
  1768. foreach ($hesk_error_buffer as $error)
  1769. {
  1770. $tmp .= "<li>$error</li>\n";
  1771. }
  1772. $hesk_error_buffer = $tmp;
  1773. $hesk_error_buffer = $hesklang['rfm'].'<br /><br /><ul>'.$hesk_error_buffer.'</ul>';
  1774. hesk_process_messages($hesk_error_buffer,'manage_knowledgebase.php');
  1775. }
  1776. $revision = sprintf($hesklang['revision1'],$now,$_SESSION['name'].' ('.$_SESSION['user'].')');
  1777. /* Add to database */
  1778. if ( ! empty($attachments))
  1779. {
  1780. foreach ($attachments as $myatt)
  1781. {
  1782. hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` (`saved_name`,`real_name`,`size`) VALUES ('".hesk_dbEscape($myatt['saved_name'])."','".hesk_dbEscape($myatt['real_name'])."','".intval($myatt['size'])."')");
  1783. $myattachments .= hesk_dbInsertID() . '#' . $myatt['real_name'] .',';
  1784. }
  1785. }
  1786. /* Get the latest reply_order */
  1787. $res = hesk_dbQuery("SELECT `art_order` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='".intval($catid)."' AND `sticky` = '" . intval($sticky) . "' ORDER BY `art_order` DESC LIMIT 1");
  1788. $row = hesk_dbFetchRow($res);
  1789. $my_order = $row[0]+10;
  1790. /* Insert article into database */
  1791. hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` (`catid`,`dt`,`author`,`subject`,`content`,`keywords`,`type`,`html`,`sticky`,`art_order`,`history`,`attachments`) VALUES (
  1792. '".intval($catid)."',
  1793. NOW(),
  1794. '".intval($_SESSION['id'])."',
  1795. '".hesk_dbEscape($subject)."',
  1796. '".hesk_dbEscape($content)."',
  1797. '".hesk_dbEscape($keywords)."',
  1798. '".intval($type)."',
  1799. '".intval($html)."',
  1800. '".intval($sticky)."',
  1801. '".intval($my_order)."',
  1802. '".hesk_dbEscape($revision)."',
  1803. '".hesk_dbEscape($myattachments)."'
  1804. )");
  1805. $_SESSION['artord'] = hesk_dbInsertID();
  1806. // Update category article count
  1807. if ($type == 0)
  1808. {
  1809. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles`=`articles`+1 WHERE `id`='".intval($catid)."'");
  1810. }
  1811. else if ($type == 1)
  1812. {
  1813. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles_private`=`articles_private`+1 WHERE `id`='".intval($catid)."'");
  1814. }
  1815. else
  1816. {
  1817. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles_draft`=`articles_draft`+1 WHERE `id`='".intval($catid)."'");
  1818. }
  1819. unset($_SESSION['hide']);
  1820. $_SESSION['article_submitted']=1;
  1821. hesk_process_messages($hesklang['your_kb_added'],'NOREDIRECT','SUCCESS');
  1822. $_GET['catid'] = $catid;
  1823. manage_category();
  1824. } // End new_article()
  1825. function remove_article()
  1826. {
  1827. global $hesk_settings, $hesklang;
  1828. /* A security check */
  1829. hesk_token_check();
  1830. $id = intval( hesk_GET('id') ) or hesk_error($hesklang['kb_art_id']);
  1831. /* Get article details */
  1832. $result = hesk_dbQuery("SELECT `catid`, `type`, `attachments` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `id`='".intval($id)."' LIMIT 1");
  1833. if (hesk_dbNumRows($result) != 1)
  1834. {
  1835. hesk_error($hesklang['kb_art_id']);
  1836. }
  1837. $article = hesk_dbFetchAssoc($result);
  1838. $catid = intval($article['catid']);
  1839. $from = hesk_GET('from');
  1840. $result = hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `id`='".intval($id)."'");
  1841. // Remove any attachments
  1842. delete_kb_attachments($article['attachments']);
  1843. // Update category article count
  1844. if ($article['type'] == 0)
  1845. {
  1846. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles`=`articles`-1 WHERE `id`='{$catid}'");
  1847. }
  1848. else if ($article['type'] == 1)
  1849. {
  1850. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles_private`=`articles_private`-1 WHERE `id`='{$catid}'");
  1851. }
  1852. else
  1853. {
  1854. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles_draft`=`articles_draft`-1 WHERE `id`='{$catid}'");
  1855. }
  1856. // Clear KB cache
  1857. hesk_purge_cache('kb');
  1858. // Redirect to the correct page
  1859. switch ($from) {
  1860. case 'draft':
  1861. $redirect_action = 'a=list_draft';
  1862. break;
  1863. case 'private':
  1864. $redirect_action = 'a=list_private';
  1865. break;
  1866. default:
  1867. $redirect_action = 'a=manage_cat&catid='.$catid;
  1868. break;
  1869. }
  1870. hesk_process_messages($hesklang['your_kb_deleted'],'./manage_knowledgebase.php?'.$redirect_action,'SUCCESS');
  1871. } // End remove_article()
  1872. function order_category()
  1873. {
  1874. global $hesk_settings, $hesklang;
  1875. /* A security check */
  1876. hesk_token_check();
  1877. $catid = intval( hesk_GET('catid') ) or hesk_error($hesklang['kb_cat_inv']);
  1878. $move = intval( hesk_GET('move') );
  1879. $_SESSION['newcat'] = $catid;
  1880. $result = hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `cat_order`=`cat_order`+".intval($move)." WHERE `id`='".intval($catid)."'");
  1881. if (hesk_dbAffectedRows() != 1)
  1882. {
  1883. hesk_error($hesklang['kb_cat_inv']);
  1884. }
  1885. update_category_order();
  1886. header('Location: manage_knowledgebase.php');
  1887. exit();
  1888. } // End order_category()
  1889. function order_article()
  1890. {
  1891. global $hesk_settings, $hesklang;
  1892. /* A security check */
  1893. hesk_token_check();
  1894. $id = intval( hesk_GET('id') ) or hesk_error($hesklang['kb_art_id']);
  1895. $catid = intval( hesk_GET('catid') ) or hesk_error($hesklang['kb_cat_inv']);
  1896. $move = intval( hesk_GET('move') );
  1897. $_SESSION['artord'] = $id;
  1898. $result = hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `art_order`=`art_order`+".intval($move)." WHERE `id`='".intval($id)."'");
  1899. if (hesk_dbAffectedRows() != 1)
  1900. {
  1901. hesk_error($hesklang['kb_art_id']);
  1902. }
  1903. /* Update article order */
  1904. update_article_order($catid);
  1905. header('Location: manage_knowledgebase.php?a=manage_cat&catid='.$catid);
  1906. exit();
  1907. } // End order_article()
  1908. function show_treeMenu() {
  1909. global $hesk_settings, $hesklang, $treeMenu;
  1910. ?>
  1911. <script src="<?php echo HESK_PATH; ?>inc/treemenu/TreeMenu_v25.js" language="JavaScript" type="text/javascript"></script>
  1912. <div class="box">
  1913. <div class="box-header with-border">
  1914. <h1 class="box-title">
  1915. <?php echo $hesklang['kbstruct']; ?>
  1916. </h1>
  1917. <div class="box-tools pull-right">
  1918. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  1919. <i class="fa fa-minus"></i>
  1920. </button>
  1921. </div>
  1922. </div>
  1923. <div class="box-body">
  1924. <?php $treeMenu->printMenu(); ?>
  1925. <i class="fa fa-plus icon-link green"></i> = <?php echo $hesklang['kb_p_art2']; ?><br />
  1926. <i class="fa fa-caret-right blue" style="font-size:18px"></i> = <?php echo $hesklang['kb_p_cat2']; ?><br />
  1927. <i class="fa fa-gear icon-link gray"></i> = <?php echo $hesklang['kb_p_man2']; ?><br />
  1928. <img src="../img/blank.gif" width="1" height="16" alt="" style="padding:1px" class="optionWhiteNbOFF" />(<span class="kb_published">1</span>, <span class="kb_private">2</span>, <span class="kb_draft">3</span>) = <?php echo $hesklang['xyz']; ?><br />
  1929. </div>
  1930. </div>
  1931. <?php
  1932. }
  1933. function show_subnav($hide='',$catid=1)
  1934. {
  1935. global $hesk_settings, $hesklang;
  1936. // If a category is selected, use it as default for articles and parents
  1937. if (isset($_SESSION['KB_CATEGORY']))
  1938. {
  1939. $catid = intval($_SESSION['KB_CATEGORY']);
  1940. }
  1941. $link['view'] = '<a href="knowledgebase_private.php"><i class="fa fa-search icon-link"></i></a> <a href="knowledgebase_private.php">'.$hesklang['gopr'].'</a> | ';
  1942. $link['newa'] = '<a href="manage_knowledgebase.php?a=add_article&amp;catid='.$catid.'"><i class="fa fa-plus icon-link green"></i></a> <a href="manage_knowledgebase.php?a=add_article&amp;catid='.$catid.'">'.$hesklang['kb_i_art'].'</a> | ';
  1943. $link['newc'] = '<a href="manage_knowledgebase.php?a=add_category&amp;parent='.$catid.'"><i class="fa fa-caret-right blue" style="font-size:18px"></i></a> <a href="manage_knowledgebase.php?a=add_category&amp;parent='.$catid.'">'.$hesklang['kb_i_cat'].'</a> | ';
  1944. if ($hide && isset($link[$hide]))
  1945. {
  1946. $link[$hide] = preg_replace('#<a([^<]*)>#', '', $link[$hide]);
  1947. $link[$hide] = str_replace('</a>','',$link[$hide]);
  1948. }
  1949. ?>
  1950. <form class="move-right-40" style="padding:0px;" method="get" action="manage_knowledgebase.php">
  1951. <p>
  1952. <?php
  1953. echo $link['view'];
  1954. echo $link['newa'];
  1955. echo $link['newc'];
  1956. ?>
  1957. <i class="fa fa-pencil icon-link orange"></i></a> <input type="hidden" name="a" value="edit_article" /><?php echo $hesklang['aid']; ?>: <input type="text" name="id" size="3" /> <input type="submit" value="<?php echo $hesklang['edit']; ?>" class="btn btn-default btn-xs" />
  1958. </p>
  1959. </form>
  1960. &nbsp;<br />
  1961. <div class="move-right-40 move-left-20">
  1962. <?php
  1963. /* This will handle error, success and notice messages */
  1964. hesk_handle_messages(); ?>
  1965. </div>
  1966. <?php
  1967. return $catid;
  1968. } // End show_subnav()
  1969. function toggle_sticky()
  1970. {
  1971. global $hesk_settings, $hesklang;
  1972. /* A security check */
  1973. hesk_token_check();
  1974. $id = intval( hesk_GET('id') ) or hesk_error($hesklang['kb_art_id']);
  1975. $catid = intval( hesk_GET('catid') ) or hesk_error($hesklang['kb_cat_inv']);
  1976. $sticky = empty($_GET['s']) ? 0 : 1;
  1977. $_SESSION['artord'] = $id;
  1978. /* Update article "sticky" status */
  1979. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `sticky`='" . intval($sticky) . " ' WHERE `id`='" . intval($id) . "'");
  1980. /* Update article order */
  1981. update_article_order($catid);
  1982. $tmp = $sticky ? $hesklang['ason'] : $hesklang['asoff'];
  1983. hesk_process_messages($tmp, './manage_knowledgebase.php?a=manage_cat&catid='.$catid,'SUCCESS');
  1984. } // END toggle_sticky()
  1985. function update_article_order($catid)
  1986. {
  1987. global $hesk_settings, $hesklang;
  1988. /* Get list of current articles ordered by sticky and article order */
  1989. $res = hesk_dbQuery("SELECT `id`, `sticky` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='".intval($catid)."' ORDER BY `sticky` DESC, `art_order` ASC");
  1990. $i = 10;
  1991. $previous_sticky = 1;
  1992. while ( $article = hesk_dbFetchAssoc($res) )
  1993. {
  1994. /* Different count for sticky and non-sticky articles */
  1995. if ($previous_sticky != $article['sticky'])
  1996. {
  1997. $i = 10;
  1998. $previous_sticky = $article['sticky'];
  1999. }
  2000. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `art_order`=".intval($i)." WHERE `id`='".intval($article['id'])."'");
  2001. $i += 10;
  2002. }
  2003. return true;
  2004. } // END update_article_order()
  2005. function update_category_order()
  2006. {
  2007. global $hesk_settings, $hesklang;
  2008. /* Get list of current articles ordered by sticky and article order */
  2009. $res = hesk_dbQuery('SELECT `id`, `parent` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_categories` ORDER BY `parent` ASC, `cat_order` ASC');
  2010. $i = 10;
  2011. while ( $category = hesk_dbFetchAssoc($res) )
  2012. {
  2013. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `cat_order`=".intval($i)." WHERE `id`='".intval($category['id'])."'");
  2014. $i += 10;
  2015. }
  2016. return true;
  2017. } // END update_category_order()
  2018. function update_count($show_success=0)
  2019. {
  2020. global $hesk_settings, $hesklang;
  2021. $update_these = array();
  2022. // Get a count of all articles grouped by category and type
  2023. $res = hesk_dbQuery('SELECT `catid`, `type`, COUNT(*) AS `num` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` GROUP BY `catid`, `type`');
  2024. while ( $row = hesk_dbFetchAssoc($res) )
  2025. {
  2026. switch ($row['type'])
  2027. {
  2028. case 0:
  2029. $update_these[$row['catid']]['articles'] = $row['num'];
  2030. break;
  2031. case 1:
  2032. $update_these[$row['catid']]['articles_private'] = $row['num'];
  2033. break;
  2034. default:
  2035. $update_these[$row['catid']]['articles_draft'] = $row['num'];
  2036. }
  2037. }
  2038. // Set all article counts to 0
  2039. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles`=0, `articles_private`=0, `articles_draft`=0");
  2040. // Now update categories that have articles with correct values
  2041. foreach ($update_these as $catid => $value)
  2042. {
  2043. $value['articles'] = isset($value['articles']) ? $value['articles'] : 0;
  2044. $value['articles_private'] = isset($value['articles_private']) ? $value['articles_private'] : 0;
  2045. $value['articles_draft'] = isset($value['articles_draft']) ? $value['articles_draft'] : 0;
  2046. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` SET `articles`={$value['articles']}, `articles_private`={$value['articles_private']}, `articles_draft`={$value['articles_draft']} WHERE `id`='{$catid}'");
  2047. }
  2048. // Show a success message?
  2049. if ($show_success)
  2050. {
  2051. hesk_process_messages($hesklang['acv'], 'NOREDIRECT','SUCCESS');
  2052. }
  2053. return true;
  2054. } // END update_count()
  2055. function delete_category_recursive($catid)
  2056. {
  2057. global $hesk_settings, $hesklang;
  2058. $catid = intval($catid);
  2059. // Don't allow infinite loops... just in case
  2060. $hesk_settings['recursive_loop'] = isset($hesk_settings['recursive_loop']) ? $hesk_settings['recursive_loop'] + 1 : 1;
  2061. if ($hesk_settings['recursive_loop'] > 20)
  2062. {
  2063. return false;
  2064. }
  2065. // Make sure any attachments are deleted
  2066. $result = hesk_dbQuery("SELECT `attachments` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}'");
  2067. while ($article = hesk_dbFetchAssoc($result))
  2068. {
  2069. delete_kb_attachments($article['attachments']);
  2070. }
  2071. // Remove articles from database
  2072. hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}'");
  2073. // Delete all sub-categories
  2074. $result = hesk_dbQuery("SELECT `id` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` WHERE `parent`='{$catid}'");
  2075. while ($cat = hesk_dbFetchAssoc($result))
  2076. {
  2077. delete_category_recursive($cat['id']);
  2078. }
  2079. return true;
  2080. } // END delete_category_recursive()
  2081. function delete_kb_attachments($attachments)
  2082. {
  2083. global $hesk_settings, $hesklang;
  2084. // If nothing to delete just return
  2085. if (empty($attachments))
  2086. {
  2087. return true;
  2088. }
  2089. // Do the delete
  2090. $att = explode(',',substr($attachments, 0, -1));
  2091. foreach ($att as $myatt)
  2092. {
  2093. list($att_id, $att_name) = explode('#', $myatt);
  2094. // Get attachment saved name
  2095. $result = hesk_dbQuery("SELECT `saved_name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` WHERE `att_id`='".intval($att_id)."' LIMIT 1");
  2096. if (hesk_dbNumRows($result) == 1)
  2097. {
  2098. $file = hesk_dbFetchAssoc($result);
  2099. hesk_unlink(HESK_PATH.$hesk_settings['attach_dir'].'/'.$file['saved_name']);
  2100. }
  2101. $result = hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` WHERE `att_id`='".intval($att_id)."'");
  2102. }
  2103. return true;
  2104. } // delete_kb_attachments()
  2105. function hesk_stray_article($id)
  2106. {
  2107. global $hesk_settings, $hesklang, $article;
  2108. // Set article to category ID 1
  2109. $article['catid'] = 1;
  2110. // Update database
  2111. hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `catid`=1 WHERE `id`='".intval($id)."'");
  2112. // Update count of articles in categories
  2113. update_count();
  2114. // Return new category ID
  2115. return 1;
  2116. } // END hesk_stray_article()
  2117. ?>