/** * @param Model\User $user * @return $this */ public function setUser(Model\User $user) { $this->user = $user; \Zend_Registry::set("pimcore_admin_user", $this->user); $this->setLanguage($this->user->getLanguage()); // update perspective settings $requestedPerspective = $this->getParam("perspective"); if ($requestedPerspective) { if ($requestedPerspective != $user->getActivePerspective()) { $existingPerspectives = array_keys(Config::getPerspectivesConfig()->toArray()); if (!in_array($requestedPerspective, $existingPerspectives)) { $requestedPerspective = null; } } } if (!$requestedPerspective) { $requestedPerspective = $user->getActivePerspective(); } //TODO check if perspective is still allowed if ($requestedPerspective != $user->getActivePerspective()) { $user->setActivePerspective($requestedPerspective); $user->save(); } return $this; }
/** * @param Model\User $user * @return $this */ public function setUser(Model\User $user) { $this->user = $user; \Zend_Registry::set("pimcore_admin_user", $this->user); $this->setLanguage($this->user->getLanguage()); // update perspective settings $requestedPerspective = $this->getParam("perspective"); if ($requestedPerspective) { if ($requestedPerspective != $user->getActivePerspective()) { $existingPerspectives = array_keys(Config::getPerspectivesConfig()->toArray()); if (!in_array($requestedPerspective, $existingPerspectives)) { $requestedPerspective = null; } } } if (!$requestedPerspective || !$user->isAllowed($requestedPerspective, "perspective")) { //choose active perspective or a first allowed $requestedPerspective = $user->isAllowed($user->getActivePerspective(), "perspective") ? $user->getActivePerspective() : $user->getFirstAllowedPerspective(); } if ($requestedPerspective != $user->getActivePerspective()) { $user->setActivePerspective($requestedPerspective); $user->save(); } return $this; }