コード例 #1
0
 public function addTicketReply()
 {
     $tID = (int) $_GET['id'];
     $array = array('no', $tID, '');
     $mergeID = isset($_POST['mergeid']) ? mswReverseTicketNumber($_POST['mergeid']) : '0';
     $newID = $mergeID > 0 ? $mergeID : $tID;
     // Are we merging this ticket..
     if ($mergeID > 0) {
         if (mswRowCount('tickets WHERE `id` = \'' . $mergeID . '\'') > 0) {
             // Get original ticket and convert it to a reply..
             $OTICKET = mswGetTableData('tickets', 'id', $tID);
             // Get new parent data for department..
             $MERGER = mswGetTableData('tickets', 'id', $mergeID);
             // Account information..
             $PORTAL = mswGetTableData('portal', 'id', $MERGER->visitorID);
             // Add original ticket as reply..
             mysql_query("INSERT INTO `" . DB_PREFIX . "replies` (\n      `ts`,\n      `ticketID`,\n      `comments`,\n      `replyType`,\n      `replyUser`,\n      `isMerged`,\n      `ipAddresses` \n      ) VALUES (\n      UNIX_TIMESTAMP(UTC_TIMESTAMP),\n      '{$mergeID}',\n      '" . mswSafeImportString($OTICKET->comments) . "',\n      'visitor',\n      '{$OTICKET->visitorID}',\n      'yes',\n      '{$OTICKET->ipAddresses}' \n      )") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
             // Now remove original ticket
             mysql_query("DELETE FROM `" . DB_PREFIX . "tickets` WHERE `id` = '{$tID}'") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
             // Move any replies attached to original ticket to new parent..
             // Update timestamp so they fall in line..
             mysql_query("UPDATE `" . DB_PREFIX . "replies` SET\n\t  `ts`              = UNIX_TIMESTAMP(UTC_TIMESTAMP),\n      `ticketID`        = '{$mergeID}',\n      `isMerged`        = 'yes'\n      WHERE `ticketID`  = '{$tID}'\n      ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
             // Move attachments to new ticket id..
             mysql_query("UPDATE `" . DB_PREFIX . "attachments` SET\n      `ticketID`        = '{$mergeID}',\n      `department`      = '{$MERGER->department}'\n      WHERE `ticketID`  = '{$tID}'\n      ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
             // Move custom field data to new ticket..
             mysql_query("UPDATE `" . DB_PREFIX . "ticketfields` SET\n      `ticketID`        = '{$mergeID}'\n      WHERE `ticketID`  = '{$tID}'\n      ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
             // Remove history for old ticket..
             mysql_query("DELETE FROM `" . DB_PREFIX . "tickethistory` WHERE `ticketID` = '{$tID}'") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
             // Move any dispute user data to new ticket..
             mysql_query("UPDATE `" . DB_PREFIX . "disputes` SET\n      `ticketID`        = '{$mergeID}'\n      WHERE `ticketID`  = '{$tID}'\n      ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
             // Overwrite array..
             $array = array('yes', $mergeID, $OTICKET->subject);
         }
     }
     // Add new reply..
     mysql_query("INSERT INTO `" . DB_PREFIX . "replies` (\n  `ts`,\n  `ticketID`,\n  `comments`,\n  `replyType`,\n  `replyUser`,\n  `isMerged`,\n  `ipAddresses` \n  ) VALUES (\n  UNIX_TIMESTAMP(UTC_TIMESTAMP),\n  '{$newID}',\n  '" . mswSafeImportString($_POST['comments']) . "',\n  'admin',\n  '{$this->team->id}',\n  'no',\n  '" . mswIPAddresses() . "' \n  )") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
     $newReply = mysql_insert_id();
     // Custom field data..
     if (!empty($_POST['customField'])) {
         // Check to see if any checkboxes arrays are now blank..
         // If there are, create empty array to prevent ommission in loop..
         if (!empty($_POST['hiddenBoxes'])) {
             foreach ($_POST['hiddenBoxes'] as $hb) {
                 if (!isset($_POST['customField'][$hb])) {
                     $_POST['customField'][$hb] = array();
                 }
             }
         }
         foreach ($_POST['customField'] as $k => $v) {
             $data = '';
             // If value is array, its checkboxes..
             if (is_array($v)) {
                 if (!empty($v)) {
                     $data = implode('#####', $v);
                 }
             } else {
                 $data = $v;
             }
             $k = (int) $k;
             // If data exists, update or add entry..
             // If blank or 'nothing-selected', delete if exists..
             if ($data != '' && $data != 'nothing-selected') {
                 if (mswRowCount('ticketfields WHERE `ticketID`  = \'' . $newID . '\' AND `fieldID` = \'' . $k . '\' AND `replyID` = \'' . $newReply . '\'') > 0) {
                     mysql_query("UPDATE `" . DB_PREFIX . "ticketfields` SET\n          `fieldData`       = '" . mswSafeImportString($data) . "'\n          WHERE `ticketID`  = '{$newID}'\n          AND `fieldID`     = '{$k}'\n          AND `replyID`     = '{$newReply}'\n          ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
                 } else {
                     mysql_query("INSERT INTO `" . DB_PREFIX . "ticketfields` (\n          `fieldData`,`ticketID`,`fieldID`,`replyID`\n          ) VALUES (\n          '" . mswSafeImportString($data) . "','{$newID}','{$k}','{$newReply}'\n          )") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
                 }
             } else {
                 mysql_query("DELETE FROM `" . DB_PREFIX . "ticketfields`\n        WHERE `ticketID`  = '{$newID}'\n        AND `fieldID`     = '{$k}'\n        AND `replyID`     = '{$newReply}'\n        ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
                 if (mswRowCount('ticketfields') == 0) {
                     @mysql_query("TRUNCATE TABLE `" . DB_PREFIX . "ticketfields`");
                 }
             }
         }
     }
     // Update ticket status..
     $status = in_array($_POST['status'], array('close', 'open', 'closed', 'submit_report')) ? $_POST['status'] : 'open';
     mysql_query("UPDATE `" . DB_PREFIX . "tickets` SET\n  `lastrevision`  = UNIX_TIMESTAMP(UTC_TIMESTAMP),\n  `ticketStatus`  = '{$status}',\n  `replyStatus`   = 'visitor'\n  WHERE `id`      = '{$newID}'\n  ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
     // If specified, add reply as standard response..
     if ($_POST['response']) {
         // Add response..
         $dept = empty($_POST['dept']) ? implode(',', $_POST['deptall']) : implode(',', $_POST['dept']);
         mysql_query("INSERT INTO `" . DB_PREFIX . "responses` (\n    `ts`,\n    `title`,\n    `answer`,\n    `departments`\n    ) VALUES (\n    UNIX_TIMESTAMP(UTC_TIMESTAMP),\n    '" . mswSafeImportString($_POST['response']) . "',\n    '" . mswSafeImportString($_POST['comments']) . "',\n    '" . mswSafeImportString($dept) . "'\n    )") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
         // Rebuild sequence..
         include_once PATH . 'control/classes/class.responses.php';
         $MSSTR = new standardResponses();
         $MSSTR->rebuildSequence();
     }
     $array[] = $newReply;
     return $array;
 }
コード例 #2
0
 public function deleteResponses()
 {
     if (!empty($_POST['del'])) {
         mysql_query("DELETE FROM `" . DB_PREFIX . "responses` \n    WHERE `id` IN(" . implode(',', $_POST['del']) . ") \n\t") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__));
         $rows = mysql_affected_rows();
         if (mswRowCount('responses') == 0) {
             @mysql_query("TRUNCATE TABLE `" . DB_PREFIX . "responses`");
         }
         // Rebuild sequence..
         standardResponses::rebuildSequence();
         return $rows;
     }
     return '0';
 }