예제 #1
0
 /**
  * Find and set the current scope
  *
  * @param Scope $scope Specify a scope to set for this request
  */
 public static function setScope($scope = null)
 {
     Logging::log("Setting current scope");
     if ($scope !== null) {
         Logging::log("Setting scope from function parameter");
         self::$_scope = $scope;
         Settings::forceSettingsReload();
         Logging::log("...done (Setting scope from function parameter)");
         return true;
     }
     $row = null;
     try {
         $hostname = null;
         if (!self::isCLI() && !self::isInstallmode()) {
             Logging::log("Checking if scope can be set from hostname (" . $_SERVER['HTTP_HOST'] . ")");
             $hostname = $_SERVER['HTTP_HOST'];
         }
         if (!self::isUpgrademode() && !self::isInstallmode()) {
             $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->getByHostnameOrDefault($hostname);
         }
         if (!$scope instanceof Scope) {
             Logging::log("It couldn't", 'main', Logging::LEVEL_WARNING);
             if (!self::isInstallmode()) {
                 throw new \Exception("The Bug Genie isn't set up to work with this server name.");
             } else {
                 return;
             }
         }
         Logging::log("Setting scope {$scope->getID()} from hostname");
         self::$_scope = $scope;
         Settings::forceSettingsReload();
         Settings::loadSettings();
         Logging::log("...done (Setting scope from hostname)");
         return true;
     } catch (\Exception $e) {
         if (self::isCLI()) {
             Logging::log("Couldn't set up default scope.", 'main', Logging::LEVEL_FATAL);
             throw new \Exception("Could not load default scope. Error message was: " . $e->getMessage());
         } elseif (!self::isInstallmode()) {
             Logging::log("Couldn't find a scope for hostname {$_SERVER['HTTP_HOST']}", 'main', Logging::LEVEL_FATAL);
             Logging::log($e->getMessage(), 'main', Logging::LEVEL_FATAL);
             throw new \Exception("Could not load scope. This is usually because the scopes table doesn't have a scope for this hostname");
         } else {
             Logging::log("Couldn't find a scope for hostname {$_SERVER['HTTP_HOST']}, but we're in installmode so continuing anyway");
         }
     }
 }
예제 #2
0
 public function loadFixtures()
 {
     // Load initial settings
     tables\Settings::getTable()->loadFixtures($this);
     \thebuggenie\core\framework\Settings::loadSettings();
     // Load group, users and permissions fixtures
     Group::loadFixtures($this);
     // Load initial teams
     Team::loadFixtures($this);
     // Set up user states, like "available", "away", etc
     Userstate::loadFixtures($this);
     // Set up data types
     list($b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id) = Issuetype::loadFixtures($this);
     $scheme = IssuetypeScheme::loadFixtures($this);
     tables\IssueFields::getTable()->loadFixtures($this, $scheme, $b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id);
     Datatype::loadFixtures($this);
     // Set up workflows
     Workflow::loadFixtures($this);
     WorkflowScheme::loadFixtures($this);
     tables\WorkflowIssuetype::getTable()->loadFixtures($this);
     // Set up left menu links
     tables\Links::getTable()->loadFixtures($this);
 }