コード例 #1
0
ファイル: Scopes.php プロジェクト: founderio/thebuggenie
 public function getByHostnameOrDefault($hostname = null)
 {
     $crit = $this->getCriteria();
     if ($hostname !== null) {
         $crit->addJoin(ScopeHostnames::getTable(), ScopeHostnames::SCOPE_ID, self::ID);
         $crit->addWhere(ScopeHostnames::HOSTNAME, $hostname);
         $crit->addOr(self::ID, 1);
         $crit->addOrderBy(self::ID, 'desc');
     } else {
         $crit->addWhere(self::ID, 1);
     }
     return $this->selectOne($crit);
 }
コード例 #2
0
ファイル: CreateScope.php プロジェクト: pkdevboxy/thebuggenie
 public function do_execute()
 {
     $hostname = $this->getProvidedArgument('hostname');
     $this->cliEcho('Checking scope availability ...');
     if (tables\ScopeHostnames::getTable()->getScopeIDForHostname($hostname) === null) {
         $this->cliEcho("available!\n");
         $this->cliEcho("Creating scope ...");
         $scope = new entities\Scope();
         $scope->addHostname($hostname);
         $scope->setName($this->getProvidedArgument('shortname'));
         $uploads_enabled = $this->getProvidedArgument('enable_uploads', 'yes') == 'yes';
         $scope->setUploadsEnabled((bool) $uploads_enabled);
         $scope->setMaxUploadLimit($this->getProvidedArgument('upload_limit', 0));
         $scope->setMaxProjects($this->getProvidedArgument('projects', 0));
         $scope->setMaxUsers($this->getProvidedArgument('users', 0));
         $scope->setMaxTeams($this->getProvidedArgument('teams', 0));
         $scope->setMaxWorkflowsLimit($this->getProvidedArgument('workflows', 0));
         $scope->setEnabled();
         $this->cliEcho(".");
         $scope->save();
         $this->cliEcho(".done!\n");
         $admin_user = $this->getProvidedArgument('scope_admin');
         if ($admin_user) {
             $user = entities\User::getByUsername($admin_user);
             if ($user instanceof entities\User) {
                 $this->cliEcho("Adding user {$admin_user} to scope\n");
                 $admin_group_id = (int) framework\Settings::get(framework\Settings::SETTING_ADMIN_GROUP, 'core', $scope->getID());
                 tables\UserScopes::getTable()->addUserToScope($user->getID(), $scope->getID(), $admin_group_id, true);
             } else {
                 $this->cliEcho("Could not add user {$admin_user} to scope (username not found)\n");
             }
         }
         if ($this->getProvidedArgument('remove_admin', 'no') == 'yes') {
             $this->cliEcho("Removing administrator user from scope\n");
             tables\UserScopes::getTable()->removeUserFromScope(1, $scope->getID());
         }
         foreach (framework\Context::getModules() as $module) {
             $module_name = $module->getName();
             if ($module_name == 'publish') {
                 continue;
             }
             if ($this->getProvidedArgument("install_module_{$module_name}", "no") == 'yes') {
                 $this->cliEcho("Installing module {$module_name}\n");
                 entities\Module::installModule($module_name, $scope);
             }
         }
     } else {
         $this->cliEcho("not available\n", 'red');
     }
     $this->cliEcho("\n");
 }
コード例 #3
0
ファイル: Settings.php プロジェクト: JonathanRH/thebuggenie
 /**
  * Returns the default scope
  *
  * @return Scope
  */
 public static function getDefaultScopeID()
 {
     if (self::$_defaultscope === null) {
         self::$_defaultscope = tables\ScopeHostnames::getTable()->getScopeIDForHostname('*');
     }
     return self::$_defaultscope;
 }
コード例 #4
0
ファイル: Scope.php プロジェクト: RTechSoft/thebuggenie
 protected function _postSave($is_new)
 {
     tables\ScopeHostnames::getTable()->saveScopeHostnames($this->getHostnames(), $this->getID());
     // Load fixtures for this scope if it's a new scope
     if ($is_new) {
         if (!$this->isDefault()) {
             $prev_scope = framework\Context::getScope();
             framework\Context::setScope($this);
         }
         $this->loadFixtures();
         if (!$this->isDefault()) {
             Module::installModule('publish', $this);
             framework\Context::setScope($prev_scope);
             framework\Context::clearPermissionsCache();
         }
     }
 }