作者:LogosLab
项目:thebuggenie-module-ap
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');
}
作者:nrense
项目:thebuggeni
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()));
}
}
作者:RTechSof
项目:thebuggeni
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) {
//.........这里部分代码省略.........
作者:pkdevbox
项目:thebuggeni
/**
* 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')));
}
}
作者:AzerothShar
项目:thebuggeni
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 <me@example.com>, 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);
//.........这里部分代码省略.........
作者:nrense
项目:thebuggeni
</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>
作者:founderi
项目:thebuggeni
$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:
作者:AzerothShar
项目:thebuggeni
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;
}
//.........这里部分代码省略.........
作者:founderi
项目:thebuggeni
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();
}
作者:founderi
项目:thebuggeni
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;
}
作者:AzerothShar
项目:thebuggeni
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;
}
作者:AzerothShar
项目:thebuggeni
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);
//.........这里部分代码省略.........
作者:founderi
项目:thebuggeni
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>
作者:founderi
项目:thebuggeni
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;
}
作者:RTechSof
项目:thebuggeni
?>
_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');
?>
作者:pkdevbox
项目:thebuggeni
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>'));
作者:pkdevbox
项目:thebuggeni
/**
* 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;
}
作者:JonathanR
项目:thebuggeni
?>
</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
作者:founderi
项目:thebuggeni
/**
*
* @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;
//.........这里部分代码省略.........
作者:founderi
项目:thebuggeni
/**
* 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;
}