Example #1
0
 /**
  * Pre-execute function
  *
  * @param framework\Request     $request
  * @param string        $action
  */
 public function preExecute(framework\Request $request, $action)
 {
     // forward 403 if you're not allowed here
     if ($request->isAjaxCall() == false) {
         $this->forward403unless(framework\Context::getUser()->canAccessConfigurationPage());
     }
     $this->access_level = $this->getAccessLevel(framework\Settings::CONFIGURATION_SECTION_IMPORT, 'core');
     if (!$request->isAjaxCall()) {
         $this->getResponse()->setPage('config');
         framework\Context::loadLibrary('ui');
         $this->getResponse()->addBreadcrumb(framework\Context::getI18n()->__('Configure %thebuggenie_name', array('%thebuggenie_name' => framework\Settings::getSiteHeaderName())), framework\Context::getRouting()->generate('configure'), $this->getResponse()->getPredefinedBreadcrumbLinks('configure'));
     }
 }
Example #2
0
 /**
  * Logs the user out
  *
  * @param \thebuggenie\core\framework\Request $request
  *
  * @return bool
  */
 public function runLogout(framework\Request $request)
 {
     if ($this->getUser() instanceof entities\User) {
         framework\Logging::log('Setting user logout state');
         $this->getUser()->setOffline();
     }
     framework\Context::logout();
     if ($request->isAjaxCall()) {
         return $this->renderJSON(array('status' => 'logout ok', 'url' => framework\Context::getRouting()->generate(framework\Settings::getLogoutReturnRoute())));
     }
     $this->forward(framework\Context::getRouting()->generate(framework\Settings::getLogoutReturnRoute()));
 }
Example #3
0
 public function runProjectIcons(framework\Request $request)
 {
     if ($this->getUser()->canManageProject($this->selected_project) || $this->getUser()->canManageProjectReleases($this->selected_project)) {
         if ($request->isPost()) {
             if ($request['clear_icons']) {
                 $this->selected_project->clearSmallIcon();
                 $this->selected_project->clearLargeIcon();
             } else {
                 switch ($request['small_icon_action']) {
                     case 'upload_file':
                         $file = $request->handleUpload('small_icon');
                         $this->selected_project->setSmallIcon($file);
                         break;
                     case 'clear_file':
                         $this->selected_project->clearSmallIcon();
                         break;
                 }
                 switch ($request['large_icon_action']) {
                     case 'upload_file':
                         $file = $request->handleUpload('large_icon');
                         $this->selected_project->setLargeIcon($file);
                         break;
                     case 'clear_file':
                         $this->selected_project->clearLargeIcon();
                         break;
                 }
             }
             $this->selected_project->save();
         }
         $route = framework\Context::getRouting()->generate('project_settings', array('project_key' => $this->selected_project->getKey()));
         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"));
 }
Example #4
0
 public function runSiteIcons(framework\Request $request)
 {
     if ($this->getAccessLevel($request['section'], 'core') == framework\Settings::ACCESS_FULL) {
         if ($request->isPost()) {
             switch ($request['small_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('small_icon');
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_TYPE, framework\Settings::APPEARANCE_FAVICON_CUSTOM);
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_TYPE, framework\Settings::APPEARANCE_FAVICON_THEME);
                     break;
             }
             switch ($request['large_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('large_icon');
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_TYPE, framework\Settings::APPEARANCE_HEADER_CUSTOM);
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_TYPE, framework\Settings::APPEARANCE_HEADER_THEME);
                     break;
             }
         }
         $route = framework\Context::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"));
 }
Example #5
0
 /**
  * Partial backdrop loader
  *
  * @Route(name="get_partial_for_backdrop", url="/get/partials/:key/*")
  * @AnonymousRoute
  *
  * @param framework\Request $request
  *
  * @return bool
  */
 public function runGetBackdropPartial(framework\Request $request)
 {
     if (!$request->isAjaxCall()) {
         return $this->return404($this->getI18n()->__('You need to enable javascript for The Bug Genie to work properly'));
     }
     try {
         $template_name = null;
         if ($request->hasParameter('issue_id')) {
             $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
             $options = array('issue' => $issue);
         } else {
             $options = array();
         }
         switch ($request['key']) {
             case 'usercard':
                 $template_name = 'main/usercard';
                 if ($user_id = $request['user_id']) {
                     $user = entities\User::getB2DBTable()->selectById($user_id);
                     $options['user'] = $user;
                 }
                 break;
             case 'login':
                 $template_name = 'main/loginpopup';
                 $options = $request->getParameters();
                 $options['content'] = $this->getComponentHTML('login', array('section' => $request->getParameter('section', 'login')));
                 $options['mandatory'] = false;
                 break;
             case 'uploader':
                 $template_name = 'main/uploader';
                 $options = $request->getParameters();
                 $options['uploader'] = $request['uploader'] == 'dynamic' ? 'dynamic' : 'standard';
                 break;
             case 'attachlink':
                 $template_name = 'main/attachlink';
                 break;
             case 'openid':
                 $template_name = 'main/openid';
                 break;
             case 'notifications':
                 $template_name = 'main/notifications';
                 $options['first_notification_id'] = $request['first_notification_id'];
                 $options['last_notification_id'] = $request['last_notification_id'];
                 break;
             case 'workflow_transition':
                 $transition = entities\WorkflowTransition::getB2DBTable()->selectById($request['transition_id']);
                 $template_name = $transition->getTemplate();
                 $options['transition'] = $transition;
                 if ($request->hasParameter('issue_ids')) {
                     $options['issues'] = array();
                     foreach ($request['issue_ids'] as $issue_id) {
                         $options['issues'][$issue_id] = new entities\Issue($issue_id);
                     }
                 } else {
                     $options['issue'] = new entities\Issue($request['issue_id']);
                 }
                 $options['show'] = true;
                 $options['interactive'] = true;
                 $options['project'] = $this->selected_project;
                 break;
             case 'reportissue':
                 $this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request);
                 if ($this->selected_project instanceof entities\Project && !$this->selected_project->isLocked() && $this->getUser()->canReportIssues($this->selected_project)) {
                     $template_name = 'main/reportissuecontainer';
                     $options['selected_project'] = $this->selected_project;
                     $options['selected_issuetype'] = $this->selected_issuetype;
                     $options['locked_issuetype'] = $this->locked_issuetype;
                     $options['selected_milestone'] = $this->_getMilestoneFromRequest($request);
                     $options['parent_issue'] = $this->_getParentIssueFromRequest($request);
                     $options['board'] = $this->_getBoardFromRequest($request);
                     $options['selected_build'] = $this->_getBuildFromRequest($request);
                     $options['issuetypes'] = $this->issuetypes;
                     $options['errors'] = array();
                 } else {
                     throw new \Exception($this->getI18n()->__('You are not allowed to do this'));
                 }
                 break;
             case 'move_issue':
                 $template_name = 'main/moveissue';
                 $options['multi'] = (bool) $request->getParameter('multi', false);
                 break;
             case 'issue_permissions':
                 $template_name = 'main/issuepermissions';
                 break;
             case 'issue_subscribers':
                 $template_name = 'main/issuesubscribers';
                 break;
             case 'issue_spenttimes':
                 $template_name = 'main/issuespenttimes';
                 $options['initial_view'] = $request->getParameter('initial_view', 'list');
                 break;
             case 'issue_spenttime':
                 $template_name = 'main/issuespenttime';
                 $options['entry_id'] = $request->getParameter('entry_id');
                 break;
             case 'relate_issue':
                 $template_name = 'main/relateissue';
                 break;
             case 'project_build':
                 $template_name = 'project/build';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 if ($request->hasParameter('build_id')) {
                     $options['build'] = entities\Build::getB2DBTable()->selectById($request['build_id']);
                 }
                 break;
             case 'project_icons':
                 $template_name = 'project/projecticons';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'project_workflow':
                 $template_name = 'project/projectworkflow';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'permissions':
                 $options['key'] = $request['permission_key'];
                 $target_module = $request['target_module'] !== 'core' ? $request['target_module'] : null;
                 if ($details = framework\Context::getPermissionDetails($options['key'], null, $target_module)) {
                     $template_name = 'configuration/permissionspopup';
                     $options['mode'] = $request['mode'];
                     $options['module'] = $request['target_module'];
                     $options['target_id'] = $request['target_id'];
                     $options['item_name'] = $details['description'];
                     $options['access_level'] = $request['access_level'];
                 }
                 break;
             case 'issuefield_permissions':
                 $options['item_key'] = $request['item_key'];
                 if ($details = framework\Context::getPermissionDetails($options['item_key'])) {
                     $template_name = 'configuration/issuefieldpermissions';
                     $options['item_name'] = $details['description'];
                     $options['item_id'] = $request['item_id'];
                     $options['access_level'] = $request['access_level'];
                 }
                 break;
             case 'site_icons':
                 $template_name = 'configuration/siteicons';
                 break;
             case 'project_config':
                 $template_name = 'project/projectconfig_container';
                 $project = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 $options['project'] = $project;
                 $options['section'] = $request->getParameter('section', 'info');
                 if ($request->hasParameter('edition_id')) {
                     $edition = entities\Edition::getB2DBTable()->selectById($request['edition_id']);
                     $options['edition'] = $edition;
                     $options['selected_section'] = $request->getParameter('section', 'general');
                 }
                 break;
             case 'issue_add_item':
                 $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
                 $template_name = 'main/issueadditem';
                 break;
             case 'client_users':
                 $options['client'] = entities\Client::getB2DBTable()->selectById($request['client_id']);
                 $template_name = 'main/clientusers';
                 break;
             case 'dashboard_config':
                 $template_name = 'main/dashboardconfig';
                 $options['tid'] = $request['tid'];
                 $options['target_type'] = $request['target_type'];
                 $options['previous_route'] = $request['previous_route'];
                 $options['mandatory'] = true;
                 break;
             case 'archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['mandatory'] = true;
                 break;
             case 'team_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'team';
                 $options['id'] = $request['tid'];
                 $options['mandatory'] = true;
                 break;
             case 'client_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'client';
                 $options['id'] = $request['cid'];
                 $options['mandatory'] = true;
                 break;
             case 'project_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'project';
                 $options['id'] = $request['pid'];
                 $options['mandatory'] = true;
                 break;
             case 'bulk_workflow':
                 $template_name = 'search/bulkworkflow';
                 $options['issue_ids'] = $request['issue_ids'];
                 break;
             case 'confirm_username':
                 $template_name = 'main/confirmusername';
                 $options['username'] = $request['username'];
                 break;
             case 'add_dashboard_view':
                 $template_name = 'main/adddashboardview';
                 break;
             case 'userscopes':
                 if (!framework\Context::getScope()->isDefault()) {
                     throw new \Exception($this->getI18n()->__('This is not allowed outside the default scope'));
                 }
                 $template_name = 'configuration/userscopes';
                 $options['user'] = new entities\User((int) $request['user_id']);
                 break;
             case 'milestone':
                 $template_name = 'project/milestone';
                 $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
                 if ($request->hasParameter('milestone_id')) {
                     $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
                 }
                 break;
             default:
                 $event = new \thebuggenie\core\framework\Event('core', 'get_backdrop_partial', $request['key']);
                 $event->triggerUntilProcessed();
                 $options = $event->getReturnList();
                 $template_name = $event->getReturnValue();
         }
         if ($template_name !== null) {
             return $this->renderJSON(array('content' => $this->getComponentHTML($template_name, $options)));
         }
     } catch (\Exception $e) {
         $this->getResponse()->cleanBuffer();
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('An error occured: %error_message', array('%error_message' => $e->getMessage()))));
     }
     $this->getResponse()->cleanBuffer();
     $this->getResponse()->setHttpStatus(400);
     $error = framework\Context::isDebugMode() ? framework\Context::getI18n()->__('Invalid template or parameter') : $this->getI18n()->__('Could not show the requested popup');
     return $this->renderJSON(array('error' => $error));
 }
Example #6
0
 /**
  * Performs the "find issues" action
  *
  * @param framework\Request $request
  */
 public function runFindIssues(framework\Request $request)
 {
     $this->resultcount = 0;
     if ($request['quicksearch'] == true) {
         if ($request->isAjaxCall()) {
             return $this->redirect('quicksearch');
         } else {
             $issues = $this->issues;
             $issue = array_shift($issues);
             if ($issue instanceof entities\Issue) {
                 return $this->forward($this->getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo())));
             }
         }
     }
     if ($this->search_object->hasQuickfoundIssues()) {
         $issues = $this->search_object->getQuickfoundIssues();
         $issue = array_shift($issues);
         if ($issue instanceof entities\Issue) {
             return $this->forward($this->getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo())));
         }
     }
     $this->search_error = framework\Context::getMessageAndClear('search_error');
     $this->search_message = framework\Context::getMessageAndClear('search_message');
     $this->appliedfilters = $this->filters;
     $this->templates = entities\SavedSearch::getTemplates();
 }