/**
  * Marks an issue as closed.
  *
  * @access  public
  * @param   resource $rpc_conn The connection resource
  * @param   array $auth Array of authentication information (email, password)
  * @param   integer $issue_id The issue ID
  */
 function closeIssue($rpc_conn, $auth, $issue_id)
 {
     $details = Command_Line::checkIssuePermissions(&$rpc_conn, $auth, $issue_id);
     Command_Line::checkIssueAssignment(&$rpc_conn, $auth, $issue_id);
     // prompt for status selection (accept abbreviations)
     $new_status = Command_Line::promptStatusSelection(&$rpc_conn, $auth, $details['iss_prj_id']);
     // check if the issue already is set to the new status
     if (strtolower($details['sta_title']) == strtolower($new_status) || strtolower($details['sta_abbreviation']) == strtolower($new_status)) {
         Command_Line::quit("Issue #{$issue_id} is already set to status '" . $details['sta_title'] . "'");
     }
     // prompt for status selection (accept abbreviations)
     $resolution_id = Command_Line::promptResolutionSelection(&$rpc_conn);
     // ask whether to send a notification email about this action or not (defaults to yes)
     $msg = "Would you like to send a notification email about this issue being closed? [y/n]";
     $ret = Misc::prompt($msg, false);
     if (strtolower($ret) == 'y') {
         $send_notification = true;
     } else {
         $send_notification = false;
     }
     // prompt for internal note
     $prompt = "Please enter a reason for closing this issue (one line only)";
     $note = Misc::prompt($prompt, false);
     $params = array(new XML_RPC_Value($auth[0], 'string'), new XML_RPC_Value($auth[1], 'string'), new XML_RPC_Value($issue_id, 'int'), new XML_RPC_Value($new_status), new XML_RPC_Value($resolution_id, 'int'), new XML_RPC_Value($send_notification, 'boolean'), new XML_RPC_Value($note));
     $msg = new XML_RPC_Message("closeIssue", $params);
     $result = $rpc_conn->send($msg);
     if ($result->faultCode()) {
         Command_Line::quit($result->faultString());
     }
     echo "OK - Issue #{$issue_id} successfully closed.\n";
     if (XML_RPC_decode($result->value()) == 'INCIDENT') {
         echo "WARNING: This customer has incidents. Please redeem incidents by running 'eventum {$issue_id} redeem'\n";
     }
 }