Esempio n. 1
0
 /**
  * Show an article
  *
  * @param TBGRequest $request
  */
 public function runShowArticle(TBGRequest $request)
 {
     $this->message = TBGContext::getMessageAndClear('publish_article_message');
     $this->error = TBGContext::getMessageAndClear('publish_article_error');
     $this->redirected_from = TBGContext::getMessageAndClear('publish_redirected_article');
     if ($this->article instanceof TBGWikiArticle) {
         if (!$this->article->hasAccess()) {
             $this->error = TBGContext::getI18n()->__("You don't have access to read this article");
             $this->article = null;
         } else {
             if (!$request->hasParameter('no_redirect') && substr($this->article->getContent(), 0, 10) == "#REDIRECT ") {
                 $content = explode("\n", $this->article->getContent());
                 preg_match('/(\\[\\[([^\\]]*?)\\]\\])$/im', substr(array_shift($content), 10), $matches);
                 if (count($matches) == 3) {
                     $redirect_article = $matches[2];
                     TBGContext::setMessage('publish_redirected_article', $this->article->getName());
                     $this->forward(TBGContext::getRouting()->generate('publish_article', array('article_name' => $redirect_article)));
                 }
             }
             try {
                 if ($request->hasParameter('revision')) {
                     $this->revision = $request->getParameter('revision');
                     $this->article->setRevision($this->revision);
                 }
             } catch (Exception $e) {
                 $this->error = TBGContext::getI18n()->__('There was an error trying to show this revision');
             }
         }
     }
 }
 /**
  * Forward the user to a specified url
  * 
  * @param string $url The URL to forward to
  * @param integer $code[optional] HTTP status code
  * @param integer $method[optional] 2 for meta redirect instead of header
  */
 public function forward($url, $code = 200)
 {
     if (TBGContext::getRequest()->isAjaxCall() || TBGContext::getRequest()->getRequestedFormat() == 'json') {
         $this->getResponse()->ajaxResponseText($code, TBGContext::getMessageAndClear('forward'));
     }
     TBGLogging::log("Forwarding to url {$url}");
     TBGLogging::log('Triggering header redirect function');
     $this->getResponse()->headerRedirect($url, $code);
 }
Esempio n. 3
0
 public function runScope(TBGRequest $request)
 {
     $this->scope = new TBGScope($request->getParameter('id'));
     $modules = TBGModulesTable::getTable()->getModulesForScope($this->scope->getID());
     $this->modules = $modules;
     $this->scope_save_error = TBGContext::getMessageAndClear('scope_save_error');
     $this->scope_saved = TBGContext::getMessageAndClear('scope_saved');
     if ($request->isMethod(TBGRequest::POST)) {
         try {
             if ($request->getParameter('scope_action') == 'delete') {
                 if (!$this->scope->isDefault()) {
                     $this->scope->delete();
                     TBGContext::setMessage('scope_deleted', true);
                     $this->forward(make_url('configure_scopes'));
                 } else {
                     $this->scope_save_error = TBGContext::getI18n()->__('You cannot delete the default scope');
                 }
             } else {
                 if (!$request->getParameter('name')) {
                     throw new Exception(TBGContext::getI18n()->__('Please specify a scope name'));
                 }
                 $this->scope->setName($request->getParameter('name'));
                 $this->scope->setDescription($request->getParameter('description'));
                 $this->scope->setCustomWorkflowsEnabled((bool) $request->getParameter('custom_workflows_enabled'));
                 $this->scope->setMaxWorkflowsLimit((int) $request->getParameter('workflow_limit'));
                 $this->scope->setUploadsEnabled((bool) $request->getParameter('file_uploads_enabled'));
                 $this->scope->setMaxUploadLimit((int) $request->getParameter('upload_limit'));
                 $this->scope->setMaxProjects((int) $request->getParameter('project_limit'));
                 $this->scope->setMaxUsers((int) $request->getParameter('user_limit'));
                 $this->scope->setMaxTeams((int) $request->getParameter('team_limit'));
                 $this->scope->save();
                 $enabled_modules = $request->getParameter('module_enabled');
                 $prev_scope = TBGContext::getScope();
                 foreach ($enabled_modules as $module => $enabled) {
                     if (!TBGContext::getModule($module)->isCore() && !$enabled && array_key_exists($module, $modules)) {
                         $module = TBGModulesTable::getTable()->getModuleForScope($module, $this->scope->getID());
                         $module->uninstall($this->scope->getID());
                     } elseif (!TBGContext::getModule($module)->isCore() && $enabled && !array_key_exists($module, $modules)) {
                         TBGContext::setScope($this->scope);
                         TBGModule::installModule($module);
                         TBGContext::setScope($prev_scope);
                     }
                 }
                 TBGContext::setMessage('scope_saved', true);
                 $this->forward(make_url('configure_scope', array('id' => $this->scope->getID())));
             }
         } catch (Exception $e) {
             TBGContext::setMessage('scope_save_error', $e->getMessage());
         }
     }
 }
Esempio n. 4
0
 /**
  * Performs the "find issues" action
  *
  * @param TBGRequest $request
  */
 public function runFindIssues(TBGRequest $request)
 {
     $this->resultcount = 0;
     if ($this->show_results) {
         $this->doSearch($request);
         $this->issues = $this->foundissues;
     }
     if ($request['quicksearch'] == true) {
         if ($request->isAjaxCall()) {
             $this->redirect('quicksearch');
         } else {
             $issues = $this->issues;
             $issue = array_shift($issues);
             if ($issue instanceof TBGIssue) {
                 return $this->forward($this->getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo())));
             }
         }
     }
     $this->search_error = TBGContext::getMessageAndClear('search_error');
     $this->search_message = TBGContext::getMessageAndClear('search_message');
     $this->appliedfilters = $this->filters;
     $this->templates = TBGSavedSearch::getTemplates();
 }
Esempio n. 5
0
 public function runReleaseCenter(TBGRequest $request)
 {
     $this->forward403if(TBGContext::getCurrentProject()->isArchived() || !$this->getUser()->canManageProjectReleases(TBGContext::getCurrentProject()));
     $this->build_error = TBGContext::getMessageAndClear('build_error');
     $this->_setupBuilds();
 }
Esempio n. 6
0
 /**
  * Performs the "find issues" action
  *
  * @param TBGRequest $request
  */
 public function runFindIssues(TBGRequest $request)
 {
     $this->_getSearchDetailsFromRequest($request);
     if ($request->isMethod(TBGRequest::POST) && !$request->getParameter('quicksearch')) {
         if ($request->getParameter('delete_saved_search')) {
             try {
                 $search = TBGSavedSearchesTable::getTable()->getByID($request->getParameter('saved_search_id'));
                 if ($search->get(TBGSavedSearchesTable::UID) == TBGContext::getUser()->getID() || $search->get(TBGSavedSearchesTable::IS_PUBLIC) && TBGContext::getUser()->canCreatePublicSearches()) {
                     TBGSavedSearchesTable::getTable()->doDeleteById($request->getParameter('saved_search_id'));
                     return $this->renderJSON(array('failed' => false, 'message' => TBGContext::getI18n()->__('The saved search was deleted successfully')));
                 }
             } catch (Exception $e) {
                 return $this->renderJSON(array('failed' => true, 'message' => TBGContext::getI18n()->__('Cannot delete this saved search')));
             }
         } elseif ($request->getParameter('saved_search_name') != '') {
             $project_id = TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : 0;
             TBGSavedSearchesTable::getTable()->saveSearch($request->getParameter('saved_search_name'), $request->getParameter('saved_search_description'), $request->getParameter('saved_search_public'), $this->filters, $this->groupby, $this->grouporder, $this->ipp, $this->templatename, $this->template_parameter, $project_id, $request->getParameter('saved_search_id'));
             if ($request->getParameter('saved_search_id')) {
                 TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search was updated'));
             } else {
                 TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search has been created'));
             }
             $params = array();
         } else {
             TBGContext::setMessage('search_error', TBGContext::getI18n()->__('You have to specify a name for the saved search'));
             $params = array('filters' => $this->filters, 'groupby' => $this->groupby, 'grouporder' => $this->grouporder, 'templatename' => $this->templatename, 'saved_search' => $request->getParameter('saved_search_id'), 'issues_per_page' => $this->ipp);
         }
         if (TBGContext::isProjectContext()) {
             $route = 'project_issues';
             $params['project_key'] = TBGContext::getCurrentProject()->getKey();
         } else {
             $route = 'search';
         }
         $this->forward(TBGContext::getRouting()->generate($route, $params));
     } else {
         $this->doSearch($request);
         $this->issues = $this->foundissues;
         if ($request->getParameter('quicksearch') == true) {
             $this->redirect('quicksearch');
         }
     }
     $this->search_error = TBGContext::getMessageAndClear('search_error');
     $this->search_message = TBGContext::getMessageAndClear('search_message');
     $this->appliedfilters = $this->filters;
     $this->templates = $this->getTemplates();
     $this->savedsearches = B2DB::getTable('TBGSavedSearchesTable')->getAllSavedSearchesByUserIDAndPossiblyProjectID(TBGContext::getUser()->getID(), TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : 0);
 }
Esempio n. 7
0
 public function listenViewIssuePostError(TBGEvent $event)
 {
     if (TBGContext::hasMessage('comment_error')) {
         $this->comment_error = true;
         $this->error = TBGContext::getMessageAndClear('comment_error');
         $this->comment_error_title = TBGContext::getMessageAndClear('comment_error_title');
         $this->comment_error_body = TBGContext::getMessageAndClear('comment_error_body');
     }
 }
Esempio n. 8
0
					<div class="issue_info error" id="viewissue_error">
						<?php 
        if ($error == 'transition_error') {
            ?>
							<div class="header"><?php 
            echo __('There was an error trying to move this issue to the next step in the workflow');
            ?>
</div>
							<div class="content" style="text-align: left;">
								<?php 
            echo __('The following actions could not be performed because of missing or invalid values: %list', array('%list' => ''));
            ?>
<br>
								<ul>
									<?php 
            foreach (TBGContext::getMessageAndClear('issue_workflow_errors') as $error_field) {
                ?>
										<li><?php 
                switch ($error_field) {
                    case TBGWorkflowTransitionValidationRule::RULE_MAX_ASSIGNED_ISSUES:
                        echo __('Could not assign issue to the selected user because this users assigned issues limit is reached');
                        break;
                    case TBGWorkflowTransitionValidationRule::RULE_PRIORITY_VALID:
                        echo __('Could not set priority');
                        break;
                    case TBGWorkflowTransitionValidationRule::RULE_REPRODUCABILITY_VALID:
                        echo __('Could not set reproducability');
                        break;
                    case TBGWorkflowTransitionValidationRule::RULE_RESOLUTION_VALID:
                        echo __('Could not set resolution');
                        break;
Esempio n. 9
0
<div id="login_backdrop">
	<div class="backdrop_box login_page login_popup" id="login_popup">
		<div id="backdrop_detail_content" class="backdrop_detail_content rounded_top login_content">
			<?php 
include_component('main/login', compact('section', 'error'));
?>
		</div>
	</div>
</div>
<script type="text/javascript">
	<?php 
if (TBGContext::hasMessage('login_message')) {
    ?>
		TBG.Main.Helpers.Message.success('<?php 
    echo TBGContext::getMessageAndClear('login_message');
    ?>
');
	<?php 
} elseif (TBGContext::hasMessage('login_message_err')) {
    ?>
		TBG.Main.Helpers.Message.error('<?php 
    echo TBGContext::getMessageAndClear('login_message_err');
    ?>
');
	<?php 
}
?>
	document.observe('dom:loaded', function() {
		$('tbg3_username').focus();
	});
</script>
Esempio n. 10
0
						<input type="submit" id="login_button" class="button button-silver" value="<?php 
echo __('Authenticate');
?>
">
					</div>
				</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	<?php 
if (TBGContext::hasMessage('elevated_login_message')) {
    ?>
		TBG.Main.Helpers.Message.success('<?php 
    echo TBGContext::getMessageAndClear('elevated_login_message');
    ?>
');
	<?php 
} elseif (TBGContext::hasMessage('elevated_login_message_err')) {
    ?>
		TBG.Main.Helpers.Message.error('<?php 
    echo TBGContext::getMessageAndClear('elevated_login_message_err');
    ?>
');
	<?php 
}
?>
	document.observe('dom:loaded', function() {
		$('tbg3_password').focus();
	});
</script>
Esempio n. 11
0
 /**
  * Show an article
  *
  * @param TBGRequest $request
  */
 public function runShowArticle(TBGRequest $request)
 {
     if ($this->special) {
         $this->redirect('specialArticle');
     }
     $this->message = TBGContext::getMessageAndClear('publish_article_message');
     $this->error = TBGContext::getMessageAndClear('publish_article_error');
     $this->redirected_from = TBGContext::getMessageAndClear('publish_redirected_article');
     if ($this->article instanceof TBGWikiArticle) {
         if (!$this->article->hasAccess()) {
             $this->error = TBGContext::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()) {
                     TBGContext::setMessage('publish_redirected_article', $this->article->getName());
                     $this->forward(TBGContext::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 = TBGContext::getI18n()->__('There was an error trying to show this revision');
             }
         }
     }
 }