Ejemplo n.º 1
0
function artifactOptionList($type)
{
    $artifacts_data = DataTable::constructFromCsvFile(new CsvFile('data/artifacts.csv'));
    $sets = array("dwarf" => "trpaslík", "elf" => "elf", "knight" => "rytíř", "legionnaire" => "legionář", "mage" => "mág", "necromant" => "nekromant", "orc" => "skřet", "royal" => "královský set", "dark elf" => "dark elf", "squire" => "zbrojnoš");
    $artifacts = $artifacts_data->get(array('type' => $type));
    foreach ($artifacts as $artifact_array) {
        $artifact = Artifact::constructFromArray($artifact_array);
        ?>
<option value="<?php 
        echo $artifact->getId();
        ?>
"><?php 
        echo $artifact->getName();
        echo !empty($sets[$artifact->getSet()]) ? " (" . $sets[$artifact->getSet()] . ")" : "";
        ?>
</option>
    <?php 
    }
}
Ejemplo n.º 2
0
 public function testFormatChangesForFollowupComments()
 {
     $this->skipUnless(MOCKFUNCTION_AVAILABLE, "Function mocking not available");
     if (MOCKFUNCTION_AVAILABLE) {
         MockFunction::generate('user_isloggedin');
         MockFunction::setReturnValue('user_isloggedin', false);
         $nullVar = null;
         $art = new Artifact($nullVar);
         $changes['comment']['add'] = '<pre>text</pre>';
         $changes['comment']['format'] = Artifact::FORMAT_TEXT;
         $this->assertPattern('/\\<pre\\>text\\<\\/pre\\>/', $art->formatChanges($changes, null, $nullVar));
         $changes['comment']['add'] = '<pre>text</pre>';
         $changes['comment']['format'] = Artifact::FORMAT_HTML;
         $this->assertPattern('/text/', $art->formatChanges($changes, null, $nullVar));
         $this->assertNoPattern('/\\<pre\\>text\\<\\/pre\\>/', $art->formatChanges($changes, null, $nullVar));
         MockFunction::restore('user_isloggedin');
     }
 }
Ejemplo n.º 3
0
 }
 $date_field = $art_field_fact->getFieldFromName("open_date");
 if ($date_field->userCanRead($group_id, $atid)) {
     $title_arr[] = $Language->getText('search_index', 'date');
 }
 $status_field = $art_field_fact->getFieldFromName("status_id");
 if ($status_field->userCanRead($group_id, $atid)) {
     $title_arr[] = $Language->getText('global', 'status');
 }
 echo html_build_list_table_top($title_arr);
 echo "\n";
 $art_displayed = 0;
 $rows = 0;
 while ($arr = db_fetch_array($result)) {
     $rows++;
     $curArtifact = new Artifact($ath, $arr['artifact_id']);
     if ($curArtifact->isStatusClosed($curArtifact->getStatusID())) {
         $status = $Language->getText('global', 'closed');
     } else {
         $status = $Language->getText('global', 'open');
     }
     // Only display artifacts that the user is allowed to see
     if ($curArtifact->userCanView(user_getid())) {
         print "\n<TR class=\"" . html_get_alt_row_color($art_displayed) . "\">";
         if ($summary_field->userCanRead($group_id, $atid)) {
             print "<TD><A HREF=\"/tracker/?group_id={$group_id}&func=detail&atid={$atid}&aid=" . $arr['artifact_id'] . "\"><IMG SRC=\"" . util_get_image_theme('msg.png') . "\" BORDER=0 HEIGHT=12 WIDTH=10> " . $arr['summary'] . "</A></TD>";
         }
         if ($submitted_field->userCanRead($group_id, $atid)) {
             print "<TD>" . $arr['user_name'] . "</TD>";
         }
         if ($date_field->userCanRead($group_id, $atid)) {
 /**
  * Send the notification mail, about an event
  *
  * @return boolean
  */
 function handleNotification()
 {
     global $art_field_fact;
     $logger = new TrackerDateReminder_Logger_Prefix($this->logger, '[handleNotification]');
     $logger->info("Start");
     $group = ProjectManager::instance()->getProject($this->getGroupId());
     $at = new ArtifactType($group, $this->getGroupArtifactId());
     $art_field_fact = new ArtifactFieldFactory($at);
     $field = $art_field_fact->getFieldFromId($this->getFieldId());
     $art = new Artifact($at, $this->getArtifactId(), false);
     $logger->info("tracker: " . $this->getGroupArtifactId());
     $logger->info("artifact: " . $this->getArtifactId());
     $sent = true;
     $week = date("W", $this->getDateValue());
     $mail = new Mail();
     $mail->setFrom($GLOBALS['sys_noreply']);
     $mail->setSubject("[" . $this->getTrackerName() . "] " . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_subject', array($field->getLabel(), date("j F Y", $this->getDateValue()), $art->getSummary())));
     $body = "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_header', array($field->getLabel(), date("l j F Y", $this->getDateValue()), $week)) . "\n\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_project', array($group->getPublicName())) . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_tracker', array($this->getTrackerName())) . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_art', array($art->getSummary())) . "\n" . $field->getLabel() . ": " . date("D j F Y", $this->getDateValue()) . "\n\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_art_link') . "\n" . get_server_url() . "/tracker/?func=detail&aid=" . $this->getArtifactId() . "&atid=" . $this->getGroupArtifactId() . "&group_id=" . $this->getGroupId() . "\n\n______________________________________________________________________" . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_footer') . "\n";
     $mail->setBody($body);
     $allNotified = $this->getNotifiedPeople();
     $logger->info("notify: " . implode(', ', $allNotified));
     foreach ($allNotified as $notified) {
         $mail->setTo($notified);
         if (!$mail->send()) {
             $logger->error("faild to notify {$notified}");
             $sent = false;
         }
     }
     $logger->info("End");
     return $sent;
 }
Ejemplo n.º 5
0
    if ($multiple_queries) {
        $multiarr = array();
        for ($i = 0; $i < $rows; $i++) {
            foreach ($all_results as $result) {
                $multiarr = array_merge($multiarr, db_fetch_array($result));
            }
            prepare_artifact_record($ath, $fields, $atid, $multiarr, 'csv');
            $curArtifact = new Artifact($ath, $multiarr['artifact_id']);
            if ($curArtifact->userCanView(user_getid())) {
                echo build_csv_record($col_list, $multiarr) . $eol;
            }
        }
    } else {
        while ($arr = db_fetch_array($result)) {
            prepare_artifact_record($ath, $fields, $atid, $arr, 'csv');
            $curArtifact = new Artifact($ath, $arr['artifact_id']);
            if ($curArtifact->userCanView(user_getid())) {
                echo build_csv_record($col_list, $arr) . $eol;
            }
        }
    }
} else {
    $params['group'] = $group_id;
    $params['toptab'] = 'tracker';
    $params['pagename'] = 'trackers';
    $params['title'] = $Language->getText('tracker_index', 'trackers_for');
    $params['sectionvals'] = array($group->getPublicName());
    $params['help'] = 'tracker-v3.html';
    $params['pv'] = $request->exist('pv') ? $request->get('pv') : '';
    site_project_header($params);
    echo '<h3>' . $Language->getText('project_export_artifact_export', 'art_export') . '</h3>';
Ejemplo n.º 6
0
require_once 'common/tracker/ArtifactFieldFactory.class.php';
$id = $request->get('id');
$artifact_id = $request->get('artifact_id');
// We have the artifact id, but not the tracker id
$sql = "SELECT group_artifact_id, group_id FROM artifact INNER JOIN artifact_group_list USING (group_artifact_id) WHERE artifact_id= " . db_ei($artifact_id);
$result = db_query($sql);
if (db_numrows($result) > 0) {
    $row = db_fetch_array($result);
    $atid = $row['group_artifact_id'];
    $pm = ProjectManager::instance();
    $group = $pm->getProject($row['group_id']);
    $at = new ArtifactType($group, $atid);
    if ($at->userCanView()) {
        $art_field_fact = new ArtifactFieldFactory($at);
        // Grrr! don't use global >_<
        $a = new Artifact($at, $artifact_id);
        if ($a->userCanView()) {
            $sql = "SELECT description,bin_data,filename,filesize,filetype FROM artifact_file WHERE id='" . db_ei($id) . "' AND artifact_id ='" . db_ei($artifact_id) . "'";
            //echo $sql;
            $result = db_query($sql);
            if ($result && db_numrows($result) > 0) {
                if (db_result($result, 0, 'filesize') == 0) {
                    exit_error($Language->getText('global', 'error'), $Language->getText('tracker_download', 'file_is_null'));
                } else {
                    // Download the patch with the correct filetype
                    require_once 'common/include/Codendi_HTTPPurifier.class.php';
                    $http = Codendi_HTTPPurifier::instance();
                    header('Content-Type: ' . $http->purify(db_result($result, 0, 'filetype')));
                    header('Content-Length: ' . $http->purify(db_result($result, 0, 'filesize')));
                    header('Content-Disposition: filename="' . $http->purify(db_result($result, 0, 'filename')) . '"');
                    header('Content-Description: ' . $http->purify(db_result($result, 0, 'description')));
Ejemplo n.º 7
0
 public function search(Search_SearchQuery $query, Search_SearchResults $search_results)
 {
     include_once 'www/tracker/include/ArtifactTypeHtml.class.php';
     include_once 'www/tracker/include/ArtifactHtml.class.php';
     $project = $query->getProject();
     if ($project->isError()) {
         return;
     }
     $group_id = $project->getId();
     $words = $query->getWords();
     $exact = $query->getExact();
     $offset = $query->getOffset();
     $atid = $query->getTrackerV3Id();
     ob_start();
     //
     //      Create the ArtifactType object
     //
     $ath = new ArtifactTypeHtml($project, $atid);
     if (!$ath || !is_object($ath)) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('global', 'error'));
     }
     if ($ath->isError()) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $ath->getErrorMessage());
     }
     // Check if this tracker is valid (not deleted)
     if (!$ath->isValid()) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('global', 'error'));
     }
     $results = $this->dao->searchGlobalPaginated($words, $exact, $offset, $atid, UserManager::instance()->getCurrentUser()->getUgroups($group_id, $atid), $query->getNumberOfResults());
     $rows_returned = $this->dao->foundRows();
     $art_displayed = 0;
     if ($rows_returned < 1) {
         echo '<H2>' . $GLOBALS['Language']->getText('search_index', 'no_match_found', htmlentities(stripslashes($words), ENT_QUOTES, 'UTF-8')) . '</H2>';
     } else {
         // Create field factory
         $art_field_fact = new ArtifactFieldFactory($ath);
         echo '<H3>' . $GLOBALS['Language']->getText('search_index', 'search_res', array(htmlentities(stripslashes($words), ENT_QUOTES, 'UTF-8'), $rows_returned)) . "</H3><P>\n";
         $title_arr = array();
         $summary_field = $art_field_fact->getFieldFromName("summary");
         if ($summary_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'artifact_summary');
         }
         $submitted_field = $art_field_fact->getFieldFromName("submitted_by");
         if ($submitted_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'submitted_by');
         }
         $date_field = $art_field_fact->getFieldFromName("open_date");
         if ($date_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'date');
         }
         $status_field = $art_field_fact->getFieldFromName("status_id");
         if ($status_field->userCanRead($group_id, $atid)) {
             $title_arr[] = $GLOBALS['Language']->getText('global', 'status');
         }
         echo html_build_list_table_top($title_arr);
         echo "\n";
         $rows = 0;
         foreach ($results as $arr) {
             $rows++;
             $curArtifact = new Artifact($ath, $arr['artifact_id']);
             if ($curArtifact->isStatusClosed($curArtifact->getStatusID())) {
                 $status = $GLOBALS['Language']->getText('global', 'closed');
             } else {
                 $status = $GLOBALS['Language']->getText('global', 'open');
             }
             // Only display artifacts that the user is allowed to see
             if ($curArtifact->userCanView(user_getid())) {
                 print "\n<TR class=\"" . html_get_alt_row_color($art_displayed) . "\">";
                 if ($summary_field->userCanRead($group_id, $atid)) {
                     print "<TD><A HREF=\"/tracker/?group_id={$group_id}&func=detail&atid={$atid}&aid=" . $arr['artifact_id'] . "\"><IMG SRC=\"" . util_get_image_theme('msg.png') . "\" BORDER=0 HEIGHT=12 WIDTH=10> " . $arr['summary'] . "</A></TD>";
                 }
                 if ($submitted_field->userCanRead($group_id, $atid)) {
                     print "<TD>" . $arr['user_name'] . "</TD>";
                 }
                 if ($date_field->userCanRead($group_id, $atid)) {
                     print "<TD>" . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $arr['open_date']) . "</TD>";
                 }
                 if ($status_field->userCanRead($group_id, $atid)) {
                     print "<TD>" . $status . "</TD>";
                 }
                 print "</TR>";
                 $art_displayed++;
                 if ($art_displayed > $query->getNumberOfResults()) {
                     break;
                 }
             }
         }
         echo "</TABLE>\n";
     }
     $maybe_more_results = $art_displayed < $query->getNumberOfResults() ? false : true;
     $search_results->setCountResults($art_displayed)->setHasMore($maybe_more_results);
     return new Search_SearchTrackerV3ResultPresenter(ob_get_clean());
 }
Ejemplo n.º 8
0
 /**
  * We keep the order of the relation in the database, even if we are getting the inverse. 
  */
 function inverse_dependencies_to_soap($artifact_type, $artifact_id, $inverse_dependencies)
 {
     $return = array();
     $rows = db_numrows($inverse_dependencies);
     for ($i = 0; $i < $rows; $i++) {
         // check the permission : is the user allowed to see the artifact ?
         $artifact = new Artifact($artifact_type, db_result($inverse_dependencies, $i, 'artifact_id'));
         if ($artifact && $artifact->userCanView()) {
             $return[] = array('artifact_depend_id' => db_result($inverse_dependencies, $i, 'artifact_depend_id'), 'artifact_id' => db_result($inverse_dependencies, $i, 'artifact_id'), 'is_dependent_on_artifact_id' => $artifact_id, 'summary' => util_unconvert_htmlspecialchars(db_result($inverse_dependencies, $i, 'summary')), 'tracker_id' => db_result($inverse_dependencies, $i, 'group_artifact_id'), 'tracker_name' => SimpleSanitizer::unsanitize(db_result($inverse_dependencies, $i, 'name')), 'group_id' => db_result($inverse_dependencies, $i, 'group_id'), 'group_name' => util_unconvert_htmlspecialchars(db_result($inverse_dependencies, $i, 'group_name')));
         }
     }
     return $return;
 }
Ejemplo n.º 9
0
	var A = function(ab, db, a, d, sp, md, es, s, t, des, ef, set) {
		this.attack_bonus = ab;
		this.defence_bonus = db;
		this.attack = a;
		this.defence = d;
		this.spell_power = sp;
		this.magical_defence = md;
		this.escape = es;
		this.survival = s;
		this.thieving = t;
		this.destruction = des;
		this.efficiency = ef;
		this.set = set;
	};

	this['nothing'] = new A(0,0,0,0,0,0,0,0,0,0,0,'');
<?php 
$artifacts_data = DataTable::constructFromCsvFile(new CsvFile('data/artifacts.csv'));
foreach (ArtifactType::values() as $artifact_type) {
    $artifacts = $artifacts_data->get(array('type' => $artifact_type));
    foreach ($artifacts as $artifact_array) {
        $artifact = Artifact::constructFromArray($artifact_array);
        echo "\t" . 'this[\'' . $artifact->getId() . '\'] = new A(' . $artifact->getAttack_bonus() . ',' . $artifact->getDefence_bonus() . ',' . $artifact->getAttack() . ',' . $artifact->getDefence() . ',' . $artifact->getSpell_power() . ',' . $artifact->getMagical_defence() . ',' . $artifact->getEscape() . ',' . $artifact->getSurvival() . ',' . $artifact->getThieving() . ',' . $artifact->getDestruction() . ',' . $artifact->getEfficiency() . ',' . '\'' . $artifact->getSet() . '\');' . PHP_EOL;
    }
}
?>
};

};
Ejemplo n.º 10
0
/**
 * Return the name of a given object
 */
function permission_get_object_name($permission_type, $object_id)
{
    global $Language, $group_id;
    $pm = ProjectManager::instance();
    if ($permission_type == 'NEWS_READ') {
        return get_news_name_from_forum_id($object_id);
    } else {
        if ($permission_type == 'PACKAGE_READ') {
            return file_get_package_name_from_id($object_id);
        } else {
            if ($permission_type == 'RELEASE_READ') {
                return file_get_release_name_from_id($object_id);
            } else {
                if ($permission_type == 'DOCUMENT_READ') {
                    return util_unconvert_htmlspecialchars(doc_get_title_from_id($object_id));
                } else {
                    if ($permission_type == 'DOCGROUP_READ') {
                        return doc_get_docgroupname_from_id($object_id);
                    } else {
                        if ($permission_type == 'WIKI_READ') {
                            return $Language->getText('project_admin_permissions', 'wiki');
                        } else {
                            if ($permission_type == 'WIKIPAGE_READ') {
                                #$wikipage= new WikiPage($object_id);
                                #return $wikipage->getPagename();
                                return "{$object_id}";
                            } else {
                                if ($permission_type == 'WIKIATTACHMENT_READ') {
                                    return $Language->getText('project_admin_permissions', 'wikiattachment');
                                } else {
                                    if (strpos($permission_type, 'TRACKER_ACCESS') === 0) {
                                        $group = $pm->getProject($group_id);
                                        $at = new ArtifactType($group, $object_id);
                                        return $at->getName();
                                    } else {
                                        if (strpos($permission_type, 'TRACKER_FIELD') === 0) {
                                            $ret = "{$object_id}";
                                            if ($group = $pm->getProject($group_id)) {
                                                $atid = permission_extract_atid($object_id);
                                                $at = new ArtifactType($group, $atid);
                                                $ret = $at->getName();
                                                if ($ath = new ArtifactTypeHtml($group, $atid)) {
                                                    if ($art_field_fact = new ArtifactFieldFactory($ath)) {
                                                        $field_id = permission_extract_field_id($object_id);
                                                        if ($field = $art_field_fact->getFieldFromId($field_id)) {
                                                            $ret = $field->getName() . ' (' . $ret . ')';
                                                        }
                                                    }
                                                }
                                            }
                                            return $ret;
                                        } else {
                                            if ($permission_type == 'TRACKER_ARTIFACT_ACCESS') {
                                                $ret = $object_id;
                                                $sql = "SELECT group_artifact_id FROM artifact WHERE artifact_id= " . db_ei($object_id);
                                                $result = db_query($sql);
                                                if (db_numrows($result) > 0) {
                                                    $row = db_fetch_array($result);
                                                    $atid = $row['group_artifact_id'];
                                                }
                                                $group = $pm->getProject($group_id);
                                                $at = new ArtifactType($group, $atid);
                                                $a = new Artifact($at, $object_id);
                                                return 'art #' . $a->getId() . ' - ' . util_unconvert_htmlspecialchars($a->getSummary());
                                            } else {
                                                $em =& EventManager::instance();
                                                $object_name = false;
                                                $em->processEvent('permission_get_object_name', array('permission_type' => $permission_type, 'object_id' => $object_id, 'object_name' => &$object_name));
                                                return $object_name ? $object_name : $object_id;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Ejemplo n.º 11
0
 function getArtifactsFromReport($group_id, $group_artifact_id, $report_id, $criteria, $offset, $max_rows, $sort_criteria, &$total_artifacts)
 {
     global $ath, $art_field_fact, $Language;
     $GLOBALS['group_id'] = $group_id;
     $chunksz = $max_rows;
     $advsrch = 0;
     // ?
     $prefs = array();
     $report = new ArtifactReport($report_id, $group_artifact_id);
     if (!$report || !is_object($report)) {
         $this->setError('Cannot Get ArtifactReport From ID : ' . $report_id);
         return false;
     } elseif ($report->isError()) {
         $this->setError($report->getErrorMessage());
         return false;
     }
     $query_fields = $report->getQueryFields();
     $result_fields = $report->getResultFields();
     // Filter part
     if (is_array($criteria)) {
         foreach ($criteria as $cr) {
             $af = $art_field_fact->getFieldFromName($cr->field_name);
             if (!$af || !is_object($af)) {
                 $this->setError('Cannot Get ArtifactField From Name : ' . $cr->field_name);
                 return false;
             } elseif ($art_field_fact->isError()) {
                 $this->setError($art_field_fact->getErrorMessage());
                 return false;
             }
             if (!array_key_exists($cr->field_name, $query_fields)) {
                 $this->setError('You cannot filter on field ' . $cr->field_name . ': it is not a query field for report ' . $report_id);
                 return false;
             }
             if ($af->isSelectBox() || $af->isMultiSelectBox()) {
                 $prefs[$cr->field_name] = explode(",", $cr->field_value);
             } else {
                 $prefs[$cr->field_name] = array($cr->field_value);
                 if (isset($cr->operator)) {
                     $prefs[$cr->field_name][] = $cr->operator;
                 }
             }
         }
     }
     // Sort part
     $morder = '';
     $array_morder = array();
     if (is_array($sort_criteria)) {
         foreach ($sort_criteria as $sort_cr) {
             $field_name = $sort_cr->field_name;
             // check if fieldname is ok
             $af = $art_field_fact->getFieldFromName($sort_cr->field_name);
             if (!$af || !is_object($af)) {
                 $this->setError('Cannot Get ArtifactField From Name : ' . $sort_cr->field_name);
                 return false;
             } elseif ($art_field_fact->isError()) {
                 $this->setError($art_field_fact->getErrorMessage());
                 return false;
             }
             if (!array_key_exists($sort_cr->field_name, $result_fields)) {
                 $this->setError('You cannot sort on field ' . $sort_cr->field_name . ': it is not a result field for report ' . $report_id);
                 return false;
             }
             // check if direction is ok
             $sort_direction = '>';
             // by default, direction is ASC
             if (isset($sort_cr->sort_direction) && $sort_cr->sort_direction == 'DESC') {
                 $sort_direction = '<';
             }
             $array_morder[] = $field_name . $sort_direction;
         }
     }
     $morder = implode(',', $array_morder);
     $pm = ProjectManager::instance();
     $group = $pm->getProject($group_id);
     $ath = new ArtifactTypeHtml($group);
     $artifact_report = new ArtifactReport($report_id, $group_artifact_id);
     // get the total number of artifact that answer the query, and the corresponding IDs
     $total_artifacts = $artifact_report->selectReportItems($prefs, $morder, $advsrch, $aids);
     // get the SQL query corresponding to the query
     $sql = $artifact_report->createQueryReport($prefs, $morder, $advsrch, $offset, $chunksz, $aids);
     $result = $artifact_report->getResultQueryReport($sql);
     $result_fields = $artifact_report->getResultFields();
     //we get from result only fields that we need to display in the report (we add at the begining id and severity only to identify the artifact and for the severity color)
     $artifacts = array();
     $i = 0;
     foreach ($result as $art) {
         $artifact_id = $art['artifact_id'];
         $severity_id = $art['severity_id'];
         $artifact = new Artifact($this->ArtifactType, $art['artifact_id'], true);
         if ($artifact->userCanView()) {
             $fields = array();
             reset($result_fields);
             $fields['severity_id'] = $severity_id;
             $fields['id'] = $artifact_id;
             while (list($key, $field) = each($result_fields)) {
                 $value = $result[$i][$key];
                 $fields[$key] = $value;
             }
             $artifacts[$artifact_id] = $fields;
         }
         $i++;
     }
     return $artifacts;
 }
 /**
  * Create new task artifact
  * 
  * @param    integer    group artifact identifier (primary key)
  * @param    string     artifact summary
  * @param    string     artifact description
  * @param    integer    user story artifact identifier
  * @param    string     release name
  *
  * @return   string     error message in case of fail
  */
 function createTask($tracker_id, $title, $description, $user_story_id = null, $release_value = NULL)
 {
     $tracker = $this->getTasksTracker($tracker_id);
     if ($tracker) {
         $artifact = new Artifact($tracker);
         $extra_fields = array();
         $user_story_alias = $this->TaskBoard->getUserStoriesReferenceField();
         $release_alias = $this->TaskBoard->getReleaseField();
         $fields = $this->getFieldsIds($tracker_id);
         // link create task to user story (if specified)
         if ($user_story_id && $user_story_alias) {
             if (array_key_exists($user_story_alias, $fields)) {
                 $extra_fields[$fields[$user_story_alias]] = $user_story_id;
             }
         }
         // link create task to release (if specified)
         if ($release_value && $release_alias) {
             if (array_key_exists($release_alias, $fields)) {
                 $elements = $this->getExtraFieldValues($tracker_id, $release_alias);
                 if (array_key_exists($release_value, $elements)) {
                     $extra_fields[$fields[$release_alias]] = $elements[$release_value];
                 }
             }
         }
         $ret = $artifact->create($title, $description, null, null, $extra_fields);
         if (!$ret) {
             return $artifact->getErrorMessage();
         }
     }
     return '';
 }
Ejemplo n.º 13
0
 public static function getPathOnFilesystem(Artifact $artifact, $attachment_id)
 {
     return self::getParentDirectoryForArtifact($artifact->getArtifactType()) . DIRECTORY_SEPARATOR . $attachment_id;
 }
Ejemplo n.º 14
0
 public function AddArtifact(Artifact $artifact)
 {
     $this->list[$artifact->GetID()] = $artifact;
     $this->save();
 }
Ejemplo n.º 15
0
require_once 'common/tracker/ArtifactFieldFactory.class.php';
$id = $request->get('id');
$artifact_id = $request->get('artifact_id');
// We have the artifact id, but not the tracker id
$sql = "SELECT group_artifact_id, group_id FROM artifact INNER JOIN artifact_group_list USING (group_artifact_id) WHERE artifact_id= " . db_ei($artifact_id);
$result = db_query($sql);
if (db_numrows($result) > 0) {
    $row = db_fetch_array($result);
    $atid = $row['group_artifact_id'];
    $pm = ProjectManager::instance();
    $group = $pm->getProject($row['group_id']);
    $at = new ArtifactType($group, $atid);
    if ($at->userCanView()) {
        $art_field_fact = new ArtifactFieldFactory($at);
        // Grrr! don't use global >_<
        $a = new Artifact($at, $artifact_id);
        if ($a->userCanView()) {
            $sql = "SELECT description,bin_data,filename,filesize,filetype FROM artifact_file WHERE id='" . db_ei($id) . "' AND artifact_id ='" . db_ei($artifact_id) . "'";
            //echo $sql;
            $result = db_query($sql);
            if ($result && db_numrows($result) > 0) {
                if (db_result($result, 0, 'filesize') == 0) {
                    exit_error($Language->getText('global', 'error'), $Language->getText('tracker_download', 'file_is_null'));
                } else {
                    // Download the patch with the correct filetype
                    require_once 'common/include/Codendi_HTTPPurifier.class.php';
                    $http = Codendi_HTTPPurifier::instance();
                    header('X-Content-Type-Options: nosniff');
                    header('Content-Type: ' . $http->purify(db_result($result, 0, 'filetype')));
                    header('Content-Length: ' . $http->purify(db_result($result, 0, 'filesize')));
                    header('Content-Disposition: attachment; filename="' . $http->purify(db_result($result, 0, 'filename')) . '"');