public function setCurrentOrganization($organization)
    {
        if (!($organization instanceof \Gems_User_Organization)) {
            $organization = $this->userLoader->getOrganization($organization);
        }

        $organizationId    = $organization->getId();
        $oldOrganizationId = $this->getCurrentOrganizationId();

        if ($organizationId != $oldOrganizationId) {
            $this->_setVar('user_organization_id', $organizationId);

            if ($this->isCurrentUser()) {
                $this->getCurrentOrganization()->setAsCurrentOrganization();

                if ($organization->canHaveRespondents()) {
                    $usedOrganizationId = $organizationId;
                } else {
                    $usedOrganizationId = null;
                }

                // Now update the requestcache to change the oldOrgId to the new orgId
                // Don't do it when the oldOrgId doesn't match
                $keysArray = array_flip($this->possibleOrgIds);
                $requestCache = $this->session->requestCache;
                if ($requestCache) {
                    foreach ($requestCache as $key => &$elements) {
                        $elements = $this->_changeIds($elements, $oldOrganizationId, $usedOrganizationId, $keysArray);
                    }
                    $this->session->requestCache = $requestCache;
                }

                // $searchSession &= $_SESSION['ModelSnippetActionAbstract_getSearchData'];
                $searchSession = new \Zend_Session_Namespace('ModelSnippetActionAbstract_getSearchData');
                foreach ($searchSession as $id => $data) {
                    $searchSession->$id = $this->_changeIds($data, $oldOrganizationId, $usedOrganizationId, $keysArray);
                }
            }
        }

        return $this;
    }
public function setCurrentOrganization($organization)
    {
        if (!($organization instanceof \Gems_User_Organization)) {
            $organization = $this->userLoader->getOrganization($organization);
        }

        $organizationId    = $organization->getId();
        $oldOrganizationId = $this->getCurrentOrganizationId();

        if ($organizationId != $oldOrganizationId) {
            $this->_setVar('user_organization_id', $organizationId);

            if ($this->isCurrentUser()) {
                $this->getCurrentOrganization()->setAsCurrentOrganization();

                if ($organization->canHaveRespondents()) {
                    $usedOrganizationId = $organizationId;
                } else {
                    $usedOrganizationId = null;
                }

                // Now update the requestcache to change the oldOrgId to the new orgId
                // Don't do it when the oldOrgId doesn't match
                $keysArray = array_flip($this->possibleOrgIds);
                $requestCache = $this->session->requestCache;
                if ($requestCache) {
                    foreach ($requestCache as $key => &$elements) {
                        $elements = $this->_changeIds($elements, $oldOrganizationId, $usedOrganizationId, $keysArray);
                    }
                    $this->session->requestCache = $requestCache;
                }

                // $searchSession &= $_SESSION['ModelSnippetActionAbstract_getSearchData'];
                $searchSession = new \Zend_Session_Namespace('ModelSnippetActionAbstract_getSearchData');
                foreach ($searchSession as $id => $data) {
                    $searchSession->$id = $this->_changeIds($data, $oldOrganizationId, $usedOrganizationId, $keysArray);
                }
            }
        }

        return $this;
    }
public function setCurrentOrganization ( $ organization ) { if ( ! ( $ organization instanceof \ Gems_User_Organization ) ) { $ organization = $ this -> userLoader -> getOrganization ( $ organization ) ; } $ organizationId = $ organization -> getId ( ) ; $ oldOrganizationId = $ this -> getCurrentOrganizationId ( ) ; if ( $ organizationId != $ oldOrganizationId ) { $ this -> _setVar ( 'user_organization_id' , $ organizationId ) ; if ( $ this -> isCurrentUser ( ) ) { $ this -> getCurrentOrganization ( ) -> setAsCurrentOrganization ( ) ; if ( $ organization -> canHaveRespondents ( ) ) { $ usedOrganizationId = $ organizationId ; } else { $ usedOrganizationId = null ; } // Now update the requestcache to change the oldOrgId to the new orgId // Don't do it when the oldOrgId doesn't match $ keysArray = array_flip ( $ this -> possibleOrgIds ) ; $ requestCache = $ this -> session -> requestCache ; if ( $ requestCache ) { foreach ( $ requestCache as $ key => & $ elements ) { $ elements = $ this -> _changeIds ( $ elements , $ oldOrganizationId , $ usedOrganizationId , $ keysArray ) ; } $ this -> session -> requestCache = $ requestCache ; } // $searchSession &= $_SESSION['ModelSnippetActionAbstract_getSearchData']; $ searchSession = new \ Zend_Session_Namespace ( 'ModelSnippetActionAbstract_getSearchData' ) ; foreach ( $ searchSession as $ id => $ data ) { $ searchSession -> $ id = $ this -> _changeIds ( $ data , $ oldOrganizationId , $ usedOrganizationId , $ keysArray ) ; } } } return $ this ; }
Set the currently selected organization for this user

@param mixed $organization \Gems_User_Organization or an organization id.
@return \Gems_User_User (continuation pattern)
Set the currently selected organization for this user