コード例 #1
0
 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;
 }
コード例 #2
0
 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()));
         }
     }
 }
コード例 #3
0
 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();
 }
コード例 #4
0
 public function componentResults_view()
 {
     $request = new TBGRequest();
     switch ($this->type) {
         case TBGDashboard::DASHBOARD_VIEW_PREDEFINED_SEARCH:
             $request->setParameter('predefined_search', $this->view);
             break;
         case TBGDashboard::DASHBOARD_VIEW_SAVED_SEARCH:
             $request->setParameter('saved_search', $this->view);
             break;
     }
     $request->setParameter('search', $this->search);
     $search = TBGContext::factory()->manufacture('searchActions', uniqid(rand(), true));
     $search->runFindIssues($request);
     $this->issues = $search->issues;
     $this->title = $search->searchtitle;
     $this->parameters = $request->getParameters();
 }
コード例 #5
0
 /**
  * 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')));
 }
コード例 #6
0
 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));
             }
         }
     }
 }
コード例 #7
0
 public static function getFromRequest(TBGRequest $request, TBGSavedSearch $search)
 {
     $filters = $request->getRawParameter('fs', array());
     if ($request['quicksearch']) {
         $filters['text']['o'] = '=';
     }
     if (TBGContext::isProjectContext()) {
         $filters['project_id'] = array('o' => '=', 'v' => TBGContext::getCurrentProject()->getID());
     }
     $return_filters = array();
     foreach ($filters as $key => $details) {
         if (!isset($details['o'])) {
             foreach ($details as $subdetails) {
                 $return_filters[$key][] = self::createFilter($key, $subdetails, $search);
             }
         } else {
             $return_filters[$key] = self::createFilter($key, $details, $search);
         }
     }
     return $return_filters;
 }
コード例 #8
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 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')));
     }
 }
コード例 #9
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runSiteIcons(TBGRequest $request)
 {
     if ($this->getAccessLevel($request['section'], 'core') == TBGSettings::ACCESS_FULL) {
         if ($request->isPost()) {
             switch ($request['small_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('small_icon');
                     TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_TYPE, TBGSettings::APPEARANCE_FAVICON_CUSTOM);
                     TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_TYPE, TBGSettings::APPEARANCE_FAVICON_THEME);
                     break;
             }
             switch ($request['large_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('large_icon');
                     TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_TYPE, TBGSettings::APPEARANCE_HEADER_CUSTOM);
                     TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_TYPE, TBGSettings::APPEARANCE_HEADER_THEME);
                     break;
             }
         }
         $route = TBGContext::getRouting()->generate('configure_settings');
         if ($request->isAjaxCall()) {
             return $this->renderJSON(array('forward' => $route));
         } else {
             $this->forward($route);
         }
     }
     return $this->forward403($this->getI18n()->__("You don't have access to perform this action"));
 }
コード例 #10
0
 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();
     }
 }
コード例 #11
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 /**
  * Show an article
  *
  * @param TBGRequest $request
  */
 public function runEditArticle(TBGRequest $request)
 {
     if (!$this->article->canEdit()) {
         TBGContext::setMessage('publish_article_error', TBGContext::getI18n()->__('You do not have permission to edit this article'));
         $this->forward(TBGContext::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(TBGArticlesTable::getTable()->getArticleByName($request['parent_article_name']));
             $this->article->setManualName($request['manual_name']);
             if ($this->article->getArticleType() == TBGWikiArticle::TYPE_MANUAL && !$this->article->getName()) {
                 $article_name_prefix = $this->article->getParentArticle() instanceof TBGWikiArticle ? $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(TBGContext::getI18n()->__('You need to specify a valid article name'));
             }
             if ($request['article_type'] == TBGWikiArticle::TYPE_MANUAL && (!$this->article->getManualName() || trim($this->article->getManualName()) == '' || !preg_match('/[\\w:]+/i', $this->article->getManualName()))) {
                 throw new Exception(TBGContext::getI18n()->__('You need to specify a valid article name'));
             }
             if (TBGPublish::getModule()->getSetting('require_change_reason') == 1 && (!$this->change_reason || trim($this->change_reason) == '')) {
                 throw new Exception(TBGContext::getI18n()->__('You have to provide a reason for the changes'));
             }
             if ($this->article->getLastUpdatedDate() != $request['last_modified']) {
                 throw new Exception(TBGContext::getI18n()->__('The file has been modified since you last opened it'));
             }
             if (($article = TBGWikiArticle::getByName($request['new_new_article_name'])) && $article instanceof TBGWikiArticle && $article->getID() != $request['article_id']) {
                 throw new Exception(TBGContext::getI18n()->__('An article with that name already exists. Please choose a different article name'));
             }
             if (!$this->preview) {
                 $this->article->doSave(array(), $request['change_reason']);
                 TBGContext::setMessage('publish_article_message', TBGContext::getI18n()->__('The article was saved'));
                 $this->forward(TBGContext::getRouting()->generate('publish_article', array('article_name' => $this->article->getName())));
             }
         } catch (Exception $e) {
             $this->error = $e->getMessage();
         }
     }
 }
コード例 #12
0
 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();
 }
コード例 #13
0
 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;
 }
コード例 #14
0
 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;
 }
コード例 #15
0
 public function runUpgrade(TBGRequest $request)
 {
     $version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
     $this->current_version = $version_info[0];
     $this->upgrade_available = $this->current_version != '3.1';
     if ($this->upgrade_available) {
         $scope = new TBGScope();
         $scope->setID(1);
         $scope->setEnabled();
         TBGContext::setScope($scope);
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isMethod(TBGRequest::POST)) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.0':
                 $this->_upgradeFrom3dot0();
                 break;
         }
         if ($this->upgrade_complete) {
             $existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
             file_put_contents(THEBUGGENIE_PATH . 'installed', TBGSettings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
             unlink(THEBUGGENIE_PATH . 'upgrade');
             $this->current_version = '3.1';
             $this->upgrade_available = false;
         }
     } elseif ($this->current_version != '3.1') {
         $this->permissions_ok = false;
         if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
             $this->permissions_ok = true;
         }
     } else {
         $this->forward(TBGContext::getRouting()->generate('home'));
     }
 }
コード例 #16
0
 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);
     }
 }
コード例 #17
0
 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')));
     }
 }
コード例 #18
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runUpgrade(TBGRequest $request)
 {
     $version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
     $this->current_version = $version_info[0];
     $this->upgrade_available = $this->current_version != '3.3';
     if ($this->upgrade_available) {
         $scope = new TBGScope();
         $scope->setID(1);
         $scope->setEnabled();
         TBGContext::setScope($scope);
         TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.2');
         $this->statuses = TBGListTypesTable::getTable()->getStatusListForUpgrade();
         $this->adminusername = TBGUsersTable3dot2::getTable()->getAdminUsername();
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isPost()) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.0':
                 $this->_upgradeFrom3dot0();
             case '3.1':
                 $this->_upgradeFrom3dot1();
             case '3.2':
                 $this->_upgradeFrom3dot2($request);
         }
         if ($this->upgrade_complete) {
             $existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
             file_put_contents(THEBUGGENIE_PATH . 'installed', TBGSettings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
             $prev_error_reportiong_level = error_reporting(0);
             unlink(THEBUGGENIE_PATH . 'upgrade');
             error_reporting($prev_error_reportiong_level);
             if (file_exists(THEBUGGENIE_PATH . 'upgrade')) {
                 $this->upgrade_file_failed = true;
             }
             $this->current_version = TBGSettings::getVersion(false, false);
             $this->upgrade_available = false;
         }
     } elseif ($this->upgrade_available) {
         $this->permissions_ok = false;
         if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
             $this->permissions_ok = true;
         }
     } elseif ($this->upgrade_complete) {
         $this->forward(TBGContext::getRouting()->generate('home'));
     }
 }
コード例 #19
0
ファイル: TBGUser.class.php プロジェクト: oparoz/thebuggenie
 /**
  * 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;
 }
コード例 #20
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 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 = '&amp;view=rev&amp;revision=%revno';
                 $link_file = '&amp;view=log';
                 $link_diff = '&amp;r1=%revno&amp;r2=%oldrev';
                 $link_view = '&amp;revision=%revno&amp;view=markup';
                 break;
             case 'viewvc_repo':
                 $base_url = $request['browser_url'];
                 $link_rev = '/?view=rev&amp;revision=%revno';
                 $link_file = '/%file?view=log';
                 $link_diff = '/%file?r1=%revno&amp;r2=%oldrev';
                 $link_view = '/%file?revision=%revno&amp;view=markup';
                 break;
             case 'websvn':
                 $base_url = $request['browser_url'];
                 $link_rev = '/revision.php?repname=' . $request['repository'] . '&amp;isdir=1&amp;rev=%revno';
                 $link_file = '/log.php?repname=' . $request['repository'] . '&amp;path=/$%file';
                 $link_diff = '/comp.php?repname=' . $request['repository'] . '&amp;compare[]=/%file@%revno&amp;compare[]=/%file@%oldrev';
                 $link_view = '/filedetails.php?repname=' . $request['repository'] . '&path=/%file&amp;rev=%revno';
                 break;
             case 'websvn_mv':
                 $base_url = $request['browser_url'];
                 $link_rev = '/' . '?repname=' . $request['repository'] . '&amp;op=log&isdir=1&amp;rev=%revno';
                 $link_file = '/%file?repname=' . $request['repository'];
                 $link_diff = '/%file?repname=' . $request['repository'] . '&amp;compare[]=/%file@%revno&amp;compare[]=/%file@%oldrev';
                 $link_view = '/%file?repname=' . $request['repository'] . '&amp;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&amp;diff1=%oldrev&amp;fulldiff=1&amp;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();
     }
 }
コード例 #21
0
 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));
             }
         }
     }
 }
コード例 #22
0
<?php

$apc_enabled = TBGRequest::CanGetUploadStatus();
?>
<div id="attach_file" style="display: none;">
	<div class="rounded_box white borderless shadowed backdrop_box medium">
		<div class="backdrop_detail_header">
			<?php 
if ($mode == 'issue') {
    ?>
				<?php 
    echo __('Attach one or more file(s) to this issue');
    ?>
			<?php 
} elseif ($mode == 'article') {
    ?>
				<?php 
    echo __('Attach one or more file(s) to this article');
    ?>
			<?php 
}
?>
		</div>
		<div id="backdrop_detail_content">
			<div id="upload_forms">
				<form method="post" action="<?php 
echo $form_action;
?>
" enctype="multipart/form-data" id="uploader_upload_form" style="margin: 10px 0 0 5px;<?php 
if ($apc_enabled) {
    ?>
コード例 #23
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runProjectWorkflowTable(TBGRequest $request)
 {
     $this->selected_project = TBGContext::factory()->TBGProject($request['project_id']);
     if ($request->isPost()) {
         try {
             $workflow_scheme = TBGContext::factory()->TBGWorkflowScheme($request['new_workflow']);
             return $this->renderJSON(array('content' => $this->getTemplateHtml('projectworkflow_table', array('project' => $this->selected_project, 'new_workflow' => $workflow_scheme))));
         } catch (Exception $e) {
             $this->getResponse()->setHTTPStatus(400);
             return $this->renderJSON(array('error' => TBGContext::geti18n()->__('This workflow scheme is not valid')));
         }
     }
 }
コード例 #24
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runAddScope(TBGRequest $request)
 {
     if ($request->isPost()) {
         $scope = TBGContext::getScope();
         $this->getUser()->addScope($scope, false);
         $this->getUser()->confirmScope($scope->getID());
         $route = TBGSettings::getLoginReturnRoute() != 'referer' ? TBGSettings::getLoginReturnRoute() : 'home';
         $this->forward(TBGContext::getRouting()->generate($route));
     }
 }
コード例 #25
0
 public function isValid(TBGRequest $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;
     }
 }
コード例 #26
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 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();
     }
 }
コード例 #27
0
 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()));
     }
 }
コード例 #28
0
 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);
         }
     }
 }