main/core/Manager/ExporterManager.php
private function exportUsers($exporter, array $extra)
    {
        $dontExport = ['password', 'description', 'salt', 'plainPassword'];

        if (isset($extra['workspace'])) {
            $users = $this->om->getRepository('ClarolineCoreBundle:User')
                ->findAllWithFacetsByWorkspace($extra['workspace']);
        } else {
            $users = $this->om->getRepository('ClarolineCoreBundle:User')
                ->findAllWithFacets();
        }

        $fieldsFacets = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacet')->findAll();
        $fields = $this->getExportableFields('Claroline\CoreBundle\Entity\User');

        foreach ($fields as $field) {
            if (in_array($field, $dontExport)) {
                unset($fields[array_search($field, $fields)]);
            }
        }

        $data = [];
        $fieldFacetsName = [];

        foreach ($fieldsFacets as $fieldsFacet) {
            $fieldFacetsName[] = $fieldsFacet->getName();
        }

        foreach ($users as $user) {
            $data[$user->getId()] = [];
            foreach ($fields as $field) {
                $data[$user->getId()][$field] = $this->formatValue($this->getValueFromObject($user, $field));
            }

            foreach ($fieldFacetsName as $fieldFacetName) {
                $found = false;
                foreach ($user->getFieldsFacetValue() as $fieldFacetValue) {
                    if ($fieldFacetValue->getFieldFacet()->getName() === $fieldFacetName) {
                        $found = true;
                        $data[$user->getId()][$fieldFacetName] = $this->formatValue($fieldFacetValue->getValue());
                    }
                }

                if (!$found) {
                    $data[$user->getId()][$fieldFacetName] = null;
                }
            }
        }

        foreach ($fieldFacetsName as $fieldFacetName) {
            $fields[] = $fieldFacetName;
        }

        return $exporter->export($fields, $data);
    }
private function exportUsers($exporter, array $extra)
    {
        $dontExport = ['password', 'description', 'salt', 'plainPassword'];

        if (isset($extra['workspace'])) {
            $users = $this->om->getRepository('ClarolineCoreBundle:User')
                ->findAllWithFacetsByWorkspace($extra['workspace']);
        } else {
            $users = $this->om->getRepository('ClarolineCoreBundle:User')
                ->findAllWithFacets();
        }

        $fieldsFacets = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacet')->findAll();
        $fields = $this->getExportableFields('Claroline\CoreBundle\Entity\User');

        foreach ($fields as $field) {
            if (in_array($field, $dontExport)) {
                unset($fields[array_search($field, $fields)]);
            }
        }

        $data = [];
        $fieldFacetsName = [];

        foreach ($fieldsFacets as $fieldsFacet) {
            $fieldFacetsName[] = $fieldsFacet->getName();
        }

        foreach ($users as $user) {
            $data[$user->getId()] = [];
            foreach ($fields as $field) {
                $data[$user->getId()][$field] = $this->formatValue($this->getValueFromObject($user, $field));
            }

            foreach ($fieldFacetsName as $fieldFacetName) {
                $found = false;
                foreach ($user->getFieldsFacetValue() as $fieldFacetValue) {
                    if ($fieldFacetValue->getFieldFacet()->getName() === $fieldFacetName) {
                        $found = true;
                        $data[$user->getId()][$fieldFacetName] = $this->formatValue($fieldFacetValue->getValue());
                    }
                }

                if (!$found) {
                    $data[$user->getId()][$fieldFacetName] = null;
                }
            }
        }

        foreach ($fieldFacetsName as $fieldFacetName) {
            $fields[] = $fieldFacetName;
        }

        return $exporter->export($fields, $data);
    }
private function exportUsers ( $ exporter , array $ extra ) { $ dontExport = [ 'password' , 'description' , 'salt' , 'plainPassword' ] ; if ( isset ( $ extra [ 'workspace' ] ) ) { $ users = $ this -> om -> getRepository ( 'ClarolineCoreBundle:User' ) -> findAllWithFacetsByWorkspace ( $ extra [ 'workspace' ] ) ; } else { $ users = $ this -> om -> getRepository ( 'ClarolineCoreBundle:User' ) -> findAllWithFacets ( ) ; } $ fieldsFacets = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Facet\FieldFacet' ) -> findAll ( ) ; $ fields = $ this -> getExportableFields ( 'Claroline\CoreBundle\Entity\User' ) ; foreach ( $ fields as $ field ) { if ( in_array ( $ field , $ dontExport ) ) { unset ( $ fields [ array_search ( $ field , $ fields ) ] ) ; } } $ data = [ ] ; $ fieldFacetsName = [ ] ; foreach ( $ fieldsFacets as $ fieldsFacet ) { $ fieldFacetsName [ ] = $ fieldsFacet -> getName ( ) ; } foreach ( $ users as $ user ) { $ data [ $ user -> getId ( ) ] = [ ] ; foreach ( $ fields as $ field ) { $ data [ $ user -> getId ( ) ] [ $ field ] = $ this -> formatValue ( $ this -> getValueFromObject ( $ user , $ field ) ) ; } foreach ( $ fieldFacetsName as $ fieldFacetName ) { $ found = false ; foreach ( $ user -> getFieldsFacetValue ( ) as $ fieldFacetValue ) { if ( $ fieldFacetValue -> getFieldFacet ( ) -> getName ( ) === $ fieldFacetName ) { $ found = true ; $ data [ $ user -> getId ( ) ] [ $ fieldFacetName ] = $ this -> formatValue ( $ fieldFacetValue -> getValue ( ) ) ; } } if ( ! $ found ) { $ data [ $ user -> getId ( ) ] [ $ fieldFacetName ] = null ; } } } foreach ( $ fieldFacetsName as $ fieldFacetName ) { $ fields [ ] = $ fieldFacetName ; } return $ exporter -> export ( $ fields , $ data ) ; }
We add the facets to the user export.
We add the facets to the user export .