public function getByHostnameOrDefault($hostname = null) { $crit = $this->getCriteria(); if ($hostname !== null) { $crit->addJoin(TBGScopeHostnamesTable::getTable(), TBGScopeHostnamesTable::SCOPE_ID, self::ID); $crit->addWhere(TBGScopeHostnamesTable::HOSTNAME, $hostname); $crit->addOr(self::ID, 1); $crit->addOrderBy(self::ID, 'desc'); } else { $crit->addWhere(self::ID, 1); } return $this->selectOne($crit); }
/** * Returns the default scope * * @return TBGScope */ public static function getDefaultScopeID() { if (self::$_defaultscope === null) { self::$_defaultscope = TBGScopeHostnamesTable::getTable()->getScopeIDForHostname('*'); } return self::$_defaultscope; }
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); } } }
protected function _upgradeFrom3dot0() { // Add new tables TBGScopeHostnamesTable::getTable()->create(); // Add classpath for existing old tables used for upgrade TBGContext::addClasspath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.0'); // Upgrade old tables TBGScopesTable::getTable()->upgrade(TBGScopesTable3dot0::getTable()); TBGIssueFieldsTable::getTable()->upgrade(TBGIssueFieldsTable3dot0::getTable()); // Upgrade all modules foreach (TBGContext::getModules() as $module) { if (method_exists($module, 'upgradeFrom3dot0')) { $module->upgradeFrom3dot0(); } } // Start a transaction to preserve the upgrade path $transaction = B2DB::startTransaction(); // Add votes to feature requests for default issue type scheme $its = new TBGIssuetypeScheme(1); foreach (TBGIssuetype::getAll() as $fr) { if ($fr instanceof TBGIssuetype) { if (in_array($fr->getKey(), array('featurerequest', 'bugreport', 'enhancement'))) { $its->setFieldAvailableForIssuetype($fr, 'votes'); } } } $ut = TBGUsersTable::getTable(); $crit = $ut->getCriteria(); $crit->addUpdate(TBGUsersTable::PRIVATE_EMAIL, true); $ut->doUpdate($crit); // Add default gravatar setting TBGSettings::saveSetting(TBGSettings::SETTING_ENABLE_GRAVATARS, 1); $trans_crit = TBGWorkflowTransitionsTable::getTable()->getCriteria(); $trans_crit->addWhere(TBGWorkflowTransitionsTable::NAME, 'Request more information'); $trans_crit->addWhere(TBGWorkflowTransitionsTable::WORKFLOW_ID, 1); $trans_row = TBGWorkflowTransitionsTable::getTable()->doSelectOne($trans_crit); if ($trans_row) { $transition = new TBGWorkflowTransition($trans_row->get(TBGWorkflowTransitionsTable::ID), $trans_row); $transition->setTemplate('main/updateissueproperties'); $transition->save(); } // End transaction and finalize upgrade $transaction->commitAndEnd(); $this->upgrade_complete = true; }