Set this organization as the one currently active

@return \Gems_User_Organization (continuation pattern)
341344
public function setAsCurrentOrganization()
    {
        $organizationId = $this->getId();

        if ($organizationId && (! \Gems_Cookies::setOrganization($organizationId, $this->basepath->getBasePath()))) {
            throw new \Exception('Cookies must be enabled for this site.');
        }

        $escort = \GemsEscort::getInstance();
        if ($escort instanceof \Gems_Project_Layout_MultiLayoutInterface) {
            $escort->layoutSwitch($this->getStyle());
        }

        return $this;
    }
373217
public function getCurrentTopOrganizationId()
    {
        $userLoader = $this->loader->getUserLoader();

        // Url determines organization first.
        if ($orgId = $userLoader->getOrganizationIdByUrl()) {
            $this->_organizationFromUrl = true;
            return ' ';
        }

        $request = $this->getRequest();
        if ($request->isPost() && ($orgId = $request->getParam($this->topOrganizationFieldName))) {
            \Gems_Cookies::set('gems_toporganization', $orgId);
            return $orgId;
        } else {
            $orgs = array_keys($this->getTopOrganizations());
            $firstId = reset($orgs);
            return \Gems_Cookies::get($this->getRequest(), 'gems_toporganization', $firstId);
        }
    }
1179769
public function setActive() {
		if (! $this->_active) {
			$this->addClass(self::CLASS_ACTIVE);
			$this->_active = true;
		}
		
		return $this;
	}
426711
public function addActive()
    {
        $row = new FormCheckbox('active', 'Опубликован');
        $this->rows['active'] = $row->setTab('main', 'Дата, вес, активность')
            ->setValid('integer|max:1|nullable')->setDefaultValue(1)->setInTableAdminEditable()->setFillable()
            ->setCssClassGroup('uk-width-1-3');

        return $this;
    }
1306335
public function getTopOrganizations()
    {
        try {
            $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_has_login=1 AND (gor_accessible_by IS NULL OR gor_accessible_by = "::") ORDER BY gor_name');
        } catch (\Exception $e) {
            try {
                // 1.4 fallback
                $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_accessible_by IS NULL ORDER BY gor_name');
            } catch (\Exception $e) {
                $organizations = array();
            }
        }

        natsort($organizations);

        return $organizations;
    }
516545
public function getOrganizations()
    {
        $sql = "SELECT gor_id_organization, gor_name
                    FROM gems__organizations
                    WHERE gor_active = 1
                    ORDER BY gor_name";

        try {
            $organizations = $this->_getSelectPairsCached(__FUNCTION__, $sql, null, 'organizations', 'natsort');
        } catch (\Exception $exc) {
            // Intentional fallthrough when no db present
            $organizations = array();
        }

        return $organizations;
    }
214567
public function setActiveOrganization(\WobbleCode\UserBundle\Model\OrganizationInterface $activeOrganization)
    {
        $this->activeOrganization = $activeOrganization;
        return $this;
    }
262568
public function user()
    {
        $userClassName = Config::get('auth.model');
        if (is_null($userClassName)) {
            $userClassName = Config::get('auth.providers.users.model');
        }

        return $this->belongsTo($userClassName);
    }
1115178
public function isactive() {
        global $PAGE;

        if ($this->is_section()) {
            $active = $PAGE->navigation->find_active_node();
            while ($active = $active->parent) {
                if ($active->key == $this->key && $active->type == $this->type) {
                    return true;
                }
            }
        }
        return $this->isactive;
    }
1236169
public function setActive($active)
    {
        if (is_callable($active) || is_string($active)) {
            $condition = $active;
        } else {
            $condition = null;
        }

        $this->activeCondition = $condition;

        return parent::setActive($active);
    }
1158106
def activate_organizations(self, user):
        
        try:
            relation_name = self.org_model().user_relation_name
        except TypeError:
            # No org_model specified, raises a TypeError because NoneType is
            # not callable. This the most sensible default:
            relation_name = "organizations_organization"
        organization_set = getattr(user, relation_name)
        for org in organization_set.filter(is_active=False):
            org.is_active = True
            org.save()
309015
public function refreshAllowedOrganizations()
    {
        // Privilege overrules organizational settings
        if ($this->hasPrivilege('pr.organization-switch')) {
            $orgs = $this->util->getDbLookup()->getOrganizations();
        } else {
            $org = $this->getBaseOrganization();

            $orgs = array($org->getId() => $org->getName()) +
                    $org->getAllowedOrganizations();
        }
        // \MUtil_Echo::track($orgs);

        $this->_setVar('__allowedOrgs', $orgs);

        // Clean this cache
        $this->_unsetVar('__allowedRespOrgs');

        return $this;
    }
806948
public static function GetUserMode()
    {
        $umode = 'register';
        if (array_key_exists('tw_order_umode', $_SESSION)) {
            $umode = $_SESSION['tw_order_umode'];
        }
        if ('user' != $umode) {
            // check if the user is signed in... if so, we change the mode to user
            $oUser = self::getExtranetUserProvider()->getActiveUser();
            if ($oUser && $oUser->IsLoggedIn()) {
                $umode = 'user';
                TShopStepUserDataV2::SetUserMode($umode);
            }
        }

        return $umode;
    }
644331
public function bindUserToOrganization()
    {
        $limit = 250;
        $offset = 0;
        $this->log('Add organizations to users...');
        $this->objectManager->startFlushSuite();
        $countUsers = $this->objectManager->count('ClarolineCoreBundle:User');
        $default = $this->organizationManager->getDefault();
        $i = 0;

        while ($offset < $countUsers) {
            $users = $this->userRepo->findBy([], null, $limit, $offset);

            /** @var User $user */
            foreach ($users as $user) {
                $this->log('Setting user administrated organization...');

                foreach ($user->getAdministratedOrganizations() as $organization) {
                    //I know this is weird but the setter is now in this method (it used to not exist)
                    $user->addAdministratedOrganization($organization);
                }

                if (0 === count($user->getOrganizations())) {
                    ++$i;
                    $this->log('Add default organization for user '.$user->getUsername());
                    $user->addOrganization($default);
                    $this->objectManager->persist($user);

                    if (0 === $i % 250) {
                        $this->log("Flushing... [UOW = {$this->objectManager->getUnitOfWork()->size()}]");
                        $this->objectManager->forceFlush();
                    }
                } else {
                    $this->log("Organization for user {$user->getUsername()} already exists");
                }
            }

            $this->log("Flushing... [UOW = {$this->objectManager->getUnitOfWork()->size()}]");
            $this->objectManager->forceFlush();
            $default = $this->organizationManager->getDefault();

            $offset += $limit;
        }

        $this->objectManager->endFlushSuite();
    }
654538
public function active()
    {
        if(!\Yii::$app->user->isGuest && !\Yii::$app->user->identity->isAdmin)
        {
            $this->andWhere(['deleted_at' => NULL]);
        }
        return $this;
    }
661105
public function isActive()
    {
        if ($this->_isActive === null) {
            //Checkbox for active Login checked
            $this->_isActive = (
                (bool)$this->getConfig()->getConfigParam('blAmazonLoginActive') === true
                && (string)$this->getConfig()->getConfigParam('sAmazonLoginClientId') !== ''
                && (string)$this->getConfig()->getConfigParam('sAmazonSellerId') !== ''
            );
        }

        return $this->_isActive;
    }
284823
public function setActiveUsers(\WobbleCode\UserBundle\Document\User $activeUsers)
    {
        $this->activeUsers = $activeUsers;
        return $this;
    }