idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
53,400
|
private function getEntitySetter ( $ entity , $ property ) { $ setter = 'set' . ucfirst ( $ property ) ; if ( ! method_exists ( $ entity , $ setter ) ) { throw new \ LogicException ( "Entity has no setter for property `{$property}`." ) ; } return $ setter ; }
|
Gets the correct setter name for an entity property .
|
53,401
|
public function getStep ( $ uuid ) { foreach ( $ this -> steps as $ step ) { if ( $ step -> getUuid ( ) === $ uuid ) { return $ step ; } } return null ; }
|
Gets a step by its UUID .
|
53,402
|
public function getQuestion ( $ uuid ) { foreach ( $ this -> steps as $ step ) { $ questions = $ step -> getQuestions ( ) ; foreach ( $ questions as $ question ) { if ( $ question -> getUuid ( ) === $ uuid ) { return $ question ; } } } return null ; }
|
Gets a question by its UUID .
|
53,403
|
public function addStep ( Step $ step ) { if ( ! $ this -> steps -> contains ( $ step ) ) { $ step -> setOrder ( $ this -> steps -> count ( ) ) ; $ this -> steps -> add ( $ step ) ; $ step -> setExercise ( $ this ) ; } return $ this ; }
|
Adds a step to the Exercise .
|
53,404
|
public function removeStep ( Step $ step ) { if ( $ this -> steps -> contains ( $ step ) ) { $ this -> steps -> removeElement ( $ step ) ; } return $ this ; }
|
Removes a Step from the Exercise .
|
53,405
|
public function deserialize ( $ data , Resource $ resource = null ) { if ( empty ( $ resource ) ) { $ resource = new Resource ( ) ; } if ( isset ( $ data [ 'resourceType' ] ) && isset ( $ data [ 'resourceType' ] [ 'name' ] ) ) { $ resourceType = $ this -> resourceTypeRepo -> findOneBy ( [ 'name' => $ data [ 'resourceType' ] [ 'name' ] ] ) ; $ resource -> setResourceType ( $ resourceType ) ; } if ( isset ( $ data [ 'name' ] ) ) { $ resource -> setName ( $ data [ 'name' ] ) ; } if ( isset ( $ data [ 'maxTimeReservation' ] ) ) { $ resource -> setMaxTimeReservation ( $ data [ 'maxTimeReservation' ] ) ; } if ( isset ( $ data [ 'description' ] ) ) { $ resource -> setDescription ( $ data [ 'description' ] ) ; } if ( isset ( $ data [ 'localization' ] ) ) { $ resource -> setLocalisation ( $ data [ 'localization' ] ) ; } if ( isset ( $ data [ 'quantity' ] ) ) { $ resource -> setQuantity ( $ data [ 'quantity' ] ) ; } if ( isset ( $ data [ 'color' ] ) ) { $ resource -> setColor ( $ data [ 'color' ] ) ; } if ( isset ( $ data [ 'organizations' ] ) ) { $ this -> deserializeOrganizations ( $ resource , $ data [ 'organizations' ] ) ; } return $ resource ; }
|
Deserializes data into a Resource entity .
|
53,406
|
private function copy ( $ source , $ target ) { $ files = $ this -> listFiles ( $ source , $ target ) ; foreach ( $ files as $ newPath => $ oldPath ) { if ( ! file_exists ( $ newPath ) ) { if ( is_dir ( $ oldPath ) ) { mkdir ( $ newPath , 0755 , true ) ; } else { copy ( $ oldPath , $ newPath ) ; } } } }
|
sf2 doesn t handle directory copies ... so we copy the directory content here
|
53,407
|
public function persistObjective ( Objective $ objective ) { $ this -> om -> persist ( $ objective ) ; $ this -> om -> flush ( ) ; return $ objective ; }
|
Persists a learning objective .
|
53,408
|
public function loadUserObjectiveCompetencies ( Objective $ objective , User $ user ) { $ competencies = $ this -> doLoadObjectiveCompetencies ( $ objective , false ) ; $ competenciesWithProgress = [ ] ; $ competencyIds = [ ] ; $ this -> competencyManager -> walkCollection ( $ competencies , function ( $ competency ) use ( & $ competencyIds ) { if ( isset ( $ competency [ 'id' ] ) ) { $ competencyIds [ ] = isset ( $ competency [ 'originalId' ] ) ? $ competency [ 'originalId' ] : $ competency [ 'id' ] ; } return $ competency ; } ) ; $ competencyProgresses = $ this -> competencyProgressRepo -> findByUserAndCompetencyIds ( $ user , $ competencyIds ) ; $ competencyProgressesById = [ ] ; foreach ( $ competencyProgresses as $ competencyProgress ) { $ competencyProgressesById [ $ competencyProgress -> getCompetency ( ) -> getId ( ) ] = $ competencyProgress ; } foreach ( $ competencies as $ competency ) { $ competenciesWithProgress [ ] = $ this -> competencyManager -> walkCollection ( $ competency , function ( $ collection ) use ( $ user , $ competencyProgressesById ) { if ( isset ( $ collection [ 'id' ] ) ) { $ id = isset ( $ collection [ 'originalId' ] ) ? $ collection [ 'originalId' ] : $ collection [ 'id' ] ; if ( isset ( $ competencyProgressesById [ $ id ] ) ) { $ progress = $ competencyProgressesById [ $ id ] ; $ collection [ 'progress' ] = $ progress -> getPercentage ( ) ; $ collection [ 'latestResource' ] = $ progress -> getResourceId ( ) ; if ( $ level = $ progress -> getLevel ( ) ) { $ collection [ 'userLevel' ] = $ level -> getName ( ) ; $ collection [ 'userLevelValue' ] = $ level -> getValue ( ) ; } } } return $ collection ; } ) ; } return $ competenciesWithProgress ; }
|
Returns an array representation of all the competencies associated with a user objective including sub - competencies and progress data at each level .
|
53,409
|
public function deleteObjective ( Objective $ objective ) { $ this -> om -> remove ( $ objective ) ; $ this -> om -> flush ( ) ; }
|
Deletes an objective .
|
53,410
|
public function linkCompetency ( Objective $ objective , Competency $ competency , Level $ level ) { $ link = $ this -> objectiveCompetencyRepo -> findOneBy ( [ 'competency' => $ competency , 'objective' => $ objective , ] ) ; if ( $ link ) { return false ; } $ framework = $ this -> competencyRepo -> findOneBy ( [ 'root' => $ competency -> getRoot ( ) ] ) ; if ( $ level -> getScale ( ) !== $ framework -> getScale ( ) ) { throw new \ LogicException ( 'Objective level must belong to the root competency scale' ) ; } $ link = new ObjectiveCompetency ( ) ; $ link -> setObjective ( $ objective ) ; $ link -> setCompetency ( $ competency ) ; $ link -> setLevel ( $ level ) ; $ link -> setFramework ( $ framework ) ; $ this -> om -> persist ( $ link ) ; $ this -> om -> flush ( ) ; $ this -> progressManager -> recomputeObjectiveProgress ( $ objective ) ; $ competency = $ this -> competencyManager -> loadCompetency ( $ competency ) ; $ competency [ 'id' ] = $ link -> getId ( ) ; $ competency [ 'framework' ] = $ framework -> getName ( ) ; $ competency [ 'level' ] = $ level -> getName ( ) ; return $ competency ; }
|
Creates an association between an objective and a competency with an expected level . Returns a full array representation of the newly associated competency if the link doesn t already exist . Otherwise returns false .
|
53,411
|
public function deleteCompetencyLink ( ObjectiveCompetency $ link ) { $ this -> om -> remove ( $ link ) ; $ this -> om -> flush ( ) ; $ this -> progressManager -> recomputeObjectiveProgress ( $ link -> getObjective ( ) ) ; }
|
Deletes a link between an objective and a competency .
|
53,412
|
public function assignObjective ( Objective $ objective , $ subject ) { $ target = $ this -> getSubjectType ( $ subject ) ; $ hasMethod = "has{$target}" ; $ addMethod = "add{$target}" ; if ( $ objective -> { $ hasMethod } ( $ subject ) ) { return false ; } $ objective -> { $ addMethod } ( $ subject ) ; $ this -> om -> flush ( ) ; $ this -> progressManager -> recomputeUserProgress ( $ subject ) ; return true ; }
|
Assigns an objective to a user or a group . If the objective has already been assigned returns false . Otherwise returns true .
|
53,413
|
public function loadSubjectObjectives ( $ subject ) { $ target = $ this -> getSubjectType ( $ subject ) ; $ repoMethod = "findBy{$target}" ; return $ this -> objectiveRepo -> { $ repoMethod } ( $ subject ) ; }
|
Returns an array representation of the objectives assigned to a user or a group .
|
53,414
|
public function removeGroupObjective ( Objective $ objective , Group $ group ) { $ objective -> removeGroup ( $ group ) ; $ this -> om -> flush ( ) ; $ this -> progressManager -> recomputeUserProgress ( $ group ) ; }
|
Removes a group objective .
|
53,415
|
public function deserialize ( $ data , PairQuestion $ pairQuestion = null , array $ options = [ ] ) { if ( empty ( $ pairQuestion ) ) { $ pairQuestion = new PairQuestion ( ) ; } if ( ! empty ( $ data [ 'penalty' ] ) || 0 === $ data [ 'penalty' ] ) { $ pairQuestion -> setPenalty ( $ data [ 'penalty' ] ) ; } $ this -> sipe ( 'random' , 'setShuffle' , $ data , $ pairQuestion ) ; $ this -> deserializeItems ( $ pairQuestion , $ data [ 'items' ] , $ options ) ; $ this -> deserializeSolutions ( $ pairQuestion , $ data [ 'solutions' ] ) ; return $ pairQuestion ; }
|
Converts raw data into a Pair question entity .
|
53,416
|
public function postLoad ( Item $ item , LifecycleEventArgs $ event ) { $ type = $ this -> itemDefinitions -> getConvertedType ( $ item -> getMimeType ( ) ) ; $ definition = $ this -> itemDefinitions -> get ( $ type ) ; $ repository = $ event -> getEntityManager ( ) -> getRepository ( $ definition -> getEntityClass ( ) ) ; $ typeEntity = $ repository -> findOneBy ( [ 'question' => $ item , ] ) ; if ( ! empty ( $ typeEntity ) ) { $ item -> setInteraction ( $ typeEntity ) ; } }
|
Loads the entity that holds the item type data when an Item is loaded .
|
53,417
|
public function prePersist ( Item $ item , LifecycleEventArgs $ event ) { $ interaction = $ item -> getInteraction ( ) ; if ( null !== $ interaction ) { $ event -> getEntityManager ( ) -> persist ( $ interaction ) ; } }
|
Persists the entity that holds the item type data when an Item is persisted .
|
53,418
|
public function preRemove ( Item $ item , LifecycleEventArgs $ event ) { $ interaction = $ item -> getInteraction ( ) ; if ( null !== $ interaction ) { $ event -> getEntityManager ( ) -> remove ( $ interaction ) ; } }
|
Deletes the entity that holds the item type data when an Item is deleted .
|
53,419
|
public function setObjectManager ( ObjectManager $ om , $ rootDir ) { $ this -> om = $ om ; $ this -> rootDir = $ rootDir . '/..' ; $ this -> baseUri = 'https://github.com/claroline/Distribution/tree/master' ; }
|
Injects Serializer service .
|
53,420
|
public function add ( $ serializer ) { if ( ! method_exists ( $ serializer , 'serialize' ) ) { throw new \ Exception ( 'The serializer ' . get_class ( $ serializer ) . ' must implement the method serialize' ) ; } $ this -> serializers [ ] = $ serializer ; }
|
Registers a new serializer .
|
53,421
|
public function getSerializerHandledClass ( $ serializer ) { if ( method_exists ( $ serializer , 'getClass' ) ) { return $ serializer -> getClass ( ) ; } else { $ p = new \ ReflectionParameter ( [ get_class ( $ serializer ) , 'serialize' ] , 0 ) ; return $ p -> getClass ( ) -> getName ( ) ; } }
|
Returns the class handled by the serializer .
|
53,422
|
public function get ( $ object ) { if ( is_string ( $ object ) ) { if ( $ meta = $ this -> om -> getClassMetaData ( $ object ) ) { $ object = $ meta -> name ; } } foreach ( $ this -> serializers as $ serializer ) { $ className = $ this -> getSerializerHandledClass ( $ serializer ) ; if ( $ object instanceof $ className || $ object === $ className ) { return $ serializer ; } } $ className = is_object ( $ object ) ? get_class ( $ object ) : $ object ; throw new \ Exception ( sprintf ( 'No serializer found for class "%s" Maybe you forgot to add the "claroline.serializer" tag to your serializer.' , is_string ( $ object ) ? $ object : get_class ( $ object ) ) ) ; }
|
Gets a registered serializer instance .
|
53,423
|
public function has ( $ object ) { foreach ( $ this -> serializers as $ serializer ) { $ className = $ this -> getSerializerHandledClass ( $ serializer ) ; if ( $ object instanceof $ className || $ object === $ className ) { return true ; } } false ; }
|
Check if serializer instance exists .
|
53,424
|
public function getIdentifiers ( $ class ) { $ schema = $ this -> getSchema ( $ class ) ; if ( isset ( $ schema -> claroline ) ) { return $ schema -> claroline -> ids ; } return [ ] ; }
|
Get the identifier list from the json schema .
|
53,425
|
public function getSchema ( $ class ) { $ serializer = $ this -> get ( $ class ) ; if ( method_exists ( $ serializer , 'getSchema' ) ) { $ url = $ serializer -> getSchema ( ) ; $ path = explode ( '/' , $ url ) ; $ absolutePath = $ this -> rootDir . '/vendor/claroline/distribution/' . $ path [ 1 ] . '/' . $ path [ 2 ] . '/Resources/schemas/' . $ path [ 3 ] ; return $ this -> loadSchema ( $ absolutePath ) ; } }
|
Gets the json schema of a class .
|
53,426
|
public function loadSchema ( $ path ) { $ schema = Utils :: LoadJsonFromFile ( $ path ) ; $ hook = function ( $ uri ) { return $ this -> resolveRef ( $ uri ) ; } ; $ resolver = new Resolver ( ) ; $ resolver -> setPreFetchHook ( $ hook ) ; $ walker = new Walker ( new Registry ( ) , $ resolver ) ; $ schema = $ walker -> resolveReferences ( $ schema , new Uri ( '' ) ) ; return $ walker -> parseSchema ( $ schema , new Context ( ) ) ; }
|
Loads a json schema .
|
53,427
|
public function prepareRightsArray ( array $ rights , array $ roles ) { $ preparedRightsArray = [ ] ; foreach ( $ rights as $ key => $ right ) { $ preparedRights = $ right ; $ preparedRights [ 'role' ] = $ roles [ $ key ] ; $ preparedRightsArray [ ] = $ preparedRights ; } return $ preparedRightsArray ; }
|
Appends a role list to a right array .
|
53,428
|
public function addFavourite ( Workspace $ workspace , User $ user ) { $ favourite = new WorkspaceFavourite ( ) ; $ favourite -> setWorkspace ( $ workspace ) ; $ favourite -> setUser ( $ user ) ; $ this -> om -> persist ( $ favourite ) ; $ this -> om -> flush ( ) ; }
|
Adds a favourite workspace .
|
53,429
|
public function removeFavourite ( WorkspaceFavourite $ favourite ) { $ this -> om -> remove ( $ favourite ) ; $ this -> om -> flush ( ) ; }
|
Removes a favourite workspace .
|
53,430
|
public function getAccesses ( TokenInterface $ token , array $ workspaces , $ toolName = null , $ action = 'open' , $ orderedToolType = 0 ) { $ userRoleNames = $ this -> sut -> getRoles ( $ token ) ; $ accesses = [ ] ; if ( in_array ( 'ROLE_ADMIN' , $ userRoleNames ) ) { foreach ( $ workspaces as $ workspace ) { $ accesses [ $ workspace -> getId ( ) ] = true ; } return $ accesses ; } $ hasAllAccesses = true ; $ workspacesWithoutManagerRole = [ ] ; foreach ( $ workspaces as $ workspace ) { if ( in_array ( 'ROLE_WS_MANAGER_' . $ workspace -> getUuid ( ) , $ userRoleNames ) ) { $ accesses [ $ workspace -> getId ( ) ] = true ; } else { $ accesses [ $ workspace -> getId ( ) ] = $ hasAllAccesses = false ; $ workspacesWithoutManagerRole [ ] = $ workspace ; } } if ( ! $ hasAllAccesses ) { $ em = $ this -> container -> get ( 'doctrine.orm.entity_manager' ) ; $ openWsIds = $ em -> getRepository ( 'ClarolineCoreBundle:Workspace\Workspace' ) -> findOpenWorkspaceIds ( $ userRoleNames , $ workspacesWithoutManagerRole , $ toolName , $ action , $ orderedToolType ) ; foreach ( $ openWsIds as $ idRow ) { $ accesses [ $ idRow [ 'id' ] ] = true ; } } foreach ( $ workspaces as $ workspace ) { if ( $ workspace -> isPersonal ( ) && $ toolName ) { $ pwc = $ this -> container -> get ( 'claroline.manager.tool_manager' ) -> getPersonalWorkspaceToolConfigs ( ) ; $ canOpen = false ; foreach ( $ pwc as $ conf ) { if ( ! $ toolName ) { $ toolName = 'home' ; } if ( $ conf -> getTool ( ) -> getName ( ) === $ toolName && in_array ( $ conf -> getRole ( ) -> getName ( ) , $ workspace -> getCreator ( ) -> getRoles ( ) ) && ( $ conf -> getMask ( ) & 1 ) ) { $ canOpen = true ; } } if ( ! $ canOpen ) { $ accesses [ $ workspace -> getId ( ) ] = false ; } } } return $ accesses ; }
|
Returns the accesses rights of a given token for a set of workspaces . If a tool name is passed in the check will be limited to that tool otherwise workspaces with at least one accessible tool will be considered open . Access to any tool is always granted to platform administrators and workspace managers .
|
53,431
|
public function getStorageDirectory ( Workspace $ workspace ) { $ ds = DIRECTORY_SEPARATOR ; return $ this -> container -> getParameter ( 'claroline.param.files_directory' ) . $ ds . 'WORKSPACE_' . $ workspace -> getId ( ) ; }
|
Get the workspace storage directory .
|
53,432
|
public function getUsedStorage ( Workspace $ workspace ) { $ dir = $ this -> getStorageDirectory ( $ workspace ) ; $ size = 0 ; if ( ! is_dir ( $ dir ) ) { return $ size ; } foreach ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ dir ) ) as $ file ) { $ size += $ file -> getSize ( ) ; } return $ size ; }
|
Get the current used storage in a workspace .
|
53,433
|
public function bindWorkspaceToOrganization ( ) { $ limit = 250 ; $ offset = 0 ; $ organizationManager = $ this -> container -> get ( 'claroline.manager.organization.organization_manager' ) ; $ this -> log ( 'Add organizations to workspaces...' ) ; $ this -> om -> startFlushSuite ( ) ; $ countWorkspaces = $ this -> om -> count ( 'ClarolineCoreBundle:Workspace\Workspace' ) ; while ( $ offset < $ countWorkspaces ) { $ workspaces = $ this -> workspaceRepo -> findBy ( [ ] , null , $ limit , $ offset ) ; $ default = $ organizationManager -> getDefault ( ) ; $ this -> om -> merge ( $ default ) ; foreach ( $ workspaces as $ workspace ) { if ( 0 === count ( $ workspace -> getOrganizations ( ) ) ) { $ this -> log ( 'Add default organization for workspace ' . $ workspace -> getCode ( ) ) ; $ workspace -> addOrganization ( $ default ) ; $ this -> om -> persist ( $ workspace ) ; } else { $ this -> log ( 'Organization already exists for workspace ' . $ workspace -> getCode ( ) ) ; } } $ this -> log ( "Flushing... [UOW = {$this->om->getUnitOfWork()->size()}]" ) ; $ this -> om -> forceFlush ( ) ; $ this -> om -> clear ( ) ; $ offset += $ limit ; } $ this -> om -> endFlushSuite ( ) ; }
|
This method will bind each workspaces that don t already have an organization to the default one .
|
53,434
|
public function copyFromCode ( Workspace $ workspace , $ code ) { if ( $ this -> logger ) { $ this -> container -> get ( 'claroline.api.serializer' ) -> setLogger ( $ this -> logger ) ; } $ newWorkspace = new Workspace ( ) ; $ newWorkspace -> setCode ( $ code ) ; $ newWorkspace -> setName ( $ code ) ; $ this -> copy ( $ workspace , $ newWorkspace ) ; return $ newWorkspace ; }
|
used for cli copy debug tool
|
53,435
|
public function copy ( Workspace $ workspace , Workspace $ newWorkspace , $ model = false ) { $ transferManager = $ this -> container -> get ( 'claroline.manager.workspace.transfer' ) ; $ fileBag = new FileBag ( ) ; $ data = $ transferManager -> serialize ( $ workspace ) ; $ data = $ transferManager -> exportFiles ( $ data , $ fileBag , $ workspace ) ; if ( $ this -> logger ) { $ transferManager -> setLogger ( $ this -> logger ) ; } if ( $ newWorkspace -> getCode ( ) ) { unset ( $ data [ 'code' ] ) ; } if ( $ newWorkspace -> getName ( ) ) { unset ( $ data [ 'name' ] ) ; } $ options = [ Options :: LIGHT_COPY , Options :: REFRESH_UUID ] ; $ workspace = $ transferManager -> deserialize ( $ data , $ newWorkspace , $ options , $ fileBag ) ; $ workspace -> setIsModel ( $ model ) ; $ managerRole = $ this -> roleManager -> getManagerRole ( $ workspace ) ; if ( $ managerRole && $ workspace -> getCreator ( ) ) { $ user = $ workspace -> getCreator ( ) ; $ user -> addRole ( $ managerRole ) ; $ this -> om -> persist ( $ user ) ; } $ root = $ this -> resourceManager -> getWorkspaceRoot ( $ workspace ) ; if ( $ root ) { $ this -> resourceManager -> createRights ( $ root ) ; } $ this -> om -> persist ( $ workspace ) ; $ this -> om -> flush ( ) ; return $ workspace ; }
|
Copies a Workspace .
|
53,436
|
public function getManagers ( Workspace $ workspace ) { $ roleManager = $ this -> roleManager -> getManagerRole ( $ workspace ) ; return $ this -> userRepo -> findUsersByRolesIncludingGroups ( [ $ roleManager ] ) ; }
|
Retrieves the managers list for a workspace .
|
53,437
|
public function cleanRecentWorkspaces ( ) { $ this -> log ( 'Cleaning recent workspaces entries that are older than six months' ) ; $ recentWorkspaceRepo = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Workspace\WorkspaceRecent' ) ; $ recentWorkspaceRepo -> removeAllEntriesBefore ( new \ DateTime ( '-6 months' ) ) ; }
|
Clean all recent workspaces that are more than 6 months old
|
53,438
|
public function favouriteToggleAction ( User $ user , Request $ request ) { $ nodes = $ this -> decodeIdsString ( $ request , 'Claroline\CoreBundle\Entity\Resource\ResourceNode' ) ; $ this -> manager -> toggleFavourites ( $ user , $ nodes ) ; return new JsonResponse ( null , 204 ) ; }
|
Creates or deletes favourite resources .
|
53,439
|
public function share ( array $ shareRequest , User $ user ) { $ errors = $ this -> validateShareRequest ( $ shareRequest ) ; if ( count ( $ errors ) > 0 ) { throw new InvalidDataException ( 'Share request is not valid' , $ errors ) ; } $ adminRights = isset ( $ shareRequest [ 'adminRights' ] ) && $ shareRequest [ 'adminRights' ] ; $ questionRepo = $ this -> om -> getRepository ( 'UJMExoBundle:Item\Item' ) ; $ questions = $ questionRepo -> findByUuids ( $ shareRequest [ 'questions' ] ) ; $ userRepo = $ this -> om -> getRepository ( 'ClarolineCoreBundle:User' ) ; $ users = $ userRepo -> findByIds ( $ shareRequest [ 'users' ] ) ; foreach ( $ questions as $ question ) { if ( $ this -> itemManager -> canEdit ( $ question , $ user ) ) { $ sharedWith = $ this -> om -> getRepository ( 'UJMExoBundle:Item\Shared' ) -> findBy ( [ 'question' => $ question ] ) ; foreach ( $ users as $ user ) { $ shared = $ this -> getSharedForUser ( $ user , $ sharedWith ) ; if ( empty ( $ shared ) ) { $ shared = new Shared ( ) ; $ shared -> setQuestion ( $ question ) ; $ shared -> setUser ( $ user ) ; } $ shared -> setAdminRights ( $ adminRights ) ; $ this -> om -> persist ( $ shared ) ; } } } $ this -> om -> flush ( ) ; }
|
Shares a list of question to users .
|
53,440
|
private function getSharedForUser ( User $ user , array $ shared ) { $ userLink = null ; foreach ( $ shared as $ shareLink ) { if ( $ shareLink -> getUser ( ) === $ user ) { $ userLink = $ shareLink ; break ; } } return $ userLink ; }
|
Gets an existing share link for a user in the share list of the question .
|
53,441
|
private function validateShareRequest ( array $ shareRequest ) { $ errors = [ ] ; if ( empty ( $ shareRequest [ 'questions' ] ) || ! is_array ( $ shareRequest [ 'questions' ] ) ) { $ errors [ ] = [ 'path' => '/questions' , 'message' => 'should be a list of question ids' , ] ; } if ( empty ( $ shareRequest [ 'users' ] ) || ! is_array ( $ shareRequest [ 'users' ] ) ) { $ errors [ ] = [ 'path' => '/users' , 'message' => 'should be a list of user ids' , ] ; } if ( ! is_bool ( $ shareRequest [ 'adminRights' ] ) ) { $ errors [ ] = [ 'path' => '/adminRights' , 'message' => 'should be boolean' , ] ; } return $ errors ; }
|
Validates a share request .
|
53,442
|
public static function normalize ( \ DateTime $ date = null ) { if ( ! empty ( $ date ) ) { return $ date -> format ( static :: DATE_FORMAT ) ; } return null ; }
|
Normalizes a DateTime to a string .
|
53,443
|
public static function denormalize ( $ dateString = null ) { if ( ! empty ( $ dateString ) ) { try { $ dateTime = \ DateTime :: createFromFormat ( static :: DATE_FORMAT , $ dateString ) ; return $ dateTime ; } catch ( \ Exception $ e ) { } } return null ; }
|
Denormalizes a string into a DateTime object .
|
53,444
|
public function load ( LoadResourceEvent $ event ) { $ event -> setData ( [ 'text' => $ this -> serializer -> serialize ( $ event -> getResource ( ) ) , ] ) ; $ event -> stopPropagation ( ) ; }
|
Loads a Text resource .
|
53,445
|
public function resetFieldFacets ( ) { foreach ( $ this -> fieldsFacet as $ field ) { $ field -> setPanelFacet ( null ) ; } $ this -> fieldsFacet = new ArrayCollection ( ) ; }
|
Remove all field facets .
|
53,446
|
public function create ( $ content , $ object , array $ users , $ sender = null , $ parent = null ) { $ message = new Message ( ) ; $ message -> setContent ( $ content ) ; $ message -> setParent ( $ parent ) ; $ message -> setObject ( $ object ) ; $ message -> setSender ( $ sender ) ; $ stringTo = '' ; foreach ( $ users as $ user ) { $ stringTo .= $ user -> getUsername ( ) . ';' ; } $ message -> setTo ( $ stringTo ) ; return $ message ; }
|
Create a message .
|
53,447
|
public function generateStringTo ( array $ receivers , array $ groups , array $ workspaces ) { $ usernames = [ ] ; foreach ( $ receivers as $ receiver ) { $ usernames [ ] = $ receiver -> getUsername ( ) ; } $ string = implode ( ';' , $ usernames ) ; foreach ( $ groups as $ group ) { $ el = '{' . $ group -> getName ( ) . '}' ; $ string .= '' === $ string ? $ el : ';' . $ el ; } foreach ( $ workspaces as $ workspace ) { $ el = '[' . $ workspace -> getCode ( ) . ']' ; $ string .= '' === $ string ? $ el : ';' . $ el ; } return $ string ; }
|
Generates a string containing the usernames from a list of users .
|
53,448
|
public function serialize ( Comment $ comment , array $ options = [ ] ) { return [ 'id' => $ comment -> getUuid ( ) , 'message' => $ comment -> getMessage ( ) , 'creationDate' => $ comment -> getCreationDate ( ) ? DateNormalizer :: normalize ( $ comment -> getCreationDate ( ) ) : null , 'updateDate' => $ comment -> getUpdateDate ( ) ? DateNormalizer :: normalize ( $ comment -> getUpdateDate ( ) ) : null , 'publicationDate' => $ comment -> getPublicationDate ( ) ? DateNormalizer :: normalize ( $ comment -> getPublicationDate ( ) ) : null , 'author' => $ comment -> getAuthor ( ) ? $ this -> userSerializer -> serialize ( $ comment -> getAuthor ( ) ) : null , 'authorName' => null !== $ comment -> getAuthor ( ) ? $ comment -> getAuthor ( ) -> getFullName ( ) : null , 'authorPicture' => null !== $ comment -> getAuthor ( ) ? $ comment -> getAuthor ( ) -> getPicture ( ) : null , 'isPublished' => $ comment -> isPublished ( ) , 'reported' => $ comment -> getReported ( ) , ] ; }
|
Serialize a post comment .
|
53,449
|
public function setDropzone ( \ Innova \ CollecticielBundle \ Entity \ Dropzone $ dropzone ) { $ this -> dropzone = $ dropzone ; return $ this ; }
|
Set dropzone .
|
53,450
|
public function setReturnReceiptType ( \ Innova \ CollecticielBundle \ Entity \ ReturnReceiptType $ returnReceiptType = null ) { $ this -> returnReceiptType = $ returnReceiptType ; return $ this ; }
|
Set returnReceiptType .
|
53,451
|
public function onError ( GetResponseForExceptionEvent $ event ) { if ( $ event -> getRequest ( ) -> isXmlHttpRequest ( ) ) { $ exception = $ event -> getException ( ) ; if ( $ exception instanceof InvalidDataException ) { $ response = new JsonResponse ( $ exception -> getErrors ( ) , 422 ) ; } else { $ response = new JsonResponse ( [ 'message' => $ exception -> getMessage ( ) , 'trace' => $ exception -> getTrace ( ) , ] , $ exception -> getCode ( ) < 200 ? 500 : $ exception -> getCode ( ) ) ; } $ event -> setResponse ( $ response ) ; } }
|
Converts Exceptions in JSON for the async api .
|
53,452
|
public function onResponse ( FilterResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ debug = $ request -> query -> get ( 'debug' ) ; $ response = $ event -> getResponse ( ) ; if ( $ response instanceof JsonResponse && $ debug ) { $ new = new Response ( ) ; $ new -> setContent ( '<body>' . $ response -> getContent ( ) . '</body>' ) ; $ event -> setResponse ( $ new ) ; } }
|
If we re returning a JsonResponse we can get the debug bar by passing ?debug = true on the query string .
|
53,453
|
public function menuAction ( ) { $ workspaces = [ ] ; $ personalWs = null ; $ user = null ; $ token = $ this -> tokenStorage -> getToken ( ) ; if ( $ token ) { $ user = $ token -> getUser ( ) ; } if ( $ user instanceof User ) { $ personalWs = $ user -> getPersonalWorkspace ( ) ; $ workspaces = $ this -> workspaceManager -> getRecentWorkspaceForUser ( $ user , $ this -> utils -> getRoles ( $ token ) ) ; } return new JsonResponse ( [ 'creatable' => $ this -> authorization -> isGranted ( 'CREATE' , new Workspace ( ) ) , 'personal' => $ personalWs ? $ this -> serializer -> serialize ( $ personalWs , [ Options :: SERIALIZE_MINIMAL ] ) : null , 'history' => array_map ( function ( Workspace $ workspace ) { return $ this -> serializer -> serialize ( $ workspace , [ Options :: SERIALIZE_MINIMAL ] ) ; } , $ workspaces ) , ] ) ; }
|
Gets the main workspace menu for the current user .
|
53,454
|
public function listCommentReportedAction ( Request $ request , Blog $ blog ) { $ this -> checkPermission ( 'OPEN' , $ blog -> getResourceNode ( ) , [ ] , true ) ; if ( $ this -> checkPermission ( 'MODERATE' , $ blog -> getResourceNode ( ) ) || $ this -> checkPermission ( 'EDIT' , $ blog -> getResourceNode ( ) ) ) { $ parameters = $ request -> query -> all ( ) ; $ posts = $ this -> commentManager -> getReportedComments ( $ blog -> getId ( ) , $ parameters ) ; return new JsonResponse ( $ posts ) ; } else { throw new AccessDeniedException ( ) ; } }
|
Get reported comments posts .
|
53,455
|
public function listTrustedUsersAction ( Request $ request , Blog $ blog ) { if ( $ this -> checkPermission ( 'MODERATE' , $ blog -> getResourceNode ( ) ) || $ this -> checkPermission ( 'EDIT' , $ blog -> getResourceNode ( ) ) ) { $ users = $ this -> commentManager -> getTrustedUsers ( $ blog ) ; return new JsonResponse ( $ users ) ; } else { throw new AccessDeniedException ( ) ; } }
|
Get unpublished comments posts .
|
53,456
|
public function updateCommentAction ( Request $ request , Blog $ blog , Comment $ comment , User $ user = null ) { $ this -> checkPermission ( 'OPEN' , $ blog -> getResourceNode ( ) , [ ] , true ) ; if ( $ blog -> isCommentsAuthorized ( ) && $ this -> isLoggedIn ( $ user ) ) { if ( $ user !== $ comment -> getAuthor ( ) ) { $ this -> checkPermission ( 'EDIT' , $ blog -> getResourceNode ( ) , [ ] , true ) ; } $ data = $ this -> decodeRequest ( $ request ) [ 'comment' ] ; $ comment = $ this -> commentManager -> updateComment ( $ blog , $ comment , $ data ) ; return new JsonResponse ( $ this -> commentSerializer -> serialize ( $ comment ) ) ; } else { throw new AccessDeniedException ( ) ; } }
|
Update post comment .
|
53,457
|
public function unpublishCommentAction ( Request $ request , Blog $ blog , Comment $ comment , User $ user ) { $ this -> checkPermission ( 'EDIT' , $ blog -> getResourceNode ( ) , [ ] , true ) ; $ comment = $ this -> commentManager -> unpublishComment ( $ blog , $ comment ) ; return new JsonResponse ( $ this -> commentSerializer -> serialize ( $ comment ) ) ; }
|
Unpublish post comment .
|
53,458
|
public function reportCommentAction ( Request $ request , Blog $ blog , Comment $ comment , User $ user ) { $ comment = $ this -> commentManager -> reportComment ( $ blog , $ comment ) ; return new JsonResponse ( $ this -> commentSerializer -> serialize ( $ comment ) ) ; }
|
Report post comment .
|
53,459
|
public function deleteCommentAction ( Request $ request , Blog $ blog , Comment $ comment , User $ user ) { if ( $ blog -> isCommentsAuthorized ( ) && $ this -> isLoggedIn ( $ user ) ) { if ( $ user === $ comment -> getAuthor ( ) || $ this -> checkPermission ( 'EDIT' , $ blog -> getResourceNode ( ) ) || $ this -> checkPermission ( 'MODERATE' , $ blog -> getResourceNode ( ) ) ) { $ commentId = $ this -> commentManager -> deleteComment ( $ blog , $ comment ) ; return new JsonResponse ( $ commentId ) ; } else { throw new AccessDeniedException ( ) ; } } else { throw new AccessDeniedException ( ) ; } }
|
Delete post comment .
|
53,460
|
public function copyRoot ( Chapter $ root_original , Chapter $ root_copy ) { $ root_copy -> setTitle ( $ root_original -> getTitle ( ) ) ; $ root_copy -> setText ( $ root_original -> getText ( ) ) ; $ this -> copyChildren ( $ root_original , $ root_copy , true ) ; }
|
Copy full lesson chapters from original root to copy root .
|
53,461
|
public function copyChapter ( Chapter $ chapter_org , Chapter $ parent , $ copy_children , $ copyName = null ) { $ chapter_copy = new Chapter ( ) ; if ( ! $ copyName ) { $ copyName = $ chapter_org -> getTitle ( ) ; } $ chapter_copy -> setTitle ( $ copyName ) ; $ chapter_copy -> setText ( $ chapter_org -> getText ( ) ) ; $ chapter_copy -> setLesson ( $ parent -> getLesson ( ) ) ; $ this -> insertChapter ( $ chapter_copy , $ parent ) ; if ( $ copy_children ) { $ this -> copyChildren ( $ chapter_org , $ chapter_copy , $ copy_children ) ; } return $ chapter_copy ; }
|
Copy chapter_org subchapters into provided chapter_copy .
|
53,462
|
public function getShareLink ( $ url , array $ options = array ( ) ) { $ options [ 'url' ] = $ url ; return sprintf ( self :: SHARE_URL , http_build_query ( $ options ) ) ; }
|
Gets the share link for provided URL .
|
53,463
|
public function serialize ( ResourceType $ resourceType ) { return [ 'id' => $ resourceType -> getId ( ) , 'name' => $ resourceType -> getName ( ) , 'class' => $ resourceType -> getClass ( ) , 'tags' => $ resourceType -> getTags ( ) , 'enabled' => $ resourceType -> isEnabled ( ) , 'actions' => array_map ( function ( MenuAction $ resourceAction ) { return [ 'name' => $ resourceAction -> getName ( ) , 'group' => $ resourceAction -> getGroup ( ) , 'scope' => $ resourceAction -> getScope ( ) , 'permission' => $ resourceAction -> getDecoder ( ) , 'default' => $ resourceAction -> isDefault ( ) , ] ; } , $ this -> actionManager -> all ( $ resourceType ) ) , ] ; }
|
Serializes a ResourceType entity for the JSON api .
|
53,464
|
public function removeShortcutsTo ( ResourceNode $ resourceNode ) { $ this -> om -> startFlushSuite ( ) ; $ shortcuts = $ this -> repository -> findBy ( [ 'target' => $ resourceNode ] ) ; foreach ( $ shortcuts as $ shortcut ) { $ this -> om -> remove ( $ shortcut -> getResourceNode ( ) ) ; } $ this -> om -> endFlushSuite ( ) ; }
|
Removes all shortcuts associated to a resource .
|
53,465
|
public function serialize ( Forum $ forum , array $ options = [ ] ) { $ currentUser = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; if ( ! is_string ( $ currentUser ) ) { $ forumUser = $ this -> manager -> getValidationUser ( $ currentUser , $ forum ) ; } else { $ forumUser = new User ( ) ; } $ now = new \ DateTime ( ) ; $ readonly = false ; if ( $ forum -> getLockDate ( ) ) { $ readonly = $ forum -> getLockDate ( ) > $ now ; } $ banned = $ this -> checkPermission ( 'EDIT' , $ forum -> getResourceNode ( ) ) ? false : $ forumUser -> isBanned ( ) || $ readonly ; return [ 'id' => $ forum -> getUuid ( ) , 'moderation' => $ forum -> getValidationMode ( ) , 'maxComment' => $ forum -> getMaxComment ( ) , 'display' => [ 'description' => $ forum -> getDescription ( ) , 'showOverview' => $ forum -> getShowOverview ( ) , 'subjectDataList' => $ forum -> getDataListOptions ( ) , 'lastMessagesCount' => $ forum -> getDisplayMessages ( ) , ] , 'restrictions' => [ 'lockDate' => $ forum -> getLockDate ( ) ? $ forum -> getLockDate ( ) -> format ( 'Y-m-d\TH:i:s' ) : null , 'banned' => $ banned , 'moderator' => $ this -> checkPermission ( 'EDIT' , $ forum -> getResourceNode ( ) ) , ] , 'meta' => [ 'users' => $ this -> finder -> fetch ( User :: class , [ 'forum' => $ forum -> getUuid ( ) ] , null , 0 , 0 , true ) , 'subjects' => $ this -> finder -> fetch ( Subject :: class , [ 'forum' => $ forum -> getUuid ( ) ] , null , 0 , 0 , true ) , 'messages' => $ this -> finder -> fetch ( Message :: class , [ 'forum' => $ forum -> getUuid ( ) ] , null , 0 , 0 , true ) , 'myMessages' => ! is_string ( $ currentUser ) ? $ this -> finder -> fetch ( Message :: class , [ 'forum' => $ forum -> getUuid ( ) , 'creator' => $ currentUser -> getUsername ( ) ] , null , 0 , 0 , true ) : 0 , 'tags' => $ this -> getTags ( $ forum ) , 'notified' => $ forumUser -> isNotified ( ) , ] , ] ; }
|
Serializes a Forum entity .
|
53,466
|
public function onDisplayWorkspace ( DisplayToolEvent $ event ) { $ levelMax = 1 ; $ workspace = $ event -> getWorkspace ( ) ; $ authenticatedUser = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; $ user = 'anon.' !== $ authenticatedUser ? $ authenticatedUser : null ; $ items = $ this -> progressionManager -> fetchItems ( $ workspace , $ user , $ levelMax ) ; $ content = $ this -> templating -> render ( 'ClarolineCoreBundle:tool:progression.html.twig' , [ 'workspace' => $ workspace , 'context' => [ 'type' => 'workspace' , 'data' => $ this -> serializer -> serialize ( $ workspace ) , ] , 'items' => $ items , 'levelMax' => null , ] ) ; $ event -> setContent ( $ content ) ; $ event -> stopPropagation ( ) ; }
|
Displays workspace progression tool .
|
53,467
|
public function findByWorkspace ( Workspace $ workspace , $ orderedBy = 'id' , $ order = 'ASC' ) { $ dql = " SELECT r FROM Claroline\CoreBundle\Entity\Role r JOIN r.workspace ws WHERE ws.id = :workspaceId ORDER BY r.{$orderedBy} {$order} " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'workspaceId' , $ workspace -> getId ( ) ) ; return $ query -> getResult ( ) ; }
|
Returns the roles associated to a workspace .
|
53,468
|
public function findByWorkspaceAndSearch ( Workspace $ workspace , $ search = '' , $ orderedBy = 'id' , $ order = 'ASC' ) { $ dql = " SELECT r FROM Claroline\CoreBundle\Entity\Role r JOIN r.workspace ws WHERE ws.id = :workspaceId AND UPPER(r.translationKey) LIKE :search ORDER BY r.{$orderedBy} {$order} " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'workspaceId' , $ workspace -> getId ( ) ) ; $ upperSearch = strtoupper ( $ search ) ; $ query -> setParameter ( 'search' , "%{$upperSearch}%" ) ; return $ query -> getResult ( ) ; }
|
Returns the searched roles associated to a workspace .
|
53,469
|
public function findPlatformRoles ( User $ user ) { $ dql = " SELECT r FROM Claroline\CoreBundle\Entity\Role r JOIN r.users u WHERE u.id = {$user->getId()} AND r.type = " . Role :: PLATFORM_ROLE ; $ query = $ this -> _em -> createQuery ( $ dql ) ; return $ query -> getResult ( ) ; }
|
Returns the platform roles of a user .
|
53,470
|
public function findAllUserRoles ( $ executeQuery = true ) { $ dql = ' SELECT r FROM Claroline\CoreBundle\Entity\Role r WHERE r.type = :type ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'type' , Role :: USER_ROLE ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; }
|
Returns all user - type roles .
|
53,471
|
public function findWorkspaceRolesByUser ( User $ user , $ executeQuery = true ) { $ dql = ' SELECT r FROM Claroline\CoreBundle\Entity\Role r JOIN r.users u WHERE u = :user AND r.type = :type AND r.workspace IS NOT NULL ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'type' , Role :: WS_ROLE ) ; $ query -> setParameter ( 'user' , $ user ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; }
|
Returns all workspace roles of an user .
|
53,472
|
public function getCell ( $ uuid ) { $ found = null ; foreach ( $ this -> cells as $ cell ) { if ( $ cell -> getUuid ( ) === $ uuid ) { $ found = $ cell ; break ; } } return $ found ; }
|
Get a cell by its uuid .
|
53,473
|
public function addCell ( Cell $ cell ) { if ( ! $ this -> cells -> contains ( $ cell ) ) { $ cell -> SetQuestion ( $ this ) ; $ this -> cells -> add ( $ cell ) ; } }
|
Add cell .
|
53,474
|
public function removeCell ( Cell $ cell ) { if ( $ this -> cells -> contains ( $ cell ) ) { $ this -> cells -> removeElement ( $ cell ) ; } }
|
Remove cell .
|
53,475
|
public function getReaderFor ( $ feedContent ) { @ $ content = new SimpleXMLElement ( $ feedContent ) ; foreach ( $ this -> readers as $ reader ) { if ( $ reader -> supports ( $ content -> getName ( ) ) ) { $ reader -> setFeed ( $ content ) ; return $ reader ; } } throw new UnknownFormatException ( "Parser has no support for '{$content->getName()}' feed format" ) ; }
|
Returns a reader object for the given feed .
|
53,476
|
public function bookSearchAction ( ParamFetcher $ paramFetcher ) { $ api_key = $ this -> getApiKey ( ) ; $ query = $ paramFetcher -> get ( 'query' ) ; $ index = $ paramFetcher -> get ( 'index' ) ; $ page = $ paramFetcher -> get ( 'page' ) ; $ url = "http://isbndb.com/api/v2/json/$api_key/books?q=$query&i=$index&p=$page&opt=keystats" ; $ result = $ this -> sendRequest ( $ url ) ; unset ( $ result [ 'keystats' ] [ 'key_id' ] ) ; return $ result ; }
|
Search in ISBNDB .
|
53,477
|
public function bookDetailsAction ( ParamFetcher $ paramFetcher ) { $ api_key = $ this -> getApiKey ( ) ; $ bookId = $ paramFetcher -> get ( 'bookId' ) ; $ url = "http://isbndb.com/api/v2/json/$api_key/book/$bookId?opt=keystats" ; $ result = $ this -> sendRequest ( $ url ) ; unset ( $ result [ 'keystats' ] [ 'key_id' ] ) ; return $ result ; }
|
Get book details from ISBNDB .
|
53,478
|
public function exportLogsToCsv ( $ query ) { $ query [ 'limit' ] = self :: CSV_LOG_BATCH ; $ query [ 'page' ] = 0 ; $ count = 0 ; $ total = 0 ; $ handle = fopen ( 'php://output' , 'w+' ) ; fputcsv ( $ handle , [ $ this -> translator -> trans ( 'date' , [ ] , 'platform' ) , $ this -> translator -> trans ( 'action' , [ ] , 'platform' ) , $ this -> translator -> trans ( 'user' , [ ] , 'platform' ) , $ this -> translator -> trans ( 'description' , [ ] , 'platform' ) , ] , ';' , '"' ) ; while ( $ count === 0 || $ count < $ total ) { $ logs = $ logs = $ this -> finder -> search ( 'Claroline\CoreBundle\Entity\Log\Log' , $ query , [ ] ) ; $ total = $ logs [ 'totalResults' ] ; $ count += self :: CSV_LOG_BATCH ; ++ $ query [ 'page' ] ; foreach ( $ logs [ 'data' ] as $ log ) { fputcsv ( $ handle , [ $ log [ 'dateLog' ] , $ log [ 'action' ] , $ log [ 'doer' ] ? $ log [ 'doer' ] [ 'name' ] : '' , $ this -> ut -> html2Csv ( $ log [ 'description' ] , true ) , ] , ';' , '"' ) ; } $ this -> om -> clear ( 'Claroline\CoreBundle\Entity\Log\Log' ) ; } fclose ( $ handle ) ; return $ handle ; }
|
Given a query params it exports all logs to a CSV file .
|
53,479
|
public function exportUserActionToCsv ( array $ finderParams = [ ] ) { $ queryParams = FinderProvider :: parseQueryParams ( $ finderParams ) ; $ allFilters = $ queryParams [ 'allFilters' ] ; $ sortBy = $ queryParams [ 'sortBy' ] ; $ limit = self :: CSV_LOG_BATCH ; $ page = 0 ; $ count = 0 ; $ total = intval ( $ this -> logRepository -> fetchUserActionsList ( $ allFilters , true ) ) ; $ handle = fopen ( 'php://output' , 'w+' ) ; fputcsv ( $ handle , [ $ this -> translator -> trans ( 'user' , [ ] , 'platform' ) , $ this -> translator -> trans ( 'actions' , [ ] , 'platform' ) , ] , ';' , '"' ) ; while ( $ count === 0 || $ count < $ total ) { $ logs = $ logs = $ this -> logRepository -> fetchUsersByActionsList ( $ allFilters , false , $ page , $ limit , $ sortBy ) ; $ count += self :: CSV_LOG_BATCH ; ++ $ page ; foreach ( $ logs as $ log ) { fputcsv ( $ handle , [ $ log [ 'doerLastName' ] . ' ' . $ log [ 'doerFirstName' ] , $ log [ 'actions' ] , ] , ';' , '"' ) ; } } fclose ( $ handle ) ; return $ handle ; }
|
Exports users actions for a given query .
|
53,480
|
private function formatDataForChart ( array $ data , \ DateTime $ minDate = null , \ DateTime $ maxDate = null ) { $ prevDate = $ minDate ; $ chartData = [ ] ; $ idx = 0 ; foreach ( $ data as $ value ) { while ( $ prevDate !== null && $ prevDate < $ value [ 'date' ] ) { $ chartData [ "c${idx}" ] = [ 'xData' => $ prevDate -> format ( 'Y-m-d\TH:i:s' ) , 'yData' => 0 ] ; $ prevDate -> add ( new \ DateInterval ( 'P1D' ) ) ; ++ $ idx ; } $ chartData [ "c${idx}" ] = [ 'xData' => $ value [ 'date' ] -> format ( 'Y-m-d\TH:i:s' ) , 'yData' => floatval ( $ value [ 'total' ] ) ] ; $ prevDate = $ value [ 'date' ] -> add ( new \ DateInterval ( 'P1D' ) ) ; ++ $ idx ; } while ( $ prevDate !== null && $ maxDate !== null && $ maxDate >= $ prevDate ) { $ chartData [ "c${idx}" ] = [ 'xData' => $ prevDate -> format ( 'Y-m-d\TH:i:s' ) , 'yData' => 0 ] ; $ prevDate -> add ( new \ DateInterval ( 'P1D' ) ) ; ++ $ idx ; } return $ chartData ; }
|
Formats raw data to the appropriate charts format .
|
53,481
|
public function linkResource ( ResourceNode $ resource ) { if ( ! $ this -> isLinkedToResource ( $ resource ) ) { $ this -> resources -> add ( $ resource ) ; ++ $ this -> resourceCount ; } }
|
Associates the ability with a resource .
|
53,482
|
public function removeResource ( ResourceNode $ resource ) { if ( $ this -> isLinkedToResource ( $ resource ) ) { $ this -> resources -> removeElement ( $ resource ) ; -- $ this -> resourceCount ; } }
|
Removes an association with a resource .
|
53,483
|
public function preUpdate ( User $ user , PreUpdateEventArgs $ event ) { if ( $ event -> hasChangedField ( 'password' ) ) { $ event -> setNewValue ( 'password' , $ this -> encodePassword ( $ user ) ) ; } }
|
Encodes the password when a User is updated and value has changed .
|
53,484
|
private function encodePassword ( User $ user ) { $ password = $ this -> encoderFactory -> getEncoder ( $ user ) -> encodePassword ( $ user -> getPlainPassword ( ) , $ user -> getSalt ( ) ) ; $ user -> setPassword ( $ password ) ; return $ password ; }
|
Encodes the user password and returns it .
|
53,485
|
public function addUser ( User $ user ) { if ( ! $ this -> users -> contains ( $ user ) ) { $ this -> users -> add ( $ user ) ; } return $ this ; }
|
Adds an user to team .
|
53,486
|
public function removeUser ( User $ user ) { if ( $ this -> users -> contains ( $ user ) ) { $ this -> users -> removeElement ( $ user ) ; } return $ this ; }
|
Removes an user to team .
|
53,487
|
public function getFormattedSize ( ) { if ( $ this -> size < 1024 ) { return $ this -> size . ' B' ; } elseif ( $ this -> size < 1048576 ) { return round ( $ this -> size / 1024 , 2 ) . ' KB' ; } elseif ( $ this -> size < 1073741824 ) { return round ( $ this -> size / 1048576 , 2 ) . ' MB' ; } elseif ( $ this -> size < 1099511627776 ) { return round ( $ this -> size / 1073741824 , 2 ) . ' GB' ; } return round ( $ this -> size / 1099511627776 , 2 ) . ' TB' ; }
|
Returns the file size with unit and in a readable format .
|
53,488
|
public function fetchChartData ( array $ filters = [ ] , $ unique = false ) { $ qb = $ this -> createQueryBuilder ( 'obj' ) ; if ( true === $ unique ) { $ qb -> select ( 'obj.shortDateLog as date, COUNT(DISTINCT obj.doer) as total' ) ; } else { $ qb -> select ( 'obj.shortDateLog as date, COUNT(obj.id) as total' ) ; } $ qb -> orderBy ( 'date' , 'ASC' ) -> groupBy ( 'date' ) ; $ this -> finder -> configureQueryBuilder ( $ qb , $ filters ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
|
Fetches data for line chart .
|
53,489
|
public function findActionAfterDate ( $ action , $ date , $ doerId = null , $ resourceId = null , $ workspaceId = null , $ receiverId = null , $ roleId = null , $ groupId = null , $ toolName = null , $ userType = null ) { $ queryBuilder = $ this -> createQueryBuilder ( 'log' ) -> orderBy ( 'log.dateLog' , 'DESC' ) -> andWhere ( 'log.action = :action' ) -> setParameter ( 'action' , $ action ) -> andWhere ( 'log.dateLog >= :date' ) -> setParameter ( 'date' , $ date ) ; if ( null !== $ doerId ) { $ queryBuilder -> leftJoin ( 'log.doer' , 'doer' ) -> andWhere ( 'doer.id = :doerId' ) -> setParameter ( 'doerId' , $ doerId ) ; } if ( null !== $ resourceId ) { $ queryBuilder -> leftJoin ( 'log.resource' , 'resource' ) -> andWhere ( 'resource.id = :resourceId' ) -> setParameter ( 'resourceId' , $ resourceId ) ; } if ( null !== $ workspaceId ) { $ queryBuilder -> leftJoin ( 'log.workspace' , 'workspace' ) -> andWhere ( 'workspace.id = :workspaceId' ) -> setParameter ( 'workspaceId' , $ workspaceId ) ; } if ( null !== $ receiverId ) { $ queryBuilder -> leftJoin ( 'log.receiver' , 'receiver' ) -> andWhere ( 'receiver.id = :receiverId' ) -> setParameter ( 'receiverId' , $ receiverId ) ; } if ( null !== $ roleId ) { $ queryBuilder -> leftJoin ( 'log.role' , 'role' ) -> andWhere ( 'role.id = :roleId' ) -> setParameter ( 'roleId' , $ roleId ) ; } if ( null !== $ groupId ) { $ queryBuilder -> leftJoin ( 'log.receiverGroup' , 'receiverGroup' ) -> andWhere ( 'receiverGroup.id = :groupId' ) -> setParameter ( 'groupId' , $ groupId ) ; } if ( null !== $ toolName ) { $ queryBuilder -> andWhere ( 'log.toolName = :toolName' ) -> setParameter ( 'toolName' , $ toolName ) ; } $ q = $ queryBuilder -> getQuery ( ) ; $ logs = $ q -> getResult ( ) ; return $ logs ; }
|
this method is never used and not up to date .
|
53,490
|
public function serialize ( LtiResource $ ltiResource , array $ options = [ ] ) { $ serialized = [ 'id' => $ ltiResource -> getUuid ( ) , 'openInNewTab' => $ ltiResource -> getOpenInNewTab ( ) , 'ratio' => $ ltiResource -> getRatio ( ) , 'ltiApp' => $ ltiResource -> getLtiApp ( ) ? $ this -> ltiAppSerializer -> serialize ( $ ltiResource -> getLtiApp ( ) , [ Options :: SERIALIZE_MINIMAL ] ) : null , 'ltiData' => $ this -> serializeLtiData ( $ ltiResource ) , ] ; return $ serialized ; }
|
Serializes a LTI resource for the JSON api .
|
53,491
|
public function viewHint ( Paper $ paper , Hint $ hint ) { $ log = $ this -> om -> getRepository ( 'UJMExoBundle:LinkHintPaper' ) -> findOneBy ( [ 'paper' => $ paper , 'hint' => $ hint ] ) ; if ( ! $ log ) { $ log = new LinkHintPaper ( $ hint , $ paper ) ; $ this -> om -> persist ( $ log ) ; $ this -> om -> flush ( ) ; } return $ hint -> getValue ( ) ; }
|
Returns the contents of a hint and records a log asserting that the hint has been consulted for a given paper .
|
53,492
|
public function serialize ( ContentItem $ contentItem , array $ options = [ ] ) { $ serialized = [ ] ; if ( 1 === preg_match ( '#^text\/[^/]+$#' , $ contentItem -> getQuestion ( ) -> getMimeType ( ) ) ) { $ serialized [ 'data' ] = $ contentItem -> getData ( ) ; } else { $ serialized [ 'url' ] = $ contentItem -> getData ( ) ; } return $ serialized ; }
|
Converts a content item into a JSON - encodable structure .
|
53,493
|
public function deserialize ( $ data , ContentItem $ contentItem = null , array $ options = [ ] ) { if ( empty ( $ contentItem ) ) { $ contentItem = new ContentItem ( ) ; } $ this -> sipe ( 'url' , 'setData' , $ data , $ contentItem ) ; $ this -> sipe ( 'data' , 'setData' , $ data , $ contentItem ) ; return $ contentItem ; }
|
Converts raw data into a content item entity .
|
53,494
|
public function findAll ( $ executeQuery = true , $ orderedBy = 'id' , $ order = null ) { if ( ! $ executeQuery ) { $ dql = " SELECT u, pws, g, r, rws FROM Claroline\CoreBundle\Entity\User u LEFT JOIN u.personalWorkspace pws LEFT JOIN u.groups g LEFT JOIN u.roles r LEFT JOIN r.workspace rws WHERE u.isRemoved = false ORDER BY u.{$orderedBy} {$order} " ; return $ this -> _em -> createQuery ( $ dql ) ; } return parent :: findAll ( ) ; }
|
Returns all the users .
|
53,495
|
public function findByGroup ( Group $ group , $ executeQuery = true , $ orderedBy = 'id' , $ order = 'ASC' ) { $ dql = " SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u JOIN u.groups g WHERE g.id = :groupId AND u.isRemoved = false ORDER BY u.{$orderedBy} {$order} " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'groupId' , $ group -> getId ( ) ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; }
|
Returns the users of a group .
|
53,496
|
public function findAllByWorkspaceAndName ( Workspace $ workspace , $ search , $ executeQuery = true ) { $ upperSearch = strtoupper ( $ search ) ; $ dql = ' SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u WHERE u IN ( SELECT u1 FROM Claroline\CoreBundle\Entity\User u1 JOIN u1.roles r1 WITH r1 IN ( SELECT pr1 from Claroline\CoreBundle\Entity\Role pr1 WHERE pr1.type = :type ) LEFT JOIN r1.workspace wol1 WHERE wol1.id = :workspaceId AND u1 IN ( SELECT us1 FROM Claroline\CoreBundle\Entity\User us1 WHERE UPPER(us1.lastName) LIKE :search OR UPPER(us1.firstName) LIKE :search OR UPPER(us1.username) LIKE :search OR CONCAT(UPPER(us1.firstName), CONCAT(\' \', UPPER(us1.lastName))) LIKE :search OR CONCAT(UPPER(us1.lastName), CONCAT(\' \', UPPER(us1.firstName))) LIKE :search ) AND u1.isRemoved = false ) OR u IN ( SELECT u2 FROM Claroline\CoreBundle\Entity\User u2 JOIN u2.groups g2 JOIN g2.roles r2 WITH r2 IN ( SELECT pr2 from Claroline\CoreBundle\Entity\Role pr2 WHERE pr2.type = :type ) LEFT JOIN r2.workspace wol2 WHERE wol2.id = :workspaceId AND u IN ( SELECT us2 FROM Claroline\CoreBundle\Entity\User us2 WHERE UPPER(us2.lastName) LIKE :search OR UPPER(us2.firstName) LIKE :search OR UPPER(us2.username) LIKE :search OR CONCAT(UPPER(us2.firstName), CONCAT(\' \', UPPER(us2.lastName))) LIKE :search OR CONCAT(UPPER(us2.lastName), CONCAT(\' \', UPPER(us2.firstName))) LIKE :search ) AND u2.isRemoved = false) ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'workspaceId' , $ workspace -> getId ( ) ) -> setParameter ( 'search' , "%{$upperSearch}%" ) ; $ query -> setParameter ( 'type' , Role :: WS_ROLE ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; }
|
Returns the users of a workspace whose first name last name or username match a given search string . Including users in groups .
|
53,497
|
public function findByUsernames ( array $ usernames ) { if ( count ( $ usernames ) > 0 ) { $ dql = ' SELECT u FROM Claroline\CoreBundle\Entity\User u WHERE u.isRemoved = false AND u.username IN (:usernames) ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'usernames' , $ usernames ) ; $ result = $ query -> getResult ( ) ; } else { $ result = [ ] ; } return $ result ; }
|
Returns users by their usernames .
|
53,498
|
public function countUsersByRole ( Role $ role , $ restrictionRoleNames = null , $ organizations = null ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> select ( 'COUNT(DISTINCT user.id)' ) -> leftJoin ( 'user.roles' , 'roles' ) -> andWhere ( 'roles.id = :roleId' ) -> andWhere ( 'user.isEnabled = :enabled' ) -> setParameter ( 'roleId' , $ role -> getId ( ) ) -> setParameter ( 'enabled' , true ) ; if ( ! empty ( $ restrictionRoleNames ) ) { $ qb -> andWhere ( 'user.id NOT IN (:userIds)' ) -> setParameter ( 'userIds' , $ this -> findUserIdsInRoles ( $ restrictionRoleNames ) ) ; } if ( null !== $ organizations ) { $ qb -> join ( 'user.userOrganizationReferences' , 'orgaRef' ) -> andWhere ( 'orgaRef.organization IN (:organizations)' ) -> setParameter ( 'organizations' , $ organizations ) ; } $ query = $ qb -> getQuery ( ) ; return $ query -> getSingleScalarResult ( ) ; }
|
Counts the users subscribed in a platform role .
|
53,499
|
public function findUserIdsInRoles ( $ roleNames ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> select ( 'DISTINCT(user.id) as id' ) -> leftJoin ( 'user.roles' , 'roles' ) -> andWhere ( 'roles.name IN (:roleNames)' ) -> andWhere ( 'user.isRemoved = false' ) -> setParameter ( 'roleNames' , $ roleNames ) ; $ query = $ qb -> getQuery ( ) ; return array_column ( $ query -> getScalarResult ( ) , 'id' ) ; }
|
Returns user Ids that are subscribed to one of the roles given .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.