コード例 #1
0
ファイル: actions.class.php プロジェクト: oparoz/thebuggenie
 public function runEditSavedSearch(TBGRequest $request)
 {
     if ($request->isPost()) {
         if ($request['delete_saved_search']) {
             try {
                 if (!$this->search_object instanceof TBGSavedSearch || !$this->search_object->getB2DBID()) {
                     throw new Exception('not a saved search');
                 }
                 if ($this->search_object->getUserID() == TBGContext::getUser()->getID() || $this->search_object->isPublic() && TBGContext::getUser()->canCreatePublicSearches()) {
                     $search->delete();
                     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['saved_search_name'] != '') {
             //					$project_id = (TBGContext::isProjectContext()) ? TBGContext::getCurrentProject()->getID() : 0;
             //					TBGSavedSearchesTable::getTable()->saveSearch($request['saved_search_name'], $request['saved_search_description'], $request['saved_search_public'], $this->filters, $this->groupby, $this->grouporder, $this->ipp, $this->templatename, $this->template_parameter, $project_id, $request['saved_search_id']);
             if (!$search instanceof TBGSavedSearch) {
                 $search = new TBGSavedSearch();
             }
             $search->setName($request['saved_search_name']);
             $search->setDescription($request['saved_search_description']);
             $search->setIsPublic((bool) $request['saved_search_public']);
             $search->save();
             if ($request['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('fs' => $this->filters, 'groupby' => $this->groupby, 'grouporder' => $this->grouporder, 'templatename' => $this->templatename, 'saved_search' => $request['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));
     }
 }
コード例 #2
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"));
 }
コード例 #3
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')));
         }
     }
 }
コード例 #4
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();
     }
 }
コード例 #5
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));
     }
 }
コード例 #6
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 = '&view=rev&revision=%revno';
                 $link_file = '&view=log';
                 $link_diff = '&r1=%revno&r2=%oldrev';
                 $link_view = '&revision=%revno&view=markup';
                 break;
             case 'viewvc_repo':
                 $base_url = $request['browser_url'];
                 $link_rev = '/?view=rev&revision=%revno';
                 $link_file = '/%file?view=log';
                 $link_diff = '/%file?r1=%revno&r2=%oldrev';
                 $link_view = '/%file?revision=%revno&view=markup';
                 break;
             case 'websvn':
                 $base_url = $request['browser_url'];
                 $link_rev = '/revision.php?repname=' . $request['repository'] . '&isdir=1&rev=%revno';
                 $link_file = '/log.php?repname=' . $request['repository'] . '&path=/$%file';
                 $link_diff = '/comp.php?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev';
                 $link_view = '/filedetails.php?repname=' . $request['repository'] . '&path=/%file&rev=%revno';
                 break;
             case 'websvn_mv':
                 $base_url = $request['browser_url'];
                 $link_rev = '/' . '?repname=' . $request['repository'] . '&op=log&isdir=1&rev=%revno';
                 $link_file = '/%file?repname=' . $request['repository'];
                 $link_diff = '/%file?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev';
                 $link_view = '/%file?repname=' . $request['repository'] . '&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&diff1=%oldrev&fulldiff=1&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();
     }
 }
コード例 #7
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'));
     }
 }
コード例 #8
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();
         }
     }
 }