Exemplo n.º 1
0
 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");
 }
Exemplo n.º 2
0
 public function getNumberOfMembers()
 {
     if ($this->_members !== null) {
         return count($this->_members);
     } elseif ($this->_num_members === null) {
         $this->_num_members = tables\UserScopes::getTable()->countUsersByGroupID($this->getID());
     }
     return $this->_num_members;
 }
Exemplo n.º 3
0
 public function confirmScope($scope)
 {
     $scope_id = $scope instanceof Scope ? $scope->getID() : $scope;
     tables\UserScopes::getTable()->confirmUserInScope($this->getID(), $scope_id);
     $this->_scopes = null;
     $this->_unconfirmed_scopes = null;
     $this->_confirmed_scopes = null;
 }
Exemplo n.º 4
0
 public function findInConfig($details, $limit = 50, $allow_keywords = true)
 {
     $crit = $this->getCriteria();
     switch ($details) {
         case 'unactivated':
             if ($allow_keywords) {
                 $crit->addWhere(self::ACTIVATED, false);
                 $limit = 500;
                 break;
             }
         case 'newusers':
             if ($allow_keywords) {
                 $crit->addWhere(self::JOINED, NOW - 1814400, Criteria::DB_GREATER_THAN_EQUAL);
                 $limit = 500;
                 break;
             }
         case '0-9':
             if ($allow_keywords) {
                 $ctn = $crit->returnCriterion(self::UNAME, array('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%'), Criteria::DB_IN);
                 $ctn->addOr(self::BUDDYNAME, array('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%'), Criteria::DB_IN);
                 $ctn->addOr(self::REALNAME, array('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%'), Criteria::DB_IN);
                 $crit->addWhere($ctn);
                 $limit = 500;
                 break;
             }
         case 'all':
             if ($allow_keywords) {
                 $limit = 500;
                 break;
             }
         default:
             if (mb_strlen($details) == 1) {
                 $limit = 500;
             }
             $details = mb_strlen($details) == 1 ? mb_strtolower("{$details}%") : mb_strtolower("%{$details}%");
             $ctn = $crit->returnCriterion(self::UNAME, $details, Criteria::DB_LIKE);
             $ctn->addOr(self::BUDDYNAME, $details, Criteria::DB_LIKE);
             $ctn->addOr(self::REALNAME, $details, Criteria::DB_LIKE);
             $ctn->addOr(self::EMAIL, $details, Criteria::DB_LIKE);
             $crit->addWhere($ctn);
             break;
     }
     $crit->addJoin(UserScopes::getTable(), UserScopes::USER_ID, self::ID, array(), Criteria::DB_INNER_JOIN);
     $crit->addWhere(UserScopes::SCOPE, framework\Context::getScope()->getID());
     $crit->addWhere(self::DELETED, false);
     $users = array();
     $res = null;
     if ($details != '' && ($res = $this->doSelect($crit))) {
         while (($row = $res->getNextRow()) && count($users) < $limit) {
             $user_id = (int) $row->get(self::ID);
             $details = UserScopes::getTable()->getUserDetailsByScope($user_id, framework\Context::getScope()->getID());
             if (!$details) {
                 continue;
             }
             $users[$user_id] = \thebuggenie\core\entities\User::getB2DBTable()->selectById($user_id);
             $users[$user_id]->setScopeConfirmed($details['confirmed']);
         }
     }
     return $users;
 }