Exemple #1
0
/**
* submits an issue inthe current tracker
* @uses CFG
* @param int $trackerid the current tracker
*/
function tracker_submitanissue($trackerid)
{
    global $CFG;
    $issue->datereported = required_param('datereported', PARAM_INT);
    $issue->summary = required_param('summary', PARAM_TEXT);
    $issue->description = addslashes(required_param('description', PARAM_CLEANHTML));
    $issue->format = addslashes(required_param('format', PARAM_CLEANHTML));
    $issue->assignedto = 0;
    $issue->bywhomid = 0;
    $issue->trackerid = $trackerid;
    $issue->status = POSTED;
    $issue->reportedby = required_param('reportedby', PARAM_INT);
    $issue->id = insert_record('tracker_issue', $issue, true);
    if ($issue->id) {
        tracker_recordelements($issue);
        // add reporter as observer on this bug
        $issuecc->trackerid = $trackerid;
        $issuecc->issueid = $issue->id;
        $issuecc->userid = $issue->reportedby;
        insert_record('tracker_issuecc', $issuecc);
        return $issue;
    } else {
        error("Could not submit issue");
    }
}
         error("Could not log old ownership");
     }
 }
 $issue->bywhomid = $USER->id;
 $issue->timeassigned = time();
 if (!update_record('tracker_issue', $issue)) {
     error("Could not update tracker issue");
 }
 // if not CCed, the assignee should be
 tracker_register_cc($tracker, $issue, $issue->assignedto);
 /// send state change notification
 if ($oldrecord->status != $issue->status) {
     tracker_notifyccs_changestate($issue->id, $tracker);
 }
 tracker_clearelements($issue->id);
 tracker_recordelements($issue);
 // TODO : process dependancies
 $dependancies = optional_param('dependancies', null, PARAM_INT);
 if (is_array($dependancies)) {
     // cleanup previous depdendancies
     if (!delete_records('tracker_issuedependancy', 'childid', $issue->id)) {
         error("Could not delete old dependancies");
     }
     // install back new one
     foreach ($dependancies as $dependancy) {
         $dependancyrec->trackerid = $tracker->id;
         $dependancyrec->parentid = $dependancy;
         $dependancyrec->childid = $issue->id;
         $dependancyrec->comment = '';
         if (!insert_record('tracker_issuedependancy', $dependancyrec)) {
             error("Could not write dependancy record");
/**
* submits an issue in the current tracker
* @uses $CFG
* @param int $trackerid the current tracker
*/
function tracker_submitanissue(&$tracker)
{
    global $CFG;
    $issue->datereported = required_param('datereported', PARAM_INT);
    $issue->summary = required_param('summary', PARAM_TEXT);
    $issue->description = addslashes(required_param('description', PARAM_CLEANHTML));
    $issue->format = addslashes(required_param('format', PARAM_CLEANHTML));
    $issue->assignedto = 0;
    $issue->bywhomid = 0;
    $issue->trackerid = $tracker->id;
    $issue->status = POSTED;
    $issue->reportedby = required_param('reportedby', PARAM_INT);
    // fetch max actual priority
    $maxpriority = get_field_select('tracker_issue', 'MAX(resolutionpriority)', " trackerid = {$tracker->id} GROUP BY trackerid ");
    $issue->resolutionpriority = $maxpriority + 1;
    $issue->id = insert_record('tracker_issue', $issue, true);
    if ($issue->id) {
        tracker_recordelements($issue);
        // if not CCed, the assignee should be
        tracker_register_cc($tracker, $issue, $issue->reportedby);
        return $issue;
    } else {
        error("Could not submit issue");
    }
}