email.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:11k
- <?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: email.php,v $
- // | $Date: 2004/02/10 01:34:30 $
- // | $Revision: 1.18 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Technician e-mail notification preferences.
- // +-------------------------------------------------------------+
- error_reporting(E_ALL ^ E_NOTICE);
- include "./../global.php";
- tech_nav('settings');
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- ############################### UPDATE CATEGORIES ###############################
- if ($_REQUEST['do'] == "update") {
- $db->query("DELETE FROM tech_email WHERE techid = '$user[id]'");
- if (!(validate_email($_REQUEST[email]))) {
- unset($_REQUEST[email]);
- }
- if (!(validate_email($_REQUEST[sms]))) {
- unset($_REQUEST[sms]);
- }
- $db->query("UPDATE tech SET " .
- iff($_REQUEST[email], " email = '$_REQUEST[email]',") .
- iff($_REQUEST[sms], " sms = '$_REQUEST[sms]',") .
- " sms = '" . mysql_escape_string($_REQUEST[sms]) . "',
- email_new_email = '$_REQUEST[email_new_email]',
- email_new_sms = '$_REQUEST[email_new_sms]',
- email_reply_email = '$_REQUEST[email_reply_email]',
- email_reply_sms = '$_REQUEST[email_reply_sms]',
- email_own_email = '$_REQUEST[email_own_email]',
- email_own_sms = '$_REQUEST[email_own_sms]',
- email_pm = '$_REQUEST[email_pm]',
- email_assigned = '$_REQUEST[email_assigned]',
- email_attachments = '$_REQUEST[email_attachments]',
- email_own_attachments = '$_REQUEST[email_own_attachments]',
- email_faq = '$_REQUEST[email_faq]'
- WHERE id = '$user[id]'
- ");
- $db->query("DELETE FROM tech_email WHERE techid = '$user[id]'");
- // format for query: userid, fieldname, value, newreply, newticket, email, sms
- // new tickets by category
- if (is_array($_REQUEST[new_cat])) {
- foreach($_REQUEST[new_cat] AS $key => $var) {
- if ($var[email]) {
- $data[] = array($user[id],'category',$key,0,1,1,0);
- }
- if ($var[sms]) {
- $data[] = array($user[id],'category',$key,0,1,0,1);
- }
- }
- }
- // replies by category
- if (is_array($_REQUEST[reply_cat])) {
- foreach($_REQUEST[reply_cat] AS $key => $var) {
- if ($var[email]) {
- $data[] = array($user[id],'category',$key,1,0,1,0);
- }
- if ($var[sms]) {
- $data[] = array($user[id],'category',$key,1,0,0,1);
- }
- }
- }
- // new tickets by priority
- if (is_array($_REQUEST[new_pri])) {
- foreach($_REQUEST[new_pri] AS $key => $var) {
- if ($var[email]) {
- $data[] = array($user[id],'priority',$key,0,1,1,0);
- }
- if ($var[sms]) {
- $data[] = array($user[id],'priority',$key,0,1,0,1);
- }
- }
- }
- // replies by priority
- if (is_array($_REQUEST[reply_pri])) {
- foreach($_REQUEST[reply_pri] AS $key => $var) {
- if ($var[email]) {
- $data[] = array($user[id],'priority',$key,1,0,1,0);
- }
- if ($var[sms]) {
- $data[] = array($user[id],'priority',$key,1,0,0,1);
- }
- }
- }
- if (is_array($data)) {
- $db->query(" INSERT INTO tech_email
- (techid, fieldname, value, newreply, newticket, email, sms)
- VALUES " . insertsql($data) . "
- ");
- }
- jump('email.php', 'Your options have been updated');
- }
- ############################### VIEW SETTINGS ###############################
- if ($_REQUEST['do'] == "view") {
- echo "<form method="post" action="email.php">" . form_hidden('do', 'update');
- $table[] = array(table_thelp('<b>Your e-mail address</b>', 'Settings', 'E-mail: Your E-mail Addresses'), form_input('email', $user[email]));
- $table[] = array(table_thelp('<b>SMS e-mail address</b>', 'Settings', 'E-mail: Your E-mail Addresses'), form_input('sms', $user[sms]));
- table_header('Update your settings');
- table_content('', $table);
- table_footer();
- unset($table);
- $table[] = array(table_thelp('<b>Notify me when I'm assigned a ticket</b>', 'Settings', 'E-mail: General Notifications'), form_radio_yn('email_assigned', '', $user[email_assigned]));
- $table[] = array(table_thelp('<b>Notify me when I am sent a private message</b>', 'Settings', 'E-mail: General Notifications'), form_radio_yn('email_pm', '', $user[email_pm]));
- $table[] = array(table_thelp('<b>Notify me when a new faq article is submitted</b>', 'Settings', 'E-mail: General Notifications'), form_radio_yn('email_faq', '', $user[email_faq]));
- $table[] = array(table_thelp('<b>Send user uploaded attachments for all notifications</b>', 'Settings', 'E-mail: General Notifications'), form_radio_yn('email_attachments', '', $user[email_attachments]));
- $table[] = array(table_thelp('<b>Send user uploaded attachments when I am the ticket owner</b>', 'Settings', 'E-mail: General Notifications'), form_radio_yn('email_own_attachments', '', $user[email_own_attachments]));
- $cols = array('Setting', 'Option');
- table_header('General Notifications');
- table_content($cols, $table);
- table_footer();
- unset($table);
- // get current data
- $new_email_cat = array();
- $new_sms_cat = array();
- $reply_email_cat = array();
- $reply_sms_cat = array();
- $new_email_pri = array();
- $new_sms_pri = array();
- $reply_email_pri = array();
- $reply_sms_pri = array();
- $db->query("SELECT * FROM tech_email WHERE techid = '$user[id]'");
- while ($result = $db->row_array()) {
- if ($result[fieldname] == 'category') {
- if ($result[newticket]) {
- if ($result[email]) {
- $new_email_cat[] = $result[value];
- }
- if ($result[sms]) {
- $new_sms_cat[] = $result[value];
- }
- } elseif ($result[newreply]) {
- if ($result[email]) {
- $reply_email_cat[] = $result[value];
- }
- if ($result[sms]) {
- $reply_sms_cat[] = $result[value];
- }
- }
- } elseif ($result[fieldname] == 'priority') {
- if ($result[newticket]) {
- if ($result[email]) {
- $new_email_pri[] = $result[value];
- }
- if ($result[sms]) {
- $new_sms_pri[] = $result[value];
- }
- } elseif ($result[newreply]) {
- if ($result[email]) {
- $reply_email_pri[] = $result[value];
- }
- if ($result[sms]) {
- $reply_sms_pri[] = $result[value];
- }
- }
- }
- }
- // mass subscribe
- $table[] = array(
- table_thelp("<B>All Tickets</B>", 'Settings', 'E-mail: Ticket Notifications'),
- "Email : " . form_checkbox_single('email_new_email', 1, $user[email_new_email]) .
- " SMS : " . form_checkbox_single('email_new_sms', 1, $user[email_new_sms]),
-
- "Email : " . form_checkbox_single('email_reply_email', 1, $user[email_reply_email]) .
- " SMS : " . form_checkbox_single('email_reply_sms', 1, $user[email_reply_sms])
- );
- $table[] = array(
- table_thelp("<B>Tickets You Own</B>", 'Settings', 'E-mail: Ticket Notifications'),
- '',
- "Email : " . form_checkbox_single('email_own_email', 1, $user[email_own_email]) .
- " SMS : " . form_checkbox_single('email_own_sms', 1, $user[email_own_sms])
- );
- // category settings
- $table[] = table_midheader('Control Notifications by Category ' . thelp('Settings', 'E-mail: Category and Priority Notifications'));
-
- $cats_admin_tmp = split(',', $user['cats_admin']);
- if (!@in_array_value(0, $cats_admin_tmp)) {
- $table[] = array(
- "<B>No Category Specified</B>",
- "Email : " . form_checkbox_single('email', 1, iff(in_array(0, $new_email_cat), 1), 'new_cat[0]') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array(0, $new_sms_cat), 1), 'new_cat[0]'),
-
- "Email : " . form_checkbox_single('email', 1, iff(in_array(0, $reply_email_cat), 1), 'reply_cat[0]') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array(0, $reply_sms_cat), 1), 'reply_cat[0]')
- );
- }
- $db->query("SELECT * from ticket_cat" . iff($user[cats_admin], " WHERE id NOT IN ($user[cats_admin])"));
- while ($category = $db->row_array()) {
-
- $bit = form_radio_yn($category[id], 'category');
-
- $table[] = array(
- "<B>" . $category[name] . "</B>",
- "Email : " . form_checkbox_single('email', 1, iff(in_array_value($category[id], $new_email_cat), 1), 'new_cat[' . $category[id] . ']') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array_value($category[id], $new_sms_cat), 1), 'new_cat[' . $category[id] . ']'),
-
- "Email : " . form_checkbox_single('email', 1, iff(in_array_value($category[id], $reply_email_cat), 1), 'reply_cat[' . $category[id] . ']') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array_value($category[id], $reply_sms_cat), 1), 'reply_cat[' . $category[id] . ']')
- );
- }
- // priority settings
- $table[] = table_midheader('Control Notifications by Priority ' . thelp('Settings', 'E-mail: Category and Priority Notifications'));
-
- $table[] = array(
- "<B>No Priority Specified</B>",
- "Email : " . form_checkbox_single('email', 1, iff(in_array(0, $new_email_pri), 1), 'new_pri[0]') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array(0, $new_sms_pri), 1), 'new_pri[0]'),
-
- "Email : " . form_checkbox_single('email', 1, iff(in_array(0, $reply_email_pri), 1), 'reply_pri[0]') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array(0, $reply_sms_pri), 1), 'reply_pri[0]')
- );
- $db->query("SELECT * from ticket_pri");
- while ($priority = $db->row_array()) {
-
- $bit = form_radio_yn($priority[id], 'priority');
-
- $table[] = array(
- "<B>" . $priority[name] . "</B>",
- "Email : " . form_checkbox_single('email', 1, iff(in_array($priority[id], $new_email_pri), 1), 'new_pri[' . $priority[id] . ']') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array($priority[id], $new_sms_pri), 1), 'new_pri[' . $priority[id] . ']'),
-
- "Email : " . form_checkbox_single('email', 1, iff(in_array($priority[id], $reply_email_pri), 1), 'reply_pri[' . $priority[id] . ']') .
- " SMS : " . form_checkbox_single('sms', 1, iff(in_array($priority[id], $reply_sms_pri), 1), 'reply_pri[' . $priority[id] . ']')
- );
- }
- // ($name, $value, $checked='', $arrayto='') {
- $cols = array('Name', 'New Tickets', 'Ticket Replies');
- table_header('Ticket Email Notifications');
- table_content($cols, $table);
- table_footer('Update Your Email Settings');
- unset($table);
- }
- tech_footer();
- ?>