コード例 #1
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runGetBackdropPartial(TBGRequest $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 = TBGContext::factory()->TBGIssue($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 = TBGContext::factory()->TBGUser($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 'openid':
                 $template_name = 'main/openid';
                 break;
             case 'notifications':
                 $template_name = 'main/notifications';
                 break;
             case 'workflow_transition':
                 $transition = TBGContext::factory()->TBGWorkflowTransition($request['transition_id']);
                 $template_name = $transition->getTemplate();
                 $options['transition'] = $transition;
                 $options['issues'] = array();
                 foreach ($request['issue_ids'] as $issue_id) {
                     $options['issues'][$issue_id] = new TBGIssue($issue_id);
                 }
                 $options['project'] = $this->selected_project;
                 break;
             case 'reportissue':
                 $template_name = 'main/reportissuecontainer';
                 $this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request);
                 $options['selected_project'] = $this->selected_project;
                 $options['selected_issuetype'] = $this->selected_issuetype;
                 if ($request->hasParameter('milestone_id')) {
                     try {
                         $options['selected_milestone'] = TBGContext::factory()->TBGMilestone((int) $request['milestone_id']);
                     } catch (Exception $e) {
                     }
                 }
                 if ($request->hasParameter('parent_issue_id')) {
                     try {
                         $options['parent_issue'] = TBGContext::factory()->TBGIssue((int) $request['parent_issue_id']);
                     } catch (Exception $e) {
                     }
                 }
                 if ($request->hasParameter('build_id')) {
                     try {
                         $options['selected_build'] = TBGContext::factory()->TBGBuild((int) $request['build_id']);
                     } catch (Exception $e) {
                     }
                 }
                 $options['issuetypes'] = $this->issuetypes;
                 $options['errors'] = array();
                 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 'milestone':
                 $template_name = 'project/milestone';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 if ($request->hasParameter('milestone_id')) {
                     $options['milestone'] = TBGContext::factory()->TBGMilestone($request['milestone_id']);
                 }
                 break;
             case 'project_build':
                 $template_name = 'project/build';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 if ($request->hasParameter('build_id')) {
                     $options['build'] = TBGContext::factory()->TBGBuild($request['build_id']);
                 }
                 break;
             case 'project_icons':
                 $template_name = 'project/projecticons';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 break;
             case 'project_workflow':
                 $template_name = 'project/projectworkflow';
                 $options['project'] = TBGContext::factory()->TBGProject($request['project_id']);
                 break;
             case 'permissions':
                 $options['key'] = $request['permission_key'];
                 if ($details = TBGContext::getPermissionDetails($options['key'])) {
                     $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 = TBGContext::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'];
                 } else {
                     die('fu');
                 }
                 break;
             case 'site_icons':
                 $template_name = 'configuration/siteicons';
                 break;
             case 'project_config':
                 $template_name = 'project/projectconfig_container';
                 $project = TBGContext::factory()->TBGProject($request['project_id']);
                 $options['project'] = $project;
                 $options['section'] = $request->getParameter('section', 'info');
                 if ($request->hasParameter('edition_id')) {
                     $edition = TBGContext::factory()->TBGEdition($request['edition_id']);
                     $options['edition'] = $edition;
                     $options['selected_section'] = $request->getParameter('section', 'general');
                 }
                 break;
             case 'issue_add_item':
                 $issue = TBGContext::factory()->TBGIssue($request['issue_id']);
                 $template_name = 'main/issueadditem';
                 break;
             case 'client_users':
                 $options['client'] = TBGContext::factory()->TBGClient($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 'userscopes':
                 if (!TBGContext::getScope()->isDefault()) {
                     throw new Exception($this->getI18n()->__('This is not allowed outside the default scope'));
                 }
                 $template_name = 'configuration/userscopes';
                 $options['user'] = new TBGUser((int) $request['user_id']);
                 break;
             default:
                 $event = new TBGEvent('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' => TBGContext::getI18n()->__('An error occured: %error_message', array('%error_message' => $e->getMessage()))));
     }
     $this->getResponse()->cleanBuffer();
     $this->getResponse()->setHttpStatus(400);
     $error = TBGContext::isDebugMode() ? TBGContext::getI18n()->__('Invalid template or parameter') : $this->getI18n()->__('Could not show the requested popup');
     return $this->renderJSON(array('error' => $error));
 }
コード例 #2
0
 public function runGetBackdropPartial(TBGRequest $request)
 {
     try {
         $template_name = null;
         if ($request->hasParameter('issue_id')) {
             $issue = TBGContext::factory()->TBGIssue($request->getParameter('issue_id'));
             $options = array('issue' => $issue);
         } else {
             $options = array();
         }
         switch ($request->getParameter('key')) {
             case 'usercard':
                 $template_name = 'main/usercard';
                 if ($user_id = $request->getParameter('user_id')) {
                     $user = TBGContext::factory()->TBGUser($user_id);
                     $options['user'] = $user;
                 }
                 break;
             case 'login':
                 $template_name = 'main/login';
                 $options = $request->getParameters();
                 $options['section'] = $request->getParameter('section', 'login');
                 $options['mandatory'] = $request->getParameter('mandatory', false);
                 break;
             case 'workflow_transition':
                 $transition = TBGContext::factory()->TBGWorkflowTransition($request->getParameter('transition_id'));
                 $template_name = $transition->getTemplate();
                 $options['transition'] = $transition;
                 break;
             case 'close_issue':
                 $template_name = 'main/closeissue';
                 break;
             case 'relate_issue':
                 $template_name = 'main/relateissue';
                 break;
             case 'markasduplicate_issue':
                 $template_name = 'main/markasduplicate';
                 break;
             case 'permissions':
                 break;
             case 'project_config':
                 $template_name = 'configuration/projectconfig_container';
                 $project = TBGContext::factory()->TBGProject($request->getParameter('project_id'));
                 $options['project'] = $project;
                 $options['section'] = $request->getParameter('section', 'info');
                 if ($request->hasParameter('edition_id')) {
                     $edition = TBGContext::factory()->TBGEdition($request->getParameter('edition_id'));
                     $options['edition'] = $edition;
                     $options['selected_section'] = $request->getParameter('section', 'general');
                 }
                 break;
             case 'issue_add_item':
                 $issue = TBGContext::factory()->TBGIssue($request->getParameter('issue_id'));
                 $template_name = 'main/issueadditem';
                 break;
             case 'client_users':
                 $options['client'] = TBGContext::factory()->TBGClient($request->getParameter('client_id'));
                 $template_name = 'main/clientusers';
                 break;
             case 'dashboard_config':
                 $template_name = 'main/dashboardconfig';
                 $options['mandatory'] = true;
                 break;
         }
         if ($template_name !== null) {
             return $this->renderJSON(array('content' => $this->getComponentHTML($template_name, $options)));
         }
     } catch (Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__('An error occured: %error_message%', array('%error_message%' => $e->getMessage()))));
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__('Invalid template or parameter')));
 }