protected function getChildDataIssue($issue, $options = null) { $data = array(); switch ($options) { case 'tasks': $items = $this->itemLinkService->getLinkedItemsOfType($issue, 'from', 'Task', array('task.complete=' => 0)); foreach ($items as $child) { $item = new stdClass(); $item->id = get_class($child) . '-' . $child->id . ''; ob_start(); $this->view->percentageBar($child->getPercentage()); $bar = ob_get_clean(); $item->text = $bar . $child->title . ' <a href="' . build_url('task', 'edit', array('id' => $child->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>'; $item->expanded = false; $item->classes = "tree-task iconed"; $item->hasChildren = false; $data[] = $item; } break; break; default: break; } return $data; }
/** * Provides an overview of the traceability of this project */ public function traceabilityAction() { $project = $this->byId(); $type = $this->_getParam('type'); $targetId = $this->_getParam('targetid'); $dir = $this->_getParam('dir'); $selected = null; if ($type != null && $targetId != null) { $selected = $this->byId($targetId, $type); } if ($project == null && $selected == null) { $this->flash("Could not load project"); $this->redirect('index'); return; } $items = new ArrayObject(); // Start with getting all the links from requirements if ($selected == null) { // Just get all the features to start with $featureService = za()->getService('FeatureService'); /* @var $featureService FeatureService */ $items = $featureService->getFeatures(array('projectid=' => $project->id)); $this->view->linkedFrom = $project; } else { $items = $this->itemLinkService->getLinkedItems($selected, $dir); $this->view->linkedFrom = $selected; } $this->view->dir = $dir; $this->view->items = $items; $this->view->model = $project; $this->renderView('project/traceability.php'); }
/** * Delete a link between an issue and a feature */ public function removefeatureAction() { $issue = $this->byId(); $feature = $this->byId($this->_getParam('featureid'), 'Feature'); $linkType = $this->_getParam('linktype'); if ($issue == null) { $this->flash('Invalid Issue specified'); $this->redirect('issue', 'edit', array('id' => $this->_getParam('id'), '#features')); return; } if ($issue == null || $feature == null) { $this->flash('Invalid Feature specified'); $this->redirect('issue', 'edit', array('id' => $this->_getParam('id'), '#features')); return; } try { if ($linkType == 'to') { // okay, delete the link from the feature TO the issue $this->itemLinkService->deleteLinkBetween($feature, $issue); $this->flash("Removed link between feature {$feature->title} and issue {$issue->title}"); } else { $this->itemLinkService->deleteLinkBetween($issue, $feature); $this->flash("Removed link between issue {$issue->title} and feature {$feature->title}"); } } catch (Exception $e) { $this->flash("Failed removing link between items: " . $e->getMessage()); } $this->redirect('issue', 'edit', array('id' => $this->_getParam('id'), '#features')); }
/** * Create a bunch of tasks from the selected features */ public function createtasksAction() { $ids = $this->_getParam('createfrom'); foreach ($ids as $id) { $feature = $this->byId($id); if ($feature) { $task = $this->itemLinkService->createTaskFromFeature($feature); } } $this->redirect('project', 'view', array('id' => $this->_getParam('projectid'), '#tasks')); }
/** * Load all the child features of a given feature * * @param unknown_type $feature */ private function loadChildFeatures($feature, $milestoneMapping) { if (isset($milestoneMapping[$feature->milestone])) { $feature->setMilestoneTitle($milestoneMapping[$feature->milestone]); } $children = $this->itemLinkService->getLinkedItemsOfType($feature, 'from', 'Feature', array(), 'sortorder asc'); $feature->setChildFeatures($children); foreach ($children as $child) { $this->loadChildFeatures($child, $milestoneMapping); } }
public function removelinkfromAction() { $to = $this->byId(); $from = $this->byId($this->_getParam('fromid'), $this->_getParam('fromtype')); if ($to && $from) { try { $this->itemLinkService->deleteLinkBetween($from, $to); $this->flash("Successfully removed link from " . $from->title . " to " . $to->title); } catch (Exception $e) { $this->flash($e->getMessage()); } if ($this->_getParam('_ajax')) { $this->redirect('task', 'edit', array('_ajax' => 1, 'id' => $to->id)); } else { $this->_redirect($this->getCallingUrl()); } } }
/** * Update all linked items to the given task to make sure * their dates are as accurate as possible * */ private function updateAffectedLinkedItems(Task $task) { // first get all issues $issues = $this->itemLinkService->getLinkedItemsOfType($task, 'to', 'Issue'); foreach ($issues as $issue) { $tasks = $this->itemLinkService->getLinkedItemsOfType($issue, 'from', 'Task'); $estimated = 0; $elapsed = 0; foreach ($tasks as $linkedTask) { /* @var $linkedTask Task */ $estimated += $linkedTask->estimated; $elapsed += $linkedTask->timespent; } // Convert elapsed to hours to match estimated time if ($elapsed > 0) { $elapsed = $elapsed / 3600; } // update the issue's time spent, but NOT its estimate - this is // separate from the task estimates. // $issue->estimated = $estimated; $issue->elapsed = $elapsed; $this->dbService->saveObject($issue); } $features = $this->itemLinkService->getLinkedItemsOfType($task, 'to', 'Feature'); foreach ($features as $feature) { $tasks = $this->itemLinkService->getLinkedItemsOfType($feature, 'from', 'Task'); $estimated = 0; $elapsed = 0; foreach ($tasks as $linkedTask) { /* @var $linkedTask Task */ $estimated += $linkedTask->estimated; $elapsed += $linkedTask->timespent; } // Convert elapsed to hours to match estimated time if ($elapsed > 0) { $elapsed = $elapsed / 3600; } // update the feature's elapsed hours $feature->hours = $elapsed; $this->dbService->saveObject($feature); } }