当前位置: 首页>>代码示例>>PHP>>正文


PHP TBGContext::setScope方法代码示例

本文整理汇总了PHP中TBGContext::setScope方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGContext::setScope方法的具体用法?PHP TBGContext::setScope怎么用?PHP TBGContext::setScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TBGContext的用法示例。


在下文中一共展示了TBGContext::setScope方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: do_execute

 public function do_execute()
 {
     /* Prepare variables */
     try {
         $project_id = $this->getProvidedArgument('projectid');
         $project_row = TBGProjectsTable::getTable()->getById($project_id, false);
         TBGContext::setScope(new TBGScope($project_row[TBGProjectsTable::SCOPE]));
         $project = new TBGProject($project_id, $project_row);
     } catch (Exception $e) {
         throw $e;
         $this->cliEcho("The project with the ID " . $this->getProvidedArgument('projectid') . " does not exist\n", 'red', 'bold');
         exit;
     }
     $author = $this->getProvidedArgument('author');
     $new_rev = $this->getProvidedArgument('revno');
     $commit_msg = $this->getProvidedArgument('log');
     $changed = $this->getProvidedArgument('changed');
     $old_rev = $this->getProvidedArgument('oldrev', null);
     $date = $this->getProvidedArgument('date', null);
     $branch = $this->getProvidedArgument('branch', null);
     if (TBGSettings::get('access_method_' . $project->getKey()) == TBGVCSIntegration::ACCESS_HTTP) {
         $this->cliEcho("This project uses the HTTP access method, and so access via the CLI has been disabled\n", 'red', 'bold');
         exit;
     }
     if ($old_rev === null && !is_integer($new_rev)) {
         $this->cliEcho("Error: if only the new revision is specified, it must be a number so that old revision can be calculated from it (by substracting 1 from new revision number).");
     } else {
         if ($old_rev === null) {
             $old_rev = $new_rev - 1;
         }
     }
     $output = TBGVCSIntegration::processCommit($project, $commit_msg, $old_rev, $new_rev, $date, $changed, $author, $branch);
     $this->cliEcho($output);
 }
开发者ID:oparoz,项目名称:thebuggenie,代码行数:34,代码来源:CliVCS_IntegrationReport.class.php

示例2: runScope

 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());
         }
     }
 }
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:51,代码来源:actions.class.php

示例3: _postSave

 protected function _postSave($is_new)
 {
     TBGScopeHostnamesTable::getTable()->saveScopeHostnames($this->getHostnames(), $this->getID());
     // Load fixtures for this scope if it's a new scope
     if ($is_new) {
         if ($this->getID() != 1) {
             $prev_scope = TBGContext::getScope();
             TBGContext::setScope($this);
         }
         $this->loadFixtures();
         if ($this->getID() != 1) {
             TBGModule::installModule('publish', $this);
             TBGContext::setScope($prev_scope);
         }
     }
 }
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:16,代码来源:TBGScope.class.php

示例4: runUpgrade

 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.1';
     if ($this->upgrade_available) {
         $scope = new TBGScope();
         $scope->setID(1);
         $scope->setEnabled();
         TBGContext::setScope($scope);
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isMethod(TBGRequest::POST)) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.0':
                 $this->_upgradeFrom3dot0();
                 break;
         }
         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);
             unlink(THEBUGGENIE_PATH . 'upgrade');
             $this->current_version = '3.1';
             $this->upgrade_available = false;
         }
     } elseif ($this->current_version != '3.1') {
         $this->permissions_ok = false;
         if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
             $this->permissions_ok = true;
         }
     } else {
         $this->forward(TBGContext::getRouting()->generate('home'));
     }
 }
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:35,代码来源:actions.class.php

示例5: do_execute


//.........这里部分代码省略.........
                         $this->cliEcho("The Bug Genie will not function properly until the .htaccess file is properly set up!\n");
                     } else {
                         $this->cliEcho("The .htaccess file was successfully set up...\n", 'green', 'bold');
                     }
                 }
             } else {
                 $this->cliEcho("Skipping .htaccess auto-setup.");
             }
             if ($this->getProvidedArgument('setup_htaccess') != 'yes') {
                 $this->cliEcho("Press ENTER to continue ... ");
                 $this->pressEnterToContinue();
                 $this->cliEcho("\n");
             }
             $enable_modules = array();
             if ($this->getProvidedArgument('enable_all_modules') != 'yes') {
                 $this->cliEcho("You will now get a list of available modules.\nTo enable the module after installation, just press ENTER.\nIf you don't want to enable the module, type \"no\".\nRemember that all these modules can be disabled/uninstalled after installation.\n\n");
             }
             $this->cliEcho("Enable incoming and outgoing email? ", 'white', 'bold') . $this->cliEcho('(yes): ');
             $enable_modules['mailing'] = $this->getProvidedArgument('enable_all_modules') == 'yes' ? true : $this->askToDecline();
             if ($this->getProvidedArgument('enable_all_modules') == 'yes') {
                 $this->cliEcho("Yes\n", 'yellow', 'bold');
             }
             $this->cliEcho("Enable communication with version control systems (i.e. svn)? ", 'white', 'bold') . $this->cliEcho('(yes): ');
             $enable_modules['vcs_integration'] = $this->getProvidedArgument('enable_all_modules') == 'yes' ? true : $this->askToDecline();
             if ($this->getProvidedArgument('enable_all_modules') == 'yes') {
                 $this->cliEcho("Yes\n", 'yellow', 'bold');
             }
             $enable_modules['publish'] = true;
             $this->cliEcho("\n");
             $this->cliEcho("Creating tables ...\n", 'white', 'bold');
             $tables_path = THEBUGGENIE_CORE_PATH . 'classes' . DIRECTORY_SEPARATOR . 'B2DB' . DIRECTORY_SEPARATOR;
             TBGContext::addClasspath($tables_path);
             $tables_path_handle = opendir($tables_path);
             $tables_created = array();
             while ($table_class_file = readdir($tables_path_handle)) {
                 if (($tablename = substr($table_class_file, 0, strpos($table_class_file, '.'))) != '') {
                     B2DB::getTable($tablename)->create();
                     $this->cliEcho("Creating table {$tablename}\n", 'white', 'bold');
                 }
             }
             $this->cliEcho("\n");
             $this->cliEcho("All tables successfully created...\n\n", 'green', 'bold');
             $this->cliEcho("Setting up initial scope... \n", 'white', 'bold');
             TBGContext::reinitializeI18n('en_US');
             $scope = new TBGScope();
             $scope->setName('The default scope');
             $scope->addHostname('*');
             $scope->setEnabled();
             TBGContext::setScope($scope);
             $scope->save();
             TBGSettings::saveSetting('language', 'en_US');
             $this->cliEcho("Initial scope setup successfully... \n\n", 'green', 'bold');
             $this->cliEcho("Setting up modules... \n", 'white', 'bold');
             try {
                 foreach ($enable_modules as $module => $install) {
                     if ((bool) $install && file_exists(THEBUGGENIE_MODULES_PATH . $module . DS . 'module')) {
                         $this->cliEcho("Installing {$module}... \n");
                         TBGModule::installModule($module);
                         $this->cliEcho("Module {$module} installed successfully...\n", 'green');
                     }
                 }
                 $this->cliEcho("\n");
                 $this->cliEcho("All modules installed successfully...\n", 'green', 'bold');
                 $this->cliEcho("\n");
                 $this->cliEcho("Finishing installation... \n", 'white', 'bold');
                 if (!is_writable(THEBUGGENIE_PATH . 'installed')) {
                     $this->cliEcho("\n");
                     $this->cliEcho("Could not create the 'installed' file.\n", 'red', 'bold');
                     $this->cliEcho("Please create the file ");
                     $this->cliEcho(THEBUGGENIE_PATH . "installed\n", 'white', 'bold');
                     $this->cliEcho("with the following line inside:\n");
                     $this->cliEcho('3.0, installed ' . date('d.m.Y H:i'), 'blue', 'bold');
                     $this->cliEcho("\n");
                     $this->cliEcho("This can be done by running the following command when installation has finished:\n");
                     $this->cliEcho('echo "3.0, installed ' . date('d.m.Y H:i') . '" > ' . THEBUGGENIE_PATH . 'installed', 'white', 'bold');
                     $this->cliEcho("\n");
                     $this->cliEcho("Press ENTER to continue ... ");
                     $this->pressEnterToContinue();
                     $this->cliEcho("\n");
                     $this->cliEcho("\n");
                 } else {
                     file_put_contents(THEBUGGENIE_PATH . 'installed', '3.0, installed ' . date('d.m.Y H:i'));
                 }
                 $this->cliEcho("The installation was completed successfully!\n", 'green', 'bold');
                 $this->cliEcho("\nTo use The Bug Genie, access http://example.com" . $url_subdir . "index.php with a web-browser.\n");
                 $this->cliEcho("The default username is ") . $this->cliEcho('Administrator') . $this->cliEcho(' and the password is ') . $this->cliEcho('admin');
                 $this->cliEcho("\n\nFor support, please visit ") . $this->cliEcho('http://www.thebuggenie.com/', 'blue', 'underline');
                 $this->cliEcho("\n");
             } catch (Exception $e) {
                 throw new Exception("Could not install the {$module} module:\n" . $e->getMessage());
             }
         }
     } catch (Exception $e) {
         $this->cliEcho("\n\nThe installation was interrupted\n", 'red');
         $this->cliEcho($e->getMessage() . "\n");
         var_dump($e->getTraceAsString());
         die;
     }
     $this->cliEcho("\n");
 }
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:101,代码来源:CliMainInstall.class.php

示例6: runUpgrade

 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'));
     }
 }
开发者ID:oparoz,项目名称:thebuggenie,代码行数:46,代码来源:actions.class.php

示例7: _processArguments

 protected final function _processArguments()
 {
     $cc = 1;
     foreach ($this->_required_arguments as $key => $argument) {
         $cc++;
         if ($this->hasProvidedArgument($key)) {
             continue;
         }
         if ($this->hasProvidedArgument($cc)) {
             if (mb_substr(self::$_provided_arguments[$cc], 0, 2) == '--' && mb_substr(self::$_provided_arguments[$cc], 2, mb_strpos(self::$_provided_arguments[$cc], '=') - 1) != $key) {
                 continue;
             }
             self::$_provided_arguments[$key] = self::$_provided_arguments[$cc];
             if (!is_numeric($key)) {
                 self::$_named_arguments[$key] = self::$_provided_arguments[$cc];
             }
             continue;
         }
     }
     foreach (self::$_provided_arguments as $key => $value) {
         $this->{$key} = $value;
     }
     $diff = array_diff(array_keys($this->_required_arguments), array_keys(self::$_named_arguments));
     if (count($diff)) {
         throw new Exception('Please include all required arguments. Missing arguments: ' . join(', ', $diff));
     }
     foreach ($this->_optional_arguments as $key => $argument) {
         $cc++;
         if ($this->hasProvidedArgument($key)) {
             continue;
         }
         if ($this->hasProvidedArgument($cc)) {
             if (mb_substr(self::$_provided_arguments[$cc], 0, 2) == '--' && mb_substr(self::$_provided_arguments[$cc], 2, mb_strpos(self::$_provided_arguments[$cc], '=') - 1) != $key) {
                 continue;
             }
             self::$_provided_arguments[$key] = self::$_provided_arguments[$cc];
             if (!is_numeric($key)) {
                 self::$_named_arguments[$key] = self::$_provided_arguments[$cc];
             }
             continue;
         }
     }
     if ($this->_scoped && array_key_exists('scope', self::$_named_arguments)) {
         $scope = TBGScopesTable::getTable()->selectById(self::$_named_arguments['scope']);
         $this->cliEcho("Using scope " . $scope->getID() . "\n");
         TBGContext::setScope($scope);
     }
 }
开发者ID:oparoz,项目名称:thebuggenie,代码行数:48,代码来源:TBGCliCommand.class.php


注:本文中的TBGContext::setScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。