public function runIssueEditTimeSpent(framework\Request $request) { try { $entry_id = $request['entry_id']; $spenttime = $entry_id ? tables\IssueSpentTimes::getTable()->selectById($entry_id) : new entities\IssueSpentTime(); if ($issue_id = $request['issue_id']) { $issue = entities\Issue::getB2DBTable()->selectById($issue_id); } else { throw new \Exception('no issue'); } framework\Context::loadLibrary('common'); $spenttime->editOrAdd($issue, $this->getUser(), array_only_with_default($request->getParameters(), array_merge(array('timespent_manual', 'timespent_specified_type', 'timespent_specified_value', 'timespent_activitytype', 'timespent_comment', 'edited_at'), \thebuggenie\core\entities\common\Timeable::getUnitsWithPoints()))); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('edited' => 'error', 'error' => $e->getMessage())); } $this->return_data = array('edited' => 'ok'); }
public function runAddAffected(framework\Request $request) { framework\Context::loadLibrary('ui'); try { $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']); $statuses = entities\Status::getAll(); switch ($request['item_type']) { case 'edition': if (!$issue->getProject()->isEditionsEnabled()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Editions are disabled'))); } elseif (!$issue->canEditAffectedEditions()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this'))); } $edition = entities\Edition::getB2DBTable()->selectById($request['which_item_edition']); if (tables\IssueAffectsEdition::getTable()->getByIssueIDandEditionID($issue->getID(), $edition->getID())) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $edition->getName())))); } $result = $issue->addAffectedEdition($edition); if ($result !== false) { $itemtype = 'edition'; $item = $result; $itemtypename = framework\Context::getI18n()->__('Edition'); $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses)); } $message = framework\Context::getI18n()->__('Edition <b>%edition</b> is now affected by this issue', array('%edition' => $edition->getName()), true); break; case 'component': if (!$issue->getProject()->isComponentsEnabled()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Components are disabled'))); } elseif (!$issue->canEditAffectedComponents()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this'))); } $component = entities\Component::getB2DBTable()->selectById($request['which_item_component']); if (tables\IssueAffectsComponent::getTable()->getByIssueIDandComponentID($issue->getID(), $component->getID())) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $component->getName())))); } $result = $issue->addAffectedComponent($component); if ($result !== false) { $itemtype = 'component'; $item = $result; $itemtypename = framework\Context::getI18n()->__('Component'); $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses)); } $message = framework\Context::getI18n()->__('Component <b>%component</b> is now affected by this issue', array('%component' => $component->getName()), true); break; case 'build': if (!$issue->getProject()->isBuildsEnabled()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Releases are disabled'))); } elseif (!$issue->canEditAffectedBuilds()) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You are not allowed to do this'))); } $build = entities\Build::getB2DBTable()->selectById($request['which_item_build']); if (tables\IssueAffectsBuild::getTable()->getByIssueIDandBuildID($issue->getID(), $build->getID())) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('%item is already affected by this issue', array('%item' => $build->getName())))); } $result = $issue->addAffectedBuild($build); if ($result !== false) { $itemtype = 'build'; $item = $result; $itemtypename = framework\Context::getI18n()->__('Release'); $content = get_component_html('main/affecteditem', array('item' => $item, 'itemtype' => $itemtype, 'itemtypename' => $itemtypename, 'issue' => $issue, 'statuses' => $statuses)); } $message = framework\Context::getI18n()->__('Release <b>%build</b> is now affected by this issue', array('%build' => $build->getName()), true); break; default: throw new \Exception('Internal error'); } $editions = array(); $components = array(); $builds = array(); if ($issue->getProject()->isEditionsEnabled()) { $editions = $issue->getEditions(); } if ($issue->getProject()->isComponentsEnabled()) { $components = $issue->getComponents(); } if ($issue->getProject()->isBuildsEnabled()) { $builds = $issue->getBuilds(); } $count = count($editions) + count($components) + count($builds); return $this->renderJSON(array('content' => $content, 'message' => $message, 'itemcount' => $count)); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $e->getMessage())); } }
public function processIncomingEmailAccount(IncomingEmailAccount $account) { $count = 0; if ($emails = $account->getUnprocessedEmails()) { try { $current_user = framework\Context::getUser(); foreach ($emails as $email) { $user = $this->getOrCreateUserFromEmailString($email->from); if ($user instanceof User) { if (framework\Context::getUser()->getID() != $user->getID()) { framework\Context::switchUserContext($user); } $message = $account->getMessage($email); $data = $message->getBodyPlain() ? $message->getBodyPlain() : strip_tags($message->getBodyHTML()); if ($data) { if (mb_detect_encoding($data, 'UTF-8', true) === false) { $data = utf8_encode($data); } $new_data = ''; foreach (explode("\n", $data) as $line) { $line = trim($line); if ($line) { $line = preg_replace('/^(_{2,}|-{2,})$/', "<hr>", $line); $new_data .= $line . "\n"; } else { $new_data .= "\n"; } } $data = nl2br($new_data, false); } // Parse the subject, and obtain the issues. $parsed_commit = Issue::getIssuesFromTextByRegex(mb_decode_mimeheader($email->subject)); $issues = $parsed_commit["issues"]; // If any issues were found, add new comment to each issue. if ($issues) { foreach ($issues as $issue) { $text = preg_replace('#(^\\w.+:\\n)?(^>.*(\\n|$))+#mi', "", $data); $text = trim($text); if (!$this->processIncomingEmailCommand($text, $issue) && $user->canPostComments()) { $comment = new Comment(); $comment->setContent($text); $comment->setPostedBy($user); $comment->setTargetID($issue->getID()); $comment->setTargetType(Comment::TYPE_ISSUE); $comment->save(); } } } else { if ($user->canReportIssues($account->getProject())) { $issue = new Issue(); $issue->setProject($account->getProject()); $issue->setTitle(mb_decode_mimeheader($email->subject)); $issue->setDescription($data); $issue->setPostedBy($user); $issue->setIssuetype($account->getIssuetype()); $issue->save(); // Append the new issue to the list of affected issues. This // is necessary in order to process the attachments properly. $issues[] = $issue; } } // If there was at least a single affected issue, and mail // contains attachments, add those attachments to related issues. if ($issues && $message->hasAttachments()) { foreach ($message->getAttachments() as $attachment_no => $attachment) { echo 'saving attachment ' . $attachment_no; $name = $attachment['filename']; $new_filename = framework\Context::getUser()->getID() . '_' . NOW . '_' . basename($name); if (framework\Settings::getUploadStorage() == 'files') { $files_dir = framework\Settings::getUploadsLocalpath(); $filename = $files_dir . $new_filename; } else { $filename = $name; } Logging::log('Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no); echo 'Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no; $content_type = $attachment['type'] . '/' . $attachment['subtype']; $file = new File(); $file->setRealFilename($new_filename); $file->setOriginalFilename(basename($name)); $file->setContentType($content_type); $file->setDescription($name); $file->setUploadedBy(framework\Context::getUser()); if (framework\Settings::getUploadStorage() == 'database') { $file->setContent($attachment['data']); } else { Logging::log('Saving file ' . $new_filename . ' with content from attachment ' . $attachment_no); file_put_contents($new_filename, $attachment['data']); } $file->save(); // Attach file to each related issue. foreach ($issues as $issue) { $issue->attachFile($file); } } } $count++; } } } catch (\Exception $e) { } if (framework\Context::getUser()->getID() != $current_user->getID()) { framework\Context::switchUserContext($current_user); } } $account->setTimeLastFetched(time()); $account->setNumberOfEmailsLastFetched($count); $account->save(); return $count; }
/** * Assign an issue to an epic * * @Route(url="/assign/issue/epic/:epic_id") * * @param framework\Request $request */ public function runAssignEpic(framework\Request $request) { try { $epic = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById((int) $request['epic_id']); $issue = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById((int) $request['issue_id']); $epic->addChildIssue($issue, true); return $this->renderJSON(array('issue_id' => $issue->getID(), 'epic_id' => $epic->getID(), 'closed_pct' => $epic->getEstimatedPercentCompleted(), 'num_child_issues' => $epic->countChildIssues(), 'estimate' => \thebuggenie\core\entities\Issue::getFormattedTime($epic->getEstimatedTime()), 'text_color' => $epic->getAgileTextColor())); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('An error occured when trying to assign the issue to the epic'))); } }
public static function processCommit(\thebuggenie\core\entities\Project $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null, \Closure $callback = null) { $output = ''; framework\Context::setCurrentProject($project); if ($project->isArchived()) { return; } if (Commits::getTable()->isProjectCommitProcessed($new_rev, $project->getID())) { return; } try { framework\Context::getI18n(); } catch (\Exception $e) { framework\Context::reinitializeI18n(null); } // Is VCS Integration enabled? if (framework\Settings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == self::MODE_DISABLED) { $output .= '[VCS ' . $project->getKey() . '] This project does not use VCS Integration' . "\n"; return $output; } // Parse the commit message, and obtain the issues and transitions for issues. $parsed_commit = \thebuggenie\core\entities\Issue::getIssuesFromTextByRegex($commit_msg); $issues = $parsed_commit["issues"]; $transitions = $parsed_commit["transitions"]; // Build list of affected files $file_lines = preg_split('/[\\n\\r]+/', $changed); $files = array(); foreach ($file_lines as $aline) { $action = mb_substr($aline, 0, 1); if ($action == "A" || $action == "U" || $action == "D" || $action == "M") { $theline = trim(mb_substr($aline, 1)); $files[] = array($action, $theline); } } // Find author of commit, fallback is guest /* * Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format * Joe Bloggs <*****@*****.**>, instead of a classic username. Therefore a user will be found via 4 queries: * a) First we extract the email if there is one, and find a user with that email * b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email) * c) the username or full name is checked against the friendly name field * d) and if we still havent found one, then we check against the username * e) and if we STILL havent found one, we use the guest user */ // a) $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($author); if (!$user instanceof \thebuggenie\core\entities\User && preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) { $email = $matches[0]; // a2) $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($email); if (!$user instanceof \thebuggenie\core\entities\User) { // Not found by email preg_match("/(?<=^)(.*)(?= <)/", $author, $matches); $author = $matches[0]; } } // b) if (!$user instanceof \thebuggenie\core\entities\User) { $user = \thebuggenie\core\entities\tables\Users::getTable()->getByRealname($author); } // c) if (!$user instanceof \thebuggenie\core\entities\User) { $user = \thebuggenie\core\entities\tables\Users::getTable()->getByBuddyname($author); } // d) if (!$user instanceof \thebuggenie\core\entities\User) { $user = \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($author); } // e) if (!$user instanceof \thebuggenie\core\entities\User) { $user = framework\Settings::getDefaultUser(); } framework\Context::setUser($user); framework\Settings::forceSettingsReload(); framework\Context::cacheAllPermissions(); $output .= '[VCS ' . $project->getKey() . '] Commit to be logged by user ' . $user->getName() . "\n"; if ($date == null) { $date = NOW; } // Create the commit data $commit = new Commit(); $commit->setAuthor($user); $commit->setDate($date); $commit->setLog($commit_msg); $commit->setPreviousRevision($old_rev); $commit->setRevision($new_rev); $commit->setProject($project); if ($branch !== null) { $data = 'branch:' . $branch; $commit->setMiscData($data); } if ($callback !== null) { $commit = $callback($commit); } $commit->save(); $output .= '[VCS ' . $project->getKey() . '] Commit logged with revision ' . $commit->getRevision() . "\n"; // Iterate over affected issues and update them. foreach ($issues as $issue) { $inst = new IssueLink(); $inst->setIssue($issue); $inst->setCommit($commit); $inst->save(); // Process all commit-message transitions for an issue. foreach ($transitions[$issue->getFormattedIssueNo()] as $transition) { if (framework\Settings::get('vcs_workflow_' . $project->getID(), 'vcs_integration') == self::WORKFLOW_ENABLED) { framework\Context::setUser($user); framework\Settings::forceSettingsReload(); framework\Context::cacheAllPermissions(); if ($issue->isWorkflowTransitionsAvailable()) { // Go through the list of possible transitions for an issue. Only // process transitions that are applicable to issue's workflow. foreach ($issue->getAvailableWorkflowTransitions() as $possible_transition) { if (mb_strtolower($possible_transition->getName()) == mb_strtolower($transition[0])) { $output .= '[VCS ' . $project->getKey() . '] Running transition ' . $transition[0] . ' on issue ' . $issue->getFormattedIssueNo() . "\n"; // String representation of parameters. Used for log message. $parameters_string = ""; // Iterate over the list of this transition's parameters, and // set them. foreach ($transition[1] as $parameter => $value) { $parameters_string .= "{$parameter}={$value} "; switch ($parameter) { case 'resolution': if (($resolution = \thebuggenie\core\entities\Resolution::getByKeyish($value)) instanceof \thebuggenie\core\entities\Resolution) { framework\Context::getRequest()->setParameter('resolution_id', $resolution->getID()); } break; case 'status': if (($status = \thebuggenie\core\entities\Status::getByKeyish($value)) instanceof \thebuggenie\core\entities\Status) { framework\Context::getRequest()->setParameter('status_id', $status->getID()); } break; } } // Run the transition. $possible_transition->transitionIssueToOutgoingStepWithoutRequest($issue); // Log an informative message about the transition. $output .= '[VCS ' . $project->getKey() . '] Ran transition ' . $possible_transition->getName() . ' with parameters \'' . $parameters_string . '\' on issue ' . $issue->getFormattedIssueNo() . "\n"; } } } } } $issue->addSystemComment(framework\Context::getI18n()->__('This issue has been updated with the latest changes from the code repository.<source>%commit_msg</source>', array('%commit_msg' => $commit_msg)), $user->getID()); $output .= '[VCS ' . $project->getKey() . '] Updated issue ' . $issue->getFormattedIssueNo() . "\n"; } // Create file links foreach ($files as $afile) { // index 0 is action, index 1 is file $inst = new File(); $inst->setAction($afile[0]); $inst->setFile($afile[1]); $inst->setCommit($commit); $inst->save(); $output .= '[VCS ' . $project->getKey() . '] Added with action ' . $afile[0] . ' file ' . $afile[1] . "\n"; } framework\Event::createNew('vcs_integration', 'new_commit')->trigger(array('commit' => $commit)); return $output; }
</td> <td class="sc_spent_time<?php if (!$issue->hasSpentTime()) { ?> faded_out<?php } ?> "<?php if (!in_array('spent_time', $visible_columns)) { ?> style="display: none;"<?php } ?> > <?php echo !$issue->hasSpentTime() ? '-' : \thebuggenie\core\entities\Issue::getFormattedTime($issue->getSpentTime(true, true)); ?> </td> <td class="smaller sc_last_updated" title="<?php echo tbg_formatTime($issue->getLastUpdatedTime(), 21); ?> "<?php if (!in_array('last_updated', $visible_columns)) { ?> style="display: none;"<?php } ?> ><?php echo tbg_formatTime($issue->getLastUpdatedTime(), 20); ?> </td>
$sheet->setCellValueByColumnAndRow(4, $cc, $issue->getDescription()); $sheet->setCellValueByColumnAndRow(5, $cc, $issue->getReproductionSteps()); $sheet->setCellValueByColumnAndRow(6, $cc, $posted_by); $sheet->setCellValueByColumnAndRow(7, $cc, $assignee); $sheet->setCellValueByColumnAndRow(8, $cc, $status); $sheet->setCellValueByColumnAndRow(9, $cc, $category); $sheet->setCellValueByColumnAndRow(10, $cc, $priority); $sheet->setCellValueByColumnAndRow(11, $cc, $reproducability); $sheet->setCellValueByColumnAndRow(12, $cc, $severity); $sheet->setCellValueByColumnAndRow(13, $cc, $resolution); $sheet->setCellValueByColumnAndRow(14, $cc, $milestone); $sheet->setCellValueByColumnAndRow(15, $cc, tbg_formatTime($issue->getPosted(), 21)); $sheet->setCellValueByColumnAndRow(16, $cc, tbg_formatTime($issue->getLastUpdatedTime(), 21)); $sheet->setCellValueByColumnAndRow(17, $cc, $issue->getPercentCompleted() . '%'); $sheet->setCellValueByColumnAndRow(18, $cc, !$issue->hasEstimatedTime() ? '-' : \thebuggenie\core\entities\Issue::getFormattedTime($issue->getEstimatedTime(true, true))); $sheet->setCellValueByColumnAndRow(19, $cc, !$issue->hasSpentTime() ? '-' : \thebuggenie\core\entities\Issue::getFormattedTime($issue->getSpentTime(true, true))); $sheet->setCellValueByColumnAndRow(20, $cc, $issue->getUserpain()); $sheet->setCellValueByColumnAndRow(21, $cc, $issue->getVotes()); $start_column = 22; foreach ($custom_columns as $column) { $value = $issue->getCustomField($column->getKey()); switch ($column->getType()) { case \thebuggenie\core\entities\CustomDatatype::DATE_PICKER: $value = strtotime($value) !== false ? tbg_formatTime($value, 20) : ''; break; case \thebuggenie\core\entities\CustomDatatype::DROPDOWN_CHOICE_TEXT: case \thebuggenie\core\entities\CustomDatatype::RADIO_CHOICE: $value = $value instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $value->getValue() : ''; break; case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE: case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE:
public function perform(\thebuggenie\core\entities\Issue $issue, $request = null) { switch ($this->_action_type) { case self::ACTION_ASSIGN_ISSUE_SELF: $issue->setAssignee(framework\Context::getUser()); break; case self::ACTION_SET_STATUS: if ($this->getTargetValue()) { $issue->setStatus(Status::getB2DBTable()->selectById((int) $this->getTargetValue())); } else { $issue->setStatus($request['status_id']); } break; case self::ACTION_CLEAR_MILESTONE: $issue->setMilestone(null); break; case self::ACTION_SET_MILESTONE: if ($this->getTargetValue()) { $issue->setMilestone(Milestone::getB2DBTable()->selectById((int) $this->getTargetValue())); } else { $issue->setMilestone($request['milestone_id']); } break; case self::ACTION_CLEAR_PRIORITY: $issue->setPriority(null); break; case self::ACTION_SET_PRIORITY: if ($this->getTargetValue()) { $issue->setPriority(Priority::getB2DBTable()->selectById((int) $this->getTargetValue())); } else { $issue->setPriority($request['priority_id']); } break; case self::ACTION_CLEAR_PERCENT: $issue->setPercentCompleted(0); break; case self::ACTION_SET_PERCENT: if ($this->getTargetValue()) { $issue->setPercentCompleted((int) $this->getTargetValue()); } else { $issue->setPercentCompleted((int) $request['percent_complete_id']); } break; case self::ACTION_CLEAR_DUPLICATE: $issue->setDuplicateOf(null); break; case self::ACTION_SET_DUPLICATE: $issue->setDuplicateOf($request['duplicate_issue_id']); break; case self::ACTION_CLEAR_RESOLUTION: $issue->setResolution(null); break; case self::ACTION_SET_RESOLUTION: if ($this->getTargetValue()) { $issue->setResolution(Resolution::getB2DBTable()->selectById((int) $this->getTargetValue())); } else { $issue->setResolution($request['resolution_id']); } break; case self::ACTION_CLEAR_REPRODUCABILITY: $issue->setReproducability(null); break; case self::ACTION_SET_REPRODUCABILITY: if ($this->getTargetValue()) { $issue->setReproducability(Reproducability::getB2DBTable()->selectById((int) $this->getTargetValue())); } else { $issue->setReproducability($request['reproducability_id']); } break; case self::ACTION_CLEAR_ASSIGNEE: $issue->clearAssignee(); break; case self::ACTION_ASSIGN_ISSUE: if ($this->getTargetValue()) { $target_details = explode('_', $this->_target_value); if ($target_details[0] == 'user') { $assignee = \thebuggenie\core\entities\User::getB2DBTable()->selectById((int) $target_details[1]); } else { $assignee = Team::getB2DBTable()->selectById((int) $target_details[1]); } $issue->setAssignee($assignee); } else { $assignee = null; switch ($request['assignee_type']) { case 'user': $assignee = \thebuggenie\core\entities\User::getB2DBTable()->selectById((int) $request['assignee_id']); break; case 'team': $assignee = Team::getB2DBTable()->selectById((int) $request['assignee_id']); break; } if ((bool) $request->getParameter('assignee_teamup', false) && $assignee instanceof \thebuggenie\core\entities\User && $assignee->getID() != framework\Context::getUser()->getID()) { $team = new \thebuggenie\core\entities\Team(); $team->setName($assignee->getBuddyname() . ' & ' . framework\Context::getUser()->getBuddyname()); $team->setOndemand(true); $team->save(); $team->addMember($assignee); $team->addMember(framework\Context::getUser()); $assignee = $team; } $issue->setAssignee($assignee); } break; case self::ACTION_USER_START_WORKING: $issue->clearUserWorkingOnIssue(); if ($issue->getAssignee() instanceof \thebuggenie\core\entities\Team && $issue->getAssignee()->isOndemand()) { $members = $issue->getAssignee()->getMembers(); $issue->startWorkingOnIssue(array_shift($members)); } elseif ($issue->getAssignee() instanceof \thebuggenie\core\entities\User) { $issue->startWorkingOnIssue($issue->getAssignee()); } break; case self::ACTION_USER_STOP_WORKING: if ($request->getParameter('did', 'nothing') == 'nothing') { $issue->clearUserWorkingOnIssue(); } elseif ($request->getParameter('did', 'nothing') == 'this') { $times = array(); if ($request['timespent_manual']) { $times = Issue::convertFancyStringToTime($request['timespent_manual']); } elseif ($request['timespent_specified_type']) { $times = array('points' => 0, 'hours' => 0, 'days' => 0, 'weeks' => 0, 'months' => 0); $times[$request['timespent_specified_type']] = $request['timespent_specified_value']; } if (array_sum($times) > 0) { $times['hours'] *= 100; $spenttime = new \thebuggenie\core\entities\IssueSpentTime(); $spenttime->setIssue($issue); $spenttime->setUser(framework\Context::getUser()); $spenttime->setSpentPoints($times['points']); $spenttime->setSpentHours($times['hours']); $spenttime->setSpentDays($times['days']); $spenttime->setSpentWeeks($times['weeks']); $spenttime->setSpentMonths($times['months']); $spenttime->setActivityType($request['timespent_activitytype']); $spenttime->setComment($request['timespent_comment']); $spenttime->save(); } $issue->clearUserWorkingOnIssue(); } else { $issue->stopWorkingOnIssue(); } break; default: if (strpos($this->_action_type, self::CUSTOMFIELD_CLEAR_PREFIX) === 0) { $customkey = substr($this->_action_type, strlen(self::CUSTOMFIELD_CLEAR_PREFIX)); $issue->setCustomField($customkey, null); } elseif (strpos($this->_action_type, self::CUSTOMFIELD_SET_PREFIX) === 0) { $customkey = substr($this->_action_type, strlen(self::CUSTOMFIELD_SET_PREFIX)); if ($this->getTargetValue()) { $issue->setCustomField($customkey, $this->getTargetValue()); } else { $issue->setCustomField($customkey, $request[$customkey . '_id']); } } else { $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionAction::perform', $issue, array('request' => $request)); $event->triggerUntilProcessed(); } } }
public function componentReportIssue() { $introarticle = \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName(ucfirst(framework\Context::getCurrentProject()->getKey()) . ':ReportIssueIntro'); $this->introarticle = $introarticle instanceof \thebuggenie\modules\publish\entities\Article ? $introarticle : \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName('ReportIssueIntro'); $reporthelparticle = \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName(ucfirst(framework\Context::getCurrentProject()->getKey()) . ':ReportIssueHelp'); $this->reporthelparticle = $reporthelparticle instanceof \thebuggenie\modules\publish\entities\Article ? $reporthelparticle : \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName('ReportIssueHelp'); $this->uniqid = framework\Context::getRequest()->getParameter('uniqid', uniqid()); $this->_setupReportIssueProperties(); $dummyissue = new entities\Issue(); $dummyissue->setProject(framework\Context::getCurrentProject()); $this->canupload = framework\Settings::isUploadsEnabled() && $dummyissue->canAttachFiles(); }
public function componentBulkWorkflow() { $workflow_items = array(); $project = null; $issues = array(); $first = true; foreach ($this->issue_ids as $issue_id) { $issue = new entities\Issue($issue_id); $issues[$issue_id] = $issue; if ($first) { $workflow_items = $issue->getAvailableWorkflowTransitions(); $project = $issue->getProject(); $first = false; } else { $transitions = $issue->getAvailableWorkflowTransitions(); foreach ($workflow_items as $transition_id => $transition) { if (!array_key_exists($transition_id, $transitions)) { unset($workflow_items[$transition_id]); } } if ($issue->getProject()->getID() != $project->getID()) { $project = null; break; } } if (!count($workflow_items)) { break; } } $this->issues = $issues; $this->project = $project; $this->available_transitions = $workflow_items; }
protected function _postSave($is_new) { $this->_saveCustomFieldValues(); if (!$is_new) { $related_issues_to_save = $this->_processChanges(); $comment = isset($this->_save_comment) ? $this->_save_comment : $this->addSystemComment('', framework\Context::getUser()->getID()); $this->triggerSaveEvent($comment, framework\Context::getUser()); if (count($related_issues_to_save)) { foreach (array_keys($related_issues_to_save) as $i_id) { $related_issue = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById((int) $i_id); $related_issue->save(); } } } else { $_description_parser = $this->_getDescriptionParser(); $_reproduction_steps_parser = $this->_getReproductionStepsParser(); if (!is_null($_description_parser) && $_description_parser->hasMentions()) { foreach ($_description_parser->getMentions() as $user) { if ($user->getID() == framework\Context::getUser()->getID()) { continue; } $this->_addNotification(Notification::TYPE_ISSUE_MENTIONED, $user, $this->getPostedBy()); } } if (!is_null($_reproduction_steps_parser) && $_reproduction_steps_parser->hasMentions()) { foreach ($_reproduction_steps_parser->getMentions() as $user) { if ($user->getID() == framework\Context::getUser()->getID()) { continue; } $this->_addNotification(Notification::TYPE_ISSUE_MENTIONED, $user, $this->getPostedBy()); } } $this->addLogEntry(tables\Log::LOG_ISSUE_CREATED, null, false, $this->getPosted()); $this->_addCreateNotifications($this->getPostedBy()); \thebuggenie\core\framework\Event::createNew('core', 'thebuggenie\\core\\entities\\Issue::createNew', $this)->trigger(); } if (in_array(\thebuggenie\core\framework\Settings::getUserSetting(\thebuggenie\core\framework\Settings::SETTINGS_USER_SUBSCRIBE_CREATED_UPDATED_COMMENTED_ISSUES, framework\Context::getUser()->getID()), array(null, true))) { $this->addSubscriber(framework\Context::getUser()->getID()); } $this->_clearChangedProperties(); $this->_log_items_added = array(); $this->getProject()->clearRecentActivities(); if ($this->isChildIssue() && ($this->hasEstimatedTime() || $this->hasSpentTime())) { foreach ($this->getParentIssues() as $issue) { $issue->calculateTime(); $issue->save(); } } if ($this->getMilestone() instanceof \thebuggenie\core\entities\Milestone) { $this->getMilestone()->updateStatus(); $this->getMilestone()->save(); } return true; }
protected function _processChanges() { $related_issues_to_save = array(); $changed_properties = $this->_getChangedProperties(); if (count($changed_properties)) { $is_saved_estimated = false; $is_saved_spent = false; $is_saved_assignee = false; $is_saved_owner = false; foreach ($changed_properties as $property => $value) { $compare_value = is_object($this->{$property}) ? $this->{$property}->getID() : $this->{$property}; $original_value = $value['original_value']; if ($original_value != $compare_value) { switch ($property) { case '_title': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_TITLE, framework\Context::getI18n()->__("Title updated"), $original_value, $compare_value); break; case '_shortname': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_SHORTNAME, framework\Context::getI18n()->__("Issue label updated"), $original_value, $compare_value); break; case '_description': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_DESCRIPTION, framework\Context::getI18n()->__("Description updated"), $original_value, $compare_value); break; case '_reproduction_steps': $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_REPRODUCTIONSTEPS, framework\Context::getI18n()->__("Reproduction steps updated"), $original_value, $compare_value); break; case '_category': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Category::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getCategory() instanceof Datatype ? $this->getCategory()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_CATEGORY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_pain_bug_type': if ($original_value != 0) { $old_name = ($old_item = self::getPainTypesOrLabel('pain_bug_type', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = ($new_item = self::getPainTypesOrLabel('pain_bug_type', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_BUG_TYPE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_pain_effect': if ($original_value != 0) { $old_name = ($old_item = self::getPainTypesOrLabel('pain_effect', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = ($new_item = self::getPainTypesOrLabel('pain_effect', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_EFFECT, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_pain_likelihood': if ($original_value != 0) { $old_name = ($old_item = self::getPainTypesOrLabel('pain_likelihood', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = ($new_item = self::getPainTypesOrLabel('pain_likelihood', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_LIKELIHOOD, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_user_pain': $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_CALCULATED, $original_value . ' ⇒ ' . $value['current_value']); break; case '_status': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getStatus() instanceof Datatype ? $this->getStatus()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_STATUS, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_reproducability': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Reproducability::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getReproducability() instanceof Datatype ? $this->getReproducability()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_REPRODUCABILITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_priority': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Priority::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getPriority() instanceof Datatype ? $this->getPriority()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_PRIORITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_assignee_team': case '_assignee_user': if (!$is_saved_assignee) { $new_name = $this->getAssignee() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getAssignee()->getName() : framework\Context::getI18n()->__('Not assigned'); if ($this->getAssignee() instanceof \thebuggenie\core\entities\User) { $this->startWorkingOnIssue($this->getAssignee()); } $this->addLogEntry(tables\Log::LOG_ISSUE_ASSIGNED, $new_name); $is_saved_assignee = true; } break; case '_posted_by': $old_identifiable = $original_value ? \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value) : framework\Context::getI18n()->__('Unknown'); $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown'); $new_name = $this->getPostedBy()->getName(); $this->addLogEntry(tables\Log::LOG_ISSUE_POSTED, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_being_worked_on_by_user': if ($original_value != 0) { $old_identifiable = \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value); $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not being worked on'); } $new_name = $this->getUserWorkingOnIssue() instanceof \thebuggenie\core\entities\User ? $this->getUserWorkingOnIssue()->getName() : framework\Context::getI18n()->__('Not being worked on'); $this->addLogEntry(tables\Log::LOG_ISSUE_USERS, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_owner_team': case '_owner_user': if (!$is_saved_owner) { $new_name = $this->getOwner() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getOwner()->getName() : framework\Context::getI18n()->__('Not owned by anyone'); $this->addLogEntry(tables\Log::LOG_ISSUE_OWNED, $new_name); $is_saved_owner = true; } break; case '_percent_complete': $this->addLogEntry(tables\Log::LOG_ISSUE_PERCENT, $original_value . '% ⇒ ' . $this->getPercentCompleted() . '', $original_value, $compare_value); break; case '_resolution': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Resolution::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getResolution() instanceof Datatype ? $this->getResolution()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_RESOLUTION, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_severity': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Severity::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getSeverity() instanceof Datatype ? $this->getSeverity()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_SEVERITY, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_milestone': if ($original_value != 0) { $old_name = ($old_item = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined'); } else { $old_name = framework\Context::getI18n()->__('Not determined'); } $new_name = $this->getMilestone() instanceof \thebuggenie\core\entities\Milestone ? $this->getMilestone()->getName() : framework\Context::getI18n()->__('Not determined'); $this->addLogEntry(tables\Log::LOG_ISSUE_MILESTONE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); $this->_milestone_order = 0; break; case '_issuetype': if ($original_value != 0) { $old_name = ($old_item = Issuetype::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); } else { $old_name = framework\Context::getI18n()->__('Unknown'); } $new_name = $this->getIssuetype() instanceof \thebuggenie\core\entities\Issuetype ? $this->getIssuetype()->getName() : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_ISSUETYPE, $old_name . ' ⇒ ' . $new_name, $original_value, $compare_value); break; case '_estimated_months': case '_estimated_weeks': case '_estimated_days': case '_estimated_hours': case '_estimated_points': if (!$is_saved_estimated) { $old_time = array('months' => $this->getChangedPropertyOriginal('_estimated_months'), 'weeks' => $this->getChangedPropertyOriginal('_estimated_weeks'), 'days' => $this->getChangedPropertyOriginal('_estimated_days'), 'hours' => $this->getChangedPropertyOriginal('_estimated_hours'), 'points' => $this->getChangedPropertyOriginal('_estimated_points')); $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('Not estimated'); $new_formatted_time = $this->hasEstimatedTime() ? Issue::getFormattedTime($this->getEstimatedTime()) : framework\Context::getI18n()->__('Not estimated'); $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_ESTIMATED, $old_formatted_time . ' ⇒ ' . $new_formatted_time, serialize($old_time), serialize($this->getEstimatedTime())); $is_saved_estimated = true; } break; case '_spent_months': case '_spent_weeks': case '_spent_days': case '_spent_hours': case '_spent_points': if (!$is_saved_spent) { $old_time = array('months' => $this->getChangedPropertyOriginal('_spent_months'), 'weeks' => $this->getChangedPropertyOriginal('_spent_weeks'), 'days' => $this->getChangedPropertyOriginal('_spent_days'), 'hours' => round($this->getChangedPropertyOriginal('_spent_hours') / 100, 2), 'points' => $this->getChangedPropertyOriginal('_spent_points')); $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('No time spent'); $new_formatted_time = $this->hasSpentTime() ? Issue::getFormattedTime($this->getSpentTime()) : framework\Context::getI18n()->__('No time spent'); $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_SPENT, $old_formatted_time . ' ⇒ ' . $new_formatted_time, serialize($old_time), serialize($this->getSpentTime())); $is_saved_spent = true; } break; case '_state': if ($this->isClosed()) { $this->addLogEntry(tables\Log::LOG_ISSUE_CLOSE); if ($this->getMilestone() instanceof \thebuggenie\core\entities\Milestone) { if ($this->getMilestone()->isSprint()) { if (!$this->getIssueType()->isTask()) { $this->setSpentPoints($this->getEstimatedPoints()); } else { if ($this->getSpentHours() < $this->getEstimatedHours()) { $this->setSpentHours($this->getEstimatedHours()); } foreach ($this->getParentIssues() as $parent_issue) { if ($parent_issue->checkTaskStates()) { $related_issues_to_save[$parent_issue->getID()] = true; } } } } $this->getMilestone()->updateStatus(); $this->getMilestone()->save(); } } else { $this->addLogEntry(tables\Log::LOG_ISSUE_REOPEN); } break; case '_blocking': if ($this->isBlocking()) { $this->addLogEntry(tables\Log::LOG_ISSUE_BLOCKED); } else { $this->addLogEntry(tables\Log::LOG_ISSUE_UNBLOCKED); } break; default: if (mb_substr($property, 0, 12) == '_customfield') { $key = mb_substr($property, 12); $customdatatype = CustomDatatype::getByKey($key); switch ($customdatatype->getType()) { case CustomDatatype::INPUT_TEXT: $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value); break; case CustomDatatype::INPUT_TEXTAREA_SMALL: case CustomDatatype::INPUT_TEXTAREA_MAIN: $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value); break; case CustomDatatype::EDITIONS_CHOICE: case CustomDatatype::COMPONENTS_CHOICE: case CustomDatatype::RELEASES_CHOICE: case CustomDatatype::MILESTONE_CHOICE: case CustomDatatype::STATUS_CHOICE: case CustomDatatype::TEAM_CHOICE: case CustomDatatype::USER_CHOICE: case CustomDatatype::CLIENT_CHOICE: $old_object = null; $new_object = null; try { switch ($customdatatype->getType()) { case CustomDatatype::EDITIONS_CHOICE: $old_object = Edition::getB2DBTable()->selectById($original_value); break; case CustomDatatype::COMPONENTS_CHOICE: $old_object = Component::getB2DBTable()->selectById($original_value); break; case CustomDatatype::RELEASES_CHOICE: $old_object = Build::getB2DBTable()->selectById($original_value); break; case CustomDatatype::MILESTONE_CHOICE: $old_object = Milestone::getB2DBTable()->selectById($original_value); break; case CustomDatatype::STATUS_CHOICE: $old_object = Status::getB2DBTable()->selectById($original_value); break; case CustomDatatype::TEAM_CHOICE: $old_object = Team::getB2DBTable()->selectById($original_value); break; case CustomDatatype::USER_CHOICE: $old_object = User::getB2DBTable()->selectById($original_value); break; case CustomDatatype::CLIENT_CHOICE: $old_object = Client::getB2DBTable()->selectById($original_value); break; } } catch (\Exception $e) { } try { switch ($customdatatype->getType()) { case CustomDatatype::EDITIONS_CHOICE: case CustomDatatype::COMPONENTS_CHOICE: case CustomDatatype::RELEASES_CHOICE: case CustomDatatype::MILESTONE_CHOICE: case CustomDatatype::STATUS_CHOICE: case CustomDatatype::TEAM_CHOICE: case CustomDatatype::USER_CHOICE: case CustomDatatype::CLIENT_CHOICE: $new_object = $this->getCustomField($key); break; } } catch (\Exception $e) { } $old_value = is_object($old_object) ? $old_object->getName() : framework\Context::getI18n()->__('Unknown'); $new_value = is_object($new_object) ? $new_object->getName() : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' ⇒ ' . $new_value, $original_value, $compare_value); break; default: $old_item = null; try { $old_item = $original_value ? new CustomDatatypeOption($original_value) : null; } catch (\Exception $e) { } $old_value = $old_item instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $old_item->getName() : framework\Context::getI18n()->__('Unknown'); $new_value = $this->getCustomField($key) instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $this->getCustomField($key)->getName() : framework\Context::getI18n()->__('Unknown'); $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' ⇒ ' . $new_value, $original_value, $compare_value); break; } } break; } } } if ($is_saved_estimated) { tables\IssueEstimates::getTable()->saveEstimate($this->getID(), $this->_estimated_months, $this->_estimated_weeks, $this->_estimated_days, $this->_estimated_hours, $this->_estimated_points); } } return $related_issues_to_save; }
echo $epic->getStatus() instanceof \thebuggenie\core\entities\Datatype ? $epic->getStatus()->getColor() : '#FFF'; ?> ;" title="<?php echo $epic->getStatus() instanceof \thebuggenie\core\entities\Datatype ? $epic->getStatus()->getName() : __('Unknown'); ?> "> </div><?php echo $epic->getStatus() instanceof \thebuggenie\core\entities\Status ? $epic->getStatus()->getName() : __('Not determined'); ?> </dd> <dt><?php echo __('Estimate'); ?> </dt> <dd id="epic_<?php echo $epic->getID(); ?> _estimate"><?php echo \thebuggenie\core\entities\Issue::getFormattedTime($epic->getEstimatedTime(true, true)); ?> </dd> <dt><?php echo __('Child issues'); ?> </dt> <dd><?php echo __('%num_child_issues issue(s)', array('%num_child_issues' => '<span id="epic_' . $epic->getID() . '_child_issues_count">' . $epic->countChildIssues() . '</span>')); ?> </dd> </dl> </li>
public function getTarget() { if ($this->_target === null) { switch ($this->getTargetType()) { case self::TYPE_ISSUE: $this->_target = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById($this->_target_id); break; case self::TYPE_ARTICLE: $this->_target = publish\entities\tables\Articles::getTable()->selectById($this->_target_id); break; default: $event = \thebuggenie\core\framework\Event::createNew('core', 'Comment::getTarget', $this); $event->trigger(); $this->_target = $event->getReturnValue(); } } return $this->_target; }
?> _name"<?php if (!$issue->hasSpentTime()) { ?> style="display: none;"<?php } ?> > <a href="javascript:void(0)" onclick="TBG.Main.Helpers.Backdrop.show('<?php echo make_url('get_partial_for_backdrop', array('key' => 'issue_spenttimes', 'issue_id' => $issue->getID())); ?> ');" id="spent_time_<?php echo $issue->getID(); ?> _value"><?php echo \thebuggenie\core\entities\Issue::getFormattedTime($issue->getSpentTime()); ?> </a> </span> <span class="faded_out" id="no_spent_time_<?php echo $issue->getID(); ?> "<?php if ($issue->hasSpentTime()) { ?> style="display: none;"<?php } ?> ><?php echo __('No time spent'); ?>
echo __("Pain bug type on issue changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>')); } break; case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_PAIN_EFFECT: echo image_tag('icon_priority.png'); if ($item->hasChangeDetails()) { $previous_value = $item->getPreviousValue() ? \thebuggenie\core\entities\Issue::getPainTypesOrLabel('pain_effect', $item->getPreviousValue()) : __('Not determined'); $new_value = $item->getCurrentValue() ? \thebuggenie\core\entities\Issue::getPainTypesOrLabel('pain_effect', $item->getCurrentValue()) : __('Not determined'); echo __("Pain effect on issue changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>')); } break; case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_PAIN_LIKELIHOOD: echo image_tag('icon_priority.png'); if ($item->hasChangeDetails()) { $previous_value = $item->getPreviousValue() ? \thebuggenie\core\entities\Issue::getPainTypesOrLabel('pain_likelihood', $item->getPreviousValue()) : __('Not determined'); $new_value = $item->getCurrentValue() ? \thebuggenie\core\entities\Issue::getPainTypesOrLabel('pain_likelihood', $item->getCurrentValue()) : __('Not determined'); echo __("Likelihood on issue changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>')); } break; case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_PAIN_CALCULATED: echo image_tag('icon_percent.png'); if ($item->hasChangeDetails()) { echo __("Calculated pain on issue changed: %value", array('%value' => '<strong>' . $item->getText() . '</strong>')); } break; case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_USERS: echo image_tag('icon_user.png'); if ($item->hasChangeDetails()) { $previous_value = $item->getPreviousValue() ? ($old_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getPreviousValue())) ? __($old_item->getNameWithUsername()) : __('Unknown') : __('Not determined'); $new_value = $item->getCurrentValue() ? ($new_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getCurrentValue())) ? __($new_item->getNameWithUsername()) : __('Unknown') : __('Not determined'); echo __("User working on issue changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
/** * Returns the object which the notification is for * * @return \thebuggenie\core\entities\common\IdentifiableScoped */ public function getTarget() { if ($this->_target === null) { if ($this->_module_name == 'core') { switch ($this->_notification_type) { case self::TYPE_ARTICLE_COMMENTED: case self::TYPE_ISSUE_COMMENTED: case self::TYPE_COMMENT_MENTIONED: $this->_target = tables\Comments::getTable()->selectById((int) $this->_target_id); break; case self::TYPE_ISSUE_UPDATED: case self::TYPE_ISSUE_CREATED: case self::TYPE_ISSUE_MENTIONED: $this->_target = \thebuggenie\core\entities\Issue::getB2DBTable()->selectById((int) $this->_target_id); break; case self::TYPE_ARTICLE_CREATED: case self::TYPE_ARTICLE_UPDATED: case self::TYPE_ARTICLE_MENTIONED: $this->_target = Articles::getTable()->selectById((int) $this->_target_id); break; } } else { $event = new \thebuggenie\core\framework\Event('core', 'thebuggenie\\core\\entities\\Notification::getTarget', $this); $event->triggerUntilProcessed(); $this->_target = $event->getReturnValue(); } } return $this->_target; }
?> </td> <tr> <td colspan="2" style="padding-top: 5px;"> <select name="pain_effect_id" id="pain_effect_id" style="width: 100%;"> <option value=""<?php if (!$selected_pain_effect) { echo ' selected'; } ?> ><?php echo __('Not specified'); ?> </option> <?php foreach (\thebuggenie\core\entities\Issue::getPainTypesOrLabel('pain_effect') as $choice_id => $choice) { ?> <option value="<?php echo $choice_id; ?> "<?php if ($selected_pain_effect == $choice_id) { ?> selected<?php } ?> ><?php echo $choice; ?> </option> <?php
/** * * @param \b2db\Criteria $crit * @param array|\thebuggenie\core\entities\SearchFilter $filters * @param \b2db\Criterion $ctn * @return null */ public function addToCriteria($crit, $filters, $ctn = null) { $filter_key = $this->getFilterKey(); if (in_array($this['operator'], array('=', '!=', '<=', '>=', '<', '>'))) { if ($filter_key == 'text') { if ($this['value'] != '') { $searchterm = mb_strpos($this['value'], '%') !== false ? $this['value'] : "%{$this['value']}%"; $issue_no = Issue::extractIssueNoFromNumber($this['value']); if ($this['operator'] == '=') { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_LIKE); } $ctn->addOr(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_LIKE); $ctn->addOr(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_LIKE); $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); if (is_numeric($issue_no)) { $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); if (is_numeric($issue_no)) { $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); } else { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_NOT_LIKE); } $ctn->addWhere(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_NOT_LIKE); $ctn->addWhere(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_NOT_LIKE); $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); if (is_numeric($issue_no)) { $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); if (is_numeric($issue_no)) { $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); } return $ctn; } } elseif (in_array($filter_key, self::getValidSearchFilters())) { if ($filter_key == 'subprojects') { if (framework\Context::isProjectContext()) { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::PROJECT_ID, framework\Context::getCurrentProject()->getID()); } if ($this->hasValue()) { foreach ($this->getValues() as $value) { switch ($value) { case 'all': $subprojects = Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject()); foreach ($subprojects as $subproject) { if ($subproject->getID() == framework\Context::getCurrentProject()->getID()) { continue; } $ctn->addOr(tables\Issues::PROJECT_ID, $subproject->getID()); } break; case 'none': case '': break; default: $ctn->addOr(tables\Issues::PROJECT_ID, (int) $value); break; } } } return $ctn; } } elseif (in_array($filter_key, array('build', 'edition', 'component'))) { switch ($filter_key) { case 'component': $tbl = tables\IssueAffectsComponent::getTable(); $fk = tables\IssueAffectsComponent::ISSUE; break; case 'edition': $tbl = tables\IssueAffectsEdition::getTable(); $fk = tables\IssueAffectsEdition::ISSUE; break; case 'build': $tbl = tables\IssueAffectsBuild::getTable(); $fk = tables\IssueAffectsBuild::ISSUE; break; } $crit->addJoin($tbl, $fk, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.' . $filter_key, $this->getValues())), \b2db\Criteria::DB_INNER_JOIN); return null; } else { if ($filter_key == 'project_id' && in_array('subprojects', $filters)) { return null; } $values = $this->getValues(); $num_values = 0; if ($filter_key == 'status') { if ($this->hasValue('open')) { $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_OPEN); $num_values++; } if ($this->hasValue('closed')) { $num_values++; if (isset($c)) { $c->addWhere(tables\Issues::STATE, Issue::STATE_CLOSED); } else { $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_CLOSED); } } if (isset($c)) { if (count($values) == $num_values) { return $c; } else { $crit->addWhere($c); } } } $dbname = tables\Issues::getTable()->getB2DBName(); foreach ($values as $value) { $operator = $this['operator']; $or = true; if ($filter_key == 'status' && in_array($value, array('open', 'closed'))) { continue; } else { $field = $dbname . '.' . $filter_key; if ($operator == '!=' || in_array($filter_key, array('posted', 'last_updated'))) { $or = false; } } if ($ctn === null) { $ctn = $crit->returnCriterion($field, $value, urldecode($operator)); } elseif ($or) { $ctn->addOr($field, $value, urldecode($operator)); } else { $ctn->addWhere($field, $value, urldecode($operator)); } } return $ctn; } } elseif (CustomDatatype::doesKeyExist($filter_key)) { $customdatatype = CustomDatatype::getByKey($filter_key); if (in_array($this->getFilterType(), CustomDatatype::getInternalChoiceFieldsAsArray())) { $tbl = clone tables\IssueCustomFields::getTable(); $crit->addJoin($tbl, tables\IssueCustomFields::ISSUE_ID, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.customfields_id', $customdatatype->getID()), array($tbl->getB2DBAlias() . '.customfieldoption_id', $this->getValues())), \b2db\Criteria::DB_INNER_JOIN); return null; } else { foreach ($this->getValues() as $value) { if ($customdatatype->hasCustomOptions()) { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID()); $ctn->addWhere(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']); } else { $ctn->addOr(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']); } } else { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID()); $ctn->addWhere(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']); } else { $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']); } } } return $ctn; } } } }
/** * Returns an array of teams which the current user is a member of * * @return array|Team */ public function getTeams() { $this->_populateTeams(); $teams = $this->_teams['assigned']; if (framework\Context::isProjectContext()) { $project = framework\Context::getCurrentProject(); } else { if (framework\Context::getRequest()->hasParameter('issue_id')) { $issue = Issue::getB2DBTable()->selectById(framework\Context::getRequest()->getParameter('issue_id')); if ($issue instanceof Issue && $issue->getProject() instanceof Project) { $project = $issue->getProject(); } } } if (isset($project)) { $project_assigned_teams = $project->getAssignedTeams(); foreach ($teams as $team_id => $team) { if (!array_key_exists($team_id, $project_assigned_teams)) { unset($teams[$team_id]); } } } return $teams; }
<div class="results_summary"> <div class="summary_header"><?php echo __('In the group above (on this page)'); ?> </div> <?php echo __('Total number of issues: %number', array('%number' => '<span class="issue_count">' . $current_count . '</span>')); ?> <br> <?php echo __('Total estimated effort: %details', array('%details' => '<span class="issue_estimated_time_summary">' . \thebuggenie\core\entities\Issue::getFormattedTime($current_estimated_time, false) . '</span>')); ?> <br> <?php echo __('Total current effort: %details', array('%details' => '<span class="issue_spent_time_summary">' . \thebuggenie\core\entities\Issue::getFormattedTime($current_spent_time, false) . '</span>')); ?> <br> </div>
/** * Formats log time * * @param $log * @param $previous_value * @param $current_value * @param bool $append_minutes * @param bool $subtract_hours * * @return string */ public static function formatTimeableLog($time, $previous_value, $current_value, $append_minutes = false, $subtract_hours = false) { if (!$append_minutes && !$subtract_hours) { return $time; } $old_time = unserialize($previous_value); $new_time = unserialize($current_value); if ($append_minutes) { if (isset($old_time['hours']) && isset($old_time['minutes'])) { $old_time['hours'] += (int) floor($old_time['minutes'] / 60); } if (isset($new_time['hours']) && isset($new_time['minutes'])) { $new_time['hours'] += (int) floor($new_time['minutes'] / 60); } } if ($subtract_hours) { if (isset($old_time['minutes'])) { $old_time['minutes'] = $old_time['minutes'] % 60; } if (isset($new_time['minutes'])) { $new_time['minutes'] = $new_time['minutes'] % 60; } } return \thebuggenie\core\entities\Issue::getFormattedTime($old_time) . ' ⇒ ' . \thebuggenie\core\entities\Issue::getFormattedTime($new_time); }
protected function _populateIssueCountsByMilestone($milestone_id) { if ($this->_issuecounts === null) { $this->_issuecounts = array(); } if (!array_key_exists('milestone', $this->_issuecounts)) { $this->_issuecounts['milestone'] = array(); } if (!array_key_exists($milestone_id, $this->_issuecounts['milestone'])) { list($this->_issuecounts['milestone'][$milestone_id]['closed'], $this->_issuecounts['milestone'][$milestone_id]['open']) = Issue::getIssueCountsByProjectIDandMilestone($this->getID(), $milestone_id); } }
public function isValid($input) { switch ($this->_name) { case self::RULE_MAX_ASSIGNED_ISSUES: $num_issues = (int) $this->getRuleValue(); return $num_issues ? (bool) (count(framework\Context::getUser()->getUserAssignedIssues()) < $num_issues) : true; break; case self::RULE_TEAM_MEMBERSHIP_VALID: $valid_items = explode(',', $this->getRuleValue()); $teams = \thebuggenie\core\entities\Team::getAll(); if ($this->isPost()) { if ($input instanceof \thebuggenie\core\entities\Issue) { $assignee = $input->getAssignee(); } } if (!isset($assignee)) { $assignee = framework\Context::getUser(); } if ($assignee instanceof \thebuggenie\core\entities\User) { if (count($valid_items) == 1 && reset($valid_items) == '') { return true; } foreach ($valid_items as $team_id) { if ($assignee->isMemberOfTeam($teams[$team_id])) { return true; } } } elseif ($assignee instanceof \thebuggenie\core\entities\Team) { foreach ($valid_items as $team_id) { if ($assignee->getID() == $team_id) { return true; } } } return false; case self::RULE_ISSUE_IN_MILESTONE_VALID: $valid_items = explode(',', $this->getRuleValue()); if ($input instanceof \thebuggenie\core\entities\Issue) { $issue = $input; } else { if ($input->hasParameter('issue_id')) { $issue = \thebuggenie\core\entities\Issue::getB2DBTable()->selectByID((int) $input->getParameter('issue_id')); } } if (isset($issue) && $issue instanceof \thebuggenie\core\entities\Issue) { if (!$issue->getMilestone() instanceof \thebuggenie\core\entities\Milestone) { return false; } if (count($valid_items) == 1 && reset($valid_items) == '') { return true; } return in_array($issue->getMilestone()->getID(), $valid_items); } return false; case self::RULE_STATUS_VALID: case self::RULE_PRIORITY_VALID: case self::RULE_RESOLUTION_VALID: case self::RULE_REPRODUCABILITY_VALID: $valid_items = explode(',', $this->getRuleValue()); $valid = false; if ($this->_name == self::RULE_STATUS_VALID) { $fieldname = 'Status'; $fieldname_small = 'status'; } elseif ($this->_name == self::RULE_RESOLUTION_VALID) { $fieldname = 'Resolution'; $fieldname_small = 'resolution'; } elseif ($this->_name == self::RULE_REPRODUCABILITY_VALID) { $fieldname = 'Reproducability'; $fieldname_small = 'reproducability'; } elseif ($this->_name == self::RULE_PRIORITY_VALID) { $fieldname = 'Priority'; $fieldname_small = 'priority'; } else { throw new framework\exceptions\ConfigurationException(framework\Context::getI18n()->__('Invalid workflow validation rule: %rule_name', array('%rule_name' => $this->_name))); } if (!$this->getRuleValue()) { if ($input instanceof \thebuggenie\core\entities\Issue) { $getter = "get{$fieldname}"; if (is_object($input->{$getter}())) { $valid = true; } } elseif ($input instanceof framework\Request) { if ($input->getParameter("{$fieldname_small}_id") && Status::has($input->getParameter("{$fieldname_small}_id"))) { $valid = true; } } } else { foreach ($valid_items as $item) { if ($input instanceof \thebuggenie\core\entities\Issue) { $type = "\\thebuggenie\\core\\entities\\{$fieldname}"; $getter = "get{$fieldname}"; if (is_object($input->{$getter}()) && $type::getB2DBTable()->selectByID((int) $item)->getID() == $input->{$getter}()->getID()) { $valid = true; break; } } elseif ($input instanceof framework\Request) { if ($input->getParameter("{$fieldname_small}_id") == $item) { $valid = true; break; } } } } return $valid; break; default: if ($this->isCustom()) { switch ($this->getCustomType()) { case CustomDatatype::RADIO_CHOICE: case CustomDatatype::DROPDOWN_CHOICE_TEXT: case CustomDatatype::TEAM_CHOICE: case CustomDatatype::STATUS_CHOICE: case CustomDatatype::MILESTONE_CHOICE: case CustomDatatype::CLIENT_CHOICE: case CustomDatatype::COMPONENTS_CHOICE: case CustomDatatype::EDITIONS_CHOICE: case CustomDatatype::RELEASES_CHOICE: $valid_items = explode(',', $this->getRuleValue()); if ($input instanceof \thebuggenie\core\entities\Issue) { $value = $input->getCustomField($this->getCustomFieldname()); } elseif ($input instanceof framework\Request) { $value = $input->getParameter($this->getCustomFieldname() . "_id"); } $valid = false; if (!$this->getRuleValue()) { foreach ($this->getCustomField()->getOptions() as $item) { if ($item->getID() == $value) { $valid = true; break; } } } else { foreach ($valid_items as $item) { if ($value instanceof Identifiable && $value->getID() == $item) { $valid = true; break; } elseif (is_numeric($value) && $value == $item) { $valid = true; break; } } } return $valid; break; } } else { $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionValidationRule::isValid', $this); $event->setReturnValue(false); $event->triggerUntilProcessed(array('input' => $input)); return $event->getReturnValue(); } } }
/** * Adds an epic * * @Route(url="/boards/:board_id/addepic") * * @param framework\Request $request */ public function runAddEpic(framework\Request $request) { $this->forward403unless($this->_checkProjectPageAccess('project_planning')); $board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']); try { $title = trim($request['title']); $shortname = trim($request['shortname']); if (!$title) { throw new \Exception($this->getI18n()->__('You have to provide a title')); } if (!$shortname) { throw new \Exception($this->getI18n()->__('You have to provide a label')); } $issue = new \thebuggenie\core\entities\Issue(); $issue->setTitle($title); $issue->setShortname($shortname); $issue->setIssuetype($board->getEpicIssuetypeID()); $issue->setProject($board->getProject()); $issue->setPostedBy($this->getUser()); $issue->save(); return $this->renderJSON(array('issue_details' => $issue->toJSON())); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $e->getMessage())); } }
public function runTransitionIssues(framework\Request $request) { try { try { $transition = entities\WorkflowTransition::getB2DBTable()->selectById($request['transition_id']); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $this->getI18n()->__('This is not a valid transition'))); } $issue_ids = $request['issue_ids']; $status = null; $closed = false; foreach ($issue_ids as $issue_id) { $issue = entities\Issue::getB2DBTable()->selectById((int) $issue_id); if (!$issue->isWorkflowTransitionsAvailable() || !$transition->validateFromRequest($request)) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('The transition could not be applied to issue %issue_number because of %errors', array('%issue_number' => $issue->getFormattedIssueNo(), '%errors' => join(', ', $transition->getValidationErrors()))))); } try { $transition->transitionIssueToOutgoingStepFromRequest($issue, $request); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); framework\Logging::log(framework\Logging::LEVEL_WARNING, 'Transition ' . $transition->getID() . ' failed for issue ' . $issue_id); framework\Logging::log(framework\Logging::LEVEL_WARNING, $e->getMessage()); return $this->renderJSON(array('error' => $this->getI18n()->__('The transition failed because of an error in the workflow. Check your workflow configuration.'))); } if ($status === null) { $status = $issue->getStatus(); } $closed = $issue->isClosed(); } framework\Context::loadLibrary('common'); $options = array('issue_ids' => array_keys($issue_ids), 'last_updated' => tbg_formatTime(time(), 20), 'closed' => $closed); $options['status'] = array('color' => $status->getColor(), 'name' => $status->getName(), 'id' => $status->getID()); if ($request->hasParameter('milestone_id')) { $milestone = new entities\Milestone($request['milestone_id']); $options['milestone_id'] = $milestone->getID(); $options['milestone_name'] = $milestone->getName(); } foreach (array('resolution', 'priority', 'category', 'severity') as $item) { $class = "\\thebuggenie\\core\\entities\\" . ucfirst($item); if ($request->hasParameter($item . '_id')) { if ($item_id = $request[$item . '_id']) { $itemobject = new $class($item_id); $itemname = $itemobject->getName(); } else { $item_id = 0; $itemname = '-'; } $options[$item] = array('name' => $itemname, 'id' => $item_id); } else { $method = 'get' . ucfirst($item); $itemname = $issue->{$method}() instanceof $class ? $issue->{$method}()->getName() : '-'; $item_id = $issue->{$method}() instanceof $class ? $issue->{$method}()->getID() : 0; $options[$item] = array('name' => $itemname, 'id' => $item_id); } } return $this->renderJSON($options); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); framework\Logging::log(framework\Logging::LEVEL_WARNING, $e->getMessage()); return $this->renderJSON(array('error' => $this->getI18n()->__('An error occured when trying to apply the transition'))); } }
public static function parseIssuelink($matches, $markdown_format = false) { $theIssue = \thebuggenie\core\entities\Issue::getIssueFromLink($matches[0]); $output = ''; $classname = ''; if ($theIssue instanceof \thebuggenie\core\entities\Issue && ($theIssue->isClosed() || $theIssue->isDeleted())) { $classname = 'closed'; } if ($theIssue instanceof \thebuggenie\core\entities\Issue) { $theIssueUrl = make_url('viewissue', array('issue_no' => $theIssue->getFormattedIssueNo(false), 'project_key' => $theIssue->getProject()->getKey())); if ($markdown_format) { if ($classname != '') { $classname = ' {.' . $classname . '}'; } $output = "[{$matches[0]}]({$theIssueUrl} \"{$theIssue->getFormattedTitle()}\"){$classname}"; } else { $output = ' ' . link_tag($theIssueUrl, $matches[0], array('class' => $classname, 'title' => $theIssue->getFormattedTitle())); } } else { $output = $matches[0]; } return $output; }
public function getIssueID() { return is_object($this->_issue_id) ? $this->_issue_id->getID() : (int) $this->_issue_id; }
public function hasQuickfoundIssues() { if ($this->_quickfound_issues === null) { $this->_quickfound_issues = array(); if ($this->getSearchterm()) { preg_replace_callback(\thebuggenie\core\helpers\TextParser::getIssueRegex(), array('\\thebuggenie\\core\\entities\\SavedSearch', 'extractIssues'), $this->getSearchterm()); } } if (!count($this->_quickfound_issues)) { $issue = Issue::getIssueFromLink($this->getSearchterm()); if ($issue instanceof Issue) { $this->_quickfound_issues[] = $issue; } } return (bool) count($this->_quickfound_issues); }
public function editOrAdd(Issue $issue, User $user, $data = array()) { if (!$this->getID()) { if ($data['timespent_manual']) { $times = Issue::convertFancyStringToTime($data['timespent_manual'], $issue); } else { $times = \thebuggenie\core\entities\common\Timeable::getZeroedUnitsWithPoints(); $times[$data['timespent_specified_type']] = $data['timespent_specified_value']; } $this->setIssue($issue); $this->setUser($user); } else { $times = array('points' => $data['points'], 'minutes' => $data['minutes'], 'hours' => $data['hours'], 'days' => $data['days'], 'weeks' => $data['weeks'], 'months' => $data['months']); $edited_at = $data['edited_at']; $this->setEditedAt(mktime(0, 0, 1, $edited_at['month'], $edited_at['day'], $edited_at['year'])); } $times['hours'] *= 100; $this->setSpentPoints($times['points']); $this->setSpentMinutes($times['minutes']); $this->setSpentHours($times['hours']); $this->setSpentDays($times['days']); $this->setSpentWeeks($times['weeks']); $this->setSpentMonths($times['months']); $this->setActivityType($data['timespent_activitytype']); $this->setComment($data['timespent_comment']); $this->save(); $this->getIssue()->saveSpentTime(); }