public function exportAction() { try { $fileContents = ""; $fileTitle = ""; $roleId = $this->getParam("roleId"); if ($roleId > 0) { $role = User_Abstract::getById($roleId); $roleCollection[] = $role; $fileContents = PimPon_Role_Export::doExport($roleCollection); $fileTitle = $role->getName(); } else { if ($roleId == 0) { $list = new User_Role_List(); $list->setCondition("parentId = ?", intval($roleId)); $list->load(); $roleCollection = $list->getRoles(); $fileContents = PimPon_Role_Export::doExport($roleCollection); $fileTitle = 'all'; } } ob_end_clean(); header("Content-type: application/json"); header("Content-Disposition: attachment; filename=\"pimponexport.roles." . $fileTitle . ".json\""); echo file_get_contents($fileContents); exit; } catch (Exception $ex) { Logger::err($ex->getMessage()); $this->_helper->json(array("success" => false, "data" => 'error'), false); } }
public function updateAction() { $user = User_Abstract::getById(intval($this->_getParam("id"))); if ($this->_getParam("data")) { $values = Zend_Json::decode($this->_getParam("data")); if (!empty($values["password"])) { $values["password"] = Pimcore_Tool_Authentication::getPasswordHash($user->getName(), $values["password"]); } if (method_exists($user, "setAllAclToFalse")) { $user->setAllAclToFalse(); } $user->setValues($values); // check for permissions $availableUserPermissionsList = new User_Permission_Definition_List(); $availableUserPermissions = $availableUserPermissionsList->load(); foreach ($availableUserPermissions as $permission) { if ($values["permission_" . $permission->getKey()]) { $user->setPermission($permission->getKey(), (bool) $values["permission_" . $permission->getKey()]); } } // check for workspaces if ($this->_getParam("workspaces")) { $workspaces = Zend_Json::decode($this->_getParam("workspaces")); foreach ($workspaces as $type => $spaces) { $newWorkspaces = array(); foreach ($spaces as $space) { $element = Element_Service::getElementByPath($type, $space["path"]); if ($element) { $className = "User_Workspace_" . ucfirst($type); $workspace = new $className(); $workspace->setValues($space); $workspace->setCid($element->getId()); $workspace->setCpath($element->getFullPath()); $workspace->setUserId($user->getId()); $newWorkspaces[] = $workspace; } } $user->{"setWorkspaces" . ucfirst($type)}($newWorkspaces); } } } $user->save(); $this->_helper->json(array("success" => true)); }