public function runResolve(framework\Request $request) { $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName(); if ($request->hasParameter('css')) { $this->getResponse()->setContentType('text/css'); if (!$request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css'); } else { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css'); } } elseif ($request->hasParameter('js')) { $this->getResponse()->setContentType('text/javascript'); if ($request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js'); } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) { $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH; $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js'); } else { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js'); } } else { throw new \Exception('The expected theme Asset type is not supported.'); } $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath))); $fileAsset->load(); // Do not decorate the asset with the theme's header/footer $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE); return $this->renderText($fileAsset->dump()); }
public function postConfigSettings(framework\Request $request) { $settings = array('hostname', 'u_type', 'g_type', 'b_dn', 'groups', 'dn_attr', 'u_attr', 'g_attr', 'e_attr', 'f_attr', 'b_attr', 'g_dn', 'control_user', 'control_pass', 'integrated_auth', 'integrated_auth_header'); foreach ($settings as $setting) { if (($setting == 'u_type' || $setting == 'g_type' || $setting == 'dn_attr') && $request->getParameter($setting) == '') { if ($setting == 'u_type') { $this->saveSetting($setting, 'person'); } elseif ($setting == 'g_type') { $this->saveSetting($setting, 'group'); } else { $this->saveSetting($setting, 'entrydn'); } } elseif ($setting == 'integrated_auth') { $this->saveSetting($setting, (int) $request->getParameter($setting, 0)); } else { if ($request->hasParameter($setting)) { $this->saveSetting($setting, $request->getParameter($setting)); } } } }
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(); }
/** * @param framework\Request $request * @param null $milestone * @return null|\thebuggenie\core\entities\Milestone * @throws \Exception */ protected function _saveMilestoneDetails(framework\Request $request, $milestone = null) { if (!$request['name']) { throw new \Exception($this->getI18n()->__('You must provide a valid milestone name')); } if ($milestone === null) { $milestone = new \thebuggenie\core\entities\Milestone(); } $milestone->setName($request['name']); $milestone->setProject($this->selected_project); $milestone->setStarting((bool) $request['is_starting']); $milestone->setScheduled((bool) $request['is_scheduled']); $milestone->setDescription($request['description']); $milestone->setVisibleRoadmap($request['visibility_roadmap']); $milestone->setVisibleIssues($request['visibility_issues']); $milestone->setType($request->getParameter('milestone_type', \thebuggenie\core\entities\Milestone::TYPE_REGULAR)); if ($request->hasParameter('sch_month') && $request->hasParameter('sch_day') && $request->hasParameter('sch_year')) { $scheduled_date = mktime(23, 59, 59, framework\Context::getRequest()->getParameter('sch_month'), framework\Context::getRequest()->getParameter('sch_day'), framework\Context::getRequest()->getParameter('sch_year')); $milestone->setScheduledDate($scheduled_date); } else { $milestone->setScheduledDate(0); } if ($request->hasParameter('starting_month') && $request->hasParameter('starting_day') && $request->hasParameter('starting_year')) { $starting_date = mktime(0, 0, 1, framework\Context::getRequest()->getParameter('starting_month'), framework\Context::getRequest()->getParameter('starting_day'), framework\Context::getRequest()->getParameter('starting_year')); $milestone->setStartingDate($starting_date); } else { $milestone->setStartingDate(0); } $milestone->save(); return $milestone; }
/** * Show an article * * @param \thebuggenie\core\framework\Request $request */ public function runShowArticle(framework\Request $request) { if ($this->special) { $this->redirect('specialArticle'); } $this->message = framework\Context::getMessageAndClear('publish_article_message'); $this->error = framework\Context::getMessageAndClear('publish_article_error'); $this->redirected_from = framework\Context::getMessageAndClear('publish_redirected_article'); if ($this->article instanceof Article) { if (!$this->article->hasAccess()) { $this->error = framework\Context::getI18n()->__("You don't have access to read this article"); $this->article = null; } else { $this->getUser()->markNotificationsRead('article', $this->article->getID()); if (!$request->hasParameter('no_redirect') && $this->article->isRedirect()) { if ($redirect_article = $this->article->getRedirectArticleName()) { framework\Context::setMessage('publish_redirected_article', $this->article->getName()); $this->forward(framework\Context::getRouting()->generate('publish_article', array('article_name' => $redirect_article))); } } try { if ($request->hasParameter('revision')) { $this->revision = $request['revision']; $this->article->setRevision($this->revision); } } catch (\Exception $e) { $this->error = framework\Context::getI18n()->__('There was an error trying to show this revision'); } } } }
public function isValid(\thebuggenie\core\framework\Request $request) { if ($this->_target_value) { return true; } switch ($this->_action_type) { case self::ACTION_ASSIGN_ISSUE: return (bool) $request['assignee_type'] && $request['assignee_id']; break; case self::ACTION_SET_MILESTONE: return (bool) $request->hasParameter('milestone_id'); break; case self::ACTION_SET_PRIORITY: return (bool) $request->hasParameter('priority_id'); break; case self::ACTION_SET_STATUS: return (bool) $request->hasParameter('status_id'); break; case self::ACTION_SET_REPRODUCABILITY: return (bool) $request->hasParameter('reproducability_id'); break; case self::ACTION_SET_RESOLUTION: return (bool) $request->hasParameter('resolution_id'); break; default: return true; } }
/** * Configure project settings * * @param framework\Request $request The request object */ public function runConfigureProjectSettings(framework\Request $request) { if ($request->isPost()) { $this->forward403unless($this->getUser()->canEditProjectDetails($this->selected_project), framework\Context::getI18n()->__('You do not have access to update these settings')); $release_date = null; if ($request['has_release_date']) { $release_date = mktime(0, 0, 1, $request['release_month'], $request['release_day'], $request['release_year']); } $this->selected_project->setReleaseDate($release_date); $old_key = $this->selected_project->getKey(); if ($request->hasParameter('project_name')) { if (trim($request['project_name']) == '') { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Please specify a valid project name'))); } else { $this->selected_project->setName($request['project_name']); } } $message = $old_key != $this->selected_project->getKey() ? framework\Context::getI18n()->__('%IMPORTANT: The project key has changed. Remember to replace the current url with the new project key', array('%IMPORTANT' => '<b>' . framework\Context::getI18n()->__('IMPORTANT') . '</b>')) : ''; if ($request->hasParameter('project_key')) { $this->selected_project->setKey($request['project_key']); } if ($request->hasParameter('use_prefix')) { $this->selected_project->setUsePrefix((bool) $request['use_prefix']); } if ($request->hasParameter('use_prefix') && $this->selected_project->doesUsePrefix()) { if (!$this->selected_project->setPrefix($request['prefix'])) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__("Project prefixes may only contain letters and numbers"))); } } if ($request->hasParameter('client')) { if ($request['client'] == 0) { $this->selected_project->setClient(null); } else { $this->selected_project->setClient(entities\Client::getB2DBTable()->selectById($request['client'])); } } if ($request->hasParameter('subproject_id')) { if ($request['subproject_id'] == 0) { $this->selected_project->clearParent(); } else { $this->selected_project->setParent(entities\Project::getB2DBTable()->selectById($request['subproject_id'])); } } if ($request->hasParameter('workflow_scheme')) { try { $workflow_scheme = entities\WorkflowScheme::getB2DBTable()->selectById($request['workflow_scheme']); $this->selected_project->setWorkflowScheme($workflow_scheme); } catch (\Exception $e) { } } if ($request->hasParameter('issuetype_scheme')) { try { $issuetype_scheme = entities\IssuetypeScheme::getB2DBTable()->selectById($request['issuetype_scheme']); $this->selected_project->setIssuetypeScheme($issuetype_scheme); } catch (\Exception $e) { } } if ($request->hasParameter('use_scrum')) { $this->selected_project->setUsesScrum((bool) $request['use_scrum']); } if ($request->hasParameter('description')) { $this->selected_project->setDescription($request->getParameter('description', null, false)); } if ($request->hasParameter('homepage')) { $this->selected_project->setHomepage($request['homepage']); } if ($request->hasParameter('doc_url')) { $this->selected_project->setDocumentationURL($request['doc_url']); } if ($request->hasParameter('wiki_url')) { $this->selected_project->setWikiURL($request['wiki_url']); } if ($request->hasParameter('released')) { $this->selected_project->setReleased((int) $request['released']); } if ($request->hasParameter('locked')) { $this->selected_project->setLocked((bool) $request['locked']); } if ($request->hasParameter('enable_builds')) { $this->selected_project->setBuildsEnabled((bool) $request['enable_builds']); } if ($request->hasParameter('enable_editions')) { $this->selected_project->setEditionsEnabled((bool) $request['enable_editions']); } if ($request->hasParameter('enable_components')) { $this->selected_project->setComponentsEnabled((bool) $request['enable_components']); } if ($request->hasParameter('allow_changing_without_working')) { $this->selected_project->setChangeIssuesWithoutWorkingOnThem((bool) $request['allow_changing_without_working']); } if ($request->hasParameter('allow_autoassignment')) { $this->selected_project->setAutoassign((bool) $request['allow_autoassignment']); } $this->selected_project->save(); return $this->renderJSON(array('message' => $this->getI18n()->__('Settings saved'))); } }
public function postConfigSettings(\thebuggenie\core\framework\Request $request) { if ($request->hasParameter('import_articles')) { $cc = 0; foreach ($request['import_article'] as $article_name => $import) { $cc++; Articles::getTable()->deleteArticleByName(urldecode($article_name)); $content = file_get_contents(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'fixtures' . DS . $article_name); Article::createNew(urldecode($article_name), $content, null, array('overwrite' => true, 'noauthor' => true)); } framework\Context::setMessage('module_message', framework\Context::getI18n()->__('%number_of_articles articles imported successfully', array('%number_of_articles' => $cc))); } else { $settings = array('allow_camelcase_links', 'menu_title', 'hide_wiki_links', 'free_edit', 'require_change_reason'); foreach ($settings as $setting) { if ($request->hasParameter($setting)) { $this->saveSetting($setting, $request->getParameter($setting)); } } } }
public function runConfigureWorkflowTransition(framework\Request $request) { $this->workflow = null; $this->transition = null; try { $this->workflow = tables\Workflows::getTable()->selectById((int) $request['workflow_id']); if ($request->hasParameter('transition_id')) { $mode = $request['mode']; $this->transition = tables\WorkflowTransitions::getTable()->selectById((int) $request['transition_id']); if ($request->isPost()) { if ($mode == 'edit') { if (!$this->transition->isInitialTransition()) { $this->transition->setName($request['transition_name']); $this->transition->setDescription($request['transition_description']); if ($request['template']) { $this->transition->setTemplate($request['template']); } else { $this->transition->setTemplate(null); } } try { $step = tables\WorkflowSteps::getTable()->selectById((int) $request['outgoing_step_id']); $this->transition->setOutgoingStep($step); } catch (\Exception $e) { } $this->transition->save(); $transition = $this->transition; $redirect_transition = true; } elseif ($mode == 'delete') { $this->transition->deleteTransition($request['direction'], $request['step_id']); $this->forward(framework\Context::getRouting()->generate('configure_workflow_step', array('workflow_id' => $this->workflow->getID(), 'step_id' => $request['step_id']))); } elseif ($mode == 'delete_action') { $this->action = tables\WorkflowTransitionActions::getTable()->selectById((int) $request['action_id']); $this->action->delete(); return $this->renderJSON(array('message' => $this->getI18n()->__('The action has been deleted'))); } elseif ($mode == 'new_action') { $action = new entities\WorkflowTransitionAction(); $action->setActionType($request['action_type']); $action->setTransition($this->transition); $action->setWorkflow($this->workflow); $action->setTargetValue(''); $action->save(); return $this->renderJSON(array('content' => $this->getComponentHTML('configuration/workflowtransitionaction', array('action' => $action)))); } elseif ($mode == 'update_action') { $this->action = tables\WorkflowTransitionActions::getTable()->selectById((int) $request['action_id']); $this->action->setTargetValue($request['target_value']); $this->action->save(); $text = $request['target_value']; switch ($this->action->getActionType()) { case entities\WorkflowTransitionAction::ACTION_ASSIGN_ISSUE: if ($this->action->hasTargetValue()) { $target_details = explode('_', $this->action->getTargetValue()); $text = $target_details[0] == 'user' ? entities\User::getB2DBTable()->selectById((int) $target_details[1])->getNameWithUsername() : entities\Team::getB2DBTable()->selectById((int) $target_details[1])->getName(); } else { $text = $this->getI18n()->__('User specified during transition'); } break; case entities\WorkflowTransitionAction::ACTION_SET_RESOLUTION: $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Resolution specified by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_REPRODUCABILITY: $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Reproducability specified by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_STATUS: $target = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? '<span class="status_badge" style="background-color: ' . $target->getColor() . '; color: ' . $target->getTextColor() . ';">' . $target->getName() . '</span>' : $this->getI18n()->__('Status provided by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_PRIORITY: $text = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Priority specified by user'); break; case entities\WorkflowTransitionAction::ACTION_SET_MILESTONE: $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Milestone specified by user'); break; case entities\WorkflowTransitionAction::CUSTOMFIELD_SET_PREFIX . $this->action->getCustomActionType(): switch (\thebuggenie\core\entities\CustomDatatype::getByKey($this->action->getCustomActionType())->getType()) { case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_MAIN: case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_SMALL: break; case \thebuggenie\core\entities\CustomDatatype::DATE_PICKER: return $this->renderJSON(array('content' => date('Y-m-d', (int) $text))); break; case \thebuggenie\core\entities\CustomDatatype::USER_CHOICE: return $this->renderJSON(array('content' => $this->getComponentHTML('main/userdropdown', array('user' => $text)))); break; case \thebuggenie\core\entities\CustomDatatype::TEAM_CHOICE: return $this->renderJSON(array('content' => $this->getComponentHTML('main/teamdropdown', array('team' => $text)))); break; case \thebuggenie\core\entities\CustomDatatype::CLIENT_CHOICE: if (is_numeric($this->action->getTargetValue())) { $text = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Clients::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::RELEASES_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Builds::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::COMPONENTS_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Components::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::EDITIONS_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Editions::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::MILESTONE_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? \thebuggenie\core\entities\tables\Milestones::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? $target->getProject()->getName() . ' - ' . $target->getName() : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::STATUS_CHOICE: if (is_numeric($this->action->getTargetValue())) { $target = $this->action->getTargetValue() ? tables\ListTypes::getTable()->selectById((int) $this->action->getTargetValue()) : null; $text = $this->action->getTargetValue() ? '<span class="status_badge" style="background-color: ' . $target->getColor() . '; color: ' . $target->getTextColor() . ';">' . $target->getName() . '</span>' : $this->getI18n()->__('Value provided by user'); } break; case \thebuggenie\core\entities\CustomDatatype::DROPDOWN_CHOICE_TEXT: default: if (is_numeric($this->action->getTargetValue())) { $text = $this->action->getTargetValue() ? tables\CustomFieldOptions::getTable()->selectById((int) $this->action->getTargetValue())->getName() : $this->getI18n()->__('Value provided by user'); } break; } break; } return $this->renderJSON(array('content' => $text)); } elseif ($mode == 'delete_validation_rule') { $this->rule = tables\WorkflowTransitionValidationRules::getTable()->selectById((int) $request['rule_id']); $this->rule->delete(); return $this->renderJSON(array('message' => $this->getI18n()->__('The validation rule has been deleted'))); } elseif ($mode == 'new_validation_rule') { if (!in_array($request['postorpre'], array('post', 'pre'))) { throw new \InvalidArgumentException($this->getI18n()->__('Invalid transition definition')); } $rule = new entities\WorkflowTransitionValidationRule(); if ($request['postorpre'] == 'post') { $exists = (bool) $this->transition->hasPostValidationRule($request['rule']); if (!$exists) { $rule->setPost(); } } elseif ($request['postorpre'] == 'pre') { $exists = (bool) $this->transition->hasPreValidationRule($request['rule']); if (!$exists) { $rule->setPre(); } } if ($exists) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('message' => $this->getI18n()->__('This validation rule already exist'))); } $rule->setRule($request['rule']); $rule->setRuleValue(''); $rule->setTransition($this->transition); $rule->setWorkflow($this->workflow); $rule->save(); return $this->renderJSON(array('content' => $this->getComponentHTML('configuration/workflowtransitionvalidationrule', array('rule' => $rule)))); } elseif ($mode == 'update_validation_rule') { $rule = tables\WorkflowTransitionValidationRules::getTable()->selectById((int) $request['rule_id']); $text = null; if ($rule->isCustom()) { switch ($rule->getCustomType()) { case entities\CustomDatatype::RADIO_CHOICE: case entities\CustomDatatype::DROPDOWN_CHOICE_TEXT: case entities\CustomDatatype::TEAM_CHOICE: case entities\CustomDatatype::STATUS_CHOICE: case entities\CustomDatatype::MILESTONE_CHOICE: case entities\CustomDatatype::CLIENT_CHOICE: case entities\CustomDatatype::COMPONENTS_CHOICE: case entities\CustomDatatype::EDITIONS_CHOICE: case entities\CustomDatatype::RELEASES_CHOICE: $rule->setRuleValue(join(',', $request['rule_value'] ?: array())); $text = $rule->getRuleValue() ? $rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value'); break; } } else { switch ($rule->getRule()) { case entities\WorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES: $rule->setRuleValue($request['rule_value']); $text = $rule->getRuleValue() ? $rule->getRuleValue() : $this->getI18n()->__('Unlimited'); break; case entities\WorkflowTransitionValidationRule::RULE_PRIORITY_VALID: case entities\WorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID: case entities\WorkflowTransitionValidationRule::RULE_RESOLUTION_VALID: case entities\WorkflowTransitionValidationRule::RULE_STATUS_VALID: case entities\WorkflowTransitionValidationRule::RULE_TEAM_MEMBERSHIP_VALID: case entities\WorkflowTransitionValidationRule::RULE_ISSUE_IN_MILESTONE_VALID: $rule->setRuleValue(join(',', $request['rule_value'] ?: array())); $text = $rule->getRuleValue() ? $rule->getRuleValueAsJoinedString() : $this->getI18n()->__('Any valid value'); break; } } $rule->save(); $this->rule = $rule; return $this->renderJSON(array('content' => $text)); } } } elseif ($request->isPost() && $request->hasParameter('step_id')) { $step = tables\WorkflowSteps::getTable()->selectById((int) $request['step_id']); if ($request['add_transition_type'] == 'existing' && $request->hasParameter('existing_transition_id')) { $transition = tables\WorkflowTransitions::getTable()->selectById((int) $request['existing_transition_id']); $redirect_transition = false; } else { if ($request['transition_name'] && $request['outgoing_step_id'] && $request->hasParameter('template')) { if (($outgoing_step = tables\WorkflowSteps::getTable()->selectById((int) $request['outgoing_step_id'])) && $step instanceof entities\WorkflowStep) { if (!$request['template'] || array_key_exists($request['template'], entities\WorkflowTransition::getTemplates())) { $transition = new entities\WorkflowTransition(); $transition->setWorkflow($this->workflow); $transition->setName($request['transition_name']); $transition->setDescription($request['transition_description']); $transition->setOutgoingStep($outgoing_step); $transition->setTemplate($request['template']); $transition->save(); $step->addOutgoingTransition($transition); $redirect_transition = true; } else { throw new \InvalidArgumentException($this->getI18n()->__('Please select a valid template')); } } else { throw new \InvalidArgumentException($this->getI18n()->__('Please select a valid outgoing step')); } } else { throw new \InvalidArgumentException($this->getI18n()->__('Please fill in all required fields')); } } $step->addOutgoingTransition($transition); } else { throw new \InvalidArgumentException('Invalid action'); } } catch (\InvalidArgumentException $e) { $this->error = $e->getMessage(); } catch (\Exception $e) { $this->error = $this->getI18n()->__('This workflow / transition does not exist'); } if (isset($redirect_transition) && $redirect_transition) { $this->forward(framework\Context::getRouting()->generate('configure_workflow_transition', array('workflow_id' => $this->workflow->getID(), 'transition_id' => $transition->getID()))); } elseif (isset($redirect_transition)) { $this->forward(framework\Context::getRouting()->generate('configure_workflow_steps', array('workflow_id' => $this->workflow->getID()))); } }
public function runResolve(framework\Request $request) { $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName(); $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH; if ($request->hasParameter('css')) { $this->getResponse()->setContentType('text/css'); if ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) { $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'css'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'css' . DS . $request->getParameter('css'); } elseif (!$request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css'); } else { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css'); } } elseif ($request->hasParameter('js')) { $this->getResponse()->setContentType('text/javascript'); if ($request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js'); } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) { $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js'); } else { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js'); } } elseif ($request->hasParameter('image')) { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'images'; if (isset($request['module_name'])) { $asset .= DS . "modules" . DS . $request['module_name']; } if (isset($request['folder'])) { $asset .= DS . $request['folder']; } $asset .= DS . $request->getParameter('image'); if (!file_exists($asset) && isset($request['module_name']) && framework\Context::isModuleLoaded($request['module_name'])) { $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'images'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'images'; if (isset($request['folder'])) { $asset .= DS . $request['folder']; } $asset .= DS . $request->getParameter('image'); } $fileinfo = finfo_open(FILEINFO_MIME_TYPE); $mimetype = finfo_file($fileinfo, $asset); finfo_close($fileinfo); $this->getResponse()->setContentType($mimetype); } else { throw new \Exception('The expected theme Asset type is not supported.'); } $last_modified = filemtime($asset); $this->getResponse()->addHeader('Cache-Control: max-age=3600, must-revalidate'); $this->getResponse()->addHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $last_modified) . 'GMT'); $this->getResponse()->addHeader('ETag: ' . md5($last_modified)); if (!$this->getResponse()->isModified($last_modified)) { return $this->return304(); } $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath))); $fileAsset->load(); // Do not decorate the asset with the theme's header/footer $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE); return $this->renderText($fileAsset->dump()); }
public function isValid(\thebuggenie\core\framework\Request $request) { if ($this->_target_value) { return true; } switch ($this->_action_type) { case self::ACTION_ASSIGN_ISSUE: return (bool) $request['assignee_type'] && $request['assignee_id']; break; case self::ACTION_SET_MILESTONE: return (bool) $request->hasParameter('milestone_id'); break; case self::ACTION_SET_PRIORITY: return (bool) $request->hasParameter('priority_id'); break; case self::ACTION_SET_STATUS: return (bool) $request->hasParameter('status_id') && ($status = Status::getB2DBTable()->selectById((int) $request->getParameter('status_id'))) instanceof Status && $status->canUserSet(framework\Context::getUser()); break; case self::ACTION_SET_REPRODUCABILITY: return (bool) $request->hasParameter('reproducability_id'); break; case self::ACTION_SET_RESOLUTION: return (bool) $request->hasParameter('resolution_id'); break; default: return true; } }
/** * 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))); } if ($this->article->getID()) { $this->article_route = 'publish_article_edit'; $this->article_route_params = array('article_name' => $request->getRawParameter('article_name')); } elseif ($request->hasParameter('parent_article_name')) { $this->article_route = 'publish_article_new_parent'; $this->article_route_params = array('parent_article_name' => $request->getRawParameter('parent_article_name')); } else { $this->article_route = 'publish_article_new'; $this->article_route_params = array(); } if ($request->isPost()) { $this->preview = (bool) $request['preview']; $this->change_reason = $request['change_reason']; try { $article_prev_name = $this->article->getName(); $article_prev_manual_name = $this->article->getManualName(); $this->article->setArticleType($request['article_type']); $this->article->setName($request->getRawParameter('new_article_name')); $this->article->setParentArticle(Articles::getTable()->getArticleByName($request->getRawParameter('parent_article_name'))); $this->article->setManualName($request->getRawParameter('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->getRawParameter('parent_article_name'); $this->article->setName($article_name_prefix . $this->article->getManualName()); } if ($this->article->getArticleType() == Article::TYPE_MANUAL && !$this->article->getParentArticle() instanceof Article && $article_prev_manual_name == $article_prev_name && $article_prev_manual_name != $this->article->getManualName()) { $this->article->setName($request['manual_name']); } $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->getRawParameter('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('article_prev_name' => $article_prev_name), $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(); } } }