Esempio n. 1
0
function EditDepartmentServer()
{
    if (isset($_GET['id'])) {
        $id = intval($_GET['id']);
    } else {
        redirect_header(XHELP_ADMIN_URL . "/department.php?op=manageDepartments", 3);
        // TODO: Make message for no mbox_id
    }
    $hDeptServers =& xhelpGetHandler('departmentMailBox');
    $deptServer =& $hDeptServers->get($id);
    if (isset($_POST['updateMailbox'])) {
        $deptServer->setVar('emailaddress', $_POST['emailaddress']);
        $deptServer->setVar('server', $_POST['server']);
        $deptServer->setVar('serverport', $_POST['port']);
        $deptServer->setVar('username', $_POST['username']);
        $deptServer->setVar('password', $_POST['password']);
        $deptServer->setVar('priority', $_POST['priority']);
        $deptServer->setVar('active', $_POST['activity']);
        if ($hDeptServers->insert($deptServer)) {
            header("Location: " . XHELP_ADMIN_URL . "/department.php?op=editDepartment&deptid=" . $deptServer->getVar('departmentid'));
        } else {
            redirect_header(XHELP_ADMIN_URL . "/department.php?op=editDepartment&deptid=" . $deptServer->getVar('departmentid'), 3);
        }
    } else {
        global $oAdminButton;
        xoops_cp_header();
        echo $oAdminButton->renderButtons('manDept');
        echo '<script type="text/javascript" src="' . XOOPS_URL . '/modules/xhelp/include/functions.js"></script>';
        echo "<form method='post' id='edit_server' action='department.php?op=EditDepartmentServer&amp;id=" . $id . "'>\r\n               <table width='100%' cellspacing='1' class='outer'>\r\n                 <tr>\r\n                   <th colspan='2'><label>" . _AM_XHELP_DEPARTMENT_EDIT_SERVER . "</label></th>\r\n                 </tr>\r\n                 <tr>\r\n                   <td class='head' width='20%'><label for='mboxtype'>" . _AM_XHELP_DEPARTMENT_SERVERS_TYPE . "</label></td>\r\n                   <td class='even'>\r\n                     <select name='mboxtype' id='mboxtype' onchange='xhelpPortOnChange(this.options[this.selectedIndex].text, \"txtPort\")'>\r\n                       <option value='" . _XHELP_MAILBOXTYPE_POP3 . "'>" . _AM_XHELP_MBOX_POP3 . "</option>\r\n                       <!--<option value='" . _XHELP_MAILBOXTYPE_IMAP . "'>" . _AM_XHELP_MBOX_IMAP . "</option>-->\r\n                     </select>\r\n                   </td>\r\n                 </tr>\r\n                 <tr>\r\n                   <td class='head'><label for='txtServer'>" . _AM_XHELP_DEPARTMENT_SERVERS_SERVERNAME . "</label></td>\r\n                   <td class='even'><input type='text' id='txtServer' name='server' value='" . $deptServer->getVar('server') . "' size='40' maxlength='50' />\r\n                 </tr>\r\n                 <tr>\r\n                   <td class='head'><label for='txtPort'>" . _AM_XHELP_DEPARTMENT_SERVERS_PORT . "</label></td>\r\n                   <td class='even'><input type='text' id='txtPort' name='port' maxlength='5' size='5' value='" . $deptServer->getVar('serverport') . "' />\r\n                 </tr>\r\n                 <tr>\r\n                   <td class='head'><label for='txtUsername'>" . _AM_XHELP_DEPARTMENT_SERVER_USERNAME . "</label></td>\r\n                   <td class='even'><input type='text' id='txtUsername' name='username' value='" . $deptServer->getVar('username') . "' size='25' maxlength='50' />\r\n                 </tr>\r\n                 <tr>\r\n                   <td class='head'><label for='txtPassword'>" . _AM_XHELP_DEPARTMENT_SERVER_PASSWORD . "</label></td>\r\n                   <td class='even'><input type='text' id='txtPassword' name='password' value='" . $deptServer->getVar('password') . "' size='25' maxlength='50' />\r\n                 </tr>\r\n                 <tr>\r\n                   <td width='38%' class='head'><label for='txtPriority'>" . _AM_XHELP_DEPARTMENT_SERVERS_PRIORITY . "</label></td>\r\n                   <td width='62%' class='even'>";
        for ($i = 1; $i < 6; $i++) {
            $checked = '';
            if ($deptServer->getVar('priority') == $i) {
                $checked = 'checked="checked"';
            }
            echo "<input type=\"radio\" value=\"{$i}\" id=\"priority{$i}\" name=\"priority\" {$checked} />";
            echo "<label for=\"priority{$i}\"><img src=\"../images/priority{$i}.png\" title=\"" . xhelpGetPriority($i) . "\" alt=\"priority{$i}\" /></label>";
        }
        echo "</td>\r\n                 </tr>\r\n                 <tr>\r\n                   <td class='head'><label for='txtEmailaddress'>" . _AM_XHELP_DEPARTMENT_SERVER_EMAILADDRESS . "</label></td>\r\n                   <td class='even'><input type='text' id='txtEmailaddress' name='emailaddress' value='" . $deptServer->getVar('emailaddress') . "' size='50' maxlength='255' />\r\n                 </tr>\r\n                 <tr>\r\n                   <td class='head'><label for='txtActive'>" . _AM_XHELP_TEXT_ACTIVITY . "</label></td>\r\n                   <td class='even'>";
        if ($deptServer->getVar('active') == 1) {
            echo "<input type='radio' value='1' name='activity' checked='checked' />" . _AM_XHELP_TEXT_ACTIVE . "\r\n                                      <input type='radio' value='0' name='activity' />" . _AM_XHELP_TEXT_INACTIVE;
        } else {
            echo "<input type='radio' value='1' name='activity' />" . _AM_XHELP_TEXT_ACTIVE . "\r\n                                      <input type='radio' value='0' name='activity' checked='checked' />" . _AM_XHELP_TEXT_INACTIVE;
        }
        echo "</td>\r\n                 </tr>\r\n\r\n                 <tr class='foot'>\r\n                   <td colspan='2'><div align='right'><span >\r\n                       <input type='button' id='email_test' name='test' value='" . _AM_XHELP_BUTTON_TEST . "' class='formButton' />\r\n                       <input type='submit' name='updateMailbox' value='" . _AM_XHELP_BUTTON_SUBMIT . "' class='formButton' />\r\n                       <input type='button' name='cancel' value='" . _AM_XHELP_BUTTON_CANCEL . "' onclick='history.go(-1)' class='formButton' />\r\n                   </span></div></td>\r\n                 </tr>\r\n               </table>\r\n             </form>";
        echo "<script type=\"text/javascript\" language=\"javascript\">\r\n          <!--\r\n          function xhelpEmailTest()\r\n          {\r\n            pop = openWithSelfMain(\"\", \"email_test\", 250, 150);\r\n            frm = xoopsGetElementById(\"edit_server\");\r\n            newaction = \"department.php?op=testMailbox\";\r\n            oldaction = frm.action;\r\n            frm.action = newaction;\r\n            frm.target = \"email_test\";\r\n            frm.submit();\r\n            frm.action = oldaction;\r\n            frm.target = \"main\";\r\n\r\n          }\r\n\r\n          xhelpDOMAddEvent(xoopsGetElementById(\"email_test\"), \"click\", xhelpEmailTest, false);\r\n\r\n          //-->\r\n          </script>";
        xhelpAdminFooter();
        xoops_cp_footer();
    }
}
 /**
  * Event: batch_delete_ticket
  * Triggered after a batch ticket deletion
  * @param array $tickets The xhelpTicket objects that were deleted
  */
 function batch_delete_ticket($tickets)
 {
     //notify staff department
     //notify submitter (if ticket is not closed)
     global $xoopsUser, $xoopsModule;
     $uname = $xoopsUser->getVar('uname');
     $uid = $xoopsUser->getVar('uid');
     $hStaff =& xhelpGetHandler('staff');
     $isStaff = $hStaff->isStaff($uid);
     $hDepartments =& xhelpGetHandler('department');
     $settings =& $this->_hNotification->get(XHELP_NOTIF_DELTICKET);
     $staff_setting = $settings->getVar('staff_setting');
     $user_setting = $settings->getVar('user_setting');
     if ($staff_setting != XHELP_NOTIF_STAFF_NONE) {
         $dept_email_tpl = $this->_getEmailTpl('dept', 'removed_ticket', $this->_module, $template_id);
     } else {
         $dept_email_tpl = false;
     }
     if ($user_setting != XHELP_NOTIF_USER_NO) {
         $user_email_tpl = $this->_getEmailTpl('ticket', 'removed_this_ticket', $this->_module, $template_id);
     } else {
         $user_email_tpl = false;
     }
     foreach ($tickets as $ticket) {
         $tags = array();
         $tags['TICKET_ID'] = $ticket->getVar('id');
         $tags['TICKET_SUBJECT'] = $this->_ts->stripslashesGPC($ticket->getVar('subject', 'n'));
         $tags['TICKET_DESCRIPTION'] = $this->_ts->stripslashesGPC($ticket->getVar('description', 'n'));
         $tags['TICKET_PRIORITY'] = xhelpGetPriority($ticket->getVar('priority'));
         $tags['TICKET_STATUS'] = xhelpGetStatus($ticket->getVar('status'));
         $tags['TICKET_POSTED'] = $ticket->posted();
         $tags['TICKET_DELETEDBY'] = $uname;
         $tags['TICKET_DEPARTMENT'] = $this->_ts->stripslashesGPC($hDepartments->getNameById($ticket->getVar('department')));
         if ($dept_email_tpl) {
             $sendTo =& $this->_getSubscribedStaff($ticket, $dept_email_tpl['bit_value'], $settings);
             $success = $this->_sendEvents($dept_email_tpl, $sendTo, $tags);
         }
         if ($user_email_tpl) {
             $status =& $this->_hStatus->get($ticket->getVar('status'));
             if (!$isStaff && $status->getVar('state') != 2 || $isStaff) {
                 // Send to ticket submitter
                 //$sendTo = $this->_getEmail($ticket->getVar('uid'));
                 $sendTo = $this->_getSubscribedUsers($ticket->getVar('id'));
                 $success = $this->_sendEvents($user_email_tpl, $sendTo, $tags);
             }
         }
     }
     return true;
 }