public function postConfigSettings(TBGRequest $request) { $settings = array('use_web_interface', 'vcs_passkey'); foreach ($settings as $setting) { if ($request->hasParameter($setting)) { $this->saveSetting($setting, $request->getParameter($setting)); } } foreach (TBGProject::getAll() as $aProduct) { if ($request->hasParameter('web_path_' . $aProduct->getID())) { // github is always at github.com if ($request->hasParameter('web_type_' . $aProduct->getID()) && $request->getParameter('web_type_' . $aProduct->getID()) == 'github') { $this->saveSetting('web_path_' . $aProduct->getID(), 'http://github.com'); } else { $this->saveSetting('web_path_' . $aProduct->getID(), $request->getParameter('web_path_' . $aProduct->getID())); } } if ($request->hasParameter('web_type_' . $aProduct->getID())) { $this->saveSetting('web_type_' . $aProduct->getID(), $request->getParameter('web_type_' . $aProduct->getID())); } if ($request->hasParameter('web_repo_' . $aProduct->getID())) { $this->saveSetting('web_repo_' . $aProduct->getID(), $request->getParameter('web_repo_' . $aProduct->getID())); } } }
public function listenIssueSaveAddComment(TBGEvent $event) { $comment = $event->getParameter('comment'); $comment->setContent($this->_request->getParameter('comment_body', null, false) . "\n\n" . $comment->getContent()); $comment->setSystemComment(false); $comment->save(); }
public function runListFieldvalues(TBGRequest $request) { $field_key = $request->getParameter('field_key'); $return_array = array('description' => null, 'type' => null, 'choices' => null); if ($field_key == 'title' || in_array($field_key, TBGDatatypeBase::getAvailableFields(true))) { switch ($field_key) { case 'title': $return_array['description'] = TBGContext::getI18n()->__('Single line text input without formatting'); $return_array['type'] = 'single_line_input'; break; case 'description': case 'reproduction_steps': $return_array['description'] = TBGContext::getI18n()->__('Text input with wiki formatting capabilities'); $return_array['type'] = 'wiki_input'; break; case 'status': case 'resolution': case 'reproducability': case 'priority': case 'severity': case 'category': $return_array['description'] = TBGContext::getI18n()->__('Choose one of the available values'); $return_array['type'] = 'choice'; $classname = "TBG" . ucfirst($field_key); $choices = $classname::getAll(); foreach ($choices as $choice_key => $choice) { $return_array['choices'][$choice_key] = $choice->getName(); } break; case 'percent_complete': $return_array['description'] = TBGContext::getI18n()->__('Value of percentage completed'); $return_array['type'] = 'choice'; $return_array['choices'][] = "1-100%"; break; case 'owner': case 'assignee': $return_array['description'] = TBGContext::getI18n()->__('Select an existing user or <none>'); $return_array['type'] = 'select_user'; break; case 'estimated_time': case 'spent_time': $return_array['description'] = TBGContext::getI18n()->__('Enter time, such as points, hours, minutes, etc or <none>'); $return_array['type'] = 'time'; break; case 'milestone': $return_array['description'] = TBGContext::getI18n()->__('Select from available project milestones'); $return_array['type'] = 'choice'; if ($this->selected_project instanceof TBGProject) { $milestones = $this->selected_project->getAllMilestones(); foreach ($milestones as $milestone) { $return_array['choices'][$milestone->getID()] = $milestone->getName(); } } break; } } else { } $this->field_info = $return_array; }
public function postConfigSettings(TBGRequest $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)); } } } }
/** * Send a test email * * @param TBGRequest $request */ public function runTestEmail(TBGRequest $request) { if ($email_to = $request->getParameter('test_email_to')) { try { if (TBGMailing::getModule()->sendTestEmail($email_to)) { TBGContext::setMessage('module_message', TBGContext::getI18n()->__('The email was successfully accepted for delivery')); } else { TBGContext::setMessage('module_error', TBGContext::getI18n()->__('The email was not sent')); TBGContext::setMessage('module_error_details', TBGLogging::getMessagesForCategory('mailing', TBGLogging::LEVEL_NOTICE)); } } catch (Exception $e) { TBGContext::setMessage('module_error', TBGContext::getI18n()->__('The email was not sent')); TBGContext::setMessage('module_error_details', $e->getMessage()); } } else { TBGContext::setMessage('module_error', TBGContext::getI18n()->__('Please specify an email address')); } $this->forward(TBGContext::getRouting()->generate('configure_module', array('config_module' => 'mailing'))); }
/** * Returns the logged in user, or default user if not logged in * * @param TBGRequest $request * @param TBGAction $action * * @return TBGUser */ public static function loginCheck(TBGRequest $request, TBGAction $action) { try { $authentication_method = $action->getAuthenticationMethodForAction(TBGContext::getRouting()->getCurrentRouteAction()); $user = null; $external = false; switch ($authentication_method) { case TBGAction::AUTHENTICATION_METHOD_ELEVATED: case TBGAction::AUTHENTICATION_METHOD_CORE: $username = $request['tbg3_username']; $password = $request['tbg3_password']; if ($authentication_method == TBGAction::AUTHENTICATION_METHOD_ELEVATED) { $elevated_password = $request['tbg3_elevated_password']; } $raw = true; // If no username and password specified, check if we have a session that exists already if ($username === null && $password === null) { if (TBGContext::getRequest()->hasCookie('tbg3_username') && TBGContext::getRequest()->hasCookie('tbg3_password')) { $username = TBGContext::getRequest()->getCookie('tbg3_username'); $password = TBGContext::getRequest()->getCookie('tbg3_password'); $user = TBGUsersTable::getTable()->getByUsername($username); if ($authentication_method == TBGAction::AUTHENTICATION_METHOD_ELEVATED) { $elevated_password = TBGContext::getRequest()->getCookie('tbg3_elevated_password'); if ($user instanceof TBGUser && !$user->hasPasswordHash($password)) { $user = null; } else { if ($user instanceof TBGUser && !$user->hasPasswordHash($elevated_password)) { TBGContext::setUser($user); TBGContext::getRouting()->setCurrentRouteName('elevated_login_page'); throw new TBGElevatedLoginException('reenter'); } } } else { if ($user instanceof TBGUser && !$user->hasPasswordHash($password)) { $user = null; } } $raw = false; if (!$user instanceof TBGUser) { TBGContext::logout(); throw new Exception('No such login'); } } } // If we have authentication details, validate them if (TBGSettings::isUsingExternalAuthenticationBackend() && $username !== null && $password !== null) { $external = true; TBGLogging::log('Authenticating with backend: ' . TBGSettings::getAuthenticationBackend(), 'auth', TBGLogging::LEVEL_INFO); try { $mod = TBGContext::getModule(TBGSettings::getAuthenticationBackend()); if ($mod->getType() !== TBGModule::MODULE_AUTH) { TBGLogging::log('Auth module is not the right type', 'auth', TBGLogging::LEVEL_FATAL); } if (TBGContext::getRequest()->hasCookie('tbg3_username') && TBGContext::getRequest()->hasCookie('tbg3_password')) { $user = $mod->verifyLogin($username, $password); } else { $user = $mod->doLogin($username, $password); } if (!$user instanceof TBGUser) { // Invalid TBGContext::logout(); throw new Exception('No such login'); //TBGContext::getResponse()->headerRedirect(TBGContext::getRouting()->generate('login')); } } catch (Exception $e) { throw $e; } } elseif (TBGSettings::isUsingExternalAuthenticationBackend()) { $external = true; TBGLogging::log('Authenticating without credentials with backend: ' . TBGSettings::getAuthenticationBackend(), 'auth', TBGLogging::LEVEL_INFO); try { $mod = TBGContext::getModule(TBGSettings::getAuthenticationBackend()); if ($mod->getType() !== TBGModule::MODULE_AUTH) { TBGLogging::log('Auth module is not the right type', 'auth', TBGLogging::LEVEL_FATAL); } $user = $mod->doAutoLogin(); if ($user == false) { // Invalid TBGContext::logout(); throw new Exception('No such login'); //TBGContext::getResponse()->headerRedirect(TBGContext::getRouting()->generate('login')); } } catch (Exception $e) { throw $e; } } elseif ($username !== null && $password !== null && !$user instanceof TBGUser) { $external = false; TBGLogging::log('Using internal authentication', 'auth', TBGLogging::LEVEL_INFO); $user = TBGUsersTable::getTable()->getByUsername($username); if (!$user->hasPassword($password)) { $user = null; } if (!$user instanceof TBGUser) { TBGContext::logout(); } } break; case TBGAction::AUTHENTICATION_METHOD_DUMMY: $user = TBGUsersTable::getTable()->getByUserID(TBGSettings::getDefaultUserID()); break; case TBGAction::AUTHENTICATION_METHOD_CLI: $user = TBGUsersTable::getTable()->getByUsername(TBGContext::getCurrentCLIusername()); break; case TBGAction::AUTHENTICATION_METHOD_RSS_KEY: $user = TBGUsersTable::getTable()->getByRssKey($request['rsskey']); break; case TBGAction::AUTHENTICATION_METHOD_APPLICATION_PASSWORD: $user = TBGUsersTable::getTable()->getByUsername($request['api_username']); if (!$user->authenticateApplicationPassword($request['api_token'])) { $user = null; } break; default: if (!TBGSettings::isLoginRequired()) { $user = TBGUsersTable::getTable()->getByUserID(TBGSettings::getDefaultUserID()); } } if ($user instanceof TBGUser) { if (!$user->isActivated()) { throw new Exception('This account has not been activated yet'); } elseif (!$user->isEnabled()) { throw new Exception('This account has been suspended'); } elseif (!$user->isConfirmedMemberOfScope(TBGContext::getScope())) { if (!TBGSettings::isRegistrationAllowed()) { throw new Exception('This account does not have access to this scope'); } } if ($external == false && $authentication_method == TBGAction::AUTHENTICATION_METHOD_CORE) { $password = $user->getHashPassword(); if (!$request->hasCookie('tbg3_username')) { if ($request->getParameter('tbg3_rememberme')) { TBGContext::getResponse()->setCookie('tbg3_username', $user->getUsername()); TBGContext::getResponse()->setCookie('tbg3_password', $user->getPassword()); } else { TBGContext::getResponse()->setSessionCookie('tbg3_username', $user->getUsername()); TBGContext::getResponse()->setSessionCookie('tbg3_password', $user->getPassword()); } } } } elseif (TBGSettings::isLoginRequired()) { throw new Exception('Login required'); } else { throw new Exception('No such login'); } } catch (Exception $e) { throw $e; } return $user; }
public function runTransitionIssue(TBGRequest $request) { try { $transition = TBGContext::factory()->TBGWorkflowTransition($request->getParameter('transition_id')); $issue = TBGContext::factory()->TBGIssue($request->getParameter('issue_id')); if (!$issue->isWorkflowTransitionsAvailable()) { throw new Exception(TBGContext::getI18n()->__('You are not allowed to perform any workflow transitions on this issue')); } if ($transition->validateFromRequest($request)) { $transition->transitionIssueToOutgoingStepFromRequest($issue); } else { TBGContext::setMessage('issue_error', 'transition_error'); TBGContext::setMessage('issue_workflow_errors', $transition->getValidationErrors()); } $this->forward(TBGContext::getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo()))); } catch (Exception $e) { throw $e; return $this->return404(); } }
public function runAddFilter(TBGRequest $request) { if ($request->getParameter('filter_name') == 'project_id' && count(TBGProject::getAll()) == 0) { return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__('No projects exist so this filter can not be added'))); } elseif (in_array($request->getParameter('filter_name'), TBGIssuesTable::getValidSearchFilters()) || TBGCustomDatatype::doesKeyExist($request->getParameter('filter_name'))) { return $this->renderJSON(array('failed' => false, 'content' => $this->getComponentHTML('search/filter', array('filter' => $request->getParameter('filter_name'), 'key' => $request->getParameter('key', 0))))); } else { return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__('This is not a valid search field'))); } }
public function runAddFilter(TBGRequest $request) { if ($request['filter_name'] == 'project_id' && count(TBGProject::getAll()) == 0) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('No projects exist so this filter can not be added'))); } elseif (in_array($request['filter_name'], TBGSearchFilter::getValidSearchFilters()) || TBGCustomDatatype::doesKeyExist($request['filter_name'])) { return $this->renderJSON(array('content' => $this->getComponentHTML('search/filter', array('filter' => $request['filter_name'], 'key' => $request->getParameter('key', 0))))); } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('This is not a valid search field'))); } }
public function runProjectWorkflow(TBGRequest $request) { if ($this->getUser()->canManageProject($this->selected_project) || $this->getUser()->canManageProjectReleases($this->selected_project)) { try { foreach ($this->selected_project->getIssuetypeScheme()->getIssuetypes() as $type) { $data = array(); foreach ($this->selected_project->getWorkflowScheme()->getWorkflowForIssuetype($type)->getSteps() as $step) { $data[] = array((string) $step->getID(), $request->getParameter('new_step_' . $type->getID() . '_' . $step->getID())); } $this->selected_project->convertIssueStepPerIssuetype($type, $data); } $this->selected_project->setWorkflowScheme(TBGContext::factory()->TBGWorkflowScheme($request['workflow_id'])); $this->selected_project->save(); return $this->renderJSON(array('message' => TBGContext::geti18n()->__('Workflow scheme changed and issues updated'))); } catch (Exception $e) { $this->getResponse()->setHTTPStatus(400); return $this->renderJSON(array('error' => TBGContext::geti18n()->__('An internal error occured'))); } } $this->getResponse()->setHTTPStatus(400); return $this->renderJSON(array('error' => TBGContext::geti18n()->__("You don't have access to perform this action"))); }
protected function _upgradeFrom3dot2(TBGRequest $request) { set_time_limit(0); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.2'); foreach (array('publish', 'mailing') as $module) { TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . $module . DS . 'classes'); TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . $module . DS . 'classes' . DS . 'B2DB'); } TBGMilestonesTable::getTable()->upgrade(TBGMilestonesTable3dot2::getTable()); TBGArticlesTable::getTable()->upgrade(TBGArticlesTable3dot2::getTable()); TBGProjectsTable::getTable()->upgrade(TBGProjectsTable3dot2::getTable()); TBGLogTable::getTable()->upgrade(TBGLogTable3dot2::getTable()); TBGUsersTable::getTable()->upgrade(TBGUsersTable3dot2::getTable()); TBGIssuesTable::getTable()->upgrade(TBGIssuesTable3dot2::getTable()); TBGWorkflowsTable::getTable()->upgrade(TBGWorkflowsTable3dot2::getTable()); TBGIncomingEmailAccountTable::getTable()->upgrade(TBGIncomingEmailAccountTable3dot2::getTable()); TBGIssueSpentTimesTable::getTable()->upgrade(TBGIssueSpentTimesTable3dot2::getTable()); TBGCommentsTable::getTable()->upgrade(TBGCommentsTable3dot2::getTable()); TBGSavedSearchesTable::getTable()->upgrade(TBGSavedSearchesTable3dot2::getTable()); TBGSettingsTable::getTable()->upgrade(TBGSettingsTable3dot2::getTable()); TBGNotificationsTable::getTable()->upgrade(TBGNotificationsTable3dot2::getTable()); TBGPermissionsTable::getTable()->upgrade(TBGPermissionsTable3dot2::getTable()); TBGUserArticlesTable::getTable()->create(); TBGApplicationPasswordsTable::getTable()->create(); TBGUserNotificationSettingsTable::getTable()->create(); $transaction = \b2db\Core::startTransaction(); // Upgrade user passwords switch ($request['upgrade_passwords']) { case 'manual': $password = $request['manul_password']; foreach (TBGUsersTable::getTable()->selectAll() as $user) { $user->setPassword($password); $user->save(); } break; case 'auto': $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email'; foreach (TBGUsersTable::getTable()->selectAll() as $user) { if ($field == 'username' && trim($user->getUsername())) { $user->setPassword(trim($user->getUsername())); $user->save(); } elseif ($field == 'email' && trim($user->getEmail())) { $user->setPassword(trim($user->getEmail())); $user->save(); } } break; } $adminuser = TBGUsersTable::getTable()->selectById(1); $adminuser->setPassword($request['admin_password']); $adminuser->save(); // Add new settings TBGSettings::saveSetting(TBGSettings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1); foreach ($request->getParameter('status') as $scope_id => $status_id) { $scope = TBGScopesTable::getTable()->selectById((int) $scope_id); if ($scope instanceof TBGScope) { foreach (TBGWorkflowsTable::getTable()->getAll((int) $scope_id) as $workflow) { $transition = new TBGWorkflowTransition(); $steps = $workflow->getSteps(); $step = array_shift($steps); $step->setLinkedStatusID((int) $status_id); $step->save(); $transition->setOutgoingStep($step); $transition->setName('Issue created'); $transition->setWorkflow($workflow); $transition->setScope($scope); $transition->setDescription('This is the initial transition for issues using this workflow'); $transition->save(); $workflow->setInitialTransition($transition); $workflow->save(); } TBGActivityType::loadFixtures($scope); } } $transaction->commitAndEnd(); TBGContext::finishUpgrading(); TBGContext::getModule('mailing')->upgradeFrom3dot2(); $this->upgrade_complete = true; }
public function runFindArticles(TBGRequest $request) { $this->articlename = $request->getParameter('articlename'); if ($this->articlename) { list($this->resultcount, $this->articles) = TBGWikiArticle::findByArticleNameAndProject($this->articlename, TBGContext::getCurrentProject(), 10); } }
public function setValuesFromRequest(TBGRequest $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); $this->_filters = TBGSearchFilter::getFromRequest($request, $this); $this->_applies_to_project = TBGContext::getCurrentProject(); $this->_columns = $request->getParameter('columns'); $this->_sortfields = $request->getParameter('sortfields'); if ($request['quicksearch']) { $this->setSortFields(array(TBGIssuesTable::LAST_UPDATED => 'asc')); } $this->_groupby = $request['groupby']; $this->_grouporder = $request->getParameter('grouporder', 'asc'); if (in_array($this->_templatename, array('results_userpain_singlepainthreshold', 'results_userpain_totalpainthreshold'))) { $this->_searchtitle = TBGContext::getI18n()->__('Showing "bug report" issues sorted by user pain, threshold set at %threshold', array('%threshold' => $this->_template_parameter)); $this->_issues_per_page = 0; $this->_groupby = 'user_pain'; $this->_grouporder = 'desc'; $this->_filters['issuetype'] = TBGSearchFilter::createFilter('issuetype', join(',', TBGIssueTypesTable::getTable()->getBugReportTypeIDs())); } elseif ($this->_templatename == 'results_votes') { $this->_searchtitle = TBGContext::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(); }
public function postAccountSettings(TBGRequest $request) { $settings = array(self::NOTIFY_ISSUE_ASSIGNED_UPDATED, self::NOTIFY_ISSUE_ONCE, self::NOTIFY_ISSUE_POSTED_UPDATED, self::NOTIFY_ISSUE_PROJECT_ASSIGNED, self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, self::NOTIFY_ISSUE_TEAMASSIGNED_UPDATED, self::NOTIFY_ISSUE_UPDATED_SELF); $uid = TBGContext::getUser()->getID(); foreach ($settings as $setting) { $this->saveSetting($setting, (int) $request->getParameter($setting, 0), $uid); } return true; }
public function runServe(TBGRequest $request) { if (TBGContext::isMinifyDisabled()) { $itemarray = array($request->getParameter('g') => explode(',', base64_decode($request->getParameter('files')))); if (array_key_exists('js', $itemarray)) { header('Content-type: text/javascript'); foreach ($itemarray['js'] as $file) { if (file_exists($file)) { echo file_get_contents($file); } } } else { header('Content-type: text/css'); foreach ($itemarray['css'] as $file) { if (file_exists($file)) { echo file_get_contents($file); } } } exit; } $this->getResponse()->setDecoration(TBGResponse::DECORATE_NONE); define('MINIFY_MIN_DIR', dirname(__FILE__) . '/../../../core/min'); // load config require MINIFY_MIN_DIR . '/config.php'; // setup include path set_include_path($min_libPath . PATH_SEPARATOR . get_include_path()); require 'Minify.php'; Minify::$uploaderHoursBehind = $min_uploaderHoursBehind; Minify::setCache(isset($min_cachePath) ? $min_cachePath : '', $min_cacheFileLocking); if ($min_documentRoot) { $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot; } elseif (0 === stripos(PHP_OS, 'win')) { Minify::setDocRoot(); // IIS may need help } $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks; if ($min_allowDebugFlag && isset($_GET['debug'])) { $min_serveOptions['debug'] = true; } if ($min_errorLogger) { require_once 'Minify/Logger.php'; if (true === $min_errorLogger) { require_once 'FirePHP.php'; Minify_Logger::setLogger(FirePHP::getInstance(true)); } else { Minify_Logger::setLogger($min_errorLogger); } } // check for URI versioning if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) { $min_serveOptions['maxAge'] = 31536000; } $itemarray = array($request->getParameter('g') => explode(',', base64_decode($request->getParameter('files')))); $min_serveOptions['minApp']['groups'] = $itemarray; $data = Minify::serve('MinApp', $min_serveOptions); header_remove('Pragma'); foreach ($data['headers'] as $name => $val) { header($name . ': ' . $val); } if ($request->getParameter('g') == 'js') { header('Content-type: text/javascript'); } elseif ($request->getParameter('g') == 'css') { header('Content-type: text/css'); } else { header('Content-type: text/plain'); } header('HTTP/1.1 ' . $data['statusCode']); if ($data['statusCode'] != 304) { echo $data['content']; } exit; }
public function runConfigureWorkflowSteps(TBGRequest $request) { $this->workflow = null; $this->mode = $request->getParameter('mode', 'list'); try { $this->workflow = TBGContext::factory()->TBGWorkflow($request['workflow_id']); // $transition = new TBGWorkflowTransition(); // $step = TBGWorkflowStepsTable::getTable()->selectById(9); // $transition->setOutgoingStep($step); // $transition->setName('Initial transition'); // $transition->setWorkflow($this->workflow); // $transition->setScope(TBGContext::getScope()); // $transition->setDescription('This is the initial transition for issues using this workflow'); // $transition->save(); // $this->workflow->setInitialTransition($transition); // $this->workflow->save(); if ($this->mode == 'copy_workflow') { if ($new_name = $request['new_name']) { $new_workflow = $this->workflow->copy($new_name); return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/workflow', array('workflow' => $new_workflow)), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } else { $this->error = $this->getI18n()->__('Please enter a valid name'); } } elseif ($this->mode == 'delete_workflow') { $this->workflow->delete(); return $this->renderJSON(array('success' => true, 'message' => $this->getI18n()->__('The workflow was deleted'), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } } catch (Exception $e) { if ($request->getRequestedFormat() == 'json') { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('success' => false, 'message' => $this->getI18n()->__('An error occured'), 'error' => $e->getMessage())); } else { $this->error = $this->getI18n()->__('This workflow does not exist'); } } }
public function postConfigSettings(TBGRequest $request) { if ($request->hasParameter('import_articles')) { $cc = 0; foreach ($request->getParameter('import_article') as $article_name => $import) { $cc++; TBGArticlesTable::getTable()->deleteArticleByName(urldecode($article_name)); $content = file_get_contents(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'fixtures' . DS . $article_name); TBGWikiArticle::createNew(urldecode($article_name), $content, true, null, array('overwrite' => true, 'noauthor' => true)); } TBGContext::setMessage('module_message', TBGContext::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'); foreach ($settings as $setting) { if ($request->hasParameter($setting)) { $this->saveSetting($setting, $request->getParameter($setting)); } } } }
public function runConfigureProjectSettings(TBGRequest $request) { $this->forward403unless($request->isPost()); if ($this->access_level != TBGSettings::ACCESS_FULL) { $project_id = $request['project_id']; $fields = array('vcs_mode', 'match_keywords', 'access_method', 'access_passkey', 'commit_url', 'log_url', 'blob_url', 'diff_url', 'browser_url', 'vcs_workflow'); foreach ($fields as $field) { TBGContext::getModule('vcs_integration')->saveSetting($field . '_' . $project_id, $request->getParameter($field)); } switch ($request['browser_type']) { case 'viewvc': $base_url = $request['browser_url']; $link_rev = '&view=rev&revision=%revno'; $link_file = '&view=log'; $link_diff = '&r1=%revno&r2=%oldrev'; $link_view = '&revision=%revno&view=markup'; break; case 'viewvc_repo': $base_url = $request['browser_url']; $link_rev = '/?view=rev&revision=%revno'; $link_file = '/%file?view=log'; $link_diff = '/%file?r1=%revno&r2=%oldrev'; $link_view = '/%file?revision=%revno&view=markup'; break; case 'websvn': $base_url = $request['browser_url']; $link_rev = '/revision.php?repname=' . $request['repository'] . '&isdir=1&rev=%revno'; $link_file = '/log.php?repname=' . $request['repository'] . '&path=/$%file'; $link_diff = '/comp.php?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev'; $link_view = '/filedetails.php?repname=' . $request['repository'] . '&path=/%file&rev=%revno'; break; case 'websvn_mv': $base_url = $request['browser_url']; $link_rev = '/' . '?repname=' . $request['repository'] . '&op=log&isdir=1&rev=%revno'; $link_file = '/%file?repname=' . $request['repository']; $link_diff = '/%file?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev'; $link_view = '/%file?repname=' . $request['repository'] . '&rev=%revno'; break; case 'loggerhead': $base_url = $request['browser_url']; $link_rev = '/revision/%revno'; $link_file = '/changes'; $link_diff = '/revision/%revno?compare_revid=%oldrev'; $link_view = '/annotate/head:/%file'; break; case 'gitweb': $base_url = $request['browser_url']; $link_rev = ';a=commitdiff;h=%revno'; $link_file = ';a=history;f=%file;hb=HEAD'; $link_diff = ';a=blobdiff;f=%file;hb=%revno;hpb=%oldrev'; $link_view = ';a=blob;f=%file;hb=%revno'; break; case 'cgit': $base_url = $request['browser_url']; $link_rev = '/commit/?id=%revno'; $link_file = '/log'; $link_diff = '/diff/%file?id=%revno?id2=%oldrev'; $link_view = '/tree/%file?id=%revno'; break; case 'hgweb': $base_url = $request['browser_url']; $link_rev = '/rev/%revno'; $link_file = '/log/tip/%file'; $link_diff = '/diff/%revno/%file'; $link_view = '/file/%revno/%file'; break; case 'github': $base_url = $request['browser_url']; $link_rev = '/commit/%revno'; $link_file = '/commits/%branch/%file'; $link_diff = '/commit/%revno'; $link_view = '/blob/%revno/%file'; break; case 'gitlab': $base_url = $request['browser_url']; $link_rev = '/commit/%revno'; $link_file = '/commits/%branch/%file'; $link_diff = '/commit/%revno'; $link_view = '/blob/%revno/%file'; break; case 'bitbucket': $base_url = $request['browser_url']; $link_rev = '/changeset/%revno'; $link_file = '/history/%file'; $link_diff = '/changeset/%revno#chg-%file'; $link_view = '/src/%revno/%file'; break; case 'gitorious': $base_url = $request['browser_url']; $link_rev = '/commit/%revno'; $link_file = '/blobs/history/%branch/%file'; $link_diff = '/commit/%revno'; $link_view = '/blobs/%revno/%file'; break; case 'rhodecode': $base_url = $request['browser_url']; $link_rev = '/changeset/%revno'; $link_file = '/changelog/%revno/%file'; $link_diff = '/diff/%file?diff2=%revno&diff1=%oldrev&fulldiff=1&diff=diff'; $link_view = '/files/%revno/%file'; break; } if ($request['browser_type'] != 'other') { TBGContext::getModule('vcs_integration')->saveSetting('browser_url_' . $project_id, $base_url); TBGContext::getModule('vcs_integration')->saveSetting('log_url_' . $project_id, $link_file); TBGContext::getModule('vcs_integration')->saveSetting('blob_url_' . $project_id, $link_view); TBGContext::getModule('vcs_integration')->saveSetting('diff_url_' . $project_id, $link_diff); TBGContext::getModule('vcs_integration')->saveSetting('commit_url_' . $project_id, $link_rev); } return $this->renderJSON(array('failed' => false, 'message' => TBGContext::getI18n()->__('Settings saved'))); } else { $this->forward403(); } }
public function isValid(TBGRequest $request) { if ($this->_target_value) { return true; } switch ($this->_action_type) { case self::ACTION_ASSIGN_ISSUE: return (bool) $request->getParameter('assignee_type') && $request->getParameter('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; } }
public function runRelateIssues(TBGRequest $request) { $status = 200; $message = null; if ($issue_id = $request['issue_id']) { try { $issue = TBGContext::factory()->TBGIssue($issue_id); } catch (Exception $e) { $status = 400; $message = TBGContext::getI18n()->__('Could not find this issue'); } } else { $status = 400; $message = TBGContext::getI18n()->__('Please provide an issue number'); } if (!$issue->canAddRelatedIssues()) { $status = 400; $message = TBGContext::getI18n()->__('You are not allowed to relate issues'); } $this->getResponse()->setHttpStatus($status); if ($status == 400) { return $this->renderJSON(array('error' => $message)); } $related_issues = $request->getParameter('relate_issues', array()); $cc = 0; $message = TBGContext::getI18n()->__('Unknown error'); if (count($related_issues)) { $mode = $request['relate_action']; $content = ''; foreach ($related_issues as $issue_id) { try { $related_issue = TBGContext::factory()->TBGIssue((int) $issue_id); if ($mode == 'relate_children') { $issue->addChildIssue($related_issue); } else { $issue->addParentIssue($related_issue); } $cc++; $content .= $this->getTemplateHTML('main/relatedissue', array('issue' => $related_issue, 'related_issue' => $issue)); } catch (Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('An error occured when relating issues: %error', array('%error' => $e->getMessage())))); } } } else { $message = TBGContext::getI18n()->__('Please select at least one issue'); } if ($cc > 0) { return $this->renderJSON(array('content' => $content, 'message' => TBGContext::getI18n()->__('The related issue was added'))); } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => TBGContext::getI18n()->__('An error occured when relating issues: %error', array('%error' => $message)))); } }
public function runConfigureProjectSettings(TBGRequest $request) { $this->forward403unless($request->isPost()); if ($this->access_level != TBGSettings::ACCESS_FULL) { $project_id = $request['project_id']; if ($request['mailing_from_address'] != '') { if (filter_var(trim($request['mailing_from_address']), FILTER_VALIDATE_EMAIL) !== false) { TBGContext::getModule('mailing')->saveSetting(TBGMailing::SETTING_PROJECT_FROM_ADDRESS . $project_id, trim(mb_strtolower($request->getParameter('mailing_from_address')))); if (trim($request['mailing_from_name']) !== '') { TBGContext::getModule('mailing')->saveSetting(TBGMailing::SETTING_PROJECT_FROM_NAME . $project_id, trim($request->getParameter('mailing_from_name'))); } else { TBGContext::getModule('mailing')->deleteSetting(TBGMailing::SETTING_PROJECT_FROM_NAME . $project_id); } } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('message' => TBGContext::getI18n()->__('Please enter a valid email address'))); } } elseif ($request->getParameter('mailing_reply_address') == '') { TBGContext::getModule('mailing')->deleteSetting(TBGMailing::SETTING_PROJECT_FROM_ADDRESS . $project_id); TBGContext::getModule('mailing')->deleteSetting(TBGMailing::SETTING_PROJECT_FROM_NAME . $project_id); } return $this->renderJSON(array('failed' => false, 'message' => TBGContext::getI18n()->__('Settings saved'))); } else { $this->forward403(); } }
/** * Runs the action for the fifth step of the installation * where it enables modules on demand * * @param TBGRequest $request The request object * * @return null */ public function runInstallStep5(TBGRequest $request) { $this->sample_data = false; try { if ($request->hasParameter('modules')) { foreach ($request->getParameter('modules', array()) as $module => $install) { if ((bool) $install && file_exists(THEBUGGENIE_MODULES_PATH . $module . DS . 'module')) { TBGModule::installModule($module); } } } elseif ($request->hasParameter('sample_data')) { $this->sample_data = true; } } catch (Exception $e) { throw $e; $this->error = $e->getMessage(); } }
public function runUnassignFromProject(TBGRequest $request) { try { $project = TBGContext::factory()->TBGProject($request->getParameter('project_id')); $project->removeAssignee($request->getParameter('assignee_type'), $request->getParameter('assignee_id')); return $this->renderJSON(array('failed' => false, 'message' => TBGContext::getI18n()->__('The assignee has been removed'))); } catch (Exception $e) { return $this->renderJSON(array('failed' => true, 'message' => $e->getMessage())); } }
public function postConfigSettings(TBGRequest $request) { TBGContext::loadLibrary('common'); $settings = array('smtp_host', 'smtp_port', 'smtp_user', 'timeout', 'mail_type', 'enable_outgoing_notifications', 'cli_mailing_url', 'smtp_pwd', 'headcharset', 'from_name', 'from_addr', 'ehlo', 'use_queue', 'no_dash_f', 'activation_needed'); foreach ($settings as $setting) { if ($request->getParameter($setting) !== null || $setting == 'no_dash_f' || $setting == 'activation_needed') { $value = $request->getParameter($setting); switch ($setting) { case 'smtp_host': if ($request['mail_type'] == TBGMailer::MAIL_TYPE_CUSTOM && !tbg_check_syntax($value, "MAILSERVER")) { throw new Exception(TBGContext::getI18n()->__('Please provide a valid setting for SMTP server address')); } break; case 'from_addr': if (!tbg_check_syntax($value, "EMAIL")) { throw new Exception(TBGContext::getI18n()->__('Please provide a valid setting for email "from"-address')); } break; case 'timeout': if ($request['mail_type'] == TBGMailer::MAIL_TYPE_CUSTOM && !is_numeric($value) || $value < 0) { throw new Exception(TBGContext::getI18n()->__('Please provide a valid setting for SMTP server timeout')); } break; case 'smtp_port': if ($request['mail_type'] == TBGMailer::MAIL_TYPE_CUSTOM && !is_numeric($value) || $value < 1) { throw new Exception(TBGContext::getI18n()->__('Please provide a valid setting for SMTP server port')); } break; case 'headcharset': // list of supported character sets based on PHP doc : http://www.php.net/manual/en/function.htmlentities.php if (!tbg_check_syntax($value, "CHARSET")) { throw new Exception(TBGContext::getI18n()->__('Please provide a valid setting for email header charset')); } break; case 'no_dash_f': $value = (int) $request->getParameter($setting, 0); break; case 'activation_needed': $value = (int) $request->getParameter($setting, 0); break; case 'cli_mailing_url': $value = $request->getParameter($setting); if (substr($value, -1) == '/') { $value = substr($value, 0, strlen($value) - 1); } break; } $this->saveSetting($setting, $value); } } }