コード例 #1
0
 /**
  * Configure project settings
  * 
  * @param TBGRequest $request The request object
  */
 public function runConfigureProjectSettings(TBGRequest $request)
 {
     try {
         $this->project = TBGContext::factory()->TBGProject($request->getParameter('project_id'));
     } catch (Exception $e) {
     }
     if (!$this->project instanceof TBGProject) {
         return $this->return404(TBGContext::getI18n()->__("This project doesn't exist"));
     }
     if ($request->isAjaxCall() && $request->isMethod(TBGRequest::POST)) {
         if ($this->access_level == TBGSettings::ACCESS_FULL) {
             if ($request->hasParameter('release_month') && $request->hasParameter('release_day') && $request->hasParameter('release_year')) {
                 $release_date = mktime(0, 0, 1, $request->getParameter('release_month'), $request->getParameter('release_day'), $request->getParameter('release_year'));
                 $this->project->setReleaseDate($release_date);
             }
             $old_key = $this->project->getKey();
             if ($request->hasParameter('project_name')) {
                 if (trim($request->getParameter('project_name')) == '') {
                     return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__('Please specify a valid project name')));
                 } else {
                     $this->project->setName($request->getParameter('project_name'));
                 }
             }
             $message = $old_key != $this->project->getKey() ? TBGContext::getI18n()->__('%IMPORTANT%: The project key has changed. Remember to replace the current url with the new project key', array('%IMPORTANT%' => '<b>' . TBGContext::getI18n()->__('IMPORTANT') . '</b>')) : '';
             if ($request->hasParameter('project_key')) {
                 $this->project->setKey($request->getParameter('project_key'));
             }
             if ($request->hasParameter('use_prefix')) {
                 $this->project->setUsePrefix((bool) $request->getParameter('use_prefix'));
             }
             if ($request->hasParameter('use_prefix') && $this->project->doesUsePrefix()) {
                 if (!$this->project->setPrefix($request->getParameter('prefix'))) {
                     return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__("Project prefixes may only contain letters and numbers")));
                 }
             }
             if ($request->hasParameter('client')) {
                 if ($request->getParameter('client') == 0) {
                     $this->project->setClient(null);
                 } else {
                     $this->project->setClient(TBGContext::factory()->TBGClient($request->getParameter('client')));
                 }
             }
             if ($request->hasParameter('workflow_scheme')) {
                 try {
                     $workflow_scheme = TBGContext::factory()->TBGWorkflowScheme($request->getParameter('workflow_scheme'));
                     $this->project->setWorkflowScheme($workflow_scheme);
                 } catch (Exception $e) {
                 }
             }
             if ($request->hasParameter('issuetype_scheme')) {
                 try {
                     $issuetype_scheme = TBGContext::factory()->TBGIssuetypeScheme($request->getParameter('issuetype_scheme'));
                     $this->project->setIssuetypeScheme($issuetype_scheme);
                 } catch (Exception $e) {
                 }
             }
             if ($request->hasParameter('use_scrum')) {
                 $this->project->setUsesScrum((bool) $request->getParameter('use_scrum'));
             }
             if ($request->hasParameter('description')) {
                 $this->project->setDescription($request->getParameter('description', null, false));
             }
             if ($request->hasParameter('homepage')) {
                 $this->project->setHomepage($request->getParameter('homepage'));
             }
             if ($request->hasParameter('doc_url')) {
                 $this->project->setDocumentationURL($request->getParameter('doc_url'));
             }
             if ($request->hasParameter('planned_release')) {
                 $this->project->setPlannedReleased($request->getParameter('planned_release'));
             }
             if ($request->hasParameter('released')) {
                 $this->project->setReleased((int) $request->getParameter('released'));
             }
             if ($request->hasParameter('locked')) {
                 $this->project->setLocked((bool) $request->getParameter('locked'));
             }
             if ($request->hasParameter('enable_builds')) {
                 $this->project->setBuildsEnabled((bool) $request->getParameter('enable_builds'));
             }
             if ($request->hasParameter('enable_editions')) {
                 $this->project->setEditionsEnabled((bool) $request->getParameter('enable_editions'));
             }
             if ($request->hasParameter('enable_components')) {
                 $this->project->setComponentsEnabled((bool) $request->getParameter('enable_components'));
             }
             if ($request->hasParameter('allow_changing_without_working')) {
                 $this->project->setChangeIssuesWithoutWorkingOnThem((bool) $request->getParameter('allow_changing_without_working'));
             }
             if ($request->hasParameter('allow_autoassignment')) {
                 $this->project->setAutoassign((bool) $request->getParameter('allow_autoassignment'));
             }
             $this->project->save();
             $project_description = new TBGTextParser($this->project->getDescription());
             $project_description = $project_description->getParsedText();
             return $this->renderJSON(array('failed' => false, 'title' => TBGContext::getI18n()->__('Your changes has been saved'), 'message' => $message, 'project_key' => $this->project->getKey(), 'project_description' => $project_description, 'content' => get_template_html('projectbox', array('project' => $this->project, 'access_level' => $this->access_level))));
         }
         return $this->renderJSON(array('failed' => true, 'error' => TBGContext::getI18n()->__("You don't have access to save settings")));
     }
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runProjectIcons(TBGRequest $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 = TBGContext::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"));
 }
コード例 #3
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));
 }
コード例 #4
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"));
 }
コード例 #5
0
 public function runAddComment(TBGRequest $request)
 {
     $i18n = TBGContext::getI18n();
     $comment = null;
     $comment_applies_type = $request->getParameter('comment_applies_type');
     try {
         if (!TBGContext::getUser()->canPostComments()) {
             throw new Exception($i18n->__('You are not allowed to do this'));
         } else {
             if ($request->getParameter('comment_body') == '') {
                 throw new Exception($i18n->__('The comment must have some content'));
             }
             if ($comment_applies_type == TBGComment::TYPE_ISSUE && !$request->isAjaxCall()) {
                 $this->comment_lines = array();
                 $this->comment = '';
                 TBGEvent::listen('core', 'TBGIssue::save', array($this, 'listenIssueSaveAddComment'));
                 $issue = TBGContext::factory()->TBGIssue($request->getParameter('comment_applies_id'));
                 $issue->save(false);
             }
             if (empty($this->comment) == false) {
                 // prevent empty lines when only user comment
                 $comment_body = $this->comment . "\n\n" . $request->getParameter('comment_body', null, false);
             } else {
                 $comment_body = $request->getParameter('comment_body', null, false);
             }
             $comment = new TBGComment();
             $comment->setTitle($i18n->__('Untitled comment'));
             $comment->setContent($comment_body);
             $comment->setPostedBy(TBGContext::getUser()->getID());
             $comment->setTargetID($request->getParameter('comment_applies_id'));
             $comment->setTargetType($request->getParameter('comment_applies_type'));
             $comment->setModuleName($request->getParameter('comment_module'));
             $comment->setIsPublic((bool) $request->getParameter('comment_visibility'));
             $comment->save();
             switch ($comment_applies_type) {
                 case TBGComment::TYPE_ISSUE:
                     $comment_html = $this->getTemplateHTML('main/comment', array('comment' => $comment, 'issue' => TBGContext::factory()->TBGIssue($request->getParameter('comment_applies_id'))));
                     break;
                 case TBGComment::TYPE_ARTICLE:
                     $comment_html = $this->getTemplateHTML('main/comment', array('comment' => $comment));
                     break;
                 default:
                     $comment_html = 'OH NO!';
             }
             if ($comment_applies_type == TBGComment::TYPE_ISSUE) {
                 $issue = TBGContext::factory()->TBGIssue($request->getParameter('comment_applies_id'));
                 TBGEvent::createNew('core', 'TBGComment::createNew', $issue, array('comment' => $comment))->trigger();
                 $issue->save();
             }
         }
     } catch (Exception $e) {
         if ($request->isAjaxCall()) {
             return $this->renderJSON(array('failed' => true, 'error' => $e->getMessage()));
         } else {
             TBGContext::setMessage('comment_error', $e->getMessage());
             TBGContext::setMessage('comment_error_body', $request->getParameter('comment_body'));
             TBGContext::setMessage('comment_error_title', $request->getParameter('comment_title'));
             TBGContext::setMessage('comment_error_visibility', $request->getParameter('comment_visibility'));
         }
     }
     if ($request->isAjaxCall()) {
         return $this->renderJSON(array('title' => $i18n->__('Comment added!'), 'comment_data' => $comment_html, 'continue_url' => $request->getParameter('forward_url'), 'commentcount' => TBGComment::countComments($request->getParameter('comment_applies_id'), $request->getParameter('comment_applies_type'))));
     }
     if ($comment instanceof TBGComment) {
         $this->forward($request->getParameter('forward_url') . "#comment_{$request->getParameter('comment_applies_type')}_{$request->getParameter('comment_applies_id')}_{$comment->getID()}");
     } else {
         $this->forward($request->getParameter('forward_url'));
     }
 }