|
|
@ -445,237 +445,4 @@ echo mfh_get_hidden_fields_for_language(array(
|
|
|
|
|
|
|
|
|
|
|
|
require_once(HESK_PATH . 'inc/footer.inc.php');
|
|
|
|
require_once(HESK_PATH . 'inc/footer.inc.php');
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
|
|
|
|
|
|
|
|
function new_cat()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
global $hesk_settings, $hesklang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A security check */
|
|
|
|
|
|
|
|
hesk_token_check('POST');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Options */
|
|
|
|
|
|
|
|
$_SESSION['cat_autoassign'] = hesk_POST('autoassign') == 'Y' ? 1 : 0;
|
|
|
|
|
|
|
|
$_SESSION['cat_type'] = hesk_POST('type') == 'Y' ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Default priority
|
|
|
|
|
|
|
|
$_SESSION['cat_priority'] = intval(hesk_POST('priority', 3));
|
|
|
|
|
|
|
|
if ($_SESSION['cat_priority'] < 0 || $_SESSION['cat_priority'] > 3) {
|
|
|
|
|
|
|
|
$_SESSION['cat_priority'] = 3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Category name */
|
|
|
|
|
|
|
|
$catname = hesk_input(hesk_POST('name'), $hesklang['enter_cat_name'], 'manage_categories.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$background_color = hesk_POST('background-color', '#ffffff');
|
|
|
|
|
|
|
|
$foreground_color = hesk_POST('foreground-color', '#000000');
|
|
|
|
|
|
|
|
$display_border = hesk_POST('display-border', 0);
|
|
|
|
|
|
|
|
if ($foreground_color == '') {
|
|
|
|
|
|
|
|
$foreground_color = 'AUTO';
|
|
|
|
|
|
|
|
$display_border = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$usage = hesk_POST('usage', 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Do we already have a category with this name? */
|
|
|
|
|
|
|
|
$res = hesk_dbQuery("SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` WHERE `name` LIKE '" . hesk_dbEscape(hesk_dbLike($catname)) . "' LIMIT 1");
|
|
|
|
|
|
|
|
if (hesk_dbNumRows($res) != 0) {
|
|
|
|
|
|
|
|
$_SESSION['catname'] = $catname;
|
|
|
|
|
|
|
|
hesk_process_messages($hesklang['cndupl'], 'manage_categories.php');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get the latest cat_order */
|
|
|
|
|
|
|
|
$res = hesk_dbQuery("SELECT `cat_order` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ORDER BY `cat_order` DESC LIMIT 1");
|
|
|
|
|
|
|
|
$row = hesk_dbFetchRow($res);
|
|
|
|
|
|
|
|
$my_order = $row[0] + 10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories`
|
|
|
|
|
|
|
|
(`name`,`cat_order`,`autoassign`,`type`, `priority`, `background_color`, `foreground_color`, `display_border_outline`, `usage`) VALUES
|
|
|
|
|
|
|
|
('" . hesk_dbEscape($catname) . "','" . intval($my_order) . "','" . intval($_SESSION['cat_autoassign']) . "',
|
|
|
|
|
|
|
|
'" . intval($_SESSION['cat_type']) . "','{$_SESSION['cat_priority']}', '" . hesk_dbEscape($background_color) . "',
|
|
|
|
|
|
|
|
'" . hesk_dbEscape($foreground_color) . "', '" . intval($display_border) . "', " . intval($usage) . ")");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_cleanSessionVars('catname');
|
|
|
|
|
|
|
|
hesk_cleanSessionVars('cat_autoassign');
|
|
|
|
|
|
|
|
hesk_cleanSessionVars('cat_type');
|
|
|
|
|
|
|
|
hesk_cleanSessionVars('cat_priority');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$_SESSION['selcat2'] = hesk_dbInsertID();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_process_messages(sprintf($hesklang['cat_name_added'], '<i>' . stripslashes($catname) . '</i>'), 'manage_categories.php', 'SUCCESS');
|
|
|
|
|
|
|
|
} // End new_cat()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function update_category()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
global $hesk_settings, $hesklang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A security check */
|
|
|
|
|
|
|
|
hesk_token_check('POST');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$_SERVER['PHP_SELF'] = 'manage_categories.php?catid=' . intval(hesk_POST('catid'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$catid = hesk_isNumber(hesk_POST('id'), $hesklang['choose_cat_ren'], $_SERVER['PHP_SELF']);
|
|
|
|
|
|
|
|
$_SESSION['selcat'] = $catid;
|
|
|
|
|
|
|
|
$_SESSION['selcat2'] = $catid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$catname = hesk_input(hesk_POST('name'), $hesklang['cat_ren_name'], $_SERVER['PHP_SELF']);
|
|
|
|
|
|
|
|
$_SESSION['catname2'] = $catname;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$background_color = hesk_POST('background-color', '#ffffff');
|
|
|
|
|
|
|
|
$foreground_color = hesk_POST('foreground-color', '#000000');
|
|
|
|
|
|
|
|
$display_border = hesk_POST('display-border', 0);
|
|
|
|
|
|
|
|
if ($foreground_color == '') {
|
|
|
|
|
|
|
|
$foreground_color = 'AUTO';
|
|
|
|
|
|
|
|
$display_border = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$manager = hesk_POST('manager', 0);
|
|
|
|
|
|
|
|
$priority = hesk_POST('priority', 0);
|
|
|
|
|
|
|
|
$usage = hesk_POST('usage', 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` SET `name`='" . hesk_dbEscape($catname) . "',
|
|
|
|
|
|
|
|
`priority` = '" . hesk_dbEscape($priority) . "',
|
|
|
|
|
|
|
|
`manager` = " . intval($manager) . ",
|
|
|
|
|
|
|
|
`background_color` = '" . hesk_dbEscape($background_color) . "',
|
|
|
|
|
|
|
|
`foreground_color` = '" . hesk_dbEscape($foreground_color) . "',
|
|
|
|
|
|
|
|
`display_border_outline` = '" . intval($display_border) . "',
|
|
|
|
|
|
|
|
`usage` = " . intval($usage) . "
|
|
|
|
|
|
|
|
WHERE `id`='" . intval($catid) . "'");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unset($_SESSION['selcat']);
|
|
|
|
|
|
|
|
unset($_SESSION['catname2']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_process_messages(sprintf($hesklang['category_updated'], stripslashes($catname)), $_SERVER['PHP_SELF'], 'SUCCESS');
|
|
|
|
|
|
|
|
} // End rename_cat()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function remove()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
global $hesk_settings, $hesklang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A security check */
|
|
|
|
|
|
|
|
hesk_token_check();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$_SERVER['PHP_SELF'] = 'manage_categories.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$mycat = intval(hesk_GET('catid')) or hesk_error($hesklang['no_cat_id']);
|
|
|
|
|
|
|
|
if ($mycat == 1) {
|
|
|
|
|
|
|
|
hesk_process_messages($hesklang['cant_del_default_cat'], $_SERVER['PHP_SELF']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` WHERE `id`='" . intval($mycat) . "'");
|
|
|
|
|
|
|
|
if (hesk_dbAffectedRows() != 1) {
|
|
|
|
|
|
|
|
hesk_error("$hesklang[int_error]: $hesklang[cat_not_found].");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `category`=1 WHERE `category`='" . intval($mycat) . "'");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_process_messages($hesklang['cat_removed_db'], $_SERVER['PHP_SELF'], 'SUCCESS');
|
|
|
|
|
|
|
|
} // End remove()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function order_cat()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
global $hesk_settings, $hesklang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A security check */
|
|
|
|
|
|
|
|
hesk_token_check();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$catid = intval(hesk_GET('catid')) or hesk_error($hesklang['cat_move_id']);
|
|
|
|
|
|
|
|
$_SESSION['selcat2'] = $catid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cat_move = intval(hesk_GET('move'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` SET `cat_order`=`cat_order`+" . intval($cat_move) . " WHERE `id`='" . intval($catid) . "'");
|
|
|
|
|
|
|
|
if (hesk_dbAffectedRows() != 1) {
|
|
|
|
|
|
|
|
hesk_error("$hesklang[int_error]: $hesklang[cat_not_found].");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Update all category fields with new order */
|
|
|
|
|
|
|
|
$res = hesk_dbQuery("SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ORDER BY `cat_order` ASC");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$i = 10;
|
|
|
|
|
|
|
|
while ($mycat = hesk_dbFetchAssoc($res)) {
|
|
|
|
|
|
|
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` SET `cat_order`=" . intval($i) . " WHERE `id`='" . intval($mycat['id']) . "'");
|
|
|
|
|
|
|
|
$i += 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
header('Location: manage_categories.php');
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
} // End order_cat()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function toggle_autoassign()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
global $hesk_settings, $hesklang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A security check */
|
|
|
|
|
|
|
|
hesk_token_check();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$catid = intval(hesk_GET('catid')) or hesk_error($hesklang['cat_move_id']);
|
|
|
|
|
|
|
|
$_SESSION['selcat2'] = $catid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (intval(hesk_GET('s'))) {
|
|
|
|
|
|
|
|
$autoassign = 1;
|
|
|
|
|
|
|
|
$tmp = $hesklang['caaon'];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$autoassign = 0;
|
|
|
|
|
|
|
|
$tmp = $hesklang['caaoff'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Update auto-assign settings */
|
|
|
|
|
|
|
|
$res = hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` SET `autoassign`='" . intval($autoassign) . "' WHERE `id`='" . intval($catid) . "'");
|
|
|
|
|
|
|
|
if (hesk_dbAffectedRows() != 1) {
|
|
|
|
|
|
|
|
hesk_process_messages($hesklang['int_error'] . ': ' . $hesklang['cat_not_found'], './manage_categories.php');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_process_messages($tmp, './manage_categories.php', 'SUCCESS');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End toggle_autoassign()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function toggle_type()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
global $hesk_settings, $hesklang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A security check */
|
|
|
|
|
|
|
|
hesk_token_check();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$catid = intval(hesk_GET('catid')) or hesk_error($hesklang['cat_move_id']);
|
|
|
|
|
|
|
|
$_SESSION['selcat2'] = $catid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (intval(hesk_GET('s'))) {
|
|
|
|
|
|
|
|
$type = 1;
|
|
|
|
|
|
|
|
$tmp = $hesklang['cpriv'];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$type = 0;
|
|
|
|
|
|
|
|
$tmp = $hesklang['cpub'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Update auto-assign settings */
|
|
|
|
|
|
|
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` SET `type`='{$type}' WHERE `id`='" . intval($catid) . "'");
|
|
|
|
|
|
|
|
if (hesk_dbAffectedRows() != 1) {
|
|
|
|
|
|
|
|
hesk_process_messages($hesklang['int_error'] . ': ' . $hesklang['cat_not_found'], './manage_categories.php');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hesk_process_messages($tmp, './manage_categories.php', 'SUCCESS');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End toggle_type()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_manager($user_id, $user_array) {
|
|
|
|
|
|
|
|
global $hesklang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($user_id == 0) {
|
|
|
|
|
|
|
|
return $hesklang['no_manager'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($user_array as $user) {
|
|
|
|
|
|
|
|
if ($user['id'] == $user_id) {
|
|
|
|
|
|
|
|
return $user['name'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 'Error!';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|