/** * Returns the top organization id that should currently be used for this form. * * @return int Returns the current organization id, if any */ 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->getTopOrganisations()); $firstId = reset($orgs); return \Gems_Cookies::get($this->getRequest(), 'gems_toporganization', $firstId); } }