modifyticket.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:6k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: modifyticket.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.24 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Ticket modification handler (fields, etc.)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- $template_cache = templatecache('HF_header,HF_footer,VIEW_edit');
- // globalise variables
- $global = array (
- array('ticketref')
- );
- rg($global);
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "start";
- }
- check_user();
- // check ticket ref
- if (!ticketref) {
- error("error_noticket");
- }
- ############################### UPDATE TICKET ###############################
- if ($_REQUEST['do'] == "submit") {
- //////////////// categories ////////////////
- if ($settings[category_user_viewable] AND $settings[category_user_editable]) {
-
- $db->query(" SELECT * FROM ticket_cat
- WHERE user_view
- AND user_select
- ORDER by cat_order
- ");
- while ($cat = $db->row_array()) {
- $cats[] = $cat[id];
- }
- // only valid categories
- if (!(in_array($_REQUEST[category], $cats))) {
- unset($_REQUEST[category]);
- }
- // category required
- if ($settings[category_require_selection] AND !$_REQUEST[category]) {
- $stop = 1;
- $error_category = 1;
- }
- }
- //////////////// priorities ////////////////
-
- if (!$settings[priority_disable] AND $settings[priority_user_viewable] AND $settings[priority_user_editable]) {
-
- $db->query(" SELECT * FROM ticket_pri
- WHERE user_view
- AND user_select
- ORDER by pri_order
- ");
- while ($pri = $db->row_array()) {
- $pris[] = $pri[id];
- }
- // only valid priorities
- if (!(in_array($_REQUEST[priority], $pris))) {
- unset($_REQUEST[priority]);
- }
- // priority required
- if ($priority_settings[require_selection] AND !$_REQUEST[priority]) {
- $stop = 1;
- $error_priority = 1;
- }
- }
- //////////////// custom fields ////////////////
- $custom = array();
- $custom_error = array();
-
- $db->query("SELECT * from ticket_def WHERE user_editable");
- $terms = array();
- while ($result = $db->row_array()) {
- $data = field_def_val($result, $_REQUEST[custom_fields][$result[name]], $_REQUEST[custom_fields]["extra" . $result[name]]);
- if ($data === NULL) {
- $tmp = unserialize($result[error_message]);
- $error_message = $tmp[$session[language]];
- // form errors;
- $custom_error[] = array('error' => $error_message);
- // for form design
- $custom_errors[] = $result[name];
-
- $stop = 1;
-
- } else {
- $terms[] = " $result[name] = '" . mysql_escape_string($data) . "' ";
- }
- }
- if ($stop) {
- $_REQUEST['do'] = 'start';
- } else {
- if (count($terms)) {
- $query2 = ', ' . join(', ', $terms);
- }
- $db->query("
- UPDATE ticket
- SET priority = '" . mysql_escape_string($_REQUEST[priority]) . "',
- category = '" . mysql_escape_string($_REQUEST[category]) . "'
- $query2
- WHERE ref = '" . mysql_escape_string($ticketref) ."'
- ");
- jump("view.php?ticketref=$ticketref", 'redirect_updated_ticket');
- }
- }
- ############################### DISPLAY FORM ###############################
- if ($_REQUEST['do'] == "start") {
- $ticket = $db->query_return("
- SELECT ticket.*, ticket_cat.name AS catname, ticket_pri.name AS priname
- FROM ticket
- LEFT JOIN ticket_cat ON (ticket.category = ticket_cat.id)
- LEFT JOIN ticket_pri ON (ticket.priority = ticket_pri.id)
- WHERE ticket.ref = '" . mysql_escape_string($ticketref) . "' AND
- ticket.userid = '$session[userid]'
- ");
- // no ticket
- if (!$db->num_rows()) {
- error("NEW_error_modify");
- }
- // ticket closed
- if ($ticket[is_open] == "0") {
- error("REPLY_error_ticket_closed");
- }
- // categories
- $categories = user_category_array('edit');
- if (is_array($categories)) {
- $category_html = form_select('category', $categories, $ticket['category']);
- }
- // priorities
- $priorities = user_priority_array('edit');
- if (is_array($priorities)) {
- $priority_html = form_select('priority', $priorities, $ticket['priority']);
- }
-
- // get rest of ticket data
- $db->query(
- "SELECT * from ticket_def
- WHERE user_editable
- ORDER by displayorder"
- );
- while ($result = $db->row_array()) {
- unset($name, $description, $error, $html);
- $tmp = unserialize($result[display_name]);
- $name = $tmp[$session[language]];
- $tmp = unserialize($result[description]);
- $description = $tmp[$session[language]];
- if ($stop) {
- $html = field_def($result, 1, $ticket[custom_fields][$result[name]], $ticket[custom_fields]["extra" . $result[name]]);
- } else {
- $html = field_def($result, 'edit', '', '', $ticket[$result[name]]);
- }
- $tmp = unserialize($result[error_message]);
- $error = $tmp[$session[language]];
- // two arrays, one for loop and one to allow custom form design
- $custom[] = array(
- 'name' => $name,
- 'description' => $description,
- 'html' => $html,
- 'error' => iff(@in_array($result[name], $custom_errors), $error, '')
- );
- ${$result[name]} = array(
- 'name' => $name,
- 'description' => $description,
- 'html' => $html,
- 'error' => iff(@in_array($result[name], $custom_errors), $error, '')
- );
-
- }
- eval(makeeval('header', 'HF_header'));
- eval(makeeval('footer', 'HF_footer'));
- eval(makeeval('echo', 'VIEW_edit'));
- }
- ?>