function manage_category()
{
    global $hesk_settings, $hesklang;
    $catid = intval(hesk_GET('catid')) or hesk_error($hesklang['kb_cat_inv']);
    $result = hesk_dbQuery('SELECT * FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_categories` ORDER BY `parent` ASC, `cat_order` ASC');
    $kb_cat = array();
    while ($cat = hesk_dbFetchAssoc($result)) {
        $kb_cat[] = $cat;
        if ($cat['id'] == $catid) {
            $this_cat = $cat;
        }
    }
    if (isset($_SESSION['manage_cat'])) {
        $_SESSION['manage_cat'] = hesk_stripArray($_SESSION['manage_cat']);
        $this_cat['type'] = $_SESSION['manage_cat']['type'];
        $this_cat['parent'] = $_SESSION['manage_cat']['parent'];
        $this_cat['name'] = $_SESSION['manage_cat']['title'];
    }
    /* Translate main category "Knowledgebase" if needed */
    $kb_cat[0]['name'] = $hesklang['kb_text'];
    require HESK_PATH . 'inc/treemenu/TreeMenu.php';
    $icon = HESK_PATH . 'img/folder.gif';
    $expandedIcon = HESK_PATH . 'img/folder-expanded.gif';
    $menu = new HTML_TreeMenu();
    $thislevel = array('0');
    $nextlevel = array();
    $i = 1;
    $j = 1;
    while (count($kb_cat) > 0) {
        foreach ($kb_cat as $k => $cat) {
            if (in_array($cat['parent'], $thislevel)) {
                $up = $cat['parent'];
                $my = $cat['id'];
                $type = $cat['type'] ? '*' : '';
                $text_short = $cat['name'] . $type . ' (' . $cat['articles'] . ', ' . $cat['articles_private'] . ', ' . $cat['articles_draft'] . ')';
                if (isset($node[$up])) {
                    $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)));
                } else {
                    $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));
                }
                $nextlevel[] = $cat['id'];
                $j++;
                unset($kb_cat[$k]);
            }
        }
        $thislevel = $nextlevel;
        $nextlevel = array();
        /* Break after 20 recursions to avoid hang-ups in case of any problems */
        if ($i > 20) {
            break;
        }
        $i++;
    }
    $menu->addItem($node[1]);
    // Create the presentation class
    $listBox =& ref_new(new HTML_TreeMenu_Listbox($menu));
    /* Print header */
    require_once HESK_PATH . 'inc/header.inc.php';
    /* Print main manage users page */
    require_once HESK_PATH . 'inc/show_admin_nav.inc.php';
    ?>

	
     <div class="container manage-kb-category-title"><a href="manage_knowledgebase.php" class="smaller"><b><?php 
    echo $hesklang['kb'];
    ?>
</b></a> &gt; <?php 
    echo $hesklang['kb_cat_man'];
    ?>
</div>

	<!-- SUB NAVIGATION -->
	<?php 
    show_subnav('', $catid);
    ?>
	<!-- SUB NAVIGATION -->

	<?php 
    if (!isset($_SESSION['hide']['article_list'])) {
        ?>

     <div class="container category-kb"><?php 
        echo $hesklang['category'];
        ?>
: <span class="black"><?php 
        echo $this_cat['name'];
        ?>
</span></div>

    &nbsp;<br />

    <?php 
        $result = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$catid}' ORDER BY `sticky` DESC, `art_order` ASC");
        $num = hesk_dbNumRows($result);
        if ($num == 0) {
            echo '<div class="container kb_no_article">' . $hesklang['kb_no_art'] . ' &nbsp;<br/><br/> 
		<a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><img src="../img/add_article.png" width="16" height="16" alt="' . $hesklang['kb_i_art2'] . '" title="' . $hesklang['kb_i_art2'] . '" border="0" style="border:none;vertical-align:text-bottom" /></a>' . '<a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><b>' . $hesklang['kb_i_art2'] . '</b></a></div>';
        } else {
            /* Get number of sticky articles */
            $res2 = hesk_dbQuery("SELECT COUNT(*) FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$catid}' AND `sticky` = '1' ");
            $num_sticky = hesk_dbResult($res2);
            $num_nosticky = $num - $num_sticky;
            ?>
        <div class="container insertArticle">
	        <?php 
            echo '<a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><img src="../img/add_article.png" width="16" height="16" alt="' . $hesklang['kb_i_art2'] . '" title="' . $hesklang['kb_i_art2'] . '" border="0" style="border:none;vertical-align:text-bottom" /></a> <a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><b>' . $hesklang['kb_i_art2'] . '</b></a>';
            ?>
	    </div>

	     <div class="container kb_cat_art_title"><?php 
            echo $hesklang['kb_cat_art'];
            ?>
</div>

		<div class="container">
		<table class="table table-bordered table-responsive kb_cat_art_table">
		<tr>
        <th class="admin_white">&nbsp;</th>
		<th class="admin_white"><b><i><?php 
            echo $hesklang['kb_subject'];
            ?>
</i></b></th>
		<th class="admin_white"><b><i><?php 
            echo $hesklang['kb_type'];
            ?>
</i></b></th>
        <th class="admin_white"><b><i><?php 
            echo $hesklang['views'];
            ?>
</i></b></th>
        <?php 
            if ($hesk_settings['kb_rating']) {
                ?>
	        <th class="admin_white" style="white-space:nowrap" nowrap="nowrap" width="130"><b><i><?php 
                echo $hesklang['rating'] . ' (' . $hesklang['votes'] . ')';
                ?>
</i></b></th>
	        <?php 
            }
            ?>
        <th class="admin_white" style="width:120px"><b><i>&nbsp;<?php 
            echo $hesklang['opt'];
            ?>
&nbsp;</i></b></th>
		</tr>
    	<?php 
            $i = 1;
            $j = 1;
            $k = 1;
            $previous_sticky = 1;
            $num = $num_sticky;
            while ($article = hesk_dbFetchAssoc($result)) {
                if ($previous_sticky != $article['sticky']) {
                    $k = 1;
                    $num = $num_nosticky;
                    $previous_sticky = $article['sticky'];
                }
                if (isset($_SESSION['artord']) && $article['id'] == $_SESSION['artord']) {
                    $color = 'admin_green';
                    unset($_SESSION['artord']);
                } elseif ($article['sticky']) {
                    $color = 'admin_yellow';
                } else {
                    $color = $i ? 'admin_white' : 'admin_gray';
                }
                $tmp = $i ? 'White' : 'Blue';
                $style = 'class="option' . $tmp . 'OFF" onmouseover="this.className=\'option' . $tmp . 'ON\'" onmouseout="this.className=\'option' . $tmp . 'OFF\'"';
                $i = $i ? 0 : 1;
                switch ($article['type']) {
                    case '1':
                        $type = '<span class="kb_private">' . $hesklang['kb_private'] . '</span>';
                        break;
                    case '2':
                        $type = '<span class="kb_draft">' . $hesklang['kb_draft'] . '</span>';
                        break;
                    default:
                        $type = '<span class="kb_published">' . $hesklang['kb_published'] . '</span>';
                }
                if ($hesk_settings['kb_rating']) {
                    $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                    $rat = '<td class="' . $color . '" style="white-space:nowrap;"><img src="../img/star_' . hesk_round_to_half($article['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /> (' . $article['votes'] . ') </td>';
                } else {
                    $rat = '';
                }
                ?>
			<tr>
			<td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $j;
                ?>
.</td>
			<td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $article['subject'];
                ?>
</td>
            <td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $type;
                ?>
</td>
            <td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $article['views'];
                ?>
</td>
            <?php 
                echo $rat;
                ?>
            <td class="<?php 
                echo $color;
                ?>
" style="text-align:center; white-space:nowrap;">
			<?php 
                if ($num > 1) {
                    if ($k == 1) {
                        ?>
                    <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />
                	<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();
                        ?>
"><img src="../img/move_down.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" title="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
	            <?php 
                    } elseif ($k == $num) {
                        ?>
					<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();
                        ?>
"><img src="../img/move_up.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_up'];
                        ?>
" title="<?php 
                        echo $hesklang['move_up'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
                    <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />
	            <?php 
                    } else {
                        ?>
					<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();
                        ?>
"><img src="../img/move_up.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_up'];
                        ?>
" title="<?php 
                        echo $hesklang['move_up'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
					<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();
                        ?>
"><img src="../img/move_down.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" title="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
	            <?php 
                    }
                } elseif ($num_sticky > 1 || $num_nosticky > 1) {
                    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;" />';
                }
                ?>
            <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();
                ?>
"><img src="../img/sticky<?php 
                if (!$article['sticky']) {
                    echo '_off';
                }
                ?>
.png" width="16" height="16" alt="<?php 
                echo $article['sticky'] ? $hesklang['stickyoff'] : $hesklang['stickyon'];
                ?>
" title="<?php 
                echo $article['sticky'] ? $hesklang['stickyoff'] : $hesklang['stickyon'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>
            <a href="knowledgebase_private.php?article=<?php 
                echo $article['id'];
                ?>
&amp;back=1<?php 
                if ($article['type'] == 2) {
                    echo '&amp;draft=1';
                }
                ?>
" target="_blank"><img src="../img/article_text.png" width="16" height="16" alt="<?php 
                echo $hesklang['viewart'];
                ?>
" title="<?php 
                echo $hesklang['viewart'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>
            <a href="manage_knowledgebase.php?a=edit_article&amp;id=<?php 
                echo $article['id'];
                ?>
"><img src="../img/edit.png" width="16" height="16" alt="<?php 
                echo $hesklang['edit'];
                ?>
" title="<?php 
                echo $hesklang['edit'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>
            <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']);
                ?>
');"><img src="../img/delete.png" width="16" height="16" alt="<?php 
                echo $hesklang['delete'];
                ?>
" title="<?php 
                echo $hesklang['delete'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>&nbsp;</td>
			</tr>
            <?php 
                $j++;
                $k++;
            }
            // End while
            ?>
		</table>
		</div>
		<?php 
        }
    }
    // END if hide article list
    /* Manage Category (except the default one) */
    if ($catid != 1) {
        ?>

        &nbsp;<br />


    <div class="container insertCategory">
		<?php 
        echo '<a href="manage_knowledgebase.php?a=add_category&amp;parent=' . $catid . '"><img src="../img/add_category.png" width="16" height="16" alt="' . $hesklang['kb_i_cat2'] . '" title="' . $hesklang['kb_i_cat2'] . '" border="0" style="border:none;vertical-align:text-bottom" /></a> <a href="manage_knowledgebase.php?a=add_category&amp;parent=' . $catid . '"><b>' . $hesklang['kb_i_cat2'] . '</b></a>';
        ?>
	</div>

	<div class="container category-settings-title"><?php 
        echo $hesklang['catset'];
        ?>
</div>
	<div class="container category-settings-form">
	<br/>
		<form action="manage_knowledgebase.php" method="post" name="form1" onsubmit="Javascript:return hesk_deleteIfSelected('dodelete','<?php 
        echo hesk_makeJsString($hesklang['kb_delcat']);
        ?>
')">
			<div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['kb_cat_title'];
        ?>
:</b></span>
				<span><input class="form-control" type="text" name="title" size="70" maxlength="255" value="<?php 
        echo $this_cat['name'];
        ?>
" /></span>
			</div>
			<br/>
			<div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['kb_cat_parent'];
        ?>
:</b></span>
				<span><select class="form-control" name="parent"><?php 
        $listBox->printMenu();
        ?>
</select></span>
			</div>
			<br/>
			<div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['kb_type'];
        ?>
:</b></span>
				<div class="form-group">
					<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><br />
					<span><?php 
        echo $hesklang['kb_cat_published'];
        ?>
</span><br/><br/>
					<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><br />
					<span><?php 
        echo $hesklang['kb_cat_private'];
        ?>
</span>
				</div>
			</div>
			<br/>
	        <div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['opt'];
        ?>
:</b></span>
				<div class="form-group">
					<label><input type="checkbox" name="dodelete" id="dodelete" value="Y" onclick="Javascript:hesk_toggleLayerDisplay('deleteoptions')" /> <i><?php 
        echo $hesklang['delcat'];
        ?>
</i></label>
					<div id="deleteoptions" style="display: none;">
					<label><input type="radio" name="movearticles" value="Y" checked="checked" /> <?php 
        echo $hesklang['move1'];
        ?>
</label><br />
					<label><input type="radio" name="movearticles" value="N" /> <?php 
        echo $hesklang['move2'];
        ?>
</label>
					</div>
				</div>
	        </div>
			<br/>
	</div>
	<br/>
		<div class="col-sm-6 col-sm-offset-6">
			<input type="hidden" name="a" value="edit_category" />
	        <input type="hidden" name="token" value="<?php 
        hesk_token_echo();
        ?>
" />
	        <input type="hidden" name="catid" value="<?php 
        echo $catid;
        ?>
" /><input type="submit" value="<?php 
        echo $hesklang['save_changes'];
        ?>
" class="btn btn-default save-cat-changes-btn" />
		</div>
	</form>
	

	<?php 
    }
    // END if $catid != 1
    /* Clean unneeded session variables */
    hesk_cleanSessionVars(array('hide', 'manage_cat', 'edit_article'));
    require_once HESK_PATH . 'inc/footer.inc.php';
    exit;
}
function hesk_kb_search($query)
{
    global $hesk_settings, $hesklang;
    define('HESK_NO_ROBOTS', 1);
    /* Print header */
    require_once HESK_PATH . 'inc/header.inc.php';
    hesk_kb_header($hesk_settings['kb_link']);
    $res = hesk_dbQuery('SELECT t1.`id`, t1.`subject`, LEFT(`t1`.`content`, ' . max(200, $hesk_settings['kb_substrart'] * 2) . ') AS `content`, t1.`rating` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_articles` AS t1 LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_categories` AS t2 ON t1.`catid` = t2.`id` ' . " WHERE t1.`type` IN ('0','1') AND MATCH(`subject`,`content`,`keywords`) AGAINST ('" . hesk_dbEscape($query) . "') LIMIT " . intval($hesk_settings['kb_search_limit']));
    $num = hesk_dbNumRows($res);
    ?>
	<p>&raquo; <b><?php 
    echo $hesklang['sr'];
    ?>
 (<?php 
    echo $num;
    ?>
)</b></p>

	<?php 
    if ($num == 0) {
        echo '<p><i>' . $hesklang['nosr'] . '</i></p>';
        hesk_show_kb_category(1, 1);
    } else {
        ?>

<tr>
	<td class="roundcornersleft">&nbsp;</td>
	<td>
		<div align="center">
        <table border="0" cellspacing="1" cellpadding="3" width="100%">
        <?php 
        while ($article = hesk_dbFetchAssoc($res)) {
            $txt = hesk_kbArticleContentPreview($article['content']);
            if ($hesk_settings['kb_rating']) {
                $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                $rat = '<td width="1" valign="top"><img src="../img/star_' . hesk_round_to_half($article['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" border="0" style="vertical-align:text-bottom" /></td>';
            } else {
                $rat = '';
            }
            echo '
				<tr>
				<td>
	                <table border="0" width="100%" cellspacing="0" cellpadding="1">
	                <tr>
	                <td width="1" valign="top"><img src="../img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" /></td>
	                <td valign="top"><a href="knowledgebase_private.php?article=' . $article['id'] . '">' . $article['subject'] . '</a></td>
	                ' . $rat . '
                    </tr>
	                </table>
	                <table border="0" width="100%" cellspacing="0" cellpadding="1">
	                <tr>
	                <td width="1" valign="top"><img src="../img/blank.gif" width="16" height="10" style="vertical-align:middle" alt="" /></td>
	                <td><span class="article_list">' . $txt . '</span></td>
                    </tr>
	                </table>

	            </td>
				</tr>';
        }
        ?>
    	</table>
        </div>
	</td>
	<td class="roundcornersright">&nbsp;</td>
</tr>

    <p>&nbsp;<br />&laquo; <a href="javascript:history.go(-1)"><?php 
        echo $hesklang['back'];
        ?>
</a></p>
    <?php 
    }
    // END else
}
Exemplo n.º 3
0
                $autoassign_code = '<a href="manage_users.php?a=autoassign&amp;s=1&amp;id=' . $myuser['id'] . '&amp;token=' . hesk_token_echo(0) . '"><img src="../img/autoassign_off.png" width="16" height="16" alt="' . $hesklang['aaoff'] . '" title="' . $hesklang['aaoff'] . '" ' . $style . ' /></a>';
            }
        } else {
            $autoassign_code = '';
        }
        echo <<<EOC
<tr>
<td class="{$color}">{$myuser['name']}</td>
<td class="{$color}"><a href="mailto:{$myuser['email']}">{$myuser['email']}</a></td>
<td class="{$color}">{$myuser['user']}</td>
<td class="{$color}">{$myuser['isadmin']}</td>

EOC;
        if ($hesk_settings['rating']) {
            $alt = $myuser['rating'] ? sprintf($hesklang['rated'], sprintf("%01.1f", $myuser['rating']), $myuser['ratingneg'] + $myuser['ratingpos']) : $hesklang['not_rated'];
            echo '<td class="' . $color . '" style="text-align:center; white-space:nowrap;"><img src="../img/star_' . hesk_round_to_half($myuser['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" />&nbsp;</td>';
        }
        echo <<<EOC
<td class="{$color}" style="text-align:center">{$autoassign_code} {$edit_code} {$remove_code}</td>
</tr>

EOC;
    }
    // End while
    ?>
</table>
</div>

<p>&nbsp;</p>
<p>&nbsp;</p>
Exemplo n.º 4
0
function hesk_show_kb_category($catid, $is_search = 0)
{
    global $hesk_settings, $hesklang;
    $res = hesk_dbQuery("SELECT `name`,`parent` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
    $thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
    if ($is_search == 0) {
        /* Print header */
        $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . hesk_htmlspecialchars($thiscat['name']);
        require_once HESK_PATH . 'inc/header.inc.php';
        hesk_kb_header($hesk_settings['kb_link']);
        // If we are in "Knowledgebase only" mode show system messages
        if ($catid == 1 && hesk_check_kb_only(false)) {
            // Service messages
            $res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `type`='0' ORDER BY `order` ASC");
            while ($sm = hesk_dbFetchAssoc($res)) {
                hesk_service_message($sm);
            }
        }
    }
    if ($thiscat['parent']) {
        $link = $thiscat['parent'] == 1 ? 'knowledgebase.php' : 'knowledgebase.php?category=' . $thiscat['parent'];
        echo '<span class="homepageh3">&raquo; ' . $hesklang['kb_cat'] . ': ' . $thiscat['name'] . '</span>
        &nbsp;(<a href="javascript:history.go(-1)">' . $hesklang['back'] . '</a>)
		';
    }
    $result = hesk_dbQuery("SELECT `id`,`name`,`articles` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `parent`='{$catid}' AND `type`='0' ORDER BY `cat_order` ASC");
    if (hesk_dbNumRows($result) > 0) {
        ?>

		<p>&raquo; <b><?php 
        echo $hesklang['kb_cat_sub'];
        ?>
:</b></p>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td width="7" height="7"><img src="img/roundcornerslt.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornerstop"></td>
	<td><img src="img/roundcornersrt.jpg" width="7" height="7" alt="" /></td>
</tr>
<tr>
	<td class="roundcornersleft">&nbsp;</td>
	<td>

		<table border="0" cellspacing="1" cellpadding="3" width="100%">

		<?php 
        $per_col = $hesk_settings['kb_cols'];
        $i = 1;
        while ($cat = hesk_dbFetchAssoc($result)) {
            if ($i == 1) {
                echo '<tr>';
            }
            echo '
		    <td width="50%" valign="top">
			<table border="0">
			<tr><td><img src="img/folder.gif" width="20" height="20" alt="" style="vertical-align:middle" /><a href="knowledgebase.php?category=' . $cat['id'] . '">' . $cat['name'] . '</a></td></tr>
			';
            /* Print most popular/sticky articles */
            if ($hesk_settings['kb_numshow'] && $cat['articles']) {
                $res = hesk_dbQuery("SELECT `id`,`subject` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$cat['id']}' AND `type`='0' ORDER BY `sticky` DESC, `views` DESC, `art_order` ASC LIMIT " . (intval($hesk_settings['kb_numshow']) + 1));
                $num = 1;
                while ($art = hesk_dbFetchAssoc($res)) {
                    echo '
		            <tr>
		            <td><img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" />
		            <a href="knowledgebase.php?article=' . $art['id'] . '" class="article">' . $art['subject'] . '</a></td>
		            </tr>';
                    if ($num == $hesk_settings['kb_numshow']) {
                        break;
                    } else {
                        $num++;
                    }
                }
                if (hesk_dbNumRows($res) > $hesk_settings['kb_numshow']) {
                    echo '<tr><td>&raquo; <a href="knowledgebase.php?category=' . $cat['id'] . '"><i>' . $hesklang['m'] . '</i></a></td></tr>';
                }
            }
            echo '
			</table>
		    </td>
			';
            if ($i == $per_col) {
                echo '</tr>';
                $i = 0;
            }
            $i++;
        }
        /* Finish the table if needed */
        if ($i != 1) {
            for ($j = 1; $j <= $per_col; $j++) {
                echo '<td width="50%">&nbsp;</td>';
                if ($i == $per_col) {
                    echo '</tr>';
                    break;
                }
                $i++;
            }
        }
        ?>
		</table>

	</td>
	<td class="roundcornersright">&nbsp;</td>
</tr>
<tr>
	<td><img src="img/roundcornerslb.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornersbottom"></td>
	<td width="7" height="7"><img src="img/roundcornersrb.jpg" width="7" height="7" alt="" /></td>
</tr>
</table>

	<?php 
    }
    // END if NumRows > 0
    ?>

	<p>&raquo; <b><?php 
    echo $hesklang['ac'];
    ?>
</b></p>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td width="7" height="7"><img src="img/roundcornerslt.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornerstop"></td>
	<td><img src="img/roundcornersrt.jpg" width="7" height="7" alt="" /></td>
</tr>
<tr>
	<td class="roundcornersleft">&nbsp;</td>
	<td>

	<?php 
    $res = hesk_dbQuery("SELECT `id`, `subject`, LEFT(`content`, " . max(200, $hesk_settings['kb_substrart'] * 2) . ") AS `content`, `rating` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$catid}' AND `type`='0' ORDER BY `sticky` DESC, `art_order` ASC");
    if (hesk_dbNumRows($res) == 0) {
        echo '<p><i>' . $hesklang['noac'] . '</i></p>';
    } else {
        echo '<div align="center"><table border="0" cellspacing="1" cellpadding="3" width="100%">';
        while ($article = hesk_dbFetchAssoc($res)) {
            $txt = hesk_kbArticleContentPreview($article['content']);
            if ($hesk_settings['kb_rating']) {
                $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                $rat = '<td width="1" valign="top"><img src="img/star_' . hesk_round_to_half($article['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /></td>';
            } else {
                $rat = '';
            }
            echo '
				<tr>
				<td>
	                <table border="0" width="100%" cellspacing="0" cellpadding="1">
	                <tr>
	                <td width="1" valign="top"><img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" /></td>
	                <td valign="top"><a href="knowledgebase.php?article=' . $article['id'] . '">' . $article['subject'] . '</a></td>
	                ' . $rat . '
                    </tr>
	                </table>
	                <table border="0" width="100%" cellspacing="0" cellpadding="1">
	                <tr>
	                <td width="1" valign="top"><img src="img/blank.gif" width="16" height="10" style="vertical-align:middle" alt="" /></td>
	                <td><span class="article_list">' . $txt . '</span></td>
                    </tr>
	                </table>
	            </td>
				</tr>';
        }
        echo '</table></div>';
    }
    ?>

	</td>
	<td class="roundcornersright">&nbsp;</td>
</tr>
<tr>
	<td><img src="img/roundcornerslb.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornersbottom"></td>
	<td width="7" height="7"><img src="img/roundcornersrb.jpg" width="7" height="7" alt="" /></td>
</tr>
</table>

	<?php 
    /* On the main KB page print out top and latest articles if needed */
    if ($catid == 1) {
        /* Get list of top articles */
        hesk_kbTopArticles($hesk_settings['kb_popart'], 0);
        /* Get list of latest articles */
        hesk_kbLatestArticles($hesk_settings['kb_latest'], 0);
    }
}
Exemplo n.º 5
0
function hesk_show_kb_category($catid, $is_search = 0)
{
    global $hesk_settings, $hesklang;
    $res = hesk_dbQuery("SELECT `name`,`parent` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
    $thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
    if ($is_search == 0) {
        /* Print header */
        $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . hesk_htmlspecialchars($thiscat['name']);
        require_once HESK_PATH . 'inc/header.inc.php';
        hesk_kb_header($hesk_settings['kb_link']);
    }
    // If we are in "Knowledgebase only" mode show system messages
    if ($catid == 1 && hesk_check_kb_only(false)) {
        // Service messages
        $res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `type`='0' ORDER BY `order` ASC");
        while ($sm = hesk_dbFetchAssoc($res)) {
            hesk_service_message($sm);
        }
    }
    if ($thiscat['parent']) {
        $link = $thiscat['parent'] == 1 ? 'knowledgebase.php' : 'knowledgebase.php?category=' . $thiscat['parent'];
        echo '<h3 class="text-left"><a href="javascript:history.go(-1)"><i class="fa fa-arrow-circle-left" data-toggle="tooltip" data-placement="top" title="' . $hesklang['back'] . '"></i></a>&nbsp;' . $hesklang['kb_cat'] . ': ' . $thiscat['name'] . ' </h3>
        <div class="footerWithBorder blankSpace"></div>
        <div class="blankSpace"></div>
		';
    }
    $result = hesk_dbQuery("SELECT `id`,`name`,`articles` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `parent`='{$catid}' AND `type`='0' ORDER BY `cat_order` ASC");
    if (hesk_dbNumRows($result) > 0) {
        ?>

        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="text-left"><?php 
        echo $hesklang['kb_cat_sub'];
        ?>
</h4>
            </div>
            <table class="table table-striped">

                <?php 
        $per_col = $hesk_settings['kb_cols'];
        $i = 1;
        while ($cat = hesk_dbFetchAssoc($result)) {
            if ($i == 1) {
                echo '<tr>';
            }
            echo '
                    <td width="50%" valign="top">
                    <table border="0">
                    <tr><td><i class="fa fa-folder"></i>&nbsp;<a href="knowledgebase.php?category=' . $cat['id'] . '">' . $cat['name'] . '</a></td></tr>
                    ';
            /* Print most popular/sticky articles */
            if ($hesk_settings['kb_numshow'] && $cat['articles']) {
                $res = hesk_dbQuery("SELECT `id`,`subject`, `sticky` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$cat['id']}' AND `type`='0' ORDER BY `sticky` DESC, `views` DESC, `art_order` ASC LIMIT " . (intval($hesk_settings['kb_numshow']) + 1));
                $num = 1;
                while ($art = hesk_dbFetchAssoc($res)) {
                    $icon = 'glyphicon glyphicon-file';
                    $style = '';
                    if ($art['sticky']) {
                        $icon = 'glyphicon glyphicon-pushpin';
                        $style = 'style="color: #FF0000"';
                    }
                    echo '
                            <tr>
                            <td ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="' . $icon . '"></span>
                            <a href="knowledgebase.php?article=' . $art['id'] . '" class="article">' . $art['subject'] . '</a></td>
                            </tr>';
                    if ($num == $hesk_settings['kb_numshow']) {
                        break;
                    } else {
                        $num++;
                    }
                }
                if (hesk_dbNumRows($res) > $hesk_settings['kb_numshow']) {
                    echo '<tr><td>&raquo; <a href="knowledgebase.php?category=' . $cat['id'] . '"><i>' . $hesklang['m'] . '</i></a></td></tr>';
                }
            }
            echo '
			</table>
		    </td>
			';
            if ($i == $per_col) {
                echo '</tr>';
                $i = 0;
            }
            $i++;
        }
        /* Finish the table if needed */
        if ($i != 1) {
            for ($j = 1; $j <= $per_col; $j++) {
                echo '<td width="50%">&nbsp;</td>';
                if ($i == $per_col) {
                    echo '</tr>';
                    break;
                }
                $i++;
            }
        }
        ?>
            </table>
        </div>

	<?php 
    }
    // END if NumRows > 0
    ?>

    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="text-left"><?php 
    echo $hesklang['ac_no_colon'];
    ?>
</h4>
        </div>
        <table class="table table-striped">
            <tbody>
            <?php 
    $res = hesk_dbQuery("SELECT `id`, `subject`, `sticky`, LEFT(`content`, " . max(200, $hesk_settings['kb_substrart'] * 2) . ") AS `content`, `rating` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$catid}' AND `type`='0' ORDER BY `sticky` DESC, `art_order` ASC");
    if (hesk_dbNumRows($res) == 0) {
        echo '<tr><td><i>' . $hesklang['noac'] . '</i></td></tr>';
    } else {
        while ($article = hesk_dbFetchAssoc($res)) {
            $icon = 'fa fa-file';
            $color = '';
            $style = '';
            $txt = hesk_kbArticleContentPreview($article['content']);
            if ($article['sticky']) {
                $icon = 'glyphicon glyphicon-pushpin';
                $style = 'style="color: #FF0000"';
            }
            if ($hesk_settings['kb_rating']) {
                $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                $rat = '<td><img src="img/star_' . hesk_round_to_half($article['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /></td>';
            } else {
                $rat = '';
            }
            echo '
                        <tr>
                            <td>
                                <i class="' . $icon . '" ' . $style . '></i>
                                <a href="knowledgebase.php?article=' . $article['id'] . '">' . $article['subject'] . '</a>
                                <br>
                                <span class="indent-15">' . $txt . '</span>
                            </td>
                            ' . $rat . '
                        </tr>';
        }
    }
    ?>
            </tbody>
        </table>
    </div>

	<?php 
    /* On the main KB page print out top and latest articles if needed */
    if ($catid == 1) {
        /* Get list of top articles */
        hesk_kbTopArticles($hesk_settings['kb_popart'], 0);
        /* Get list of latest articles */
        hesk_kbLatestArticles($hesk_settings['kb_latest'], 0);
    }
    hesk_kbFooter();
}
Exemplo n.º 6
0
function hesk_show_kb_article($artid)
{
    global $hesk_settings, $hesklang, $article;
    // Print header
    $hesk_settings['tmp_title'] = $article['subject'];
    require_once HESK_PATH . 'inc/header.inc.php';
    hesk_kb_header($hesk_settings['kb_link']);
    // Update views by 1 - exclude known bots and reloads because of ratings
    if (!isset($_GET['rated']) && !hesk_detect_bots()) {
        hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid} LIMIT 1");
    }
    echo '<div class="container subject-art">' . $article['subject'] . '</div>' . '<div class="solution-knowledgebasePhp">' . '<div id="content-kb">' . $article['content'] . '</div></div><br/>';
    if (!empty($article['attachments'])) {
        echo '<p><b>' . $hesklang['attachments'] . ':</b><br />';
        $att = explode(',', substr($article['attachments'], 0, -1));
        foreach ($att as $myatt) {
            list($att_id, $att_name) = explode('#', $myatt);
            echo '<img src="img/clip.png" width="16" height="16" alt="' . $att_name . '" style="align:text-bottom" /> <a href="download_attachment.php?kb_att=' . $att_id . '" rel="nofollow">' . $att_name . '</a><br />';
        }
        echo '</p>';
    }
    // Article rating
    if ($hesk_settings['kb_rating'] && strpos(hesk_COOKIE('hesk_kb_rate'), 'a' . $artid . '%') === false) {
        echo '
	    <div id="rating" class="col-sm-4 col-sm-offset-8 container rate">' . '<span id="rate-article">' . $hesklang['rart'] . '</span>' . '<a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=5&amp;id=' . $article['id'] . '\'" rel="nofollow">' . '<button type="submit" class="btn btn-default rate-yes">' . $hesklang['yes'] . '</button></a>' . '<a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=1&amp;id=' . $article['id'] . '\'" rel="nofollow">' . '<button type="submit" class="btn btn-default rate-no">' . $hesklang['no'] . '</button></a>
	    </div><br/><br/>
        ';
    }
    // Related articles
    if ($hesk_settings['kb_related']) {
        require HESK_PATH . 'inc/mail/email_parser.php';
        $query = hesk_dbEscape($article['subject'] . ' ' . convert_html_to_text($article['content']));
        // Get relevant articles from the database
        $res = hesk_dbQuery("SELECT t1.`id`, t1.`subject`, MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') AS `score` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_articles` AS t1 LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS t2 ON t1.`catid` = t2.`id` WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') LIMIT " . intval($hesk_settings['kb_related'] + 1));
        // Array with related articles
        $related_articles = array();
        while ($related = hesk_dbFetchAssoc($res)) {
            // Get base match score from the first article
            if (!isset($base_score)) {
                $base_score = $related['score'];
            }
            // Ignore this article
            if ($related['id'] == $artid) {
                continue;
            }
            // Stop when articles reach less than 10% of base score
            if ($related['score'] / $base_score < 0.1) {
                break;
            }
            // This is a valid related article
            $related_articles[$related['id']] = $related['subject'];
        }
        // Print related articles if we have any valid matches
        if (count($related_articles)) {
            echo '<fieldset><legend>' . $hesklang['relart'] . '</legend>';
            foreach ($related_articles as $id => $subject) {
                echo '<img src="img/article_text.jpg" width="16" height="16" border="0" alt="" style="vertical-align:middle;padding:2px;" /> <a href="knowledgebase.php?article=' . $id . '">' . $subject . '</a><br />';
            }
            echo '</fieldset>';
        }
    }
    if ($article['catid'] == 1) {
        $link = 'knowledgebase.php';
    } else {
        $link = 'knowledgebase.php?category=' . $article['catid'];
    }
    ?>
<br/><br/>

	<div class="container art-deails"><?php 
    echo $hesklang['ad'];
    ?>
</div>
    <div class="container article-details-knowledgebasePhp">	
		<div class="form-group">
			<div class="row" style="padding-bottom: 5px;">
				<span class="col-sm-2"><?php 
    echo $hesklang['aid'];
    ?>
: </span>
				<span><?php 
    echo $article['id'];
    ?>
</span>
			</div>
			
			<div class="row" style="padding-bottom: 5px;">
				<span class="col-sm-2"><?php 
    echo $hesklang['category'];
    ?>
: </span>
				<span><a href="<?php 
    echo $link;
    ?>
"><?php 
    echo $article['cat_name'];
    ?>
</a></span>
			</div>

			<?php 
    if ($hesk_settings['kb_date']) {
        ?>
			<div class="row" style="padding-bottom: 5px;">
				<span class="col-sm-2"><?php 
        echo $hesklang['dta'];
        ?>
: </span>
				<span><?php 
        echo hesk_date($article['dt'], true);
        ?>
</span>
			</div>
			<?php 
    }
    if ($hesk_settings['kb_views']) {
        ?>
			<div class="row" style="padding-bottom: 5px;" style="padding-bottom: 5px;">
				<span class="col-sm-2"><?php 
        echo $hesklang['views'];
        ?>
: </span>
				<span><?php 
        echo isset($_GET['rated']) ? $article['views'] : $article['views'] + 1;
        ?>
</span>
			</div>
			<?php 
    }
    if ($hesk_settings['kb_rating']) {
        $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
        echo '
				<div class="row">
				<span class="col-sm-2">' . $hesklang['rating'] . ' (' . $hesklang['votes'] . '):</span>
				<span><img src="img/star_' . hesk_round_to_half($article['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /> (' . $article['votes'] . ')</span>
				</div><br/>
				';
    }
    ?>
		</div>
    </div>

    <?php 
    if (!isset($_GET['suggest'])) {
        ?>
		<br/><div class="container"><a href="javascript:history.go(<?php 
        echo isset($_GET['rated']) ? '-2' : '-1';
        ?>
)"><button type="submit" class="btn btn-default goback-btn"><?php 
        echo $hesklang['back'];
        ?>
</button></a></div>
        <?php 
    } else {
        ?>
        <p>&nbsp;</p>
        <?php 
    }
}
Exemplo n.º 7
0
        if ($myuser['permission_template'] != -1) {
            $result = hesk_dbQuery("SELECT `name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` WHERE `id` = " . intval($myuser['permission_template']));
            $row = hesk_dbFetchAssoc($result);
            $templateName = $row['name'];
        }
        echo <<<EOC
<tr>
<td>{$myuser['name']}</td>
<td><a href="mailto:{$myuser['email']}">{$myuser['email']}</a></td>
<td>{$myuser['user']}</td>
<td>{$templateName}</td>

EOC;
        if ($hesk_settings['rating']) {
            $alt = $myuser['rating'] ? sprintf($hesklang['rated'], sprintf("%01.1f", $myuser['rating']), $myuser['ratingneg'] + $myuser['ratingpos']) : $hesklang['not_rated'];
            echo '<td><img src="../img/star_' . hesk_round_to_half($myuser['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" data-toggle="tooltip" data-placement="top" title="' . $alt . '" border="0" style="vertical-align:text-bottom" />&nbsp;</td>';
        }
        echo <<<EOC
<td>{$autoassign_code} {$edit_code} {$remove_code} {$activeMarkup}</td>
</tr>

EOC;
    }
    // End while
    ?>
</table>
<?php 
    if ($hesk_settings['online']) {
        echo '&nbsp;&nbsp;&nbsp;<i style="color: green" class="fa fa-circle"></i> ' . $hesklang['online'] . ' &nbsp;&nbsp;&nbsp; <i style="color: gray" class="fa fa-circle"></i> ' . $hesklang['offline'];
    }
    ?>