[CS-Project-svn_notify] SF.net SVN: cs-project:[925] trunk/1.2
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-02-05 17:41:53
|
Revision: 925 http://cs-project.svn.sourceforge.net/cs-project/?rev=925&view=rev Author: crazedsanity Date: 2009-02-05 17:41:48 +0000 (Thu, 05 Feb 2009) Log Message: ----------- Partial implementation for single action button on issues (#99). NOTE: there are still some display issues to work out, but the code properly handles updates, remarks, solving, or any combination thereof. A future commit will fix the display issue (shows a remark box when the issue is solved). NOTE2: there is currently no handling of whether the person looking at the issue has any authority to do anything to it; I believe at one point only the owner could make modifications or solve it... this make come back in the future... /includes/content/helpdesk.inc: * "submit" action (for $_POST) handles updates, remarks, and solutions. * there was a segment involving change of ancestry, but it doesn't seem to have ever been called. * the updates, remarks, solving, etc all happen in a big transaction: if one part fails, the whole thing fails. Not sure about sending emails; that is probably out of the scope of this fix... * updated one comment so it's easier to tell what it is supposed to do. /templates/content/helpdesk/view.content.tmpl: * dropped the solution row * replaced the remark/modify/solve buttons with a single "submit" button. * added a checkbox for "isSolution". Modified Paths: -------------- trunk/1.2/includes/content/helpdesk.inc trunk/1.2/templates/content/helpdesk/view.content.tmpl Modified: trunk/1.2/includes/content/helpdesk.inc =================================================================== --- trunk/1.2/includes/content/helpdesk.inc 2009-02-05 16:36:30 UTC (rev 924) +++ trunk/1.2/includes/content/helpdesk.inc 2009-02-05 17:41:48 UTC (rev 925) @@ -22,23 +22,36 @@ ); } $byPassUrlExtras = FALSE; - if($action) { + if(strlen($action)) { - if($action == "modify") { - //update the ancestry... - $_POST['updates']['parentRecordId'] = $_POST['updates']['project_id']; - unset($_POST['updates']['project_id']); + 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'])) { - //retrieve the old info. - $oldData = $proj->helpdeskObj->get_record($_POST['id']); - - if($oldData['name'] !== $_POST['updates']['name']) { - $addRemark = 'Updated [b]name[/b] from ([b][i]'. $oldData['name'] .'[/i][/b])'; - } + 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"); @@ -47,72 +60,107 @@ } $result = $proj->helpdeskObj->update_record($helpdeskId, $_POST['updates']); - if(strlen($addRemark)) { - $proj->helpdeskObj->remark($_POST['id'], $addRemark); - } - - //tell them what happened. + //SET/UPDATE THE TYPE OF MESSAGE THAT WILL DISPLAY... if($result == 1) { - set_message_wrapper(array( - "title" => "Update Successful", - "message" => "Your issue was updated successfully.", - "type" => "status" - )); + $success = true; + $messageTitle[] = "Updated"; + $messageText[] = "Your issue was updated successfully."; } else { - set_message_wrapper(array( - "title" => "Update FAILURE", - "message" => "Update returned [$result]. Last error was [". $proj->helpdeskObj->lastError ."]", - "type" => "error" - )); + #$setMessage['type'] = "error"; + $success = false; } - $urlSection = "view"; - } - elseif($action == "remark") { - $helpdeskData = $proj->helpdeskObj->get_record($helpdeskId); - //only care about the remark data... if they changed something, well... they're stupid. - $useRespondLink = FALSE; - if($helpdeskData['email'] != $_SESSION['email']) { - $useRespondLink = $proj->helpdeskObj->create_md5($helpdeskId); - } - $result = $proj->helpdeskObj->remark($helpdeskId, $_POST['remark'], FALSE, $useRespondLink); - if($result > 0) { - set_message_wrapper(array( - "title" => "Remark Added Successfully", - "message" => "Your thoughts have been dually noted in the database... or at least singly. :D", - "type" => "status" - )); + ################################# + # ---------> 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 { - set_message_wrapper(array( - "title" => "Unable to Add Remark", - "message" => "Dually noted, summarily denied. Beotch.", - "type" => "error" - )); + $proj->helpdeskObj->db->rollbackTrans(); + $setMessage = array( + 'title' => "Update FAILED", + 'message' => "Update returned [". $result ."]. Last error was [". $proj->helpdeskObj->lastError ."]", + 'type' => "error" + ); } - } - elseif($action == "solve") { - //solve it & make sure they know if it was good or not. - $result = $proj->helpdeskObj->solve($helpdeskId, $_POST['solution']); - $extra = NULL; - if($result == 1) { - set_message_wrapper(array( - "title" => "Solved Successfully", - "message" => "Your solution was logged, and the issue was updated accordingly. Confirmation emails " . - "have been sent.", - "type" => "status" - )); - } - else { - set_message_wrapper(array( - "title" => "Unable to Solve", - "message" => "Try using a longer explanation... or check the error log.", - "type" => "error" - )); - } + #$page->gfObj->debug_print($_POST,1); + #$page->gfObj->debug_print($setMessage,1); + #exit; + $page->set_message_wrapper($setMessage); } elseif($action == "filter") { if($_POST['reset_filter']) { @@ -410,6 +458,7 @@ } else { + //DISPLAY ALL AVAILABLE HELPDESK ISSUES. //change the content of the page properly. $page->set_all_block_rows("content", array("helpdesk_search")); Modified: trunk/1.2/templates/content/helpdesk/view.content.tmpl =================================================================== --- trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-02-05 16:36:30 UTC (rev 924) +++ trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-02-05 17:41:48 UTC (rev 925) @@ -213,13 +213,6 @@ </td> </tr> <!-- END remark_row --> -<!-- BEGIN solution_row --> -<tr> - <td colspan="3">Solution: <br> - <textarea name="solution" rows="10" cols="80" {solution_readonly}></textarea> - </td> -</tr> -<!-- END solution_row --> <!-- BEGIN reopen_button --> <tr> <td> </td> @@ -228,21 +221,16 @@ <!-- END reopen_button --> <!-- BEGIN buttons_row --> <tr> - <td colspan="3"><i>(Changes only take effect when clicking "modify", while "solve" only cares about the solution field, and "remark" only cares about the remarks field.)</i></td> -</tr> -<tr> - <td colspan="3"> - <input name="action" value="Remark" type="submit"> -<!-- BEGIN update_button --> - <input name="action" value="Modify" type="submit"> -<!-- END update_button --> -<!-- BEGIN owner_options --> - <input name="action" value="solve" type="submit"> -<!-- END owner_options --> + <td colspan="3" align="center"> + <input name="action" value="Submit" type="submit"> <a href="/help/helpdesk/submit_buttons" target="_blank"> <img src="/images/icon-help.png" border="0"></a> + + <BR> + Is this a <b>Solution</b>? + <input name="isSolution" type="checkbox"> </td> </tr> <!-- END buttons_row --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |