[CS-Project-svn_notify] SF.net SVN: cs-project:[932] trunk/1.2/includes/content/helpdesk
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-02-06 17:45:47
|
Revision: 932 http://cs-project.svn.sourceforge.net/cs-project/?rev=932&view=rev Author: crazedsanity Date: 2009-02-06 17:45:43 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Move $_POST actions into individual includes (except the "filter" action, for now). Modified Paths: -------------- trunk/1.2/includes/content/helpdesk/shared.inc trunk/1.2/includes/content/helpdesk/view.inc Added Paths: ----------- trunk/1.2/includes/content/helpdesk/create.inc Copied: trunk/1.2/includes/content/helpdesk/create.inc (from rev 930, trunk/1.2/includes/content/helpdesk/shared.inc) =================================================================== --- trunk/1.2/includes/content/helpdesk/create.inc (rev 0) +++ trunk/1.2/includes/content/helpdesk/create.inc 2009-02-06 17:45:43 UTC (rev 932) @@ -0,0 +1,63 @@ +<?php +/* + * SVN INFORMATION::: + * ------------------ + * Last Author: $Author:crazedsanity $ + * Current Revision: $Revision:637 $ + * Repository Location: $HeadURL:https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/includes/content/helpdesk.inc $ + * Last Updated: $Date:2007-11-20 11:04:33 -0600 (Tue, 20 Nov 2007) $ + */ + + +if($_POST) { + //CREATING NEW RECORD!!! + $dataArr = $_POST['data']; + $result = $proj->helpdeskObj->create_record($dataArr); + + if($result > 0) { + //TODO: implement email portion. + set_message_wrapper(array( + "title" => "Success", + "message" => "Helpdesk issue #". $result ." created successfully. You should receive an email confirmation shortly", + "type" => "notice" + )); + + //only go back to helpdesk if we're supposed to. + if($_SESSION['goBackLink']) { + $byPassUrlExtras = TRUE; + $baseUrl = $_SESSION['goBackLink']; + } + else { + $helpdeskId = $result; + $urlExtrasArr['ID'] = $result; + } + } + else { + //something bad happened. + set_message_wrapper(array( + "title" => "", + "message" => "", + "type" => "error" + )); + } + + //redirect them. + $url = "/content/helpdesk/view?ID=". $result; + if($_SESSION['goBackLink']) { + $url = $_SESSION['goBackLink']; + } + $page->gfObj->conditional_header($url); +} +else { + create_page_title($page, array('title' => "Create a Helpdesk Issue")); + $page->set_all_block_rows("content"); + + //show the "category" selection. + $categoryList = $proj->helpdeskObj->get_category_list('bug', TRUE); + $page->add_template_var("select_tags", $categoryList); + + // + $page->add_template_var("email", $_SESSION['email']); + $page->add_template_var("linked_proj", cleanString($_GET['proj']),"numeric"); +} +?> \ No newline at end of file Modified: trunk/1.2/includes/content/helpdesk/shared.inc =================================================================== --- trunk/1.2/includes/content/helpdesk/shared.inc 2009-02-06 17:14:54 UTC (rev 931) +++ trunk/1.2/includes/content/helpdesk/shared.inc 2009-02-06 17:45:43 UTC (rev 932) @@ -12,156 +12,8 @@ if($_POST) { $action = strtolower($_POST['action']); - $helpdeskId = $_POST['id']; - $baseUrl = "/content/helpdesk"; - $urlSection = "view"; - if(is_numeric($helpdeskId)) { - $urlExtrasArr = array( - "ID" => $helpdeskId - ); - } - $byPassUrlExtras = FALSE; if(strlen($action)) { - - if($action == "submit") { - $proj->helpdeskObj->db->beginTrans(); - - //SETUP THE MESSAGE THEY'LL SEE... - $setMessage = array( - "title" => "", - "message" => "... SET ME!!! ...", - "type" => "error" - ); - $success = false; - $remarks = array(); - - - $oldData = $proj->helpdeskObj->get_record($helpdeskId); - - - ################################# - # ---------> BEGIN "update" - ################################# - - - //if they've changed the name, we gotta log it. - //TODO: probably log this within helpdeskClass::update(). - if(isset($_POST['updates']['name']) && $oldData['name'] !== $_POST['updates']['name']) { - $remarks[] = array( - "remark" => 'Updated [b]name[/b] from ([b][i]'. $oldData['name'] .'[/i][/b])', - false - ); - } - - $doNotAcceptFields = array("solution", "remark"); - foreach($doNotAcceptFields as $unsetThis) { - unset($_POST['updates'][$unsetThis]); - } - $result = $proj->helpdeskObj->update_record($helpdeskId, $_POST['updates']); - - - //SET/UPDATE THE TYPE OF MESSAGE THAT WILL DISPLAY... - if($result == 1) { - $success = true; - $messageTitle[] = "Updated"; - $messageText[] = "Your issue was updated successfully."; - } - else { - #$setMessage['type'] = "error"; - $success = false; - } - - ################################# - # ---------> BEGIN "remark/solve" - ################################# - if($success === true && strlen($_POST['remark'])) { - //now check remark stuff. - $useRespondLink = FALSE; - if($_POST['isSolution']) { - //IT'S A SOLUTION - //solve it & make sure they know if it was good or not. - #$result = $proj->helpdeskObj->solve($helpdeskId, $_POST['solution']); - $remarks[] = array( - 'remark' => $_POST['remark'], - 'isSolution' => true - ); - $extra = NULL; - - if($result == 1 && $success === true) { - $messageTitle[] = "Solved"; - $messageText[] = "Your solution was logged, and the issue was updated accordingly. Confirmation emails have been sent."; - } - } - else { - //JUST A REMARK... - if($oldData['email'] != $_SESSION['email']) { - $useRespondLink = $proj->helpdeskObj->create_md5($helpdeskId); - } - $remarks[] = array( - 'remark' => $_POST['remark'], - 'isSolution' => false, - 'link' => $useRespondLink - ); - - if($result > 0) { - $success = true; - $messageTitle[] = "Remarked Upon"; - $messageText[] = "Your thoughts have been dually noted in the database... or at least singly. :D"; - } - }//end REMARK - } - - if($success) { - //TODO: this is where a queued email system would be good; if the first remark succeeds but the second fails, this will generate an erroneous email. - if(count($remarks)) { - foreach($remarks as $num=>$remarkData) { - $result = $proj->helpdeskObj->remark($helpdeskId, $remarkData['remark'], $remarkData['isSolution'], $remarkData['link']); - if($result <= 0) { - $success = false; - break; - } - } - } - - if($success === true) { - $proj->helpdeskObj->db->commitTrans(); - //format the message so it looks nice... - $setMessage['message'] = ""; - if(count($messageTitle) > 2) { - $lastMessage = array_pop($setMessage); - $setMessage['title'] = $page->gfObj->string_from_array($messageTitle, null, ", "); - $setMessage['title'] .= " and ". $lastMessage; - } - else { - $setMessage['title'] = $page->gfObj->string_from_array($messageTitle, null, " and "); - } - $setMessage['message'] = $page->gfObj->string_from_array($messageText, null, "<BR>\n"); - $setMessage['type'] = "status"; - } - else { - $proj->helpdeskObj->db->rollbackTrans(); - $setMessage = array( - 'title' => "Update FAILED", - 'message' => "The update would have worked, but you didn't put enough information into your remark.", - 'type' => "error" - ); - } - } - else { - $proj->helpdeskObj->db->rollbackTrans(); - $setMessage = array( - 'title' => "Update FAILED", - 'message' => "Update returned [". $result ."]. Last error was [". $proj->helpdeskObj->lastError ."]", - 'type' => "error" - ); - } - - #$page->gfObj->debug_print($_POST,1); - #$page->gfObj->debug_print($setMessage,1); - #exit; - $page->set_message_wrapper($setMessage); - } - elseif($action == "filter") { + if($action == "filter") { if($_POST['reset_filter']) { $page->ui->unset_cache("helpdesk/filter"); $result = "unset"; @@ -171,88 +23,10 @@ $page->ui->set_cache("helpdesk/filter", $_POST['filter']); $result = "set"; } - $byPassUrlExtras = TRUE; unset($extra); + $page->gfObj->conditional_header("/content/helpdesk"); } - elseif($action == "re-open") { - //we'll update some fields, then remark the old solution. - $oldData = $proj->helpdeskObj->get_record($helpdeskId); - $oldSolution = $oldData['solution']; - $updatesArr = array( - "status_id" => 6 - ); - - $updateRes = $proj->helpdeskObj->update_record($helpdeskId, $updatesArr); - - //make the old solution... better. - $oldSolution = "Re-opened."; - $remarkRes = $proj->helpdeskObj->remark($helpdeskId, $oldSolution); - - } - else { - exit("invalid action: [$action]"); - } - } elseif(isset($_POST['submit']) && count($_POST['data']) > 1) { - //CREATING NEW RECORD!!! - $dataArr = $_POST['data']; - $result = $proj->helpdeskObj->create_record($dataArr); - - if($result > 0) { - //TODO: implement email portion. - set_message_wrapper(array( - "title" => "Success", - "message" => "Helpdesk issue #". $result ." created successfully. You should receive an email confirmation shortly", - "type" => "notice" - )); - - //only go back to helpdesk if we're supposed to. - if($_SESSION['goBackLink']) { - $byPassUrlExtras = TRUE; - $baseUrl = $_SESSION['goBackLink']; - } - else { - $helpdeskId = $result; - $urlExtrasArr['ID'] = $result; - } - } - else { - //something bad happened. - set_message_wrapper(array( - "title" => "", - "message" => "", - "type" => "error" - )); - } } - - //build the redirection URL. - $url = $baseUrl; - - //don't bother redirecting to the "view" page if the ID isn't valid. - if(isset($_POST['xajax'])) { - //don't exit or anything here: let the AJAX stuff work itself out, I guess. - } - elseif(preg_match('/view/', $urlSection) && !is_numeric($urlExtrasArr['ID'])) { - unset($urlSection); - conditional_header('/content/helpdesk'); - exit; - } - else { - if(isset($urlSection) && !preg_match('/\?/', $url)) { - if(!preg_match('/$\//', $url)) { - $urlSection = "/". $urlSection; - } - $url .= $urlSection; - } - if(!$byPassUrlExtras && count($urlExtrasArr) > 0) { - $urlExtrasStr = string_from_array($urlExtrasArr, "url"); - if($urlExtrasStr !== 0) { - $url .= "?". $urlExtrasStr .'&random='. time(); - } - } - conditional_header($url); - exit; - } } Modified: trunk/1.2/includes/content/helpdesk/view.inc =================================================================== --- trunk/1.2/includes/content/helpdesk/view.inc 2009-02-06 17:14:54 UTC (rev 931) +++ trunk/1.2/includes/content/helpdesk/view.inc 2009-02-06 17:45:43 UTC (rev 932) @@ -9,7 +9,181 @@ */ - +if($_POST) { + $action = strtolower($_POST['action']); + $helpdeskId = $_POST['id']; + $baseUrl = "/content/helpdesk"; + $urlSection = "view"; + if(is_numeric($helpdeskId)) { + $urlExtrasArr = array( + "ID" => $helpdeskId + ); + } + $byPassUrlExtras = FALSE; + if(strlen($action)) { + + if($action == "submit") { + $proj->helpdeskObj->db->beginTrans(); + + //SETUP THE MESSAGE THEY'LL SEE... + $setMessage = array( + "title" => "", + "message" => "... SET ME!!! ...", + "type" => "error" + ); + $success = false; + $remarks = array(); + + + $oldData = $proj->helpdeskObj->get_record($helpdeskId); + + + ################################# + # ---------> BEGIN "update" + ################################# + + + //if they've changed the name, we gotta log it. + //TODO: probably log this within helpdeskClass::update(). + if(isset($_POST['updates']['name']) && $oldData['name'] !== $_POST['updates']['name']) { + $remarks[] = array( + "remark" => 'Updated [b]name[/b] from ([b][i]'. $oldData['name'] .'[/i][/b])', + false + ); + } + + $doNotAcceptFields = array("solution", "remark"); + foreach($doNotAcceptFields as $unsetThis) { + unset($_POST['updates'][$unsetThis]); + } + $result = $proj->helpdeskObj->update_record($helpdeskId, $_POST['updates']); + + + //SET/UPDATE THE TYPE OF MESSAGE THAT WILL DISPLAY... + if($result == 1) { + $success = true; + $messageTitle[] = "Updated"; + $messageText[] = "Your issue was updated successfully."; + } + else { + #$setMessage['type'] = "error"; + $success = false; + } + + ################################# + # ---------> BEGIN "remark/solve" + ################################# + if($success === true && strlen($_POST['remark'])) { + //now check remark stuff. + $useRespondLink = FALSE; + if($_POST['isSolution']) { + //IT'S A SOLUTION + //solve it & make sure they know if it was good or not. + #$result = $proj->helpdeskObj->solve($helpdeskId, $_POST['solution']); + $remarks[] = array( + 'remark' => $_POST['remark'], + 'isSolution' => true + ); + $extra = NULL; + + if($result == 1 && $success === true) { + $messageTitle[] = "Solved"; + $messageText[] = "Your solution was logged, and the issue was updated accordingly. Confirmation emails have been sent."; + } + } + else { + //JUST A REMARK... + if($oldData['email'] != $_SESSION['email']) { + $useRespondLink = $proj->helpdeskObj->create_md5($helpdeskId); + } + $remarks[] = array( + 'remark' => $_POST['remark'], + 'isSolution' => false, + 'link' => $useRespondLink + ); + + if($result > 0) { + $success = true; + $messageTitle[] = "Remarked Upon"; + $messageText[] = "Your thoughts have been dually noted in the database... or at least singly. :D"; + } + }//end REMARK + } + + if($success) { + //TODO: this is where a queued email system would be good; if the first remark succeeds but the second fails, this will generate an erroneous email. + if(count($remarks)) { + foreach($remarks as $num=>$remarkData) { + $result = $proj->helpdeskObj->remark($helpdeskId, $remarkData['remark'], $remarkData['isSolution'], $remarkData['link']); + if($result <= 0) { + $success = false; + break; + } + } + } + + if($success === true) { + $proj->helpdeskObj->db->commitTrans(); + //format the message so it looks nice... + $setMessage['message'] = ""; + if(count($messageTitle) > 2) { + $lastMessage = array_pop($setMessage); + $setMessage['title'] = $page->gfObj->string_from_array($messageTitle, null, ", "); + $setMessage['title'] .= " and ". $lastMessage; + } + else { + $setMessage['title'] = $page->gfObj->string_from_array($messageTitle, null, " and "); + } + $setMessage['message'] = $page->gfObj->string_from_array($messageText, null, "<BR>\n"); + $setMessage['type'] = "status"; + } + else { + $proj->helpdeskObj->db->rollbackTrans(); + $setMessage = array( + 'title' => "Update FAILED", + 'message' => "The update would have worked, but you didn't put enough information into your remark.", + 'type' => "error" + ); + } + } + else { + $proj->helpdeskObj->db->rollbackTrans(); + $setMessage = array( + 'title' => "Update FAILED", + 'message' => "Update returned [". $result ."]. Last error was [". $proj->helpdeskObj->lastError ."]", + 'type' => "error" + ); + } + + #$page->gfObj->debug_print($_POST,1); + #$page->gfObj->debug_print($setMessage,1); + #exit; + $page->set_message_wrapper($setMessage); + } + elseif($action == "re-open") { + //we'll update some fields, then remark the old solution. + $oldData = $proj->helpdeskObj->get_record($helpdeskId); + $oldSolution = $oldData['solution']; + $updatesArr = array( + "status_id" => 6 + ); + + $updateRes = $proj->helpdeskObj->update_record($helpdeskId, $updatesArr); + + //make the old solution... better. + $oldSolution = "Re-opened."; + $remarkRes = $proj->helpdeskObj->remark($helpdeskId, $oldSolution); + + } + else { + } + } + + if(!isset($_POST['xajax'])) { + $page->gfObj->conditional_header("/content/helpdesk/view?ID=". $helpdeskId); + } +} +else { $helpdeskId = $_GET['ID']; $action = $page->ftsSections[2]; @@ -211,7 +385,7 @@ $page->add_template_var('associatedUser_data', $parsedRow); } - +} //call the function to add AJAX stuff... addAjax(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |