/**
  * Switch the active organization
  */
 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 organisation 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()));
 }
 /**
  * Default overview action
  */
 public function indexAction()
 {
     if ($this->checkForAnswersOnLoad) {
         $this->loader->getTracker()->processCompletedTokens(null, $this->currentUser->getUserId(), $this->currentUser->getCurrentOrganizationId(), true);
     }
     parent::indexAction();
 }
 /**
  * Returns the default search values for this class instance.
  *
  * Used to specify the filter when no values have been entered by the user.
  *
  * @return array
  */
 public function getDefaultSearchData()
 {
     if ($this->getModel()->isMultiOrganization()) {
         $orgId = $this->currentUser->getCurrentOrganizationId();
         $orgs = $this->currentUser->getRespondentOrganizations();
         if (isset($orgs[$orgId])) {
             return array(\MUtil_Model::REQUEST_ID2 => $orgId);
         }
     }
     return parent::getDefaultSearchData();
 }
 /**
  * Set the organizationID specific to the staff class
  */
 protected function loadOrganizationId()
 {
     $this->organizationId = $this->user->getCurrentOrganizationId();
 }
 /**
  * The current organization id of the current user
  *
  * @return int
  */
 public function getCurrentOrganization()
 {
     return $this->user->getCurrentOrganizationId();
 }