public function changeUiAction()
    {
        $request  = $this->getRequest();
        $orgId    = urldecode($request->getParam('org'));
        $oldOrg   = $this->currentUser->getCurrentOrganizationId();
        $origUrl  = base64_decode($request->getParam('current_uri'));

        $allowedOrganizations = $this->currentUser->getAllowedOrganizations();
        if (isset($allowedOrganizations[$orgId])) {
            $this->currentUser->setCurrentOrganization($orgId);

            if ($origUrl) {
                // Check for organization id in url, but not when a patient id is stated
                if (strpos($origUrl, '/' . \MUtil_Model::REQUEST_ID1 . '/') === false) {
                    foreach ($this->currentUser->possibleOrgIds as $key) {
                        $finds[]    = '/' . $key. '/' . $oldOrg;
                        $replaces[] = '/' . $key. '/' . $orgId;
                    }
                    $correctUrl = str_replace($finds, $replaces, $origUrl);
                } else {
                    $correctUrl = $origUrl;
                }
                // \MUtil_Echo::track($origUrl, $correctUrl);
                $this->getResponse()->setRedirect($correctUrl);
            } else {
                $this->currentUser->gotoStartPage($this->menu, $request);
            }
            return;
        }

        throw new \Gems_Exception(
                $this->_('Inaccessible or unknown organization'),
                403, null,
                sprintf(
                        $this->_('Access to this page is not allowed for current role: %s.'),
                        $this->currentUser->getRole()
                        )
                );
    }
public function changeUiAction()
    {
        $request  = $this->getRequest();
        $orgId    = urldecode($request->getParam('org'));
        $oldOrg   = $this->currentUser->getCurrentOrganizationId();
        $origUrl  = base64_decode($request->getParam('current_uri'));

        $allowedOrganizations = $this->currentUser->getAllowedOrganizations();
        if (isset($allowedOrganizations[$orgId])) {
            $this->currentUser->setCurrentOrganization($orgId);

            if ($origUrl) {
                // Check for organization id in url, but not when a patient id is stated
                if (strpos($origUrl, '/' . \MUtil_Model::REQUEST_ID1 . '/') === false) {
                    foreach ($this->currentUser->possibleOrgIds as $key) {
                        $finds[]    = '/' . $key. '/' . $oldOrg;
                        $replaces[] = '/' . $key. '/' . $orgId;
                    }
                    $correctUrl = str_replace($finds, $replaces, $origUrl);
                } else {
                    $correctUrl = $origUrl;
                }
                // \MUtil_Echo::track($origUrl, $correctUrl);
                $this->getResponse()->setRedirect($correctUrl);
            } else {
                $this->currentUser->gotoStartPage($this->menu, $request);
            }
            return;
        }

        throw new \Gems_Exception(
                $this->_('Inaccessible or unknown organization'),
                403, null,
                sprintf(
                        $this->_('Access to this page is not allowed for current role: %s.'),
                        $this->currentUser->getRole()
                        )
                );
    }
public function changeUiAction ( ) { $ request = $ this -> getRequest ( ) ; $ orgId = urldecode ( $ request -> getParam ( 'org' ) ) ; $ oldOrg = $ this -> currentUser -> getCurrentOrganizationId ( ) ; $ origUrl = base64_decode ( $ request -> getParam ( 'current_uri' ) ) ; $ allowedOrganizations = $ this -> currentUser -> getAllowedOrganizations ( ) ; if ( isset ( $ allowedOrganizations [ $ orgId ] ) ) { $ this -> currentUser -> setCurrentOrganization ( $ orgId ) ; if ( $ origUrl ) { // Check for organization id in url, but not when a patient id is stated if ( strpos ( $ origUrl , '/' . \ MUtil_Model :: REQUEST_ID1 . '/' ) === false ) { foreach ( $ this -> currentUser -> possibleOrgIds as $ key ) { $ finds [ ] = '/' . $ key . '/' . $ oldOrg ; $ replaces [ ] = '/' . $ key . '/' . $ orgId ; } $ correctUrl = str_replace ( $ finds , $ replaces , $ origUrl ) ; } else { $ correctUrl = $ origUrl ; } // \MUtil_Echo::track($origUrl, $correctUrl); $ this -> getResponse ( ) -> setRedirect ( $ correctUrl ) ; } else { $ this -> currentUser -> gotoStartPage ( $ this -> menu , $ request ) ; } return ; } throw new \ Gems_Exception ( $ this -> _ ( 'Inaccessible or unknown organization' ) , 403 , null , sprintf ( $ this -> _ ( 'Access to this page is not allowed for current role: %s.' ) , $ this -> currentUser -> getRole ( ) ) ) ; }
Switch the active organization
Switch the active organization