idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
4,900 | public function convert ( $ markdown ) { $ this -> getContainer ( 'events' ) -> dispatch ( 'laradown.entity.converting' ) ; $ text = $ this -> text ( $ markdown ) ; $ this -> getContainer ( 'events' ) -> dispatch ( 'laradown.entity.converted' ) ; return $ text ; } | Convert markdown to html . |
4,901 | public function loadStyle ( $ file = null ) { $ content = '' ; if ( is_null ( $ file ) ) { $ file = __DIR__ . '/../public/github.css' ; } if ( $ this -> filesystem -> exists ( $ file ) ) { $ content = $ this -> filesystem -> get ( $ file ) ; } return "<style>{$content}</style>" ; } | Get style . |
4,902 | public function setConnectionTimeout ( $ connectionTimeout ) { if ( ! is_numeric ( $ connectionTimeout ) || $ connectionTimeout < 0 ) { throw new \ InvalidArgumentException ( 'Timeout value must be numeric and a non-negative number.' ) ; } $ this -> connectionTimeout = $ connectionTimeout ; return $ this ; } | Sets the connection timeout in seconds . |
4,903 | public function addDefaultHeader ( $ key , $ value ) { if ( ! is_string ( $ key ) ) { throw new \ InvalidArgumentException ( 'The header key must be a string.' ) ; } $ defaultHeaders [ $ key ] = $ value ; return $ this ; } | Adds a default header . |
4,904 | public function setDebugFile ( $ debugFile ) { $ this -> debugFile = $ debugFile ; $ this -> serializer -> setDebugFile ( $ debugFile ) ; return $ this ; } | Sets the path to the debug file . |
4,905 | public function selectHeaderContentType ( $ contentType ) { if ( count ( $ contentType ) === 0 or ( count ( $ contentType ) === 1 and $ contentType [ 0 ] === '' ) ) { return 'application/json' ; } elseif ( preg_grep ( "/application\/json/i" , $ contentType ) ) { return 'application/json' ; } else { return implode ( ','... | Returns the Content Type based on an array of content types . |
4,906 | private function buildRequestUrl ( $ path , $ queryParams ) { $ url = $ this -> getBasePath ( ) . $ path ; if ( ! empty ( $ queryParams ) ) { $ url = ( $ url . '?' . http_build_query ( $ queryParams ) ) ; } return $ url ; } | Returns the request url . |
4,907 | private function getAuthenticationHeaders ( HttpRequest $ request ) { $ timestamp = time ( ) ; $ version = '1' ; $ path = $ request -> getPath ( ) ; $ securedData = $ version . '|' . $ this -> userId . '|' . $ timestamp . '|' . $ request -> getMethod ( ) . '|' . $ path ; $ headers = array ( ) ; $ headers [ 'x-mac-versi... | Returns the headers used for authentication . |
4,908 | private function calculateHmac ( $ securedData ) { $ decodedSecret = base64_decode ( $ this -> applicationKey ) ; return base64_encode ( hash_hmac ( "sha512" , $ securedData , $ decodedSecret , true ) ) ; } | Calculates the hmac of the given data . |
4,909 | private function generateUniqueToken ( ) { $ s = strtoupper ( md5 ( uniqid ( rand ( ) , true ) ) ) ; return substr ( $ s , 0 , 8 ) . '-' . substr ( $ s , 8 , 4 ) . '-' . substr ( $ s , 12 , 4 ) . '-' . substr ( $ s , 16 , 4 ) . '-' . substr ( $ s , 20 ) ; } | Generates a unique token to assign to the request . |
4,910 | public function setDeprecationReason ( $ deprecationReason ) { if ( is_array ( $ deprecationReason ) && empty ( $ deprecationReason ) ) { $ this -> deprecationReason = new \ stdClass ; } else { $ this -> deprecationReason = $ deprecationReason ; } return $ this ; } | Sets deprecationReason . |
4,911 | public function setMerchantDescription ( $ merchantDescription ) { if ( is_array ( $ merchantDescription ) && empty ( $ merchantDescription ) ) { $ this -> merchantDescription = new \ stdClass ; } else { $ this -> merchantDescription = $ merchantDescription ; } return $ this ; } | Sets merchantDescription . |
4,912 | public function setMetricDescription ( $ metricDescription ) { if ( is_array ( $ metricDescription ) && empty ( $ metricDescription ) ) { $ this -> metricDescription = new \ stdClass ; } else { $ this -> metricDescription = $ metricDescription ; } return $ this ; } | Sets metricDescription . |
4,913 | public function setMetricName ( $ metricName ) { if ( is_array ( $ metricName ) && empty ( $ metricName ) ) { $ this -> metricName = new \ stdClass ; } else { $ this -> metricName = $ metricName ; } return $ this ; } | Sets metricName . |
4,914 | public function autoload ( $ class ) { $ filePath = $ this -> folder . '/' . str_replace ( '\\' , '/' , $ class ) . '.php' ; if ( file_exists ( $ filePath ) ) { return ( ( require_once $ filePath ) === false ? true : false ) ; } return false ; } | Handel autoloading of classes |
4,915 | private function readFromSocket ( ApiClient $ apiClient , HttpRequest $ request , $ socket ) { $ inBody = false ; $ responseMessage = '' ; $ chunked = false ; $ chunkLength = false ; $ maxTime = $ this -> getStartTime ( ) + $ apiClient -> getConnectionTimeout ( ) ; $ contentLength = - 1 ; $ endReached = false ; while (... | This method reads from the given socket . Depending on the given header the read process may be halted after reading the last chunk . This method is required because some servers do not close the connection in chunked transfer . Hence the timeout of the connection must be reached before the connection is closed . By tr... |
4,916 | private function readContentFromSocket ( ApiClient $ apiClient , HttpRequest $ request , $ socket , $ maxNumberOfBytes ) { stream_set_blocking ( $ socket , false ) ; $ maxTime = $ this -> getStartTime ( ) + $ apiClient -> getConnectionTimeout ( ) ; $ numberOfBytesRead = 0 ; $ result = '' ; while ( $ maxTime >= time ( )... | This method reads in blocking fashion from the socket . |
4,917 | private function readLineFromSocket ( ApiClient $ apiClient , HttpRequest $ request , $ socket , $ maxNumberOfBytes ) { stream_set_blocking ( $ socket , false ) ; $ maxTime = $ this -> getStartTime ( ) + $ apiClient -> getConnectionTimeout ( ) ; $ result = false ; while ( $ maxTime >= time ( ) && $ result === false && ... | This method reads a single line in blocking fashion from the socket . The method does respect the timeout configured . |
4,918 | private function startStreamSocket ( ApiClient $ apiClient , HttpRequest $ request ) { $ this -> configureRequest ( $ request ) ; $ socket = $ this -> createSocketStream ( $ apiClient , $ request ) ; $ message = $ request -> toString ( ) ; if ( $ apiClient -> isDebuggingEnabled ( ) ) { error_log ( "[DEBUG] HTTP Request... | Creates a socket and sends the request to the remote host . As result a stream socket is returned . Which can be used to read the response . |
4,919 | private function configureRequest ( HttpRequest $ request ) { $ proxyUrl = $ this -> readEnvironmentVariable ( self :: ENVIRONMENT_VARIABLE_PROXY_URL ) ; if ( $ proxyUrl !== null ) { $ proxyUser = parse_url ( $ proxyUrl , PHP_URL_USER ) ; $ proxyPass = parse_url ( $ proxyUrl , PHP_URL_PASS ) ; if ( $ proxyUser !== NULL... | This method modifies the request so it can be sent . Sub classes may override this method to apply further modifications . |
4,920 | private function createSocketStream ( ApiClient $ apiClient , HttpRequest $ request ) { if ( $ request -> isSecureConnection ( ) ) { if ( ! extension_loaded ( 'openssl' ) ) { throw new \ Exception ( "You have to enable OpenSSL." ) ; } } $ proxyUrl = $ this -> readEnvironmentVariable ( self :: ENVIRONMENT_VARIABLE_PROXY... | This method creates a stream socket to the server . |
4,921 | private function getSslProtocol ( ) { $ version = $ this -> readEnvironmentVariable ( self :: ENVIRONMENT_VARIABLE_SSL_VERSION ) ; $ rs = null ; switch ( $ version ) { case self :: SSL_VERSION_SSLV2 : $ rs = 'sslv2' ; break ; case self :: SSL_VERSION_SSLV3 : $ rs = 'sslv3' ; break ; case self :: SSL_VERSION_TLSV1 : $ r... | Returns the protocol to use in case of an SSL connection . |
4,922 | private function createStreamContext ( ApiClient $ apiClient , HttpRequest $ request ) { return stream_context_create ( $ this -> buildStreamContextOptions ( $ apiClient , $ request ) ) ; } | Creates and returns a new stream context . |
4,923 | private function buildStreamContextOptions ( ApiClient $ apiClient , HttpRequest $ request ) { $ options = array ( 'http' => array ( ) , 'ssl' => array ( ) ) ; if ( $ request -> isSecureConnection ( ) ) { $ options [ 'ssl' ] [ 'verify_host' ] = true ; $ options [ 'ssl' ] [ 'allow_self_signed' ] = false ; $ options [ 's... | Generates an option array for creating the stream context . |
4,924 | private function readEnvironmentVariable ( $ name ) { if ( isset ( $ _SERVER [ $ name ] ) ) { return $ _SERVER [ $ name ] ; } else if ( isset ( $ _SERVER [ strtolower ( $ name ) ] ) ) { return $ _SERVER [ strtolower ( $ name ) ] ; } else { return null ; } } | Reads the environment variable indicated by the name . Returns null when the variable is not defined . |
4,925 | public function setOption ( $ key , $ value ) { if ( isset ( $ this -> options [ $ key ] ) && is_array ( $ this -> options [ $ key ] ) && is_array ( $ value ) ) { $ oldValues = $ this -> options [ $ key ] ; $ value = array_merge ( $ oldValues , $ value ) ; } $ this -> options [ $ key ] = $ value ; } | Set single Option |
4,926 | public function getClientId ( ) { $ clientId = $ this -> getOption ( 'client_id' ) ; if ( $ clientId ) { return $ clientId ; } if ( isset ( $ _COOKIE [ '_ga' ] ) ) { $ gaCookie = explode ( '.' , $ _COOKIE [ '_ga' ] ) ; if ( isset ( $ gaCookie [ 2 ] ) ) { if ( $ this -> checkUuid ( $ gaCookie [ 2 ] ) ) { return $ gaCook... | Return the Current Client Id |
4,927 | final private function generateUuid ( ) { return sprintf ( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0x0fff ) | 0x4000 , mt_rand ( 0 , 0x3fff ) | 0x8000 , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) ) ; ... | Generate UUID v4 function - needed to generate a CID when one isn t available |
4,928 | protected function getTrackingPayloadData ( Tracking \ AbstractTracking $ event ) { $ payloadData = $ event -> getPackage ( ) ; $ payloadData [ 'v' ] = $ this -> apiProtocolVersion ; $ payloadData [ 'tid' ] = $ this -> analyticsAccountUid ; $ payloadData [ 'uid' ] = $ this -> getOption ( 'user_id' ) ; $ payloadData [ '... | Build the Tracking Payload Data |
4,929 | private function callEndpoint ( $ tracking ) { $ trackingHolder = is_array ( $ tracking ) ? $ tracking : array ( $ tracking ) ; $ trackingCollection = new Request \ TrackingRequestCollection ( ) ; foreach ( $ trackingHolder as $ tracking ) { if ( ! $ tracking instanceof Tracking \ AbstractTracking ) { continue ; } $ pa... | Call the client adapter |
4,930 | public function createTracking ( $ className , $ options = null ) { if ( strstr ( strtolower ( $ className ) , 'abstracttracking' ) ) { return false ; } $ class = 'Racecore\GATracking\Tracking\\' . $ className ; if ( $ options ) { return new $ class ( $ options ) ; } return new $ class ; } | Create a Tracking Class Instance - eg . Event or Ecommerce \ Transaction |
4,931 | public function sendTracking ( Tracking \ AbstractTracking $ tracking ) { $ responseCollection = $ this -> callEndpoint ( $ tracking ) ; $ responseCollection -> rewind ( ) ; return $ responseCollection -> current ( ) ; } | Send single tracking request |
4,932 | public function setResolvedDescription ( $ resolvedDescription ) { if ( is_array ( $ resolvedDescription ) && empty ( $ resolvedDescription ) ) { $ this -> resolvedDescription = new \ stdClass ; } else { $ this -> resolvedDescription = $ resolvedDescription ; } return $ this ; } | Sets resolvedDescription . |
4,933 | public function setResolvedTitle ( $ resolvedTitle ) { if ( is_array ( $ resolvedTitle ) && empty ( $ resolvedTitle ) ) { $ this -> resolvedTitle = new \ stdClass ; } else { $ this -> resolvedTitle = $ resolvedTitle ; } return $ this ; } | Sets resolvedTitle . |
4,934 | private function getCurrentUser ( ) { if ( is_object ( $ token = $ this -> get ( 'security.token_storage' ) -> getToken ( ) ) and is_object ( $ user = $ token -> getUser ( ) ) ) { return $ user ; } } | Get Current User |
4,935 | public function editActivity ( Activity $ activity ) { $ this -> om -> persist ( $ activity ) ; $ this -> om -> flush ( ) ; $ this -> initializePermissions ( $ activity ) ; return $ activity ; } | Edit an activity |
4,936 | public function addResource ( Activity $ activity , ResourceNode $ resource ) { if ( ! $ activity -> getParameters ( ) -> getSecondaryResources ( ) -> contains ( $ resource ) ) { $ activity -> getParameters ( ) -> getSecondaryResources ( ) -> add ( $ resource ) ; $ this -> initializePermissions ( $ activity ) ; $ this ... | Link a resource to an activity |
4,937 | public function removePrimaryResource ( Activity $ activity ) { $ activity -> setPrimaryResource ( ) ; $ this -> om -> persist ( $ activity ) ; $ this -> om -> flush ( ) ; } | Remove the primary resource of an activity |
4,938 | public function removeResource ( Activity $ activity , ResourceNode $ resource ) { if ( $ activity -> getParameters ( ) -> getSecondaryResources ( ) -> contains ( $ resource ) ) { $ activity -> getParameters ( ) -> getSecondaryResources ( ) -> removeElement ( $ resource ) ; $ this -> om -> persist ( $ activity ) ; $ th... | Remove a resource from an activity |
4,939 | public function copyActivity ( Activity $ resource ) { $ activity = new Activity ( ) ; $ activity -> setTitle ( $ resource -> getTitle ( ) ) ; $ activity -> setDescription ( $ resource -> getDescription ( ) ) ; $ activity -> setParameters ( $ this -> copyParameters ( $ resource ) ) ; if ( $ primaryResource = $ resource... | Copy an activity |
4,940 | public function createBlankEvaluation ( User $ user , ActivityParameters $ activityParams ) { $ evaluationType = $ activityParams -> getEvaluationType ( ) ; $ status = null ; $ nbAttempts = null ; if ( $ evaluationType === AbstractEvaluation :: TYPE_AUTOMATIC ) { $ status = AbstractEvaluation :: STATUS_NOT_ATTEMPTED ; ... | Creates an empty activity evaluation for a user so that an evaluation is available for display and edition even when the user hasn t actually performed the activity . |
4,941 | public function initializePermissions ( Activity $ activity ) { $ primary = $ activity -> getPrimaryResource ( ) ; $ secondaries = [ ] ; $ nodes = [ ] ; $ token = $ this -> tokenStorage -> getToken ( ) ; $ user = $ token === null ? $ activity -> getResourceNode ( ) -> getCreator ( ) : $ token -> getUser ( ) ; if ( $ pr... | What does it do ? I can t remember . It s annoying . Initialize the resource permissions of an activity |
4,942 | public function defaultTemplate ( $ path ) { $ dir = explode ( ':' , $ path ) ; $ controller = preg_split ( '/(?=[A-Z])/' , $ dir [ 0 ] ) ; $ controller = array_slice ( $ controller , ( count ( $ controller ) - 2 ) ) ; $ controller = implode ( '' , $ controller ) ; $ base = __DIR__ . "/../../Resources/views/" ; if ( $ ... | Verify if a twig template exists If the template does not exists a default path will be return ; |
4,943 | public function isDefinedPush ( $ array , $ name , $ variable , $ method = null ) { if ( $ method and $ variable ) { $ array [ $ name ] = $ variable -> $ method ( ) ; } elseif ( $ variable ) { $ array [ $ name ] = $ variable ; } return $ array ; } | Reduce some overall complexity |
4,944 | public function installFromKernel ( $ withOptionalFixtures = true ) { $ this -> launchPreInstallActions ( ) ; $ coreBundle = $ this -> kernel -> getBundle ( 'ClarolineCoreBundle' ) ; $ bundles = $ this -> kernel -> getBundles ( ) ; $ this -> baseInstaller -> install ( $ coreBundle , ! $ withOptionalFixtures ) ; foreach... | This is the method fired at the 1st installation . Either command line or from the web installer . |
4,945 | public function createCustomTheme ( $ name , File $ file ) { $ theme = new Theme ( ) ; $ theme -> setName ( $ name ) ; $ themeDir = "{$this->themeDir}/{$theme->getNormalizedName()}" ; $ fs = new Filesystem ( ) ; $ fs -> mkdir ( $ themeDir ) ; $ file -> move ( $ themeDir , 'bootstrap.css' ) ; $ this -> om -> persist ( $... | Creates a custom theme based on a css file . |
4,946 | public function findByAnonymous ( $ orderedToolType = 0 ) { $ dql = " SELECT DISTINCT w FROM Claroline\CoreBundle\Entity\Workspace\Workspace w JOIN w.orderedTools ot JOIN ot.rights otr JOIN otr.role r WHERE r.name = 'ROLE_ANONYMOUS' AND ot.typ... | Returns the workspaces whose at least one tool is accessible to anonymous users . |
4,947 | public function findOpenWorkspaceIds ( array $ roleNames , array $ workspaces , $ toolName = null , $ action = 'open' , $ orderedToolType = 0 ) { if ( count ( $ roleNames ) === 0 || count ( $ workspaces ) === 0 ) { return array ( ) ; } else { $ dql = ' SELECT DISTINCT w.id FROM Claroline\C... | Finds which workspaces can be opened by one of the given roles in a given 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 . Only the ids are returned . |
4,948 | public function findByRoleNamesBySearch ( array $ roleNames , $ search , $ orderedToolType = 0 ) { $ dql = ' SELECT DISTINCT w FROM Claroline\CoreBundle\Entity\Workspace\Workspace w JOIN w.orderedTools ot JOIN ot.rights otr JOIN otr.role r WHERE r.name I... | Returns the workspaces whose at least one tool is accessible to one of the given roles and whose name matches the given search string . |
4,949 | public function findDisplayableWorkspacesWithout ( array $ excludedWorkspaces ) { $ dql = ' SELECT w FROM Claroline\CoreBundle\Entity\Workspace\Workspace w WHERE w.displayable = true AND w NOT IN (:excludedWorkspaces) ORDER BY w.name ' ; $ query = $ this -> ... | Returns the workspaces which are visible and are not in the given list . |
4,950 | public function findMyWorkspacesByRoleNames ( array $ roleNames ) { $ dql = ' SELECT DISTINCT w FROM Claroline\CoreBundle\Entity\Workspace\Workspace w WHERE w IN ( SELECT rw.id FROM Claroline\CoreBundle\Entity\Role r JOIN Claroline\CoreBundle... | Returns the workspaces accessible by one of the given roles . |
4,951 | public function findAllPersonalWorkspaces ( $ orderedBy = 'name' , $ order = 'ASC' ) { $ dql = " SELECT w FROM Claroline\CoreBundle\Entity\Workspace\Workspace w WHERE EXISTS ( SELECT u FROM Claroline\CoreBundle\Entity\User u JOIN u.personalWo... | Returns all personal workspaces . |
4,952 | public function dispatch ( $ eventName , $ shortEventClassName , array $ eventArgs = array ( ) ) { $ className = class_exists ( $ shortEventClassName ) ? $ shortEventClassName : "Claroline\CoreBundle\Event\\{$shortEventClassName}Event" ; if ( ! class_exists ( $ className ) ) { throw new MissingEventClassException ( "No... | Dispatches an event and returns its associated event object . The event object is created according to the short event class name parameter which must match an event class located in the core event directory without the first path segments and the Event suffix . |
4,953 | public function handleFormView ( $ template , $ form , array $ options = array ( ) ) { $ httpCode = isset ( $ options [ 'http_code' ] ) ? $ options [ 'http_code' ] : 200 ; $ parameters = isset ( $ options [ 'form_view' ] ) ? $ options [ 'form_view' ] : array ( ) ; $ serializerGroup = isset ( $ options [ 'serializer_gro... | helper for the API controllers methods . We only do this in case of html request |
4,954 | public function findAdminHierarchiesByParent ( WorkspaceTag $ workspaceTag ) { $ dql = ' SELECT h FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h WHERE h.user IS NULL AND h.parent = :workspaceTag ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ;... | Returns all admin relations where given workspaceTag is parent |
4,955 | public function findHierarchiesByParent ( User $ user , WorkspaceTag $ workspaceTag ) { $ dql = ' SELECT h FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h WHERE h.user = :user AND h.parent = :workspaceTag ' ; $ query = $ this -> _em -> createQuery ( ... | Returns all relations where given workspaceTag is parent |
4,956 | public function findAllGroupsBySearch ( $ search ) { $ upperSearch = strtoupper ( trim ( $ search ) ) ; if ( $ search !== '' ) { $ dql = ' SELECT g FROM Claroline\CoreBundle\Entity\Group g WHERE UPPER(g.name) LIKE :search ' ; $ query = $ this -> _em -> createQuery... | Returns all the groups by search . |
4,957 | public function findByName ( $ search , $ executeQuery = true , $ orderedBy = 'id' , $ order = null ) { $ upperSearch = strtoupper ( $ search ) ; $ upperSearch = trim ( $ upperSearch ) ; $ upperSearch = preg_replace ( '/\s+/' , ' ' , $ upperSearch ) ; $ dql = " SELECT u, r, g FROM Claroline\CoreBundle\Entity... | Search users whose first name last name or username match a given search string . |
4,958 | public function findByNameAndGroup ( $ search , 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 (UPPER(u.username) LIKE :search ... | Returns the users of a group whose first name last name or username match a given search string . |
4,959 | public function findUsersByWorkspacesAndSearch ( array $ workspaces , $ search ) { $ upperSearch = strtoupper ( trim ( $ search ) ) ; $ dql = ' SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u JOIN u.roles wr LEFT JOIN u.groups g LEFT JOIN g.roles gr LEFT ... | Returns the users who are members of one of the given workspaces . User list is filtered by a search on first name last name and username |
4,960 | public function countUsersByRole ( $ role , $ restrictionRoleNames ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> select ( 'COUNT(DISTINCT user.id)' ) -> leftJoin ( 'user.roles' , 'roles' ) -> andWhere ( 'roles.id = :roleId' ) -> setParameter ( 'roleId' , $ role -> getId ( ) ) ; if ( ! empty ( $ restrictionRoleN... | Counts the users subscribed in a platform role |
4,961 | public function findUserIdsInRoles ( $ roleNames ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> select ( 'user.id' ) -> leftJoin ( 'user.roles' , 'roles' ) -> andWhere ( 'roles.name IN (:roleNames)' ) -> andWhere ( 'user.isEnabled = true' ) -> setParameter ( 'roleNames' , $ roleNames ) ; $ query = $ qb -> getQue... | Returns user Ids that are subscribed to one of the roles given |
4,962 | public function findGroupOutsidersByName ( Group $ group , $ search , $ executeQuery = true , $ orderedBy = 'id' ) { $ dql = " SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u WHERE ( UPPER(u.lastName) LIKE :search OR UPPER(u.firstName) LIKE :search ... | Returns the users who are not members of a group and whose first name last name or username match a given search string . |
4,963 | public function setPlatformRoles ( $ platformRoles ) { $ roles = $ this -> getEntityRoles ( ) ; $ removedRoles = array ( ) ; foreach ( $ roles as $ role ) { if ( $ role -> getType ( ) != Role :: WS_ROLE ) { $ removedRoles [ ] = $ role ; } } foreach ( $ removedRoles as $ removedRole ) { $ this -> roles -> removeElement ... | Replace the old platform roles of a user by a new array . |
4,964 | private function checkAccess ( $ permission , $ collection ) { if ( ! $ this -> authorization -> isGranted ( $ permission , $ collection ) ) { throw new AccessDeniedException ( print_r ( $ collection -> getErrorsForDisplay ( ) , true ) ) ; } } | Checks if the current user has the right to do an action on a ResourceCollection . Be carrefull ResourceCollection may need some aditionnal parameters . |
4,965 | public function createInstance ( Widget $ widget , $ isAdmin , $ isDesktop , User $ user = null , Workspace $ ws = null ) { if ( ! $ widget -> isDisplayableInDesktop ( ) ) { if ( $ isDesktop || $ user ) { throw new \ Exception ( "This widget doesn't support the desktop" ) ; } } if ( ! $ widget -> isDisplayableInWorkspa... | Creates a widget instance . |
4,966 | public function rename ( Workspace $ workspace , $ name ) { $ workspace -> setName ( $ name ) ; $ root = $ this -> resourceManager -> getWorkspaceRoot ( $ workspace ) ; $ root -> setName ( $ name ) ; $ this -> om -> persist ( $ workspace ) ; $ this -> om -> persist ( $ root ) ; $ this -> om -> flush ( ) ; } | Rename a workspace . |
4,967 | public function create ( Configuration $ configuration , User $ manager ) { $ transfertManager = $ this -> container -> get ( 'claroline.manager.transfert_manager' ) ; if ( $ this -> logger ) $ transfertManager -> setLogger ( $ this -> logger ) ; $ workspace = $ transfertManager -> createWorkspace ( $ configuration , $... | Creates a workspace . |
4,968 | public function importInExistingWorkspace ( Configuration $ configuration , Workspace $ workspace ) { $ root = $ this -> resourceManager -> getResourceFromNode ( $ this -> resourceManager -> getWorkspaceRoot ( $ workspace ) ) ; $ wsRoles = $ this -> roleManager -> getRolesByWorkspace ( $ workspace ) ; $ entityRoles = [... | Import the content of an archive in a workspace . |
4,969 | public function countResources ( Workspace $ workspace ) { $ root = $ this -> resourceManager -> getWorkspaceRoot ( $ workspace ) ; if ( ! $ root ) return 0 ; $ descendants = $ this -> resourceManager -> getDescendants ( $ root ) ; return count ( $ descendants ) ; } | Count the number of resources in a workspace |
4,970 | public function resourceWorkspace ( $ workspaceId ) { if ( ! $ this -> request ) { throw new NoHttpRequestException ( ) ; } $ breadcrumbsIds = $ this -> request -> query -> get ( '_breadcrumbs' ) ; if ( $ breadcrumbsIds != null ) { $ ancestors = $ this -> manager -> getByIds ( $ breadcrumbsIds ) ; if ( ! $ this -> mana... | Renders the resources page with its layout . |
4,971 | public function resourceDesktop ( ) { $ resourceTypes = $ this -> em -> getRepository ( 'ClarolineCoreBundle:Resource\ResourceType' ) -> findAll ( ) ; $ resourceActions = $ this -> em -> getRepository ( 'ClarolineCoreBundle:Resource\MenuAction' ) -> findByResourceType ( null ) ; return $ this -> templating -> render ( ... | Displays the resource manager . |
4,972 | public function extractTo ( $ extractPath , $ files = null ) { $ fs = new FileSystem ( ) ; $ ds = DIRECTORY_SEPARATOR ; for ( $ i = 0 ; $ i < $ this -> numFiles ; $ i ++ ) { $ oldName = parent :: getNameIndex ( $ i ) ; $ newName = mb_convert_encoding ( $ this -> getNameIndex ( $ i ) , 'ISO-8859-1' , 'CP850,UTF-8' ) ; $... | It actually works but in this code lies madness . |
4,973 | public function whereInUserWorkspace ( User $ user ) { $ eol = PHP_EOL ; $ clause = "node.workspace IN{$eol}" . "({$eol}" . " SELECT aw FROM Claroline\CoreBundle\Entity\Workspace\Workspace aw{$eol}" . " JOIN aw.roles r{$eol}" . " WHERE r IN (SELECT r2 FROM Claroline\CoreBundle\Entity\Role r2 {$eol}" . " ... | Filters nodes belonging to any of the workspaces a given user has access to . |
4,974 | public function whereTypeIn ( array $ types ) { if ( count ( $ types ) > 0 ) { $ this -> joinSingleRelatives = true ; $ clause = '' ; for ( $ i = 0 , $ count = count ( $ types ) ; $ i < $ count ; $ i ++ ) { $ clause .= $ i === 0 ? "resourceType.name = :type_{$i}" : "OR resourceType.name = :type_{$i}" ; $ clause .= $ i ... | Filters nodes of any of the given types . |
4,975 | public function whereRootIn ( array $ roots ) { if ( 0 !== $ count = count ( $ roots ) ) { $ eol = PHP_EOL ; $ clause = "{$eol}({$eol}" ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ clause .= $ i > 0 ? ' OR ' : ' ' ; $ clause .= "node.path LIKE :root_{$i}{$eol}" ; $ this -> parameters [ ":root_{$i}" ] = "{$roots... | Filters nodes that are the descendants of any of the given root directory paths . |
4,976 | public function whereIsShortcut ( ) { $ eol = PHP_EOL ; $ this -> joinRelativesClause = "JOIN rs.resourceNode node{$eol}" . $ this -> joinRelativesClause ; $ this -> joinRelativesClause = "JOIN rs.target target{$eol}" . $ this -> joinRelativesClause ; $ this -> fromClause = "FROM Claroline\CoreBundle\Entity\Resource\Re... | Filters nodes that are shortcuts and selects their target . |
4,977 | public function whereIsAccessible ( $ user ) { $ currentDate = new \ DateTime ( ) ; $ clause = '( creator.id = :creatorId OR ( node.published = true AND (node.accessibleFrom IS NULL OR node.accessibleFrom <= :currentdate) AND (node.accessibleUntil IS NU... | Filters nodes that are published . |
4,978 | public function executeGroupAdminAction ( Group $ group , AdditionalAction $ action ) { $ event = $ this -> eventDispatcher -> dispatch ( $ action -> getType ( ) . '_' . $ action -> getAction ( ) , 'AdminGroupAction' , array ( 'group' => $ group ) ) ; return $ event -> getResponse ( ) ; } | This method should be moved |
4,979 | public function refresh ( ) { $ this -> removeCache ( ) ; $ event = $ this -> eventManager -> dispatch ( 'refresh_cache' , 'RefreshCache' ) ; $ this -> writeCache ( $ event -> getParameters ( ) ) ; } | Refresh the claroline cache |
4,980 | public function endFlushSuite ( ) { if ( $ this -> flushSuiteLevel === 0 ) { throw new NoFlushSuiteStartedException ( 'No flush suite has been started' ) ; } -- $ this -> flushSuiteLevel ; $ this -> flush ( ) ; if ( $ this -> activateLog && $ this -> showFlushLevel ) $ this -> logFlushLevel ( ) ; } | Ends a previously opened flush suite . If there is no other active suite a flush is performed . |
4,981 | public function forceFlush ( ) { if ( $ this -> allowForceFlush ) { if ( $ this -> activateLog ) $ this -> log ( 'Flush was forced for level ' . $ this -> flushSuiteLevel . '.' ) ; parent :: flush ( ) ; } } | Forces a flush . |
4,982 | public function findByIds ( $ class , array $ ids ) { if ( count ( $ ids ) === 0 ) { return array ( ) ; } $ dql = "SELECT object FROM {$class} object WHERE object.id IN (:ids)" ; $ query = $ this -> wrapped -> createQuery ( $ dql ) ; $ query -> setParameter ( 'ids' , $ ids ) ; $ objects = $ query -> getResult ( ) ; if ... | Finds a set of objects by their ids . |
4,983 | public function getAssetPath ( ) { $ path = $ this -> assetsHelper -> getUrl ( '' ) ; if ( $ path [ strlen ( $ path ) - 1 ] === '/' ) { $ path = rtrim ( $ path , '/' ) ; } return $ path ; } | Returns the URI under which assets are served without any trailing slash . |
4,984 | public function callbackReplace ( $ matches ) { if ( $ matches [ 1 ] !== '' ) { return $ matches [ 0 ] ; } $ url = $ matches [ 2 ] ; $ urlWithPrefix = $ matches [ 2 ] ; if ( strpos ( $ url , '@' ) !== false ) { $ urlWithPrefix = 'mailto:' . $ url ; } elseif ( strpos ( $ url , 'https://' ) === 0 ) { $ urlWithPrefix = $ ... | For every url match in string encapsulate if needed and return string . |
4,985 | public function validateRequired ( string $ key , array $ def , $ value ) { if ( isset ( $ def [ 'required' ] ) && ( $ def [ 'required' ] === true ) && ( $ value === null || $ value === '' || $ value === false ) ) { $ this -> addError ( $ key , 'form.value_must_not_be_empty' ) ; } } | Validator for the required form field property |
4,986 | public function validateMatches ( string $ key , array $ def , $ value ) { if ( isset ( $ def [ 'matches' ] ) ) { if ( $ def [ 'matches' ] [ 0 ] == '!' ) { $ fieldName = substr ( $ def [ 'matches' ] , 1 ) ; if ( $ value == $ this -> getForm ( ) -> $ fieldName ) { $ this -> addError ( $ key , 'form.value_must_not_be_the... | Validator for the matches form field property |
4,987 | public function validateMin ( string $ key , array $ def , $ value ) { if ( ! isset ( $ def [ 'options' ] ) && isset ( $ def [ 'min' ] ) && $ value != '' ) { if ( isset ( $ def [ 'type' ] ) && ( $ def [ 'type' ] == 'int' || $ def [ 'type' ] == 'numeric' || $ def [ 'type' ] == 'float' ) ) { if ( $ value < $ def [ 'min' ... | Validator for the min form field property |
4,988 | public function validateDepends ( string $ key , array $ def , $ value ) { if ( isset ( $ def [ 'depends' ] ) ) { if ( $ this -> getForm ( ) -> { $ def [ 'depends' ] } != '' && $ value == '' && ! isset ( $ def [ 'depends_value_empty' ] ) ) { if ( isset ( $ def [ 'depends_first_option' ] ) && $ this -> getDefinition ( $... | Validator for the depends form field property |
4,989 | public function validateRegex ( string $ key , array $ def , $ value ) { if ( is_scalar ( $ value ) && isset ( $ def [ 'regex' ] ) && ! empty ( $ value ) && ! preg_match ( $ def [ 'regex' ] , $ value ) ) { $ this -> addError ( $ key , 'form.value_not_valid_regex' ) ; } } | Validator for the regex form field property |
4,990 | public function validateOptions ( string $ key , array $ def , $ value ) { if ( isset ( $ def [ 'options' ] ) && $ value != '' ) { if ( isset ( $ def [ 'min' ] ) || isset ( $ def [ 'max' ] ) ) { if ( ! is_array ( $ value ) ) { $ this -> addError ( $ key , 'form.value_must_be_list' ) ; } else { if ( isset ( $ def [ 'min... | Validator for the options form field property |
4,991 | public function validateField ( string $ key , array $ def , $ value ) { $ this -> validateRequired ( $ key , $ def , $ value ) ; $ this -> validateMin ( $ key , $ def , $ value ) ; $ this -> validateMax ( $ key , $ def , $ value ) ; $ this -> validateMatches ( $ key , $ def , $ value ) ; $ this -> validateDepends ( $ ... | Applies the validators to a form field . Can be extended by inherited classes . |
4,992 | private function validateArray ( $ templateVersionData ) { $ isValid = true ; $ isValid = $ isValid && is_array ( $ templateVersionData ) ; if ( $ isValid ) { $ keys = array_keys ( $ templateVersionData ) ; $ isValid = $ isValid && in_array ( 'id' , $ keys ) && in_array ( 'template_id' , $ keys ) && in_array ( 'active'... | Validates template version data is an array with all the expected keys |
4,993 | public function getFilters ( ) { return array ( 'timeAgo' => new \ Twig_Filter_Method ( $ this , 'timeAgo' ) , 'homeLink' => new \ Twig_Filter_Method ( $ this , 'homeLink' ) , 'activeLink' => new \ Twig_Filter_Method ( $ this , 'activeLink' ) , 'activeRoute' => new \ Twig_Filter_Method ( $ this , 'activeRoute' ) , 'com... | Get filters of the service |
4,994 | public function homeLink ( $ link ) { if ( ! ( strpos ( $ link , "http://" ) === 0 or strpos ( $ link , "https://" ) === 0 or strpos ( $ link , "ftp://" ) === 0 or strpos ( $ link , "www." ) === 0 ) ) { $ home = $ this -> container -> get ( "router" ) -> generate ( 'claro_index' ) . $ link ; $ home = str_replace ( "//"... | Check if a link is local or external |
4,995 | public function activeLink ( $ link ) { $ pathinfo = $ this -> getPathInfo ( ) ; if ( ( $ pathinfo and '/' . $ pathinfo === $ link ) or ( ! $ pathinfo and $ link === '/' ) ) { return ' active' ; } return '' ; } | Return active if a given link match to the path info |
4,996 | public function vote ( TokenInterface $ token , $ object , array $ attributes ) { if ( $ object instanceof FieldFacet ) { return $ this -> fieldFacetVote ( $ object , $ token , $ attributes [ 0 ] ) ; } return VoterInterface :: ACCESS_ABSTAIN ; } | Attributes can either be open or edit |
4,997 | public function initSecret ( ) { $ secret = $ this -> owner -> { $ this -> secretAttribute } ; if ( ! empty ( $ secret ) ) { $ this -> otp -> setSecret ( $ secret ) ; } } | Init secret attribute |
4,998 | public function confirmSecret ( ) { $ secret = $ this -> owner -> { $ this -> secretAttribute } ; if ( empty ( $ secret ) ) { $ this -> owner -> addError ( $ this -> codeAttribute , Yii :: t ( 'yii' , 'The secret is empty.' ) ) ; } else { $ this -> otp -> setSecret ( $ secret ) ; if ( ! $ this -> secretConfirmed ( ) ) ... | Confirm secret by code |
4,999 | public function decreaseSide ( $ side , $ size ) { $ x = $ y = 1 ; $ x2 = $ this -> width ; $ y2 = $ this -> height ; switch ( $ side ) { case 'top' : $ y = $ size ; break ; case 'right' : $ x2 -= $ size ; break ; case 'bottom' : $ y2 -= $ size ; break ; case 'left' : $ x = $ size ; break ; } $ this -> crop ( $ x , $ y... | Deletes a piece of image from specific side . For example if side = top and size = 100 100px from top will be deleted . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.