tech.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:18k
- <?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: tech.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.32 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Technician maintenance (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- // globalise variables
- $global = array (
- array('id')
- );
- rg($global);
- ############################### EMAIL TECHS ###############################
- if ($_REQUEST['do'] == "email") {
- admin_header('Technicians', 'Email');
- $table[] = array('<b>From Email Address</b>', form_input('from'));
- $table[] = array('<b>Email Subject</b>', form_input('subject'));
- $table[] = array('<b>Email Body</b>', form_textarea('body', 100, 20));
- table_header('Email Technicians', 'tech.php', array('do' => 'email2'));
- table_content('', $table);
- table_footer('Send Email');
- unset($columns, $table);
- }
- ############################### EMAIL TECHS ###############################
- if ($_REQUEST['do'] == "email2") {
- admin_header('Technicians', 'Email');
- echo "<br />";
- $db->query("SELECT email FROM tech");
-
- while ($tech = $db->row_array()) {
- if (validate_email($tech[email])) {
- dp_mail($tech[email], $_REQUEST[subject], $_REQUEST[body], $_REQUEST[from]);
- echo "Email sent to $tech[email]<br />";
- }
- }
- echo "<br /><b>All Sent</b>";
- }
- ############################### 1st STAGE OF NEW TECH CREATION ###############################
- if ($_REQUEST['do'] == "add") {
- admin_header('Technicians', 'Add Technician');
- $db->query("SELECT id,username FROM tech");
- while ($result = $db->row_array()) {
- // Disabled for demo
- if ($REQUEST[username] == 'admin') {
- alert("Editing the 'admin' account is disabled in the demo.");
- $error = 1;
- }
- // Disabled for demo
- if ($REQUEST[username] == 'admin') {
- alert("Editing the 'admin' account is disabled in the demo.");
- $error = 1;
- }
- $tech_array[$result[id]] = $result[username];
- }
- $table[] = array('<input type="radio" name="permission" value="1" checked>', 'To create a new technician based on the permissions of another technician', form_select('tech_id', $tech_array));
- $table[] = array('<input type="radio" name="permission" value="0">', 'Create a new technician not based on the permissions of another technician');
- table_header('Create New User', 'tech.php', array('do' => 'add2'));
- table_content('', $table);
- table_footer('Create Technician');
- unset($table);
- }
- ############################### CREATE / UPDATE TECH ###############################
- if (($_REQUEST['do'] == "submit") OR ($_REQUEST['do'] == "update")) {
- if (($user[id] == $id) AND ($id != '') AND ($_REQUEST[is_admin] != 1)) {
- alert('You can not remove your own admin status');
- $error = 1;
- }
- if ($_REQUEST['username'] == '') {
- alert('You did not enter a username');
- $error = 1;
- }
- if ($_REQUEST['password'] == '') {
- alert('You have not entered a password');
- $error = 1;
- unset($_REQUEST['password']);
- }
- if ($_REQUEST['password'] != $_REQUEST['password2']) {
- alert('The passwords do not match');
- $error = 1;
- unset($_REQUEST['password']);
- }
- if (!validate_email($_REQUEST[email])) {
- alert('You have not entered a valid email address');
- $error = 1;
- }
- if (!$error) {
-
- if ($_REQUEST['do'] == "submit") {
- $query = "INSERT INTO tech SET";
- } elseif ($_REQUEST['do'] == "update") {
- $query = "UPDATE tech SET";
- }
- $query .= " username = '" . mysql_escape_string($_REQUEST[username]) . "',";
- if ($_REQUEST['password'] != "**********") {
- $query .= "password = '" . mysql_escape_string($_REQUEST[password]) . "', ";
- }
- $query .= "
- signature = '" . mysql_escape_string($_REQUEST[signature]) . "',
- email = '" . mysql_escape_string($_REQUEST['email']) . "',
- p_close_ticket = '" . $_REQUEST['p_close_ticket'] . "',
- p_tech_view = '" . $_REQUEST['p_tech_view'] . "',
- p_tech_edit = '$_REQUEST[p_tech_edit]',
- p_add_k = '$_REQUEST[p_add_k]',
- p_edit_k = '$_REQUEST[p_edit_k]',
- p_delete_k = '$_REQUEST[p_delete_k]',
- p_add_c_k = '$_REQUEST[p_add_c_k]',
- p_edit_c_k = '$_REQUEST[p_edit_c_k]',
- p_delete_c_k = '$_REQUEST[p_delete_c_k]',
- p_delete_announcements = '$_REQUEST[p_delete_announcements]',
- p_edit_announcements = '$_REQUEST[p_edit_announcements]',
- p_add_announcements = '$_REQUEST[p_add_announcements]',
- p_delete_users = '$_REQUEST[p_delete_users]',
- p_approve_new_registrations = '$_REQUEST[p_approve_new_registrations]',
- p_create_users = '$_REQUEST[p_create_users]',
- p_edit_users = '$_REQUEST[p_edit_users]',
- p_delete_own = '$_REQUEST[p_delete_own]',
- p_delete_other = '$_REQUEST[p_delete_other]',
- p_quickedit = '$_REQUEST[p_quickedit]',
- p_user_expire = '$_REQUEST[p_user_expire]',
- p_global_note = '$_REQUEST[p_global_note]',
- p_html_tech = '$_REQUEST[p_html_tech]',
- p_html_user = '$_REQUEST[p_html_user]',
- is_admin = '$_REQUEST[is_admin]',
- alert_reply_your = 1,
- alert_new_cat = 1,
- alert_pm = 1,
- alert_sound = 1,
- alert_popup = 1,
- email_new_email = 1,
- email_own_email = 1,
- email_reply_email = 1,
- email_assigned = 1,
- email_pm = 1
- ";
-
- if ($_REQUEST['do'] == "submit") {
- $db->query($query);
- jump('tech.php', 'Technician Created');
- }
-
- if ($_REQUEST['do'] == "update") {
- $query .= " WHERE id = '$id'";
- $db->query($query);
- jump('tech.php', 'Technician Updated');
- }
- } else {
- $tech = $_REQUEST;
- $_REQUEST['do'] = 'redo';
- $password = $_REQUEST['password'];
- }
- }
- ############################### FORM TO CREATE / UPDATE TECH ###############################
- if (($_REQUEST['do'] == "add2") OR ($_REQUEST['do'] == "edit") OR ($_REQUEST['do'] == "redo")) {
- if ($_REQUEST['do'] == "edit") {
- $tech = $db->query_return("SELECT * FROM tech WHERE id = '$id'");
- $password = '**********';
- admin_header('Technicians', 'Edit Technician');
- } else {
- admin_header('Technicians', 'Add Technician');
- // sort out permissions if creating from another technician
- if ($_REQUEST[permission] == "1") {
- $tech = $db->query_return("SELECT * FROM tech WHERE id = '$_REQUEST[tech_id]'");
- echo table_border("<center><b>Permissions have been prefilled with the permissions assigned to technician $tech[username]</b></center>");
- echo "<BR>";
- unset($tech[username], $tech[password], $tech[email], $tech[real_name]);
- }
- }
- $bit = form_input('username', $tech[username], '30');
- $table[] = array('<b>Username</b><br />Your technicians username', $bit);
- $bit = form_password('password', $password, '30');
- $table[] = array('<b>Password</b><br />Your technicians password', $bit);
- $bit = form_password('password2', $password, '30');
- $table[] = array('<b>Password</b><br />Please confirm the password', $bit);
- $bit = form_textarea('signature', '30', '5', $tech[signature]);
- $table[] = array('<b>Signature</b><br />A signature for your technician', $bit);
- $bit = form_input('email', $tech[email], '30');
- $table[] = array('<b>Email</b><br />Your technicians email', $bit);
- $bit = form_radio_yn('is_admin', '', $tech[is_admin]);
- $table[] = array('<b>Is Admin</b><br />Do you wish to grant access to the admin control panel to your technician?', $bit);
- $table[] = table_midheader('General Permissions');
- $bit = form_radio_yn('p_add_announcements', '', $tech[p_add_announcements]);
- $table[] = array('<b>PERMISSION: can add announcements</b><br />Can your technician add announcements?', $bit);
- $bit = form_radio_yn('p_delete_announcements', '', $tech[p_delete_announcements]);
- $table[] = array('<b>PERMISSION: can edit announcements</b><br />Can your technician edit announcements?', $bit);
- $bit = form_radio_yn('p_edit_announcements', '', $tech[p_edit_announcements]);
- $table[] = array('<b>PERMISSION: delete announcements</b><br />Can your technician delete announcements?', $bit);
- $bit = form_radio_yn('p_quickedit', '', $tech[p_quickedit]);
- $table[] = array('<b>PERMISSION: edit quick responses</b><br />Can your technician add, edit, delete, and categorize quick responses?', $bit);
- $bit = form_radio_yn('p_html_tech', '', $tech[p_html_tech]);
- $table[] = array('<b>PERMISSION: can use unquoted HTML for techs</b><br />Is unquoted HTML submitted by this technician for objects viewed by other technicians allowed?', $bit);
- $bit = form_radio_yn('p_html_user', '', $tech[p_html_user]);
- $table[] = array('<b>PERMISSION: can use unquoted HTML for users</b><br />Is unquoted HTML submitted by this technician for objects viewed by users allowed?', $bit);
- $table[] = table_midheader('User Permissions');
- $bit = form_radio_yn('p_create_users', '', $tech[p_create_users]);
- $table[] = array('<b>PERMISSION: create Users</b><br />Can your technician create users?', $bit);
- $bit = form_radio_yn('p_edit_users', '', $tech[p_edit_users]);
- $table[] = array('<b>PERMISSION: edit user details</b><br />Can your technician edit the user fields set as editable in the user field settings?', $bit);
- $bit = form_radio_yn('p_delete_users', '', $tech[p_delete_users]);
- $table[] = array('<b>PERMISSION: delete users</b><br />Can your technician delete users?', $bit);
- $bit = form_radio_yn('p_approve_new_registrations', '', $tech[p_approve_new_registrations]);
- $table[] = array('<b>PERMISSION: approve new registrations</b><br />Can your technician approve new pending user registrations?', $bit);
- $bit = form_radio_yn('p_user_expire', '', $tech[p_user_expire]);
- $table[] = array('<b>PERMISSION: edit user expiration</b><br />Can your technician set and update user expirations?', $bit);
- $bit = form_radio_yn('p_global_note', '', $tech[p_global_note]);
- $table[] = array('<b>PERMISSION: edit global user notes</b><br />Can your technician create, edit, and delete global user notes that all technicians can see?', $bit);
- $table[] = table_midheader('Ticket Permissions');
- $bit = form_radio_yn('p_delete_own', '', $tech[p_delete_own]);
- $table[] = array('<b>PERMISSION: delete own tickets</b><br />Can your technician delete their own tickets?', $bit);
- $bit = form_radio_yn('p_delete_other', '', $tech[p_delete_other]);
- $table[] = array('<b>PERMISSION: delete techs tickets</b><br />Can your technician delete other techs tickets?', $bit);
- $bit = form_radio_yn('p_close_ticket', '', $tech[p_close_ticket]);
- $table[] = array('<b>PERMISSION: close and re-open tickets</b><br />Can your technician close and re-open tickets?', $bit);
- $bit = form_radio_yn('p_tech_view', '', $tech[p_tech_view]);
- $table[] = array('<b>PERMISSION: view techs tickets</b><br />Can your technician view other techs tickets?', $bit);
- $bit = form_radio_yn('p_tech_edit', '', $tech[p_tech_edit]);
- $table[] = array('<b>PERMISSION: edit techs tickets</b><br />Can your technician edit other techs tickets?', $bit);
- $table[] = table_midheader('FAQ Permissions');
-
- $bit = form_radio_yn('p_add_k', '', $tech[p_add_k]);
- $table[] = array('<b>PERMISSION: add to knowledgebase</b><br />Can your technician add entries to the knowledgebase?', $bit);
- $bit = form_radio_yn('p_edit_k', '', $tech[p_edit_k]);
- $table[] = array('<b>PERMISSION: edit knowledge base entry</b><br />Can your technician edit entries in the knowledgebase?', $bit);
- $bit = form_radio_yn('p_delete_k', '', $tech[p_delete_k]);
- $table[] = array('<b>PERMISSION: delete knowledgebase entry</b><br />Can your technician delete entries in the knowledgebase?', $bit);
- $bit = form_radio_yn('p_add_c_k', '', $tech[p_add_c_k]);
- $table[] = array('<b>PERMISSION: add knowledgebase category</b><br />Can your technician add new categories to the knowledgebase?', $bit);
- $bit = form_radio_yn('p_delete_c_k', '', $tech[p_delete_c_k]);
- $table[] = array('<b>PERMISSION: delete knowledgebase category</b><br />Can your technician delete categories in the knowlegebase?', $bit);
- $bit = form_radio_yn('p_edit_c_k', '', $tech[p_edit_c_k]);
- $table[] = array('<b>PERMISSION: edit knowledgebase category</b><br />Can your technician edit categories in the knowlegebase?', $bit);
- if ($_REQUEST['do'] == "add2" OR $_REQUEST['do'] == "redo") {
-
- table_header('Your new technician', 'tech.php', array('do' => 'submit'));
- table_content('', $table);
- table_footer('Create Technician');
- unset($table);
- } else {
- table_header('Edit your technician', 'tech.php', array('do' => 'update', 'id' => $tech[id]));
- table_content('', $table);
- table_footer('Update Technician');
- unset($table);
- }
- }
- ############################### DELETE TECH ###############################
- if ($_REQUEST['do'] == "delete") {
- if ($id != $user['id']) {
- $db->query("DELETE FROM tech WHERE id = '$id'");
- $db->query("DELETE FROM tech_attachments WHERE techid = '$id'");
- $db->query("DELETE FROM tech_bookmarks WHERE techid = '$id'");
- $db->query("DELETE FROM tech_email WHERE techid = '$id'");
- $db->query("DELETE FROM tech_notes WHERE techid = '$id'");
- $db->query("DELETE FROM tech_session WHERE techid = '$id'");
- $db->query("DELETE FROM tech_start_tickets WHERE techid = '$id'");
- $db->query("DELETE FROM tech_ticket_save WHERE techid = '$id'");
- $db->query("DELETE FROM tech_ticket_watch WHERE techid = '$id'");
- $db->query("DELETE FROM tech_timelog WHERE techid = '$id'");
- $db->query("DELETE FROM calendar_task_tech WHERE techid = '$id'");
- $db->query("SELECT id FROM ticket WHERE tech = '$id'");
- while ($logs = $db->row_array()) { // Add entries to ticket logs for each affected ticket
- ticketlog($logs[id], 'tech', $id, 0);
- }
- $db->query("UPDATE ticket SET tech = '0' WHERE tech = '$id'");
- jump('tech.php', 'Tech Deleted');
-
- } else {
- mistake("You cannot delete your own account!");
- }
- }
- ############################### DISABLE TECH ###############################
- if ($_REQUEST['do'] == "disable") {
- if ($id != $user['id']) {
- $db->query("SELECT id FROM ticket WHERE tech = '$id'");
- while ($logs = $db->row_array()) { // Add entries to ticket logs for each affected ticket
- ticketlog($logs[id], 12, $id, 0);
- }
- $db->query("UPDATE ticket SET tech = '0' WHERE tech = '$id'");
- $db->query("UPDATE tech SET disabled = '1' WHERE id = '$id'");
- jump('tech.php', 'Tech Disabled');
- } else {
- mistake('You cannot disable your own account!');
- }
- }
- ############################### ENABLE TECH ###############################
- if ($_REQUEST['do'] == "enable") {
- $db->query("UPDATE tech SET disabled = '0' WHERE id = '$id'");
- jump('tech.php', 'Tech Enabled');
- }
- ############################### VIEW TECHS ###############################
-
- if ($_REQUEST['do'] == "view") {
- admin_header('Technicians', 'View Technicians');
-
- $db->query("SELECT id, disabled, username, cats_admin from tech");
- while ($tech = $db->row_array()) {
- // check current category restrictions
- if (strlen($tech[cats_admin])) {
- $pbit = "Category restrictions <font color="red">enabled</font>";
- } else {
- $pbit = "No Category restrictions";
- }
-
- $table[] = array(
- iff($tech[disabled], "<b>DISABLED</b> <i><a href="tech.php?do=edit&id=$tech[id]">" . $tech[username] . "</a></i>", "<b><a href="tech.php?do=edit&id=$tech[id]">" . $tech[username] . "</a></b>"),
- "$pbit - <a href="tech.php?do=cats&id=$tech[id]"><b>Edit</b></a>",
- "<a href="tech.php?do=edit&id=$tech[id]">Edit</a>",
- iff($tech[disabled],
- jprompt("Re-enable technician $tech[username]",
- "tech.php?do=enable&id=$tech[id]",
- 'Enable',
- 1),
- jprompt("Confirm disabling of technician $tech[username]\nThe technician's tickets will be set as unassigned.",
- "tech.php?do=disable&id=$tech[id]",
- 'Disable',
- 1)
- ),
- jprompt("Confirm deletion of technician $tech[username]\nThe technician's tickets will be set as unassigned\nDeleting a technician (instead of disabling) will result in loss of information\nin reports and in the ticket log. Where ever possible, disable the technician instead.",
- "tech.php?do=delete&id=$tech[id]",
- 'Delete',
- 1)
- );
- }
- $table[] = array('<CENTER><A HREF="tech.php?do=add">Add a Technician</A></center>');
- $cols = array('Technician's Name', 'Edit Category Permissions', 'Edit', 'Disable', 'Delete');
- table_header('Edit your technician');
- table_content($cols, $table);
- table_footer();
- }
- ############################### VIEW TECHS ###############################
- if ($_REQUEST['do'] == "cats") {
- admin_header('Technicians', 'Technician Categories');
- $tech = $db->query_return("SELECT cats_admin FROM tech WHERE id = '$id'");
- $restrictions = explode(',', $tech[cats_admin]);
- $table[] = array('<b>No Category Specified</b>', form_radio_yn(0, 'categories', in_array('0', $restrictions)));
-
- $db->query("SELECT id, name FROM ticket_cat");
- while ($result = $db->row_array()) {
- $table[] = array('<b>' .$result[name] . '</b>', form_radio_yn($result[id], 'categories', in_array($result[id], $restrictions)));
- }
- $cols = array('Category Name', 'Select YES to disable tech's access to this category');
- table_header('Update Category Access', 'tech.php', array('do' => 'cats2', 'id' => $id));
- table_content($cols, $table);
- table_footer('Update Category Access');
- }
- ############################### VIEW TECHS ###############################
- if ($_REQUEST['do'] == "cats2") {
- foreach ($_REQUEST['categories'] AS $key => $var) {
- if ($var == '1') {
- $disabled .= $key . ',';
- }
- }
- $disabled = substr($disabled, 0, -1);
-
- $db->query("UPDATE tech SET cats_admin = '$disabled' WHERE id = '$id'");
- jump('tech.php', 'Selected categories disabled to this technician');
- }