Example #1
0
 /**
  * Method used to remotely set the status of a given issue.
  *
  * @param   integer $issue_id The issue ID
  * @param   integer $usr_id The user ID of the person performing this change
  * @param   integer $new_status The new status ID
  * @return  integer 1 if the update worked, -1 otherwise
  */
 public static function setRemoteStatus($issue_id, $usr_id, $new_status)
 {
     $sta_id = Status::getStatusID($new_status);
     $res = self::setStatus($issue_id, $sta_id);
     if ($res == 1) {
         // record history entry
         History::add($issue_id, $usr_id, 'remote_status_change', "Status remotely changed to '{status}' by {user}", array('status' => $new_status, 'user' => User::getFullName($usr_id)));
     }
     return $res;
 }
Example #2
0
 /**
  * Plot various stats charts
  *
  * @param string $plotType
  * @param bool $hide_closed
  * @return bool return false if no data is available
  */
 public function StatsChart($plotType, $hide_closed)
 {
     // don't bother if user has no access
     $prj_id = Auth::getCurrentProject();
     if (Auth::getCurrentRole() <= User::getRoleID('Reporter') && Project::getSegregateReporters($prj_id)) {
         return false;
     }
     $colors = array();
     switch ($plotType) {
         case 'status':
             $data = Stats::getAssocStatus($hide_closed);
             $graph_title = ev_gettext('Issues by Status');
             // use same colors as defined for statuses
             foreach ($data as $sta_title => $trash) {
                 $sta_id = Status::getStatusID($sta_title);
                 $status_details = Status::getDetails($sta_id);
                 $colors[] = $status_details['sta_color'];
             }
             break;
         case 'release':
             $data = Stats::getAssocRelease($hide_closed);
             $graph_title = ev_gettext('Issues by Release');
             break;
         case 'priority':
             $data = Stats::getAssocPriority($hide_closed);
             $graph_title = ev_gettext('Issues by Priority');
             break;
         case 'user':
             $data = Stats::getAssocUser($hide_closed);
             $graph_title = ev_gettext('Issues by Assignment');
             break;
         case 'category':
             $data = Stats::getAssocCategory($hide_closed);
             $graph_title = ev_gettext('Issues by Category');
             break;
         default:
             return false;
     }
     // check the values coming from the database and if they are all empty, then
     // output a pre-generated 'No Data Available' picture
     if (!Stats::hasData($data)) {
         return false;
     }
     $plot = $this->create(360, 200);
     $plot->SetImageBorderType('plain');
     $plot->SetTitle($graph_title);
     $plot->SetPlotType('pie');
     $plot->SetDataType('text-data-single');
     if ($colors) {
         $plot->SetDataColors($colors);
     }
     $legend = $dataValue = array();
     foreach ($data as $label => $count) {
         $legend[] = $label . ' (' . $count . ')';
         $dataValue[] = array($label, $count);
     }
     $plot->SetDataValues($dataValue);
     foreach ($legend as $label) {
         $plot->SetLegend($label);
     }
     return $plot->DrawGraph();
 }
Example #3
0
 /**
  * @param int $issue_id
  * @param string $new_status
  * @param int $resolution_id
  * @param bool $send_notification
  * @param string $note
  * @return string
  * @access protected
  */
 public function closeIssue($issue_id, $new_status, $resolution_id, $send_notification, $note)
 {
     $usr_id = Auth::getUserID();
     $status_id = Status::getStatusID($new_status);
     AuthCookie::setProjectCookie(Issue::getProjectID($issue_id));
     $res = Issue::close($usr_id, $issue_id, $send_notification, $resolution_id, $status_id, $note);
     if ($res == -1) {
         throw new RemoteApiException("Could not close issue #{$issue_id}");
     }
     $prj_id = Issue::getProjectID($issue_id);
     if (CRM::hasCustomerIntegration($prj_id)) {
         $crm = CRM::getInstance($prj_id);
         try {
             $contract = $crm->getContract(Issue::getContractID($issue_id));
             if ($contract->hasPerIncident()) {
                 return 'INCIDENT';
             }
         } catch (CRMException $e) {
         }
     }
     return 'OK';
 }
Example #4
0
function closeIssue($p)
{
    $email = XML_RPC_decode($p->getParam(0));
    $password = XML_RPC_decode($p->getParam(1));
    $auth = authenticate($email, $password);
    if (is_object($auth)) {
        return $auth;
    }
    $usr_id = User::getUserIDByEmail($email);
    $issue_id = XML_RPC_decode($p->getParam(2));
    $new_status = XML_RPC_decode($p->getParam(3));
    $status_id = Status::getStatusID($new_status);
    $resolution_id = XML_RPC_decode($p->getParam(4));
    $send_notification = XML_RPC_decode($p->getParam(5));
    $note = XML_RPC_decode($p->getParam(6));
    createFakeCookie($email, Issue::getProjectID($issue_id));
    $res = Issue::close($usr_id, $issue_id, $send_notification, $resolution_id, $status_id, $note);
    if ($res == -1) {
        return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "Could not close issue #{$issue_id}");
    } else {
        $prj_id = Issue::getProjectID($issue_id);
        if (Customer::hasCustomerIntegration($prj_id) && Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($issue_id))) {
            return new XML_RPC_Response(XML_RPC_Encode('INCIDENT'));
        } else {
            return new XML_RPC_Response(XML_RPC_Encode('OK'));
        }
    }
}
Example #5
0
 /**
  * Method used to remotely set the status of a given issue.
  *
  * @access  public
  * @param   integer $issue_id The issue ID
  * @param   integer $usr_id The user ID of the person performing this change
  * @param   integer $new_status The new status ID
  * @return  integer 1 if the update worked, -1 otherwise
  */
 function setRemoteStatus($issue_id, $usr_id, $new_status)
 {
     $sta_id = Status::getStatusID($new_status);
     $res = Issue::setStatus($issue_id, $sta_id);
     if ($res == 1) {
         // record history entry
         History::add($issue_id, $usr_id, History::getTypeID('remote_status_change'), "Status remotely changed to '{$new_status}' by " . User::getFullName($usr_id));
     }
     return $res;
 }
Example #6
0
include_once APP_INC_PATH . "class.issue.php";
include_once APP_INC_PATH . "class.status.php";
include_once APP_INC_PATH . "class.notification.php";
include_once APP_INC_PATH . "class.note.php";
include_once APP_INC_PATH . "db_access.php";
$day_limit = 4;
$sql = "SELECT \n\t\t\tiss_id,iss_prj_id\n\t\tFROM \n\t\t\t`ev_issue` \n\t\t\tleft join ev_status on sta_id = `iss_sta_id` \n\t\twhere \n\t\t\tsta_is_closed = 0 \n\t\t\tand `iss_control_status` = 'Answered' \n\t\t\tand iss_last_response_date < subdate(now(),interval {$day_limit} day);\n\t\t";
$issues = $GLOBALS["db_api"]->dbh->getAll($sql);
$closed_id = Status::getStatusID('Closed');
$c = 0;
$k = 0;
foreach ($issues as $issue) {
    $res = Issue::setStatus($issue[0], $closed_id);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], 0, History::getTypeID('status_changed'), "Issue automatically set to status '" . Status::getStatusTitle(7) . "' due to ({$day_limit}) day inactivity ");
        Notification::notify($issue[0], 'closed');
    }
    $c++;
}
$killed_id = Status::getStatusID('Killed');
$sql = "SELECT \n\t\t\tiss_id\n\t\tFROM \n\t\t\t`ev_issue` \n\t\t\tleft join ev_status on sta_id = `iss_sta_id` \n\t\twhere \n\t\t\tsta_is_closed = 1\n\t\t\tand `iss_sta_id` = '{$killed_id}'\n\t\t";
$issues = $GLOBALS["db_api"]->dbh->getCol($sql);
foreach ($issues as $issue) {
    $GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue` where iss_id = '" . $issue . "'");
    $GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_subscription` where sub_iss_id = '" . $issue . "'");
    $GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue_user` where isu_iss_id = '" . $issue . "'");
    $GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue_history` where his_iss_id = '" . $issue . "'");
    $GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue_user_replier` where iur_iss_id = '" . $issue . "'");
    $k++;
}
echo "({$c}) Closed. ({$k}) Deleted";