= 0) and ($day < 32) and ($day >= 0)); } //----------------------------------------------------------------------------- // // Function: UpdateLastCommentId // Description: // Updates the last_comment_id of a ticket. // Parameters: // int $ticket_id ID of ticket to update. // Return Values: // None. // Remarks: // None. //----------------------------------------------------------------------------- function UpdateLastCommentId($ticket_id) { global $db; $last_comment_id = GetLastCommentOfTicket($ticket_id); $query = "UPDATE ticket SET last_comment_id='$last_comment_id', "; $query .= "date_created = date_created"; $query .= " WHERE id='$ticket_id'"; mysql_query($query, $db); UpdateTicketStatus($ticket_id, $last_comment_id); } //----------------------------------------------------------------------------- // // Function: UpdateTicketStatus // Description: // Changes the status of a ticket. // Parameters: // int $ticket_id ID of ticket to update. // int $comment_id ID of comment to update. Defaults to newest comment. // Return Values: // None. // Remarks: // None. //----------------------------------------------------------------------------- function UpdateTicketStatus($ticket_id, $comment_id = "") { global $db; if ($comment_id == "") { $query = "select max(comment.id) as comment_id from ticket, comment "; $query .= "where comment.ticket_id=ticket.id and ticket.id='$ticket_id' "; $query .= "group by ticket.id"; $result = mysql_query($query, $db); if (($result) && ($row = mysql_fetch_object($result))) { $comment_id = $row->comment_id; } } $query = "select comment.date_created, comment.status, current_status "; $query .= "from ticket, comment where ticket.id='$ticket_id' and "; $query .= "comment.id='$comment_id' limit 1"; $row = mysql_fetch_object(mysql_query($query, $db)); if (($row->status != "") && ($row->status != $row->current_status)) { $query = "update ticket set last_comment_id='$comment_id', "; $query .= "date_created=date_created, current_status='$row->status', "; $query .= "status_change_date='$row->date_created' "; $query .= "where id='$ticket_id'"; mysql_query($query, $db); } } //----------------------------------------------------------------------------- // // Function: UpdateFirstCommentId // Description: // Updates first_comment_id for a ticket. // Parameters: // int $ticket_id ID of ticket to update. // Return Values: // None. // Remarks: // None. //----------------------------------------------------------------------------- function UpdateFirstCommentId($ticket_id) { global $db; $first_comment_id = GetFirstCommentOfTicket($ticket_id); $query = "UPDATE ticket SET first_comment_id='$first_comment_id', "; $query .= "date_created = date_created"; $query .= " WHERE id='$ticket_id'"; mysql_query($query, $db); } //----------------------------------------------------------------------------- // // Function: PrintArray // Description: // Creates a string of the values of an array. // Parameters: // array $array Array to print. // Return Values: // Returns the string. // Remarks: // None. //----------------------------------------------------------------------------- function PrintArray($array = "") { $output = ""; for ($i = 0; $i < sizeof($array); $i++) { $output .= $array[$i]."
"; } return $output; } //----------------------------------------------------------------------------- // // Function: PrintCheckboxArray // Description: // Prints a list of checkboxes labelled with the items in the arrays. // Parameters: // string $array_name Name to use for the checkboxes. // array or string $array_values Either "combined" or checkbox values. // array or string $array_shows If "", $array_values used. Can be 2D. // Return Values: // Returns HTML to output. // Remarks: // None. //----------------------------------------------------------------------------- function PrintCheckboxArray($array_name, $array_values = "", $array_shows = "") { if ($array_shows == "combined") { $array_shows = $array_values[0]; $array_values = $array_values[1]; } if ($array_shows == "") { $array_shows = $array_values; } $size = sizeof($array_values); $size2 = sizeof($array_shows); if ($size > $size2) { $size = $size2; } $output = ""; return $output; } //----------------------------------------------------------------------------- // // Function: PrintSpecialFieldsCheckboxArray // Description: // Prints a list of checkboxes labelled with the items in the arrays. // Parameters: // string $array_name Name of checkbox array. // array $array_values Values of checkboxes. // int $diff_ques Adds additional info. // Return Values: // HTML to display the checkbox array. // Remarks: // None. //----------------------------------------------------------------------------- function PrintSpecialFieldsCheckboxArray($array_name, $array_values = "", $diff_ques = "") { global $self; $queue = $_GET['queue']; $array_shows = $array_values; $size = mysql_num_rows($array_values); $output = ""; return $output; } //----------------------------------------------------------------------------- // // Function: FixVarName // Description: // Fixes a variable name by removing certain characters. // Parameters: // string $var String to fix. // Return Values: // Returns the fixed var name. // Remarks: // None. //----------------------------------------------------------------------------- function FixVarName($var) { $search = array("?", "%", " ", "\$"); $replace = array("", "", "_", ""); $var = str_replace($search, $replace, $var); return $var; } //----------------------------------------------------------------------------- // // Function: PrintSelectArray // Description: // Creates an HTML select box from array options. // Parameters: // string $name Name to use for the array. // array $array_values Values for the select box // string or array $array_shows "combined" "" or display for array. // string $firstvalue Value of first item. // string $firstshow Display for first item. // Return Values: // Returns HTML to output. // Remarks: // None. //----------------------------------------------------------------------------- function PrintSelectArray($name, $array_values = "", $array_shows = "", $firstvalue = "", $firstshow = "") { $output = ""; if ($firstshow == "") { $firstshow = $firstvalue; } if ($array_shows == "combined") { $array_shows = $array_values[0]; $array_values = $array_values[1]; } if ($array_shows == "") { $array_shows = $array_values; } $size = sizeof($array_values); $size2 = sizeof($array_shows); if ($size > $size2) { $size = $size2; } if ($size == 0) { $output .= "No Choices Available"; return 0; } else { $output .= ""; return $output; } //----------------------------------------------------------------------------- // // Function: GetMoreEmail // Description: // Splits strings of emails into individual emails. // Parameters: // string $requester Single email. // string $cc Multiple emails, seperated buy ", " // string $admin_cc Multiple emails, seperated buy ", " // int $combine Combine arrays into one or not. // Return Values: // Returns either 3 seperate arrays or 1 array of emails depending on value // of $combine. // Remarks: // None. //----------------------------------------------------------------------------- function GetMoreEmail($requester = "", $cc = "", $admin_cc = "", $combine = 0) { $arr1 = $requester; $arr2 = split(', ', $cc); $arr3 = split(', ', $admin_cc); if (!($combine)) { $pre_arr = array_merge($arr1, $arr2, $arr3); $final_arr = array(); for ($i = 0; $i < sizeof($pre_arr); $i++) { if (EmailGood($pre_arr[$i])) { array_push($final_arr, $pre_arr[$i]); } } } else { return array($arr1, $arr2, $arr3); } return $final_arr; } //----------------------------------------------------------------------------- // // Function: DateWarning // Description: // Inform user how to enter a date. // Parameters: // None. // Return Values: // Returns HTML to display. // Remarks: // None. //----------------------------------------------------------------------------- function DateWarning() { return Font("in a yyyy-mm-dd format"); } //----------------------------------------------------------------------------- // // Function: ArrayToString // Description: // Explodes an array's items as a string. // Parameters: // array $array Array to explode. // string $spacer String to place between elements of array. // Return Values: // Returns a string. // Remarks: // None. //----------------------------------------------------------------------------- function ArrayToString($array = "", $spacer = "") { $output = ""; for($i = 0; $i < sizeof($array); $i++) { $output .= "$array[$i]$spacer"; } return $output; } //----------------------------------------------------------------------------- // // Function: LinkToTicket // Description: // Generates a link to a specific ticket. // Parameters: // int $ticket_id ID of ticket to link to. // Return Values: // Returns HTML to display the link. // Remarks: // None. //----------------------------------------------------------------------------- function LinkToTicket($ticket_id = "") { $url = ""; $url .= "Click here for info on ticket #$ticket_id"; return $url; } //----------------------------------------------------------------------------- // // Function: CreateLinksFromArray // Description: // Used to create a list of links in a row. // Parameters: // array $array Contains the text and value to use for each link. // string $var_name Variable name to use in link. // string $space Added to the end of each link after . // string $hl If this matches an item in $array, mark with arrow. // Return Values: // Returns HTML to display the links. // Remarks: // None. //----------------------------------------------------------------------------- function CreateLinksFromArray($array = "", $var_name = "", $space = "", $hl = "") { global $self; $special = 0; $image = ""; $output = $null = ""; $size = sizeof($array); if ($size < 1) { $output .= "Array of zero size passed to create_links_from_array()"; return $output; } if ($hl == "first") { $special = 1; } for($i = 0; $i < $size; $i++) { //$value = str_replace(" ", "_", $array[$i]); $value = $array[$i]; if (($array[$i] == $hl || str_replace(" ", "_", $array[$i]) == $hl) or $special) { $output .= Font("$array[$i]$image"); $special = 0; } else { $output .= Font("$array[$i]"); } $output .= $space; } return $output; } //---------------------------------------------------------------------- // // Function: SpaceInputValue // // Description: Converts all underscores in array into spaces // // Parameters: // $input_array: input array (containing underscores) by reference // // Return Values: // None. // Remarks: // None. //---------------------------------------------------------------------- function SpaceInputValue(&$input_array){ for($i=0; $i. // string $selected_string Matched to an item in the array, "selected". // string $username Appended to the values in $array. // Return Values: // Returns HTML to display the options. // Remarks: // Only creates the options, not the actual form. //----------------------------------------------------------------------------- function CreateSelectOptions($array = "", $open = "", $selected_string = "", $show_array = "", $username = "") { $output = ""; if ($username != "") $username = $username."---"; $size = sizeof($array); if ($show_array == "") $show_array = $array; if ($size < 1) return "Array of zero size passed to create_select_options()"; if ($open == "open") $tag = ""; else $tag = ""; if (empty($selected_string)) { for ($i = 0; $i < $size; $i++) { $value = str_replace(" ", "_", $array[$i]); $output .= "