protected static function _populateAvailableActions() { if (self::$_available_actions === null) { $initial_list = array('special' => array(), 'set' => array(), 'clear' => array()); $i18n = framework\Context::getI18n(); $initial_list['special'][self::ACTION_ASSIGN_ISSUE] = $i18n->__('Assign the issue to a user'); $initial_list['special'][self::ACTION_ASSIGN_ISSUE_SELF] = $i18n->__('Assign the issue to the current user'); $initial_list['special'][self::ACTION_CLEAR_DUPLICATE] = $i18n->__('Mark as not duplicate'); $initial_list['special'][self::ACTION_SET_DUPLICATE] = $i18n->__('Possibly mark as duplicate'); $initial_list['special'][self::ACTION_USER_START_WORKING] = $i18n->__('Start logging time'); $initial_list['special'][self::ACTION_USER_STOP_WORKING] = $i18n->__('Stop logging time and optionally add time spent'); $initial_list['clear'][self::ACTION_CLEAR_ASSIGNEE] = $i18n->__('Clear issue assignee'); $initial_list['clear'][self::ACTION_CLEAR_PRIORITY] = $i18n->__('Clear issue priority'); $initial_list['clear'][self::ACTION_CLEAR_PERCENT] = $i18n->__('Clear issue percent'); $initial_list['clear'][self::ACTION_CLEAR_REPRODUCABILITY] = $i18n->__('Clear issue reproducability'); $initial_list['clear'][self::ACTION_CLEAR_RESOLUTION] = $i18n->__('Clear issue resolution'); $initial_list['clear'][self::ACTION_CLEAR_MILESTONE] = $i18n->__('Clear issue milestone'); $initial_list['set'][self::ACTION_SET_PRIORITY] = $i18n->__('Set issue priority'); $initial_list['set'][self::ACTION_SET_PERCENT] = $i18n->__('Set issue percent'); $initial_list['set'][self::ACTION_SET_REPRODUCABILITY] = $i18n->__('Set issue reproducability'); $initial_list['set'][self::ACTION_SET_RESOLUTION] = $i18n->__('Set issue resolution'); $initial_list['set'][self::ACTION_SET_STATUS] = $i18n->__('Set issue status'); $initial_list['set'][self::ACTION_SET_MILESTONE] = $i18n->__('Set issue milestone'); foreach (CustomDatatype::getAll() as $key => $details) { $initial_list['clear'][self::CUSTOMFIELD_CLEAR_PREFIX . $key] = $i18n->__('Clear issue field %key', array('%key' => $key)); $initial_list['set'][self::CUSTOMFIELD_SET_PREFIX . $key] = $i18n->__('Set issue field %key', array('%key' => $key)); } $event = new \thebuggenie\core\framework\Event('core', 'WorkflowTransitionAction::getAvailableTransitionActions', null, array(), $initial_list); $event->trigger(); self::$_available_actions = $event->getReturnList(); } }
public function getAbbreviation() { if ($this->_abbreviation === null) { $this->_abbreviation = mb_substr(framework\Context::getI18n()->__($this->getName()), 0, 1); } return $this->_abbreviation; }
public function componentEditAgileBoard() { $i18n = framework\Context::getI18n(); $this->autosearches = array(\thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES => $i18n->__('Project open issues (recommended)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES_INCLUDING_SUBPROJECTS => $i18n->__('Project open issues (including subprojects)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES => $i18n->__('Project closed issues'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES_INCLUDING_SUBPROJECTS => $i18n->__('Project closed issues (including subprojects)'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_REPORTED_THIS_MONTH => $i18n->__('Project issues reported last month'), \thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_WISHLIST => $i18n->__('Project wishlist')); $this->savedsearches = \thebuggenie\core\entities\tables\SavedSearches::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(framework\Context::getUser()->getID(), $this->board->getProject()->getID()); $this->issuetypes = $this->board->getProject()->getIssuetypeScheme()->getIssuetypes(); $this->swimlane_groups = array('priority' => $i18n->__('Issue priority'), 'severity' => $i18n->__('Issue severity'), 'category' => $i18n->__('Issue category')); $this->priorities = \thebuggenie\core\entities\Priority::getAll(); $this->severities = \thebuggenie\core\entities\Severity::getAll(); $this->categories = \thebuggenie\core\entities\Category::getAll(); $fakecolumn = new entities\BoardColumn(); $fakecolumn->setBoard($this->board); $this->fakecolumn = $fakecolumn; }
/** * Pre-execute function * * @param framework\Request $request * @param string $action */ public function preExecute(framework\Request $request, $action) { try { if ($project_id = $request['project_id']) { $this->selected_project = entities\Project::getB2DBTable()->selectById($project_id); } elseif ($project_key = $request['project_key']) { $this->selected_project = entities\Project::getByKey($project_key); } } catch (\Exception $e) { } if (!$this->selected_project instanceof entities\Project) { return $this->return404(framework\Context::getI18n()->__('This project does not exist')); } framework\Context::setCurrentProject($this->selected_project); $this->project_key = $this->selected_project->getKey(); }
public function componentLeftmenu() { $config_sections = framework\Settings::getConfigSections(framework\Context::getI18n()); $breadcrumblinks = array(); foreach ($config_sections as $key => $sections) { foreach ($sections as $section) { if ($key == framework\Settings::CONFIGURATION_SECTION_MODULES) { $url = is_array($section['route']) ? make_url($section['route'][0], $section['route'][1]) : make_url($section['route']); $breadcrumblinks[] = array('url' => $url, 'title' => $section['description']); } else { $breadcrumblinks[] = array('url' => make_url($section['route']), 'title' => $section['description']); } } } $this->breadcrumblinks = $breadcrumblinks; $this->config_sections = $config_sections; if ($this->selected_section == framework\Settings::CONFIGURATION_SECTION_MODULES) { if (framework\Context::getRouting()->getCurrentRouteName() == 'configure_modules') { $this->selected_subsection = 'core'; } else { $this->selected_subsection = framework\Context::getRequest()->getParameter('config_module'); } } }
<rss version="2.0"> <channel> <title><?php echo \thebuggenie\core\framework\Settings::getSiteHeaderName() . ' ~ ' . $searchtitle; ?> </title> <link><?php echo make_url('home', array(), false); ?> </link> <description><?php echo strip_tags(\thebuggenie\core\framework\Settings::getSiteHeaderName()); ?> </description> <language><?php echo mb_strtolower(str_replace('_', '-', \thebuggenie\core\framework\Context::getI18n()->getCurrentLanguage())); ?> </language> <image> <?php if (\thebuggenie\core\framework\Settings::isUsingCustomHeaderIcon() == '2') { ?> <url><?php echo \thebuggenie\core\framework\Settings::getHeaderIconURL(); ?> </url> <?php } elseif (\thebuggenie\core\framework\Settings::isUsingCustomHeaderIcon() == '1') { ?> <url><?php echo \thebuggenie\core\framework\Context::getUrlHost() . \thebuggenie\core\framework\Context::getWebroot() . 'header.png';
?> </div> </div> <?php if ($issue->isEditable() && $issue->canEditReproductionSteps()) { ?> <div id="reproduction_steps_change" style="display: none;" class="editor_container"> <form id="reproduction_steps_form" action="<?php echo make_url('issue_setfield', array('project_key' => $issue->getProject()->getKey(), 'issue_id' => $issue->getID(), 'field' => 'reproduction_steps')); ?> " method="post" onSubmit="TBG.Issues.Field.set('<?php echo make_url('issue_setfield', array('project_key' => $issue->getProject()->getKey(), 'issue_id' => $issue->getID(), 'field' => 'reproduction_steps')); ?> ', 'reproduction_steps'); return false;"> <?php include_component('main/textarea', array('area_name' => 'value', 'target_type' => 'issue', 'target_id' => $issue->getID(), 'area_id' => 'reproduction_steps_form_value', 'syntax' => \thebuggenie\core\framework\Settings::getSyntaxClass($issue->getReproductionStepsSyntax()), 'height' => '250px', 'width' => '100%', 'value' => htmlentities($issue->getReproductionSteps(), ENT_COMPAT, \thebuggenie\core\framework\Context::getI18n()->getCharset()))); ?> <div class="textarea_save_container"> <?php echo __('%cancel or %save', array('%save' => '<input class="button button-silver" type="submit" value="' . __('Save') . '">', '%cancel' => javascript_link_tag(__('Cancel'), array('onclick' => "\$('reproduction_steps_change').hide();" . ($issue->getReproductionSteps() != '' ? "\$('reproduction_steps_name').show();" : "\$('no_reproduction_steps').show();") . "return false;")))); ?> </div> </form> <?php echo image_tag('spinning_16.gif', array('style' => 'display: none; float: left; margin-right: 5px;', 'id' => 'reproduction_steps_spinning')); ?> <div id="reproduction_steps_change_error" class="error_message" style="display: none;"></div> </div> <?php } ?>
/** * Milestone actions * * @Route(url="/milestone/:milestone_id/*") * * @param \thebuggenie\core\framework\Request $request */ public function runMilestone(framework\Request $request) { $milestone_id = $request['milestone_id'] ? $request['milestone_id'] : null; $milestone = new \thebuggenie\core\entities\Milestone($milestone_id); try { if (!$this->getUser()->canManageProject($this->selected_project) || !$this->getUser()->canManageProjectReleases($this->selected_project)) { throw new \Exception($this->getI18n()->__("You don't have access to modify milestones")); } switch (true) { case $request->isDelete(): $milestone->delete(); $no_milestone = new \thebuggenie\core\entities\Milestone(0); $no_milestone->setProject($milestone->getProject()); return $this->renderJSON(array('issue_count' => $no_milestone->countIssues(), 'hours' => $no_milestone->getHoursEstimated(), 'points' => $no_milestone->getPointsEstimated())); case $request->isPost(): $this->_saveMilestoneDetails($request, $milestone); $board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']); if ($request->hasParameter('issues') && $request['include_selected_issues']) { \thebuggenie\core\entities\tables\Issues::getTable()->assignMilestoneIDbyIssueIDs($milestone->getID(), $request['issues']); } $message = framework\Context::getI18n()->__('Milestone saved'); return $this->renderJSON(array('message' => $message, 'component' => $this->getComponentHTML('agile/milestonebox', array('milestone' => $milestone, 'board' => $board)), 'milestone_id' => $milestone->getID())); default: return $this->renderJSON(array('content' => framework\Action::returnComponentHTML('agile/milestonebox', array('milestone' => $milestone)), 'milestone_id' => $milestone->getID(), 'milestone_name' => $milestone->getName(), 'milestone_order' => array_keys($milestone->getProject()->getMilestonesForRoadmap()))); } } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $e->getMessage())); } }
/** * Create an imap connection for this account */ public function connect() { if ($this->_connection === null) { $options = array(); if ($this->usesPlaintextAuthentication()) { $options['DISABLE_AUTHENTICATOR'] = 'GSSAPI'; } $this->_connection = imap_open($this->getConnectionString(), $this->getUsername(), $this->getPassword(), 0, 0, $options); } if (!is_resource($this->_connection)) { $error = imap_last_error(); $error = $error === false ? \thebuggenie\core\framework\Context::getI18n()->__('No error message provided') : $error; throw new \Exception(\thebuggenie\core\framework\Context::getI18n()->__('Could not connect to the specified email server(%connection_string): %error_message', array('%connection_string' => $this->getConnectionString(), '%error_message' => $error))); } }
public function setValuesFromRequest(\thebuggenie\core\framework\Request $request) { if ($request->hasParameter('predefined_search')) { $this->setPredefinedVariables($request['predefined_search']); } else { $this->_templatename = $request->hasParameter('template') && self::isTemplateValid($request['template']) ? $request['template'] : 'results_normal'; $this->_templateparameter = $request['template_parameter']; $this->_issues_per_page = $request->getParameter('issues_per_page', 50); $this->_offset = $request->getParameter('offset', 0); if ($request['quicksearch']) { $this->setSortFields(array(tables\Issues::LAST_UPDATED => 'asc')); } $this->_filters = SearchFilter::getFromRequest($request, $this); $this->_applies_to_project = framework\Context::getCurrentProject(); $this->_columns = $request->getParameter('columns'); $this->_sortfields = $request->getParameter('sortfields'); $this->_groupby = $request['groupby']; $this->_grouporder = $request->getParameter('grouporder', 'asc'); if (in_array($this->_templatename, array('results_userpain_singlepainthreshold', 'results_userpain_totalpainthreshold'))) { $this->_searchtitle = framework\Context::getI18n()->__('Showing "bug report" issues sorted by user pain, threshold set at %threshold', array('%threshold' => $this->_templateparameter)); $this->_issues_per_page = 0; $this->_groupby = 'user_pain'; $this->_grouporder = 'desc'; $this->_filters['issuetype'] = SearchFilter::createFilter('issuetype', array('operator' => '=', 'value' => join(',', tables\IssueTypes::getTable()->getBugReportTypeIDs()))); } elseif ($this->_templatename == 'results_votes') { $this->_searchtitle = framework\Context::getI18n()->__('Showing issues ordered by number of votes'); $this->_issues_per_page = $request->getParameter('issues_per_page', 100); $this->_groupby = 'votes'; $this->_grouporder = 'desc'; } } $this->_setupGenericFilters(); }
</ul> <?php if ($tbg_user->canSearchForIssues()) { ?> <form accept-charset="<?php echo \thebuggenie\core\framework\Context::getI18n()->getCharset(); ?> " action="<?php echo \thebuggenie\core\framework\Context::isProjectContext() ? make_url('search', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey())) : make_url('search'); ?> " method="get" name="quicksearchform" id="quicksearchform"> <div style="width: auto; padding: 0; position: relative;" id="quicksearch_container"> <input type="hidden" name="fs[text][o]" value="="> <?php echo image_tag('spinning_16.gif', array('id' => 'quicksearch_indicator', 'style' => 'display: none;')); ?> <input type="search" name="fs[text][v]" accesskey="f" id="searchfor" placeholder="<?php echo __('Search for anything here'); ?> "><div id="searchfor_autocomplete_choices" class="autocomplete rounded_box"></div> <input type="submit" class="button-blue" id="quicksearch_submit" value="<?php echo \thebuggenie\core\framework\Context::getI18n()->__('Find'); ?> "> </div> </form> <?php } ?> </nav>
<?php \thebuggenie\core\framework\Context::getI18n()->setCharset('utf-8'); setlocale(LC_ALL, array('en_US@euro', 'en_US', 'en'));
public function doSave($options = array(), $reason = null) { if (tables\Articles::getTable()->doesNameConflictExist($this->_name, $this->_id, framework\Context::getScope()->getID())) { if (!array_key_exists('overwrite', $options) || !$options['overwrite']) { throw new \Exception(framework\Context::getI18n()->__('Another article with this name already exists')); } } $user_id = framework\Context::getUser() instanceof User ? framework\Context::getUser()->getID() : 0; if (!isset($options['revert']) || !$options['revert']) { $revision = tables\ArticleHistory::getTable()->addArticleHistory($this->_name, $this->_old_content, $this->_content, $user_id, $reason); } else { $revision = null; } tables\ArticleLinks::getTable()->deleteLinksByArticle($this->_name); ArticleCategories::getTable()->deleteCategoriesByArticle($this->_name); if ($this->getArticleType() == self::TYPE_MANUAL && isset($options['article_prev_name']) && $this->_name != $options['article_prev_name']) { $manual_articles = Articles::getTable()->getManualSidebarArticles(framework\Context::getCurrentProject(), $options['article_prev_name']); foreach ($manual_articles as $manual_article) { $manual_article->setName(str_replace($options['article_prev_name'], $this->_name, $manual_article->getName())); $manual_article->doSave(); } } $this->save(); $this->_old_content = $this->_content; if (mb_substr($this->getContent(), 0, 10) == "#REDIRECT ") { $content = explode("\n", $this->getContent()); preg_match('/(\\[\\[([^\\]]*?)\\]\\])$/im', mb_substr(array_shift($content), 10), $matches); if (count($matches) == 3) { return; } } list($links, $categories) = $this->_retrieveLinksAndCategoriesFromContent($options); foreach ($links as $link => $occurrences) { tables\ArticleLinks::getTable()->addArticleLink($this->_name, $link); } foreach ($categories as $category => $occurrences) { ArticleCategories::getTable()->addArticleCategory($this->_name, $category, $this->isCategory()); } $this->_history = null; \thebuggenie\core\framework\Event::createNew('core', 'thebuggenie\\modules\\publish\\entities\\Article::doSave', $this, compact('reason', 'revision', 'user_id'))->trigger(); return true; }
protected function _parse_internallink($matches) { $href = html_entity_decode($matches[4], ENT_QUOTES, 'UTF-8'); if (isset($matches[6]) && $matches[6]) { $title = $matches[6]; } else { $title = $href; if (isset($matches[7]) && $matches[7]) { $title .= $matches[7]; } } $namespace = $matches[3]; if (mb_strtolower($namespace) == 'category') { if (mb_substr($matches[2], 0, 1) != ':') { $this->addCategorizer($href); return ''; } } if (mb_strtolower($namespace) == 'wikipedia') { if (framework\Context::isCLI()) { return $href; } $options = explode('|', $title); $title = (array_key_exists(5, $matches) && mb_strpos($matches[5], '|') !== false ? '' : $namespace . ':') . array_pop($options); return link_tag('http://en.wikipedia.org/wiki/' . $href, $title); } if (preg_match("/embed(\\s+url\\=)?/", mb_strtolower($namespace)) || preg_match("/embed((:)?|(\\s+url\\=)?)/", mb_strtolower($matches[0]))) { if (framework\Context::isCLI()) { return $href; } // if the name space is null more than likely the user is // using embed url= format without the http:// in front of the URL // and the href tag will contain "embed url=" and it must be removed if ($namespace == null) { $href = preg_replace("/embed(\\s+)url=/", "", $href); } // if the href is empty or set to 'embed' then stop processing // an empty embed tag was entered '[[embed]]' if ($href == 'embed' || $href == null) { return; } $options = explode('|', $title); // Default values $width = 500; $height = 400; $type = 'iframe'; // if the link is a youtube link prepare it for embedding if (tbg_youtube_link($href)) { $href = tbg_youtube_prepare_link($href); } // check to see if any size options exist if (array_key_exists(0, $options)) { $settings = $options[0]; // if width exists override default setting if (preg_match_all("/width=(\\d+)/", $settings, $width_matches)) { if (!empty($width_matches)) { $width = $width_matches[1][0]; } } // if height exists override default setting if (preg_match_all("/height=(\\d+)/", $settings, $height_matches)) { if (!empty($height_matches)) { $height = $height_matches[1][0]; } } // if type exists override default setting if (preg_match_all("/type=(iframe|object)/", $settings, $type_matches)) { if (!empty($type_matches)) { $type = $type_matches[1][0]; } } } if ($type == 'object') { $code = object_tag($href, $width, $height); } else { $code = iframe_tag($href, $width, $height); } return $code; } if (in_array(mb_strtolower($namespace), array('image', 'file'))) { $retval = $namespace . ':' . $href; if (!framework\Context::isCLI()) { $options = explode('|', $title); $filename = $href; $issuemode = (bool) (isset($this->options['issue']) && $this->options['issue'] instanceof \thebuggenie\core\entities\Issue); $articlemode = (bool) (isset($this->options['article']) && $this->options['article'] instanceof Article); $file = null; $file_link = $filename; $caption = $filename; if ($issuemode) { $file = $this->options['issue']->getFileByFilename($filename); } elseif ($articlemode) { $file = $this->options['article']->getFileByFilename($filename); } if ($file instanceof \thebuggenie\core\entities\File) { $caption = !empty($options) ? array_pop($options) : htmlentities($file->getDescription(), ENT_COMPAT, framework\Context::getI18n()->getCharset()); $caption = $caption != '' ? $caption : htmlentities($file->getOriginalFilename(), ENT_COMPAT, framework\Context::getI18n()->getCharset()); $file_link = make_url('showfile', array('id' => $file->getID())); } else { $caption = !empty($options) ? array_pop($options) : false; } if (($file instanceof \thebuggenie\core\entities\File && $file->isImage() || $articlemode) && (mb_strtolower($namespace) == 'image' || $issuemode) && \thebuggenie\core\framework\Settings::isCommentImagePreviewEnabled()) { $divclasses = array('image_container'); $style_dimensions = ''; foreach ($options as $option) { $optionlen = mb_strlen($option); if (mb_substr($option, $optionlen - 2) == 'px') { if (is_numeric($option[0])) { $style_dimensions = ' width: ' . $option . ';'; break; } else { $style_dimensions = ' height: ' . mb_substr($option, 1) . ';'; break; } } } if (in_array('thumb', $options)) { $divclasses[] = 'thumb'; } if (in_array('left', $options)) { $divclasses[] = 'icleft'; } if (in_array('center', $options)) { $divclasses[] = 'iccenter'; } if (in_array('right', $options)) { $divclasses[] = 'icright'; } $retval = '<div class="' . join(' ', $divclasses) . '"'; if ($issuemode) { $retval .= ' style="float: left; clear: left;"'; } $retval .= '>'; $retval .= image_tag($file_link, array('alt' => $caption, 'title' => $caption, 'style' => $style_dimensions, 'class' => 'image'), true); if ($caption != '') { $retval .= '<br>' . $caption; } $retval .= link_tag($file_link, image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open image in new window'))); $retval .= '</div>'; } else { if (strpos($file_link, 'http') === 0) { $retval = $this->_parse_image($file_link, $caption, $options); } else { if ($file_link == $filename) { $retval = $caption . image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;', 'title' => __('File no longer exists.'))); } else { $retval = link_tag($file_link, $caption . image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open file in new window'))); } } } } return $retval; //$file_id = \thebuggenie\core\entities\tables\Files::get } if ($namespace == 'TBG') { if (framework\Context::isCLI()) { return $href; } if (!framework\Context::getRouting()->hasRoute($href)) { return $href; } $options = explode('|', $title); $title = array_pop($options); try { return link_tag(make_url($href), $title); // $this->parse_image($href,$title,$options); } catch (\Exception $e) { return $href; } } if (mb_substr($href, 0, 1) == '/') { if (framework\Context::isCLI()) { return $href; } $options = explode('|', $title); $title = array_pop($options); return link_tag($href, $title); // $this->parse_image($href,$title,$options); } $title = preg_replace('/\\(.*?\\)/', '', $title); $title = preg_replace('/^.*?\\:/', '', $title); if (!$namespace || !array_key_exists($namespace, array('ftp', 'http', 'https', 'gopher', 'mailto', 'news', 'nntp', 'telnet', 'wais', 'file', 'prospero', 'aim', 'webcal'))) { if ($namespace) { $href = $namespace . ':' . $href; } $href = $this->_wiki_link($href); $title = isset($title) ? $title : $href; $this->addInternalLinkOccurrence($href); if (framework\Context::isCLI()) { return $href; } $href = framework\Context::getRouting()->generate('publish_article', array('article_name' => $href)); } else { $href = $namespace . ':' . $this->_wiki_link($href); } if (framework\Context::isCLI()) { return $href; } return link_tag($href, $title); }
/** * Sanitize a string * * @param string $string The string to sanitize * * @return string the sanitized string */ protected function __sanitize_string($string) { try { $charset = class_exists('\\thebuggenie\\core\\framework\\Context') ? Context::getI18n()->getCharset() : 'utf-8'; } catch (\Exception $e) { $charset = 'utf-8'; } return htmlspecialchars($string, ENT_QUOTES, $charset); }
/** * Return array of visible fields used by the Project * * @param bool $includeTextareas * @param array $excludeFields * @return array */ public function getIssueFields($includeTextareas = true, $excludeFields = array()) { $fields = $this->getIssuetypeScheme()->getVisibleFields(); foreach ($fields as $key => $field) { switch ($key) { case 'user_pain': $fields[$key]['label'] = framework\Context::getI18n()->__('Triaging: User pain'); break; case 'percent_complete': $fields[$key]['label'] = framework\Context::getI18n()->__('Percent completed'); break; case 'build': $fields[$key]['label'] = framework\Context::getI18n()->__('Release'); break; case 'component': $fields[$key]['label'] = framework\Context::getI18n()->__('Components'); break; case 'edition': $fields[$key]['label'] = framework\Context::getI18n()->__('Edition'); break; case 'estimated_time': $fields[$key]['label'] = framework\Context::getI18n()->__('Estimated time to complete'); break; case 'spent_time': $fields[$key]['label'] = framework\Context::getI18n()->__('Time spent working on the issue'); break; case 'votes': $fields[$key]['label'] = framework\Context::getI18n()->__('Votes'); break; default: if (!isset($fields[$key]['label'])) { $fields[$key]['label'] = ucfirst($key); } break; } } if (!$includeTextareas) { unset($fields['description'], $fields['reproduction_steps']); foreach ($fields as $key => $field) { if (in_array($field['type'], array(CustomDatatype::INPUT_TEXTAREA_MAIN, CustomDatatype::INPUT_TEXTAREA_SMALL))) { unset($fields[$key]); } } } foreach ($excludeFields as $field) { unset($fields[$field]); } return $fields; }
/** * Returns an ISO-8859-1 encoded string if UTF-8 encoded and current charset not UTF-8 * * @param string $str the encode string * @param boolean $htmlentities [optional] whether to convert applicable characters to HTML entities * * @return string */ function tbg_decodeUTF8($str, $htmlentities = false) { if (tbg_isUTF8($str) && !mb_stristr(\thebuggenie\core\framework\Context::getI18n()->getCharset(), 'UTF-8')) { $str = utf8_decode($str); } if ($htmlentities) { $str = htmlentities($str, ENT_NOQUOTES + ENT_IGNORE, \thebuggenie\core\framework\Context::getI18n()->getCharset()); } return $str; }
public function getTitle() { $all_titles = self::getAvailableViews($this->getTargetType()); foreach ($all_titles as $type => $titles) { if (array_key_exists($this->getType(), $titles) && array_key_exists($this->getDetail(), $titles[$this->getType()])) { $title = $titles[$this->getType()][$this->getDetail()]['title']; break; } } if ($this->getType() == self::VIEW_SAVED_SEARCH) { $search = tables\SavedSearches::getTable()->selectById($this->getDetail()); if ($search instanceof SavedSearch) { $title = $search->getName(); } } return isset($title) ? $title : framework\Context::getI18n()->__('Unknown dashboard item'); }
/** * Show an article * * @param \thebuggenie\core\framework\Request $request */ public function runEditArticle(framework\Request $request) { if (!$this->article->canEdit()) { framework\Context::setMessage('publish_article_error', framework\Context::getI18n()->__('You do not have permission to edit this article')); $this->forward(framework\Context::getRouting()->generate('publish_article', array('article_name' => $this->article_name))); } $this->article_route = $this->article->getID() ? 'publish_article_edit' : 'publish_article_new'; $this->article_route_params = $this->article->getID() ? array('article_name' => $this->article_name) : array(); if ($request->isPost()) { $this->preview = (bool) $request['preview']; $this->change_reason = $request['change_reason']; try { $this->article->setArticleType($request['article_type']); $this->article->setName($request['new_article_name']); $this->article->setParentArticle(Articles::getTable()->getArticleByName($request['parent_article_name'])); $this->article->setManualName($request['manual_name']); if ($this->article->getArticleType() == Article::TYPE_MANUAL && !$this->article->getName()) { $article_name_prefix = $this->article->getParentArticle() instanceof Article ? $this->article->getParentArticle()->getName() . ':' : $request['parent_article_name']; $this->article->setName(str_replace(' ', '', $article_name_prefix . $this->article->getManualName())); } $this->article->setContentSyntax($request['article_content_syntax']); $this->article->setContent($request->getRawParameter('article_content')); if (!$this->article->getName() || trim($this->article->getName()) == '' || !preg_match('/[\\w:]+/i', $this->article->getName())) { throw new \Exception(framework\Context::getI18n()->__('You need to specify a valid article name')); } if ($request['article_type'] == Article::TYPE_MANUAL && (!$this->article->getManualName() || trim($this->article->getManualName()) == '' || !preg_match('/[\\w:]+/i', $this->article->getManualName()))) { throw new \Exception(framework\Context::getI18n()->__('You need to specify a valid article name')); } if (!$this->preview && framework\Context::getModule('publish')->getSetting('require_change_reason') == 1 && (!$this->change_reason || trim($this->change_reason) == '')) { throw new \Exception(framework\Context::getI18n()->__('You have to provide a reason for the changes')); } if ($this->article->getLastUpdatedDate() != $request['last_modified']) { throw new \Exception(framework\Context::getI18n()->__('The file has been modified since you last opened it')); } if (($article = Article::getByName($request['new_new_article_name'])) && $article instanceof Article && $article->getID() != $request['article_id']) { throw new \Exception(framework\Context::getI18n()->__('An article with that name already exists. Please choose a different article name')); } if (!$this->preview) { $this->article->doSave(array(), $request['change_reason']); framework\Context::setMessage('publish_article_message', framework\Context::getI18n()->__('The article was saved')); $this->forward(framework\Context::getRouting()->generate('publish_article', array('article_name' => $this->article->getName()))); } } catch (\Exception $e) { $this->error = $e->getMessage(); } } }
} ?> </div> <?php } ?> <?php } ?> <?php if ($mode == 'edit') { ?> <div id="article_edit_header_information"> <div id="article_parent_container"> <input type="hidden" name="parent_article_name" id="parent_article_name" value="<?php echo $article->getParentArticleName() ? $article->getParentArticleName() : htmlentities($tbg_request['parent_article_name'], ENT_COMPAT, \thebuggenie\core\framework\Context::getI18n()->getCharset()); ?> " style="width: 400px;"> <span class="parent_article_name <?php if (!$article->getParentArticle() instanceof \thebuggenie\modules\publish\entities\Article) { echo ' faded_out'; } ?> "> <span id="parent_article_name_span"> <?php if ($article->getParentArticle() instanceof \thebuggenie\modules\publish\entities\Article) { ?> <?php echo $article->getParentArticle()->getManualName() ? $article->getParentArticle()->getManualName() : $article->getParentArticle()->getName(); ?>
<?php \thebuggenie\core\framework\Context::getI18n()->setCharset('utf-8'); setlocale(LC_ALL, array('fr_FR@euro', 'fr_FR', 'fr')); // see \thebuggenie\core\entities\i18n::getDateTimeFormat for the list of all available formats \thebuggenie\core\framework\Context::getI18n()->setDateTimeFormats(array(1 => '%H:%M - %a %d %b %Y', 2 => '%H:%M - %a %d.m %Y', 3 => '%a %d %b %H:%M', 4 => '%d %b %H:%M', 5 => '%d %B %Y', 6 => '%d %B %Y (%H:%M)', 7 => '%A %d %B %Y (%H:%M)', 8 => '%d %b %Y %H:%M', 9 => '%d %b %Y - %H:%M', 10 => '%d %b %Y (%H:%M)', 11 => '%B', 12 => '%d %b', 13 => '%a', 14 => '%H:%M', 15 => '%d %b %Y', 16 => '%Gh %im', 17 => '%a, %d %b %Y %H:%M:%S GMT'));
/** * Retrieve the users real name * * @return string */ public function getName() { if ($this->isDeleted()) { return framework\Context::getI18n()->__('No such user'); } switch (framework\Settings::getUserDisplaynameFormat()) { case framework\Settings::USER_DISPLAYNAME_FORMAT_REALNAME: return $this->_realname ? $this->_realname : $this->_username; case framework\Settings::USER_DISPLAYNAME_FORMAT_BUDDY: default: return $this->_buddyname ? $this->_buddyname : ($this->_realname ? $this->_realname : $this->_username); } }
protected function _getNotificationSettings() { $i18n = framework\Context::getI18n(); $notificationsettings = array(); $notificationsettings[self::NOTIFY_SUBSCRIBED_ISSUES] = $i18n->__('Notify by email when there are updates to my subscribed issues'); $notificationsettings[self::NOTIFY_SUBSCRIBED_ARTICLES] = $i18n->__('Notify by email when there are updates to my subscribed articles'); $notificationsettings[self::NOTIFY_NEW_ISSUES_MY_PROJECTS] = $i18n->__('Notify by email when new issues are created in my project(s)'); $notificationsettings[self::NOTIFY_NEW_ARTICLES_MY_PROJECTS] = $i18n->__('Notify by email when new articles are created in my project(s)'); $notificationsettings[self::NOTIFY_ITEM_ONCE] = $i18n->__('Only send one email per issue or article until I view the issue or article in my browser'); $notificationsettings[self::NOTIFY_UPDATED_SELF] = $i18n->__('Notify by email also when I am the one making the changes'); return $notificationsettings; }
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; }
?> <?php echo __('No parent article'); ?> <?php } ?> </span> »</span> </div> <input type="text" name="new_article_name" id="new_article_name" value="<?php echo \thebuggenie\core\framework\Context::getI18n()->__e($article->getName()); ?> "> <input type="text" name="manual_name" id="manual_name" value="<?php echo \thebuggenie\core\framework\Context::getI18n()->__e($article->getManualName()); ?> "> </div> <?php } else { ?> <?php if ($article->getArticleType() == \thebuggenie\modules\publish\entities\Article::TYPE_MANUAL) { echo get_spaced_name($article->getManualName()); } else { $namespaces = explode(':', $article_name); if (count($namespaces) > 1 && $namespaces[0] == 'Category') { array_shift($namespaces); echo '<span class="faded_out blue">Category:</span>';
public static function getSiteHeaderName() { try { if (!Context::isReadySetup()) { return 'The Bug Genie'; } $name = self::get(self::SETTING_TBG_NAME); if (!self::isHeaderHtmlFormattingAllowed()) { $name = htmlspecialchars($name, ENT_COMPAT, Context::getI18n()->getCharset()); } return $name; } catch (\Exception $e) { return 'The Bug Genie'; } }
public function loadFixtures(\thebuggenie\core\entities\Scope $scope) { $i18n = framework\Context::getI18n(); $settings = array(); $settings[\thebuggenie\core\framework\Settings::SETTING_THEME_NAME] = 'oxygen'; $settings[\thebuggenie\core\framework\Settings::SETTING_REQUIRE_LOGIN] = 0; $settings[\thebuggenie\core\framework\Settings::SETTING_DEFAULT_USER_IS_GUEST] = 1; $settings[\thebuggenie\core\framework\Settings::SETTING_ALLOW_REGISTRATION] = 1; $settings[\thebuggenie\core\framework\Settings::SETTING_RETURN_FROM_LOGIN] = 'referer'; $settings[\thebuggenie\core\framework\Settings::SETTING_RETURN_FROM_LOGOUT] = 'home'; $settings[\thebuggenie\core\framework\Settings::SETTING_SHOW_PROJECTS_OVERVIEW] = 1; $settings[\thebuggenie\core\framework\Settings::SETTING_ALLOW_USER_THEMES] = 0; $settings[\thebuggenie\core\framework\Settings::SETTING_ENABLE_UPLOADS] = 0; $settings[\thebuggenie\core\framework\Settings::SETTING_ENABLE_GRAVATARS] = 1; $settings[\thebuggenie\core\framework\Settings::SETTING_UPLOAD_RESTRICTION_MODE] = 'blacklist'; $settings[\thebuggenie\core\framework\Settings::SETTING_UPLOAD_EXTENSIONS_LIST] = 'exe,bat,php,asp,jsp'; $settings[\thebuggenie\core\framework\Settings::SETTING_UPLOAD_STORAGE] = 'files'; $settings[\thebuggenie\core\framework\Settings::SETTING_UPLOAD_LOCAL_PATH] = THEBUGGENIE_PATH . 'files/'; $settings[\thebuggenie\core\framework\Settings::SETTING_UPLOAD_ALLOW_IMAGE_CACHING] = 0; $settings[\thebuggenie\core\framework\Settings::SETTING_UPLOAD_DELIVERY_USE_XSEND] = 0; $settings[\thebuggenie\core\framework\Settings::SETTING_TBG_NAME] = 'The Bug Genie'; $settings[\thebuggenie\core\framework\Settings::SETTING_SYNTAX_HIGHLIGHT_DEFAULT_LANGUAGE] = 'html4strict'; $settings[\thebuggenie\core\framework\Settings::SETTING_SYNTAX_HIGHLIGHT_DEFAULT_NUMBERING] = '3'; $settings[\thebuggenie\core\framework\Settings::SETTING_SYNTAX_HIGHLIGHT_DEFAULT_INTERVAL] = '10'; $settings[\thebuggenie\core\framework\Settings::SETTING_ICONSET] = 'oxygen'; $settings[\thebuggenie\core\framework\Settings::SETTING_SERVER_TIMEZONE] = date_default_timezone_get(); if ($scope->isDefault()) { $settings[\thebuggenie\core\framework\Settings::SETTING_SALT] = sha1(time() . mt_rand(1000, 10000)); } $scope_id = $scope->getID(); foreach ($settings as $settings_name => $settings_val) { $this->saveSetting($settings_name, 'core', $settings_val, 0, $scope_id); } }
?> </span> <span class="single" style="display: none;"><?php echo __('%click_here to add files', array('%click_here' => '<span class="upload_click_here">' . __('click here') . '</span>')); ?> </span> </div> <div class="upload_file_listing"> <ul id="file_upload_list" data-filename-label="<?php echo htmlentities(__('File'), ENT_COMPAT, \thebuggenie\core\framework\Context::getI18n()->getCharset()); ?> " data-description-label="<?php echo htmlentities(__('Description'), ENT_COMPAT, \thebuggenie\core\framework\Context::getI18n()->getCharset()); ?> " data-description-placeholder="<?php echo htmlentities(__('Enter a short file description here'), ENT_COMPAT, \thebuggenie\core\framework\Context::getI18n()->getCharset()); ?> " data-preview-src="<?php echo image_url('icon_file_generic.png'); ?> "> <?php if (isset($existing_files)) { ?> <?php foreach ($existing_files as $file) { ?> <li> <?php if ($file->isImage()) { ?>
<div class="header"><?php echo __('Global content'); ?> </div> <?php echo link_tag($url, \thebuggenie\core\framework\Context::getModule('publish')->getMenuTitle(false)); ?> <?php $quicksearch_title = __('Find any article (press enter to search)'); ?> <div style="font-weight: normal; margin: 0 0 15px 5px;"> <form action="<?php echo make_url('publish_find_articles'); ?> " method="get" accept-charset="<?php echo \thebuggenie\core\framework\Context::getI18n()->getCharset(); ?> "> <input type="search" name="articlename" placeholder="<?php echo $quicksearch_title; ?> "> </form> </div> <?php if (count(\thebuggenie\core\entities\Project::getAll()) > (int) \thebuggenie\core\framework\Context::isProjectContext()) { ?> <div class="header"><?php echo __('Project wikis'); ?> </div>
<h2><?php echo __('Find articles'); ?> </h2> <form action="<?php echo \thebuggenie\core\framework\Context::isProjectContext() ? make_url('publish_find_project_articles', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey())) : make_url('publish_find_articles'); ?> " method="get" accept-charset="<?php echo \thebuggenie\core\framework\Context::getI18n()->getCharset(); ?> "> <label for="find_article_name" style="font-size: 1.1em; float: left;"><?php echo __('Find articles by name'); ?> </label><input type="text" name="articlename" id="find_article_name" value="<?php echo \thebuggenie\core\framework\Context::getI18n()->__e($articlename); ?> " style="width: 400px; float: left; margin-left: 5px; padding: 2px; font-size: 1.3em;"> <input type="submit" value="<?php echo __('Find'); ?> " class="wiki-find-articles-button" style="float: left; margin-left: 5px; font-size: 1.2em; padding: 3px 5px"> </form> <br style="clear: both;"> <?php if (isset($resultcount)) { ?> <?php if ($resultcount) { ?> <div class="header_div" style="font-size: 1.3em;"><?php