| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:53:39 2008 ] | [ PHProjekt 5.0.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 // helpdesk_data.php - PHProjekt Version 5.0 4 // copyright © 2000-2005 Albrecht Guenther ag@phprojekt.com 5 // www.phprojekt.com 6 // Author: Albrecht Guenther, $Author: fgraf $ 7 // $Id: helpdesk_data.php,v 1.23.2.2 2005/09/07 09:19:18 fgraf Exp $ 8 9 // check whether the lib has been included - authentication! 10 if (!defined("lib_included")) { die("Please use index.php!"); } 11 12 // check role 13 if (check_role("helpdesk") < 2) { die("You are not allowed to do this!"); } 14 15 use_mail('1'); 16 17 // fetch permission routine 18 include_once("$lib_path/permission.inc.php"); 19 $include_path3 = $path_pre."lib/access.inc.php"; 20 include_once $include_path3; 21 $acc_read = assign_acc($acc_read, 'helpdesk'); 22 23 // delete request 24 if ($delete_b) { 25 if ($ID > 0) manage_delete_records($ID,$module); 26 elseif( $ID_s <> '') manage_delete_records($ID_s,$module); 27 } 28 29 30 // delete a file attached to a record 31 elseif ($delete_file) {delete_attached_file($file_field_name, $ID, 'helpdesk'); } 32 33 // insert new request 34 elseif (!$ID && isset($_REQUEST['name'])) { 35 if ($acc_write <> '') { $acc_write = 'w'; } 36 sqlstrings_create(); 37 $status = $helpdesk_states[0]['key']; 38 $result = db_query(xss("insert into ".DB_PREFIX."rts 39 (ID, gruppe, parent, von, acc, acc_read, acc_write ,status, ".$sql_fieldstring." ) 40 values ($dbIDnull,'$user_group','$parent','$user_ID','$acc','$acc_read','$acc_write','$status', ".$sql_valuestring.")")) or db_die(); 41 } 42 43 // update request 44 elseif ($ID > 0 && isset($_REQUEST['name'])) { 45 // check permission 46 $result = db_query("select ID, assigned, acc_write, von, status 47 from ".DB_PREFIX."rts 48 where ID = '$ID' and 49 (acc_read like 'system' or ((von = '$user_ID' or assigned = '$user_ID' or acc_read like 'group' or acc_read like '%\"$user_kurz\"%') and $sql_user_group))") or db_die(); 50 $row = db_fetch_row($result); 51 if (!$row[0] or ($row[1] <> $user_ID and $row[3] <> $user_ID and $row[2] <> 'w')) { die("You are not allowed to do this"); } 52 53 // check whether this record is assigned to this user - if yes, allow him to change the permission status 54 // otherwise don't change this field 55 if ($row[1] == $user_ID ) { 56 $accessstring = "acc_read = '$acc_read',"; 57 if ($acc_write <> '') $accesswritestring = "acc_write = 'w',"; 58 else $accesswritestring = "acc_write = '',"; 59 } 60 else { 61 $accessstring = ''; 62 $accesswritestring = ''; 63 } 64 // end check permission 65 66 //keep history 67 if (PHPR_HISTORY_LOG) { 68 sqlstrings_create(); 69 history_keep('rts','acc_read,acc_write,'.$sql_fieldstring,$ID); 70 } 71 //These options aren't available anymore! 72 /** 73 if ($action == 'solve') { $rts_normal ? $status = 2 : $status = 4; } 74 if ($action == 'stall') $status = 20; 75 if ($action == 'moveto') $status = 21; 76 */ 77 // include the library from lib 78 include_once("$lib_path/email_notification.inc.php"); 79 $change_user= slookup('users','nachname,vorname','ID',$user_ID); 80 81 // notify if the assigned user has been changed 82 if ($assigned <> $row[1]) { email_notification('rts', $acc_read,$change_user." ".__("has reassigned the following request").": ".$name, $add_mail); } 83 84 // notify if the status has been changed 85 if ($status <> $row[4]) { email_notification('rts', $acc_read, $name.": ".__("Ticket status changed")."(".$helpdesk_states[$status-1]["label"].")", $add_mail); } 86 //isn't needed! 87 //$status = $helpdesk_states[$status-1]['key']; 88 89 $sql_string = sqlstrings_modify(); 90 // update record in db 91 $result = db_query(xss("update ".DB_PREFIX."rts 92 set $sql_string 93 $accessstring 94 $accesswritestring 95 parent = '$parent', 96 status = '$status', 97 acc = '$acc' 98 where ID = '$ID'")) or db_die(); 99 // ******** 100 // solve request, mail to customer, set access 101 if(($status=='solved' or $status==5)&&$status <> $row[4]){ 102 //if ($action == 'solve') { 103 $result = db_query(xss("update ".DB_PREFIX."rts 104 set solved = '$user_ID', 105 solve_time = '$dbTSnull' 106 where ID = '$ID'")) or db_die(); 107 108 // fetch original question 109 $result = db_query("select name, note 110 from ".DB_PREFIX."rts 111 where ID = '$ID'") or db_die(); 112 $row = db_fetch_row($result); 113 114 // body of the mail consists of: "has been answered by NN, question: xyz, answer: xyz ... 115 $body = __('Your request was solved by')." $user_firstname $user_name\n ".__('Request').": $row[0]\n $row[1]\n ".__('Solution').": $solution"; 116 // fetch mail adress 117 118 if (PHPR_RTS_CUST_ACC and PHPR_CONTACTS) { 119 $result2 = db_query("select email 120 from ".DB_PREFIX."contacts 121 where ID = '$row[0]'") or db_die(); 122 $row2 = db_fetch_row($result2); 123 $cust_mail = $row2[0]; 124 } 125 if(empty($cust_mail)) { 126 $result = db_query("select contact, email 127 from ".DB_PREFIX."rts 128 where ID = '$ID'") or db_die(); 129 $row = db_fetch_row($result); 130 $cust_mail = $row[1]; 131 } 132 // mail to the customer with the solution 133 $success = $mail->go($cust_mail, __('Answer to your request Nr.')." $ID", $body, $user_email); 134 // confirmation screen for the author 135 message_stack_in(__('Your solution was mailed to the customer and taken into the database'),"helpdesk","notice"); 136 } 137 138 // ******** 139 // move request 140 elseif ($action == 'moveto') { 141 $result = db_query("select ID, name, note, remark 142 from ".DB_PREFIX."rts 143 where ID = '$ID'") or db_die(); 144 $row = db_fetch_row($result); 145 $result2 = db_query("select ID, name, note, remark 146 from ".DB_PREFIX."rts 147 where ID = '$moveto'") or db_die(); 148 $row2 = db_fetch_row($result2); 149 $name = quote_runtime($row2[1]."\n+ Nr. $row[0]:\n ".$row[1]); 150 $note = quote_runtime($row2[2]."\n+ Nr. $row[0]:\n ".$row[2]); 151 $remark = quote_runtime($row2[3]."\n+ Nr. $row[0]:\n ".$row[3]); 152 // update new record 153 $result = db_query(xss("update ".DB_PREFIX."rts 154 set remark = '$remark', 155 note='$note', 156 name = '$name' 157 where ID = '$moveto'")) or db_die(); 158 // put a remark into the old record that it has moved 159 $result = db_query(xss("update ".DB_PREFIX."rts 160 set remark = 'moved to $moveto' 161 where ID = '$ID'")) or db_die(); 162 } 163 } 164 165 // show the helpdesk list :-) 166 $fields = build_array('helpdesk', $ID, 'view'); 167 include_once ("./helpdesk_view.php"); 168 169 function delete_record($ID) { 170 global $fields, $user_ID; 171 // check permission 172 $result = db_query("select assigned, acc_write,ID,von 173 from ".DB_PREFIX."rts 174 where ID = '$ID'") or db_die(); 175 $row = db_fetch_row($result); 176 if ($row[2] == 0) { die("no entry found."); } 177 if ($row[0] <> $user_ID and !$row[1] and (!(($row[0]==0 or $row[0]=='')and $row[3]==$user_ID ))) { die("You are not privileged to do this!"); } 178 179 // delete all files associated with this record 180 foreach($fields as $field_name => $field) { 181 if ($field['form_type'] == 'upload' ) { 182 $sql_value = upload_file_delete($field_name, $ID, 'helpdesk'); 183 } 184 } 185 // delete record in db 186 $result = db_query("delete from ".DB_PREFIX."rts 187 where ID = '$ID'") or db_die(); 188 // delete corresponding entry from db_record 189 $result = db_query("delete from ".DB_PREFIX."db_records 190 where t_record = '$ID' and t_module = 'rts'") or db_die(); 191 192 // delete history for this db entry 193 if (PHPR_HISTORY_LOG) { history_delete('rts',$ID); } 194 } 195 196 ?> 197 198 </body> 199 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |