Renders the workspace properties page.

@param integer $workspaceId

@return string
490905
public function workspaceParameters($workspaceId)
    {
        $workspace = $this->workspaceManager->getWorkspaceById($workspaceId);
        $tools = $this->toolManager->getToolByCriterias(
            array('isConfigurableInWorkspace' => true, 'isDisplayableInWorkspace' => true)
        );

        $canOpenResRights = true;

        if ($workspace->isPersonal() && !$this->rightsManager->canEditPwsPerm(
            $this->tokenStorage->getToken()
        )) {
            $canOpenResRights = false;
        }

        return $this->templating->render(
            'ClarolineCoreBundle:Tool\workspace\parameters:parameters.html.twig',
            array('workspace' => $workspace, 'tools' => $tools, 'canOpenResRights' => $canOpenResRights)
        );
    }
970556
public function addWorkspace($title)
    {
        $workspaces = $this->getWorkspaces();

        /** @var Workspace $workspace */
        $workspace = $this->getExtensions()->createElement($this, 'app:workspace');
        $workspace->addTitle($title);

        $workspaces[] = $workspace;
        $this->setCachedProperty('workspaces', $workspaces);

        return $workspace;
    }
32625
public function renderToolListAction(Workspace $workspace, $_breadcrumbs)
    {
        //first we add check if some tools will be missing from the navbar and we add them if necessary
        //lets be sure we loaded everything properly because the pathbundle broke something
        $workspace = $this->workspaceManager->getWorkspaceByCode($workspace->getCode());
        $this->toolManager->addMissingWorkspaceTools($workspace);

        if ($_breadcrumbs != null) {
            //for manager.js, id = 0 => "no root".
            if ($_breadcrumbs[0] != 0) {
                $rootId = $_breadcrumbs[0];
            } else {
                $rootId = $_breadcrumbs[1];
            }
            $workspace = $this->resourceManager->getNode($rootId)->getWorkspace();
        }

        $currentRoles = $this->utils->getRoles($this->tokenStorage->getToken());
        //do I need to display every tools.
        $hasManagerAccess = false;
        $managerRole = $this->roleManager->getManagerRole($workspace);

        foreach ($currentRoles as $role) {
            if ($managerRole->getName() === $role) {
                $hasManagerAccess = true;
            }
        }

        if ($this->authorization->isGranted('ROLE_ADMIN')) {
            $hasManagerAccess = true;
        }

        //if manager or admin, show every tools
        if ($hasManagerAccess) {
            $orderedTools = $this->toolManager->getOrderedToolsByWorkspace($workspace);
            $hideToolsMenu = false;
        } else {
            //otherwise only shows the relevant tools
            $orderedTools = $this->toolManager->getOrderedToolsByWorkspaceAndRoles($workspace, $currentRoles);
            $hideToolsMenu = $this->workspaceManager->isToolsMenuHidden($workspace);
        }
        $roleHasAccess = array();
        $workspaceRolesWithAccess = $this->roleManager
            ->getWorkspaceRoleWithToolAccess($workspace);

        foreach ($workspaceRolesWithAccess as $workspaceRole) {
            $roleHasAccess[$workspaceRole->getId()] = $workspaceRole;
        }

        return array(
            'hasManagerAccess' => $hasManagerAccess,
            'orderedTools' => $orderedTools,
            'workspace' => $workspace,
            'roleHasAccess' => $roleHasAccess,
            'hideToolsMenu' => $hideToolsMenu
        );
    }
191217
public function ccxml($projectId)
    {
        /* @var Project $project */
        $project = $this->projectStore->getById($projectId);
        $xml = new \SimpleXMLElement('<Projects/>');

        if (!$project instanceof Project || !$project->getAllowPublicStatus()) {
            return $this->renderXml($xml);
        }

        try {
            $branchList = $this->buildStore->getBuildBranches($projectId);

            if (!$branchList) {
                $branchList = array($project->getBranch());
            }

            foreach ($branchList as $branch) {
                $buildStatusService = new BuildStatusService($branch, $project, $project->getLatestBuild($branch));
                if ($attributes = $buildStatusService->toArray()) {
                    $projectXml = $xml->addChild('Project');
                    foreach ($attributes as $attributeKey => $attributeValue) {
                        $projectXml->addAttribute($attributeKey, $attributeValue);
                    }
                }
            }
        } catch (\Exception $e) {
            $xml = new \SimpleXMLElement('<projects/>');
        }

        return $this->renderXml($xml);
    }
753909
public function render($dataGrid)
    {
        if (null !== $this->request->get('q')) {
            foreach ($this->request->get('q') as $key => $val) {
                $dataGrid->model->where($key, 'like', '%' . $val . '%');
            }
        }

        $options = ['path' => asset(request()->path())];
        if (!$dataGrid->model instanceof Collection) {
            $dataGrid->data = $dataGrid->model->paginate(
                $this->pageItem,
                ['*'],
                $dataGrid->pageName()
            );

            if (null !== $this->request->get('asc')) {
                $dataGrid->model->orderBy($this->request->get('asc'), 'asc');
            }
            if (null !== $this->request->get('desc', 'id')) {
                $dataGrid->model->orderBy($this->request->get('desc', 'id'), 'desc');
            }
        } else {
            $dataGrid->data = $this->paginate(
                $dataGrid->model,
                $this->pageItem,
                null,
                $options
            );
        }

        return view('avored-framework::datagrid.grid')->with('dataGrid', $dataGrid);
    }
442196
public function findGroupsByWorkspaces(array $workspaces, $executeQuery = true)
    {
        $dql = '
            SELECT g
            FROM Claroline\CoreBundle\Entity\Group g
            LEFT JOIN g.roles wr WITH wr IN (
                SELECT pr from Claroline\CoreBundle\Entity\Role pr WHERE pr.type = :type
            )
            LEFT JOIN wr.workspace w
            WHERE w IN (:workspaces)
            ORDER BY g.name
       ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('workspaces', $workspaces);
        $query->setParameter('type', Role::WS_ROLE);

        return $executeQuery ? $query->getResult() : $query;
    }
1167624
public function getParametersByWorkspace(
        Workspace $workspace,
        $executeQuery = true
    )
    {
        return $this->workspaceTeamParamsRepo->findParametersByWorkspace(
            $workspace,
            $executeQuery
        );
    }
175621
public function listCommand()
    {
        $workspaces = $this->workspaceRepository->findAll();

        if ($workspaces->count() === 0) {
            $this->outputLine('No workspaces found.');
            $this->quit(0);
        }

        $tableRows = [];
        $headerRow = ['Name', 'Base Workspace', 'Title', 'Owner', 'Description'];

        foreach ($workspaces as $workspace) {
            $owner = $workspace->getOwner() ? $workspace->getOwner()->getName() : '';
            $tableRows[] = [$workspace->getName(), ($workspace->getBaseWorkspace() ? $workspace->getBaseWorkspace()->getName() : ''), $workspace->getTitle(), $owner, $workspace->getDescription()];
        }
        $this->output->outputTable($tableRows, $headerRow);
    }
160966
public function workspaceEditFormAction(Workspace $workspace)
    {
        $user = $this->tokenStorage->getToken()->getUser();
        $this->checkAccess($workspace);
        $username = is_null($workspace->getCreator()) ? '' : $workspace->getCreator()->getUsername();
        $creationDate = is_null($workspace->getCreationDate()) ? null : $this->utilities->intlDateFormat(
            $workspace->getCreationDate()
        );
        $expDate = is_null($workspace->getEndDate()) ? null : $this->utilities->intlDateFormat(
            $workspace->getEndDate()
        );
        $count = $this->workspaceManager->countUsers($workspace, true);
        $storageUsed = $this->workspaceManager->getUsedStorage($workspace);
        $storageUsed = $this->utilities->formatFileSize($storageUsed);
        $countResources = $this->workspaceManager->countResources($workspace);
        $workspaceAdminTool = $this->toolManager->getAdminToolByName('workspace_management');
        $isAdmin = $this->authorization->isGranted('OPEN', $workspaceAdminTool);

        $form = $this->formFactory->create(
            FormFactory::TYPE_WORKSPACE_EDIT,
            array(
                $username,
                $creationDate,
                $count,
                $storageUsed,
                $countResources,
                $isAdmin,
                $expDate
            ),
            $workspace
        );

        if ($workspace->getSelfRegistration()) {
            $url = $this->router->generate(
                'claro_workspace_subscription_url_generate',
                array('workspace' => $workspace->getId()),
                true
            );
        } else {
            $url = '';
        }

        return array(
            'form' => $form->createView(),
            'workspace' => $workspace,
            'url' => $url,
            'user' => $user,
            'count' => $count
        );
    }
568628
public function block_controls($actions, $blockid = null) {
        global $CFG;
        if (empty($actions)) {
            return '';
        }
        $menu = new action_menu($actions);
        if ($blockid !== null) {
            $menu->set_owner_selector('#'.$blockid);
        }
        $menu->set_constraint('.block-region');
        $menu->attributes['class'] .= ' block-control-actions commands';
        return $this->render($menu);
    }
224063
public String getSpaces(String storeID) throws ResourceException {

        Element spacesElem = new Element("spaces");

        try {
            StorageProvider storage =
                storageProviderFactory.getStorageProvider(storeID);

            Iterator<String> spaces = storage.getSpaces();
            while (spaces.hasNext()) {
                String spaceID = spaces.next();
                Element spaceElem = new Element("space");
                spaceElem.setAttribute("id", spaceID);
                spacesElem.addContent(spaceElem);
            }
        } catch (Exception e) {
            storageProviderFactory.expireStorageProvider(storeID);
            throw new ResourceException("Error attempting to build spaces XML",
                                        e);
        }

        Document doc = new Document(spacesElem);
        XMLOutputter xmlConverter = new XMLOutputter();
        return xmlConverter.outputString(doc);
    }
1173269
public function serialize(WorkspaceTeamParameters $parameters)
    {
        $serialized = [
            'id' => $parameters->getUuid(),
            'selfRegistration' => $parameters->isSelfRegistration(),
            'selfUnregistration' => $parameters->isSelfUnregistration(),
            'publicDirectory' => $parameters->isPublic(),
            'deletableDirectory' => $parameters->isDirDeletable(),
            'allowedTeams' => $parameters->getMaxTeams(),
            'workspace' => [
              'uuid' => $parameters->getWorkspace()->getUuid(),
            ],
        ];

        return $serialized;
    }
823355
protected function getNodeDataByNodeTypeAndWorkspace($nodeType, $workspaceName)
    {
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();

        $queryBuilder->select('n')
            ->distinct()
            ->from(NodeData::class, 'n')
            ->where('n.nodeType = :nodeType')
            ->andWhere('n.workspace = :workspace')
            ->andWhere('n.movedTo IS NULL OR n.removed = :removed')
            ->setParameter('nodeType', $nodeType)
            ->setParameter('workspace', $workspaceName)
            ->setParameter('removed', false, \PDO::PARAM_BOOL);
        return $queryBuilder->getQuery()->getResult();
    }
114126
public function removeUndefinedProperties($workspaceName, /** @noinspection PhpUnusedParameterInspection */$dryRun, NodeType $nodeType = null)
    {
        $this->dispatch(self::EVENT_NOTICE, 'Checking for undefined properties ...');

        /** @var \Neos\ContentRepository\Domain\Model\Workspace $workspace */
        $workspace = $this->workspaceRepository->findByIdentifier($workspaceName);

        $nodesWithUndefinedPropertiesNodes = [];
        $undefinedPropertiesCount = 0;
        $nodes = $nodeType !== null ? $this->getNodeDataByNodeTypeAndWorkspace($nodeType, $workspaceName) : $this->nodeDataRepository->findByWorkspace($workspace);
        foreach ($nodes as $nodeData) {
            try {
                /** @var NodeData $nodeData */
                if ($nodeData->getNodeType()->getName() === 'unstructured') {
                    continue;
                }
                $context = $this->nodeFactory->createContextMatchingNodeData($nodeData);
                $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
                if (!$node instanceof NodeInterface) {
                    continue;
                }
                $nodeType = $node->getNodeType();

                $nodeTypePropertyNames = array_keys($nodeType->getProperties());
                $undefinedProperties = [];

                foreach ($node->getProperties() as $propertyName => $propertyValue) {
                    if (!in_array($propertyName, $nodeTypePropertyNames)) {
                        $undefinedProperties[] = $propertyName;
                    }
                }
                if ($undefinedProperties !== []) {
                    $nodesWithUndefinedPropertiesNodes[$node->getIdentifier()] = ['node' => $node, 'undefinedProperties' => $undefinedProperties];
                    foreach ($undefinedProperties as $undefinedProperty) {
                        $undefinedPropertiesCount++;
                        $this->dispatch(self::EVENT_NOTICE, sprintf('Found undefined property named "<i>%s</i>" in "<i>%s</i>" (<i>%s</i>)', $undefinedProperty, $node->getPath(), $node->getNodeType()->getName()));
                    }
                }
            } /** @noinspection PhpRedundantCatchClauseInspection */ catch (NodeTypeNotFoundException $exception) {
                $this->dispatch(self::EVENT_NOTICE, sprintf('Skipped undefined node type in "%s"', $nodeData->getPath()));
            }
        }

        if ($undefinedPropertiesCount > 0) {
            $taskDescription = sprintf('Remove <i>%d</i> undefined propert%s.', $undefinedPropertiesCount, $undefinedPropertiesCount > 1 ? 'ies' : 'y');
            $taskClosure = function () use ($nodesWithUndefinedPropertiesNodes) {
                foreach ($nodesWithUndefinedPropertiesNodes as $nodesWithUndefinedPropertiesNode) {
                    /** @var NodeInterface $node */
                    $node = $nodesWithUndefinedPropertiesNode['node'];
                    foreach ($nodesWithUndefinedPropertiesNode['undefinedProperties'] as $undefinedProperty) {
                        if ($node->hasProperty($undefinedProperty)) {
                            $node->removeProperty($undefinedProperty);
                        }
                    }
                }
            };
            $taskRequiresConfirmation = true;
            $this->dispatch(self::EVENT_TASK, $taskDescription, $taskClosure, $taskRequiresConfirmation);
        }

        $this->persistenceManager->persistAll();
    }
415602
public function serialize(Workspace $workspace)
    {
        $serialized = $this->serializer->serialize($workspace, [Options::REFRESH_UUID]);

        //if roles duplicatas, remove them
        $roles = $serialized['roles'];

        foreach ($roles as $role) {
            $uniques[$role['translationKey']] = ['type' => $role['type']];
        }

        $roles = [];
        foreach ($uniques as $key => $val) {
            $val['translationKey'] = $key;
            $roles[] = $val;
        }

        $serialized['roles'] = $roles;

        //we want to load  the ressources first
        $ot = $workspace->getOrderedTools()->toArray();

        $idx = 0;

        foreach ($ot as $key => $tool) {
            if ('resource_manager' === $tool->getName()) {
                $idx = $key;
            }
        }

        $first = $ot[$idx];
        unset($ot[$idx]);
        array_unshift($ot, $first);

        $serialized['orderedTools'] = array_map(function (OrderedTool $tool) {
            $data = $this->ots->serialize($tool, [Options::SERIALIZE_TOOL, Options::REFRESH_UUID]);

            return $data;
        }, $ot);

        return $serialized;
    }
308618
private function serializeTools(Role $role, $workspaceId)
    {
        $tools = [];
        $workspace = $this->om->getRepository(Workspace::class)->findBy(['uuid' => $workspaceId]);
        $orderedTools = $this->orderedToolRepo->findBy(['workspace' => $workspace]);

        foreach ($orderedTools as $orderedTool) {
            $toolRights = $this->toolRightsRepo->findBy(['role' => $role, 'orderedTool' => $orderedTool], ['id' => 'ASC']);
            $mask = 0 < count($toolRights) ? $toolRights[0]->getMask() : 0;
            $toolName = $orderedTool->getTool()->getName();
            $tools[$toolName] = [];

            foreach (ToolMaskDecoder::$defaultActions as $action) {
                $actionValue = ToolMaskDecoder::$defaultValues[$action];
                $tools[$toolName][$action] = $mask & $actionValue ? true : false;
            }
        }

        return count($tools) > 0 ? $tools : new \stdClass();
    }
72593
public function userSearchInWorkspaceAction($workspaceId, $search)
    {
        $workspace = $this->workspaceManager->getWorkspaceById($workspaceId);
        $users = $this->userManager->getAllUsersByWorkspaceAndName($workspace, $search, 1, 10);
        $usersArray = $this->userManager->toArrayForPicker($users);

        return new JsonResponse($usersArray);
    }