本文整理汇总了PHP中TrackerFactory::getInstanceFromRow方法的典型用法代码示例。如果您正苦于以下问题:PHP TrackerFactory::getInstanceFromRow方法的具体用法?PHP TrackerFactory::getInstanceFromRow怎么用?PHP TrackerFactory::getInstanceFromRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackerFactory
的用法示例。
在下文中一共展示了TrackerFactory::getInstanceFromRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailablePlanningTrackers
/**
* Retrieve the project trackers that can be used as planning trackers.
*
* @param Planning $planning The planning for which we want to know the available trackers.
*
* @return Array of Tracker
*/
public function getAvailablePlanningTrackers(Planning $planning)
{
$planning_trackers = array($planning->getPlanningTracker());
foreach ($this->dao->searchNonPlanningTrackersByGroupId($planning->getGroupId()) as $row) {
$planning_trackers[] = $this->tracker_factory->getInstanceFromRow($row);
}
return $planning_trackers;
}
示例2: getAvailableBacklogTrackers
/**
* @param int $group_id the project id the trackers to retrieve belong to
*
* @return Array of Tracker
*/
public function getAvailableBacklogTrackers(PFUser $user, $group_id)
{
$potential_planning_trackers = $this->getPotentialPlanningTrackerIds($user, $group_id);
$backlog_trackers = array();
foreach ($this->dao->searchNonPlanningTrackersByGroupId($group_id) as $row) {
if (!in_array($row['id'], $potential_planning_trackers)) {
$backlog_trackers[] = $this->tracker_factory->getInstanceFromRow($row);
}
}
return $backlog_trackers;
}
示例3: getInstanceFromXML
/**
* Creates a Tracker Object
*
* @param SimpleXMLElement $xml containing the structure of the imported tracker
* @param int $groupId - id of the project into which the tracker is imported
* @param string $name of the tracker given by the user
* @param string $description of the tracker given by the user
* @param string $itemname - short_name of the tracker given by the user
*
* @return Tracker Object
*/
protected function getInstanceFromXML($xml, $groupId, $name, $description, $itemname)
{
// set general settings
// real id will be set during Database update
$att = $xml->attributes();
$row = array('id' => 0, 'name' => $name, 'group_id' => $groupId, 'description' => $description, 'item_name' => $itemname, 'submit_instructions' => (string) $xml->submit_instructions, 'browse_instructions' => (string) $xml->browse_instructions, 'status' => '', 'deletion_date' => '', 'color' => (string) $xml->color);
$row['allow_copy'] = isset($att['allow_copy']) ? (int) $att['allow_copy'] : 0;
$row['instantiate_for_new_projects'] = isset($att['instantiate_for_new_projects']) ? (int) $att['instantiate_for_new_projects'] : 0;
$row['log_priority_changes'] = isset($att['log_priority_changes']) ? (int) $att['log_priority_changes'] : 0;
$row['stop_notification'] = isset($att['stop_notification']) ? (int) $att['stop_notification'] : 0;
$tracker = $this->tracker_factory->getInstanceFromRow($row);
// set canned responses
if (isset($xml->cannedResponses)) {
foreach ($xml->cannedResponses->cannedResponse as $index => $response) {
$tracker->cannedResponses[] = $this->canned_response_factory->getInstanceFromXML($response);
}
}
// set formElements
foreach ($xml->formElements->formElement as $index => $elem) {
$tracker->formElements[] = $this->formelement_factory->getInstanceFromXML($tracker, $elem, $this->xmlFieldsMapping);
}
// set semantics
if (isset($xml->semantics)) {
foreach ($xml->semantics->semantic as $xml_semantic) {
$semantic = $this->semantic_factory->getInstanceFromXML($xml_semantic, $this->xmlFieldsMapping, $tracker);
if ($semantic) {
$tracker->semantics[] = $semantic;
}
}
}
/*
* Legacy compatibility
*
* All new Tuleap versions will not export dependencies but rules instead.
* However, we still want to be able to import old xml files.
*
* SimpleXML does not allow for nodes to be moved so have to recursively
* generate rules from the dependencies data.
*/
if (isset($xml->dependencies)) {
$list_rules = null;
if (!isset($xml->rules)) {
$list_rules = $xml->addChild('rules')->addChild('list_rules');
} elseif (!isset($xml->rules->list_rules)) {
$list_rules = $xml->rules->addChild('list_rules', $xml->dependencies);
}
if ($list_rules !== null) {
foreach ($xml->dependencies->rule as $old_rule) {
$source_field_attributes = $old_rule->source_field->attributes();
$target_field_attributes = $old_rule->target_field->attributes();
$source_value_attributes = $old_rule->source_value->attributes();
$target_value_attributes = $old_rule->target_value->attributes();
$new_rule = $list_rules->addChild('rule', $old_rule);
$new_rule->addChild('source_field')->addAttribute('REF', $source_field_attributes['REF']);
$new_rule->addChild('target_field')->addAttribute('REF', $target_field_attributes['REF']);
$new_rule->addChild('source_value')->addAttribute('REF', $source_value_attributes['REF']);
$new_rule->addChild('target_value')->addAttribute('REF', $target_value_attributes['REF']);
}
}
}
//set field rules
if (isset($xml->rules)) {
$tracker->rules = $this->rule_factory->getInstanceFromXML($xml->rules, $this->xmlFieldsMapping, $tracker);
}
// set report
if (isset($xml->reports)) {
foreach ($xml->reports->report as $report) {
$tracker->reports[] = $this->report_factory->getInstanceFromXML($report, $this->xmlFieldsMapping, $groupId);
}
}
//set workflow
if (isset($xml->workflow->field_id)) {
$tracker->workflow = $this->workflow_factory->getInstanceFromXML($xml->workflow, $this->xmlFieldsMapping, $tracker);
}
//set permissions
if (isset($xml->permissions->permission)) {
$allowed_tracker_perms = array(Tracker::PERMISSION_ADMIN, Tracker::PERMISSION_FULL, Tracker::PERMISSION_SUBMITTER, Tracker::PERMISSION_ASSIGNEE, Tracker::PERMISSION_SUBMITTER_ONLY);
$allowed_field_perms = array('PLUGIN_TRACKER_FIELD_READ', 'PLUGIN_TRACKER_FIELD_UPDATE', 'PLUGIN_TRACKER_FIELD_SUBMIT');
foreach ($xml->permissions->permission as $permission) {
switch ((string) $permission['scope']) {
case 'tracker':
//tracker permissions
$ugroup = (string) $permission['ugroup'];
$type = (string) $permission['type'];
if (isset($GLOBALS['UGROUPS'][$ugroup]) && in_array($type, $allowed_tracker_perms)) {
$tracker->setCachePermission($GLOBALS['UGROUPS'][$ugroup], $type);
}
break;
case 'field':
//.........这里部分代码省略.........