idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
21,000 | public function video ( $ file , $ caption = null ) { $ this -> messages [ ] = $ this -> media -> compile ( $ file , $ caption , 'video' ) ; } | Send video message |
21,001 | public function transformMessages ( array $ messages ) { $ transformed = null ; if ( count ( $ messages ) ) { $ transformed = [ ] ; foreach ( $ messages as $ message ) { $ attributes = ( object ) $ message -> getAttributes ( ) ; $ attributes -> timestamp = $ attributes -> t ; unset ( $ attributes -> t ) ; $ child = is_null ( $ message -> getChild ( 1 ) ) ? $ message -> getChild ( 0 ) : $ message -> getChild ( 1 ) ; $ node = new stdClass ( ) ; $ node -> tag = $ child -> getTag ( ) ; $ node -> attributes = ( object ) $ child -> getAttributes ( ) ; $ node -> data = $ child -> getData ( ) ; $ attributes -> body = $ node ; if ( $ attributes -> type == 'media' ) { if ( $ attributes -> body -> attributes -> type == 'vcard' ) { $ vcard = new VCardReader ( null , $ child -> getChild ( 0 ) -> getData ( ) ) ; if ( count ( $ vcard ) == 1 ) { $ attributes -> body -> vcard [ ] = $ vcard -> parse ( $ vcard ) ; } else { foreach ( $ vcard as $ card ) { $ attributes -> body -> vcard [ ] = $ vcard -> parse ( $ card ) ; } } } else { $ tmp = $ this -> media -> link ( $ attributes ) ; $ attributes -> body -> file = $ tmp -> file ; $ attributes -> body -> html = $ tmp -> html ; $ attributes -> body -> attributes2 = $ node -> attributes ; } } $ transformed [ ] = $ attributes ; } } return $ transformed ; } | Parse messages and determines message type and set captions and links |
21,002 | public function findCached ( ) : array { $ output = [ ] ; $ introspect = $ this -> introspection -> introspect ( ) ; $ tags = $ this -> introspection -> findTags ( CachedDataSource :: class ) ; foreach ( $ tags as $ tag ) { foreach ( $ tag as $ key => $ value ) { foreach ( $ introspect as $ item ) { if ( $ item -> tags [ 'services' ] [ 'subreport' ] === $ value ) { $ output [ ] = [ 'id' => $ item -> rid . '.' . $ item -> sid , 'report_id' => $ item -> rid , 'subreport_id' => $ item -> sid , 'report' => $ item -> tags [ 'services' ] [ 'report' ] , 'subreport' => $ item -> tags [ 'services' ] [ 'subreport' ] , 'key' => $ item -> tags [ 'services' ] [ 'subreport' ] , 'cache' => $ item -> tags [ 'cache' ] , ] ; } } } } return $ output ; } | Returns array of subreports which have cached datasource . All lazy - loaded . |
21,003 | public function warmupSubreport ( string $ subreport ) : Resultable { $ subreport = $ this -> introspection -> getService ( $ subreport ) ; if ( ! ( $ subreport instanceof Subreport ) ) { throw new InvalidStateException ( sprintf ( 'Service "%s" is not subreport' , get_class ( $ subreport ) ) ) ; } return $ subreport -> getDataSource ( ) -> compile ( $ subreport -> getParameters ( ) ) ; } | Warmup subreport cache |
21,004 | private function addDays ( $ extraSpec ) { if ( preg_match ( '/(\d+)D$/' , $ extraSpec , $ matches ) ) { $ days = end ( $ matches ) ; $ this -> dateInterval = DateInterval :: __set_state ( array ( 'y' => $ this -> dateInterval -> y , 'm' => $ this -> dateInterval -> m , 'd' => $ this -> dateInterval -> d , 'h' => $ this -> dateInterval -> h , 'i' => $ this -> dateInterval -> i , 's' => $ this -> dateInterval -> s , 'invert' => $ this -> dateInterval -> invert , 'days' => $ days ) ) ; } } | Add days property that is lost when constructing a new DateInterval |
21,005 | public function clear ( ) : void { $ this -> errors = [ ] ; if ( file_exists ( $ this -> cacheFileName ( ) ) ) { @ unlink ( $ this -> cacheFileName ( ) ) ; } } | Clear errors and cache |
21,006 | public function upload ( $ file , $ format = 'json' , $ album = null , $ name = null , $ title = null , $ description = null ) { return $ this -> post ( 'https://api.imgur.com/3/image.' . $ format , array ( 'image' => $ file , 'album' => $ album , 'name' => $ name , 'title' => $ title , 'description' => $ description ) , array ( 'Authorization: Client-ID ' . $ this -> key ) ) ; } | Upload an image to Imgur |
21,007 | public static function store ( FileSystemCacheKey $ key , $ data , $ ttl = null ) { $ filename = $ key -> getFileName ( ) ; $ data = new FileSystemCacheValue ( $ key , $ data , $ ttl ) ; $ fh = self :: getFileHandle ( $ filename , 'c' ) ; if ( ! $ fh ) return false ; if ( ! self :: putContents ( $ fh , $ data ) ) return false ; return true ; } | Stores data in the cache |
21,008 | public static function retrieve ( FileSystemCacheKey $ key , $ newer_than = null ) { $ filename = $ key -> getFileName ( ) ; if ( ! file_exists ( $ filename ) ) return false ; if ( $ newer_than && filemtime ( $ filename ) < $ newer_than ) return false ; $ fh = self :: getFileHandle ( $ filename , 'r' ) ; if ( ! $ fh ) return false ; $ data = self :: getContents ( $ fh , $ key ) ; if ( ! $ data ) return false ; self :: closeFile ( $ fh ) ; return $ data -> value ; } | Retrieve data from cache |
21,009 | public static function getAndModify ( FileSystemCacheKey $ key , \ Closure $ callback , $ resetTtl = false ) { $ filename = $ key -> getFileName ( ) ; if ( ! file_exists ( $ filename ) ) return false ; $ fh = self :: getFileHandle ( $ filename , 'c+' ) ; if ( ! $ fh ) return false ; $ data = self :: getContents ( $ fh , $ key ) ; if ( ! $ data ) return false ; $ old_value = $ data -> value ; $ data -> value = $ callback ( $ data -> value ) ; if ( $ data -> value === false ) { self :: closeFile ( $ fh ) ; self :: invalidate ( $ key ) ; return false ; } if ( ! $ resetTtl && $ data -> value === $ old_value ) { self :: closeFile ( $ fh ) ; return $ data -> value ; } if ( $ resetTtl ) { $ data -> created = time ( ) ; if ( $ data -> ttl ) { $ data -> expires = $ data -> created + $ data -> ttl ; } } if ( ! self :: emptyFile ( $ fh ) ) return false ; self :: putContents ( $ fh , $ data ) ; return $ data -> value ; } | Atomically retrieve data from cache modify it and store it back |
21,010 | public static function invalidate ( FileSystemCacheKey $ key ) { $ filename = $ key -> getFileName ( ) ; if ( file_exists ( $ filename ) ) { try { unlink ( $ filename ) ; } catch ( \ Exception $ ex ) { } } return true ; } | Invalidate a specific cache key |
21,011 | public static function invalidateGroup ( $ name = null , $ recursive = true ) { if ( $ name ) { $ name = trim ( $ name , '/' ) . '/' ; if ( strpos ( $ name , '..' ) !== false ) { throw new Exception ( "Invalidate path cannot go up directories." ) ; } } array_map ( "unlink" , glob ( self :: $ cacheDir . '/' . $ name . '*.cache' ) ) ; if ( $ recursive ) { $ subdirs = glob ( self :: $ cacheDir . '/' . $ name . '*' , GLOB_ONLYDIR ) ; foreach ( $ subdirs as $ dir ) { $ dir = basename ( $ dir ) ; if ( $ dir [ 0 ] == '.' ) continue ; self :: invalidateGroup ( $ name . $ dir , true ) ; } } } | Invalidate a group of cache keys |
21,012 | private static function getFileHandle ( $ filename , $ mode = 'c' ) { $ write = in_array ( $ mode , array ( 'c' , 'c+' ) ) ; if ( $ write ) { $ directory = dirname ( $ filename ) ; if ( ! file_exists ( $ directory ) ) { if ( ! mkdir ( $ directory , 0777 , true ) ) { return false ; } } elseif ( ! is_dir ( $ directory ) ) { return false ; } elseif ( ! is_writable ( $ directory ) ) { return false ; } } $ fh = fopen ( $ filename , $ mode ) ; if ( ! $ fh ) return false ; if ( $ write ) { if ( ! flock ( $ fh , LOCK_EX ) ) { self :: closeFile ( $ fh ) ; return false ; } } else { if ( ! flock ( $ fh , LOCK_SH ) ) { self :: closeFile ( $ fh ) ; return false ; } } return $ fh ; } | Get a file handle from a file name . Will create the directory if it doesn t exist already . Also automatically locks the file with the proper read or write lock . |
21,013 | private static function emptyFile ( $ fh ) { rewind ( $ fh ) ; if ( ! ftruncate ( $ fh , 0 ) ) { self :: closeFile ( $ fh ) ; return false ; } else { return true ; } } | Empties a file . If empty fails the file will be closed and it will return false . |
21,014 | private static function getContents ( $ fh , FileSystemCacheKey $ key ) { $ contents = stream_get_contents ( $ fh ) ; $ data = @ unserialize ( $ contents ) ; if ( ! $ data || ! ( $ data instanceof FileSystemCacheValue ) || $ data -> isExpired ( ) ) { self :: closeFile ( $ fh ) ; self :: invalidate ( $ key ) ; return false ; } return $ data ; } | Returns the contents of a cache file . If the data is not in the right form or expired it will be invalidated . |
21,015 | private static function putContents ( $ fh , FileSystemCacheValue $ data ) { try { fwrite ( $ fh , serialize ( $ data ) ) ; fflush ( $ fh ) ; } catch ( \ Exception $ ex ) { } self :: closeFile ( $ fh ) ; return true ; } | Writes to a file . Also closes and releases any locks on the file . |
21,016 | public function getEndpoint ( $ name = self :: DEFAULT_ENDPOINT ) : Endpoint { $ endpoints = $ this -> endpointsConfig ; unset ( $ endpoints [ self :: DEFAULT_ENDPOINT ] ) ; $ endpointsNames = array_keys ( $ endpoints ) ; if ( self :: DEFAULT_ENDPOINT !== $ name && ! \ in_array ( $ name , $ endpointsNames ) ) { throw new EndpointNotValidException ( $ name , $ endpointsNames ) ; } if ( isset ( self :: $ endpoints [ $ name ] ) ) { return self :: $ endpoints [ $ name ] ; } self :: $ endpoints [ $ name ] = $ this -> loadCache ( $ name ) ; if ( isset ( self :: $ endpoints [ $ name ] ) && self :: $ endpoints [ $ name ] instanceof Endpoint ) { return self :: $ endpoints [ $ name ] ; } $ this -> initialize ( $ name ) ; return self :: $ endpoints [ $ name ] ; } | Get endpoint schema |
21,017 | public function clearCache ( $ warmUp = false ) { @ unlink ( $ this -> cacheFileName ( 'default.raw' ) ) ; foreach ( $ this -> endpointsConfig as $ name => $ config ) { unset ( self :: $ endpoints [ $ name ] ) ; @ unlink ( $ this -> cacheFileName ( $ name ) ) ; if ( $ warmUp ) { $ this -> initialize ( $ name ) ; } } } | remove the specification cache |
21,018 | protected function compile ( Endpoint $ endpoint ) : void { foreach ( $ this -> plugins as $ plugin ) { foreach ( $ endpoint -> allTypes ( ) as $ type ) { $ this -> configureDefinition ( $ plugin , $ type , $ endpoint ) ; if ( $ type instanceof FieldsAwareDefinitionInterface ) { foreach ( $ type -> getFields ( ) as $ field ) { $ this -> configureDefinition ( $ plugin , $ field , $ endpoint ) ; foreach ( $ field -> getArguments ( ) as $ argument ) { $ this -> configureDefinition ( $ plugin , $ argument , $ endpoint ) ; } } } } foreach ( $ endpoint -> allQueries ( ) as $ query ) { $ this -> configureDefinition ( $ plugin , $ query , $ endpoint ) ; foreach ( $ query -> getArguments ( ) as $ argument ) { $ this -> configureDefinition ( $ plugin , $ argument , $ endpoint ) ; } } foreach ( $ endpoint -> allMutations ( ) as $ mutation ) { $ this -> configureDefinition ( $ plugin , $ mutation , $ endpoint ) ; foreach ( $ mutation -> getArguments ( ) as $ argument ) { $ this -> configureDefinition ( $ plugin , $ argument , $ endpoint ) ; } } foreach ( $ endpoint -> allSubscriptions ( ) as $ subscription ) { $ this -> configureDefinition ( $ plugin , $ subscription , $ endpoint ) ; foreach ( $ subscription -> getArguments ( ) as $ argument ) { $ this -> configureDefinition ( $ plugin , $ argument , $ endpoint ) ; } } $ plugin -> configureEndpoint ( $ endpoint ) ; } } | Verify endpoint definitions and do some tasks to prepare the endpoint |
21,019 | public function addColumn ( $ content , $ columnIndex = null , $ rowIndex = null ) { $ rowIndex = $ rowIndex === null ? $ this -> rowIndex : $ rowIndex ; if ( $ columnIndex === null ) { $ columnIndex = isset ( $ this -> rows [ $ rowIndex ] ) ? count ( $ this -> rows [ $ rowIndex ] ) : 0 ; } $ this -> rows [ $ rowIndex ] [ $ columnIndex ] = $ content ; return $ this ; } | Adds a column to the table |
21,020 | private function fig_cdata ( Context $ context ) { $ filename = $ this -> dataFile ; $ realfilename = dirname ( $ context -> getFilename ( ) ) . '/' . $ filename ; if ( ! file_exists ( $ realfilename ) ) { $ message = "File not found: $filename called from: " . $ context -> getFilename ( ) . '(' . $ this -> xmlLineNumber . ')' ; throw new FileNotFoundException ( $ message , $ filename ) ; } $ cdata = file_get_contents ( $ realfilename ) ; return $ cdata ; } | Imports at the current output position the contents of specified file unparsed rendered as is . |
21,021 | public function resizeTable ( int $ maxSize = null ) { if ( $ maxSize !== null ) { $ this -> maxSize = $ maxSize ; } while ( $ this -> size > $ this -> maxSize ) { list ( $ name , $ value ) = \ array_pop ( $ this -> headers ) ; $ this -> size -= 32 + \ strlen ( $ name ) + \ strlen ( $ value ) ; } } | Resizes the table to the given max size removing old entries as per section 4 . 4 if necessary . |
21,022 | private function collapseType ( array $ originDefinition ) : ? array { $ definition = [ ] ; if ( $ type = $ originDefinition [ 'type' ] ?? null ) { $ typeName = $ type [ 'name' ] ; if ( ! empty ( $ type [ 'ofType' ] ?? [ ] ) ) { $ typeName = $ type [ 'ofType' ] [ 'name' ] ; $ ofType = $ type ; if ( in_array ( $ ofType [ 'kind' ] , [ 'NON_NULL' , 'LIST' ] ) ) { $ typeName = '%s' ; while ( $ ofType ) { if ( $ ofType [ 'kind' ] === 'NON_NULL' ) { $ typeName = str_replace ( '%s' , '%s!' , $ typeName ) ; } elseif ( $ ofType [ 'kind' ] === 'LIST' ) { $ typeName = str_replace ( '%s' , '[%s]' , $ typeName ) ; } else { $ typeName = sprintf ( $ typeName , $ ofType [ 'name' ] ) ; break ; } $ ofType = $ ofType [ 'ofType' ] ?? null ; } } } $ definition [ 'type' ] = $ typeName ; } if ( $ fields = $ originDefinition [ 'fields' ] ?? null ) { foreach ( $ fields as $ field ) { $ definition [ 'fields' ] [ $ field [ 'name' ] ] = $ this -> collapseType ( $ field ) ; } } if ( $ inputFields = $ originDefinition [ 'inputFields' ] ?? null ) { foreach ( $ inputFields as $ inputField ) { $ definition [ 'inputFields' ] [ $ inputField [ 'name' ] ] = $ this -> collapseType ( $ inputField ) ; } } if ( $ args = $ originDefinition [ 'args' ] ?? null ) { foreach ( $ args as $ arg ) { $ definition [ 'args' ] [ $ arg [ 'name' ] ] = $ this -> collapseType ( $ arg ) ; } } if ( $ possibleTypes = $ originDefinition [ 'possibleTypes' ] ?? null ) { foreach ( $ possibleTypes as $ possibleType ) { $ definition [ 'possibleTypes' ] [ $ possibleType [ 'name' ] ] = $ this -> collapseType ( $ possibleType ) ; } } if ( $ interfaces = $ originDefinition [ 'interfaces' ] ?? null ) { foreach ( $ interfaces as $ interface ) { $ definition [ 'interfaces' ] [ ] = $ interface [ 'name' ] ; } } if ( $ enumValues = $ originDefinition [ 'enumValues' ] ?? null ) { foreach ( $ enumValues as $ enumValue ) { $ definition [ 'enumValues' ] [ ] = $ enumValue [ 'name' ] ; } } return empty ( $ definition ) ? null : $ definition ; } | Collapse type definition |
21,023 | protected function getDefinition ( ) : Definition { if ( isset ( self :: $ definitions [ static :: class ] ) ) { return self :: $ definitions [ static :: class ] ; } $ definition = new Definition ( ) ; $ this -> buildDefinition ( $ definition ) ; return self :: $ definitions [ static :: class ] = $ definition ; } | Returns the definition . |
21,024 | private function publicPropertyPath ( FormInterface $ form , $ path ) { $ pathArray = [ $ path ] ; if ( strpos ( $ path , '.' ) !== false ) { $ pathArray = explode ( '.' , $ path ) ; } if ( strpos ( $ path , '[' ) !== false ) { $ path = str_replace ( ']' , null , $ path ) ; $ pathArray = explode ( '[' , $ path ) ; } if ( in_array ( $ pathArray [ 0 ] , [ 'data' , 'children' ] ) ) { array_shift ( $ pathArray ) ; } $ contextForm = $ form ; foreach ( $ pathArray as & $ propName ) { if ( preg_match ( '/\.(data|children)$/' , $ propName ) ) { $ propName = preg_replace ( '/\.(data|children)/' , null , $ propName ) ; } $ index = null ; if ( preg_match ( '/(\w+)(\[\d+\])$/' , $ propName , $ matches ) ) { list ( , $ propName , $ index ) = $ matches ; } if ( ! $ contextForm -> has ( $ propName ) ) { foreach ( $ contextForm -> all ( ) as $ child ) { if ( $ child -> getConfig ( ) -> getOption ( 'property_path' ) === $ propName ) { $ propName = $ child -> getName ( ) ; } } } if ( $ index ) { $ propName = sprintf ( '%s%s' , $ propName , $ index ) ; } } unset ( $ propName ) ; return implode ( '.' , $ pathArray ) ; } | Convert internal validation property path to the public one required when use property_path in the form |
21,025 | public function index ( $ listener ) { $ eloquent = $ this -> model -> newQuery ( ) ; $ table = $ this -> presenter -> table ( $ eloquent ) ; $ this -> fireEvent ( 'list' , [ $ eloquent , $ table ] ) ; $ this -> presenter -> actions ( $ table ) ; return $ listener -> indexSucceed ( compact ( 'eloquent' , 'table' ) ) ; } | View list roles page . |
21,026 | public function edit ( $ listener , $ id ) { $ eloquent = $ this -> model -> findOrFail ( $ id ) ; $ form = $ this -> presenter -> form ( $ eloquent ) ; $ this -> fireEvent ( 'form' , [ $ eloquent , $ form ] ) ; return $ listener -> editSucceed ( compact ( 'eloquent' , 'form' ) ) ; } | View edit a role page . |
21,027 | public function store ( $ listener , array $ input ) { $ validation = $ this -> validator -> on ( 'create' ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> storeValidationFailed ( $ validation ) ; } $ role = $ this -> model ; try { $ this -> saving ( $ role , $ input , 'create' ) ; } catch ( Exception $ e ) { return $ listener -> storeFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> storeSucceed ( $ role ) ; } | Store a role . |
21,028 | public function update ( $ listener , array $ input , $ id ) { if ( ( int ) $ id !== ( int ) $ input [ 'id' ] ) { return $ listener -> userVerificationFailed ( ) ; } $ validation = $ this -> validator -> on ( 'update' ) -> bind ( [ 'roleID' => $ id ] ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> updateValidationFailed ( $ validation , $ id ) ; } $ role = $ this -> model -> findOrFail ( $ id ) ; try { $ this -> saving ( $ role , $ input , 'update' ) ; } catch ( Exception $ e ) { return $ listener -> updateFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> updateSucceed ( $ role ) ; } | Update a role . |
21,029 | public function destroy ( $ listener , $ id ) { $ role = $ this -> model -> findOrFail ( $ id ) ; try { DB :: transaction ( function ( ) use ( $ role ) { $ role -> delete ( ) ; } ) ; } catch ( Exception $ e ) { return $ listener -> destroyFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> destroySucceed ( $ role ) ; } | Delete a role . |
21,030 | protected function saving ( Eloquent $ role , $ input = [ ] , $ type = 'create' ) { $ beforeEvent = ( $ type === 'create' ? 'creating' : 'updating' ) ; $ afterEvent = ( $ type === 'create' ? 'created' : 'updated' ) ; $ role -> setAttribute ( 'name' , $ input [ 'name' ] ) ; $ this -> fireEvent ( $ beforeEvent , [ $ role ] ) ; $ this -> fireEvent ( 'saving' , [ $ role ] ) ; DB :: transaction ( function ( ) use ( $ role ) { $ role -> save ( ) ; } ) ; $ this -> fireEvent ( $ afterEvent , [ $ role ] ) ; $ this -> fireEvent ( 'saved' , [ $ role ] ) ; return true ; } | Save the role . |
21,031 | function all ( ) : \ React \ Promise \ PromiseInterface { return \ React \ Promise \ Stream \ all ( $ this ) -> then ( function ( array $ rows ) { return ( new \ Plasma \ QueryResult ( $ this -> affectedRows , $ this -> warningsCount , $ this -> insertID , $ this -> columns , $ rows ) ) ; } ) ; } | Buffers all rows and returns a promise which resolves with an instance of QueryResultInterface . This method does not guarantee that all rows get returned as the buffering depends on when this method gets invoked . There s no automatic buffering as such rows may be missing if invoked too late . |
21,032 | function pause ( ) { $ this -> paused = true ; if ( $ this -> started && ! $ this -> closed ) { $ this -> driver -> pauseStreamConsumption ( ) ; } } | Pauses the connection where this stream is coming from . This operation halts ALL read activities . You may still receive data events until the underlying network buffer is drained . |
21,033 | function resume ( ) { $ this -> paused = false ; if ( $ this -> started && ! $ this -> closed ) { $ this -> driver -> resumeStreamConsumption ( ) ; } } | Resumes the connection where this stream is coming from . |
21,034 | function close ( ) { if ( $ this -> closed ) { return ; } $ this -> closed = true ; if ( $ this -> started && $ this -> paused ) { $ this -> driver -> resumeStreamConsumption ( ) ; } $ this -> emit ( 'close' ) ; $ this -> removeAllListeners ( ) ; } | Closes the stream . Resumes the connection stream . |
21,035 | public function edit ( $ listener , $ metric ) { $ collection = [ ] ; $ instances = $ this -> acl -> all ( ) ; $ eloquent = null ; foreach ( $ instances as $ name => $ instance ) { $ collection [ $ name ] = ( string ) $ this -> getAuthorizationName ( $ name ) ; $ name === $ metric && $ eloquent = $ instance ; } if ( is_null ( $ eloquent ) ) { return $ listener -> aclVerificationFailed ( ) ; } $ actions = $ this -> getAuthorizationActions ( $ eloquent , $ metric ) ; $ roles = $ this -> getAuthorizationRoles ( $ eloquent ) ; return $ listener -> indexSucceed ( compact ( 'actions' , 'roles' , 'eloquent' , 'collection' , 'metric' ) ) ; } | List ACL collection . |
21,036 | public function update ( $ listener , array $ input ) { $ metric = $ input [ 'metric' ] ; $ acl = $ this -> acl -> get ( $ metric ) ; if ( is_null ( $ acl ) ) { return $ listener -> aclVerificationFailed ( ) ; } $ roles = $ acl -> roles ( ) -> get ( ) ; $ actions = $ acl -> actions ( ) -> get ( ) ; foreach ( $ roles as $ roleKey => $ roleName ) { foreach ( $ actions as $ actionKey => $ actionName ) { $ value = ( 'yes' === Arr :: get ( $ input , "acl-{$roleKey}-{$actionKey}" , 'no' ) ) ; $ acl -> allow ( $ roleName , $ actionName , $ value ) ; } } return $ listener -> updateSucceed ( $ metric ) ; } | Update ACL metric . |
21,037 | public function sync ( $ listener , $ vendor , $ package = null ) { $ roles = [ ] ; $ name = $ this -> getExtension ( $ vendor , $ package ) -> get ( 'name' ) ; $ acl = $ this -> acl -> get ( $ name ) ; if ( is_null ( $ acl ) ) { return $ listener -> aclVerificationFailed ( ) ; } foreach ( $ this -> model -> all ( ) as $ role ) { $ roles [ ] = $ role -> name ; } $ acl -> roles ( ) -> attach ( $ roles ) ; $ acl -> sync ( ) ; return $ listener -> syncSucceed ( new Fluent ( compact ( 'vendor' , 'package' , 'name' ) ) ) ; } | Sync role for an ACL instance . |
21,038 | protected function getAuthorizationActions ( AuthorizationContract $ acl , $ metric ) { return collect ( $ acl -> actions ( ) -> get ( ) ) -> map ( function ( $ slug ) use ( $ metric ) { $ key = "orchestra/foundation::acl.{$metric}.{$slug}" ; $ name = $ this -> translator -> has ( $ key ) ? $ this -> translator -> get ( $ key ) : Str :: humanize ( $ slug ) ; return compact ( 'slug' , 'name' ) ; } ) ; } | Get authorization actions . |
21,039 | protected function getAuthorizationRoles ( AuthorizationContract $ acl ) { return collect ( $ acl -> roles ( ) -> get ( ) ) -> reject ( function ( $ role ) { return in_array ( $ role , [ 'guest' ] ) ; } ) -> map ( function ( $ slug ) { $ name = Str :: humanize ( $ slug ) ; return compact ( 'slug' , 'name' ) ; } ) ; } | Get authorization roles . |
21,040 | function download ( ) { if ( ! $ this -> card ) { $ this -> build ( ) ; } if ( ! $ this -> filename ) { $ this -> filename = $ this -> data [ 'display_name' ] ; } $ this -> filename = str_replace ( ' ' , '_' , $ this -> filename ) ; header ( "Content-type: text/directory" ) ; header ( "Content-Disposition: attachment; filename=" . $ this -> filename . ".vcf" ) ; header ( "Pragma: public" ) ; echo $ this -> card ; return true ; } | Streams the vcard to the browser client . |
21,041 | protected function buildChoiceLookupList ( $ choices ) { $ array = array ( ) ; foreach ( $ choices as $ range => $ choice ) { $ range = explode ( ':' , $ range ) ; if ( count ( $ range ) < 2 ) { $ range [ ] = '' ; } $ array [ ] = ( object ) array ( 'range' => ( object ) array ( 'from' => $ range [ 0 ] , 'to' => $ range [ 1 ] , ) , 'string' => $ choice ) ; } return $ array ; } | Build a choice lookup list from the passed language choice array . |
21,042 | protected function fetchChoice ( $ choices , $ index , $ count ) { $ choice = $ choices [ $ index ] ; if ( ! $ choice -> range -> from ) { if ( $ index > 0 ) { $ choice -> range -> from = ( $ choices [ ( $ index - 1 ) ] -> range -> to + 1 ) ; } else { $ choice -> range -> from = ( - PHP_INT_MAX ) ; } } if ( ! $ choice -> range -> to ) { if ( $ index < ( $ count - 1 ) ) { $ choice -> range -> to = ( $ choices [ ( $ index + 1 ) ] -> range -> from - 1 ) ; } else { $ choice -> range -> to = PHP_INT_MAX ; } } return $ choice ; } | Extract a single choice from the array of choices and sanitize its values . |
21,043 | public static function from ( $ time ) : self { if ( $ time instanceof DateTimeInterface ) { return new static ( $ time -> format ( 'Y-m-d H:i:s' ) , $ time -> getTimezone ( ) ) ; } elseif ( is_numeric ( $ time ) ) { return ( new static ( '@' . $ time ) ) -> setTimezone ( new DateTimeZone ( date_default_timezone_get ( ) ) ) ; } else { return new static ( $ time ) ; } } | DateTime object factory . |
21,044 | public function evaluate ( Context $ context , $ arity , $ arguments ) { $ rangeSize = intval ( $ arguments [ 0 ] ) ; $ result = array ( ) ; for ( $ i = 1 ; $ i <= $ rangeSize ; ++ $ i ) { $ result [ ] = $ i ; } return $ result ; } | This function returns an array of N elements from 1 to N . It is useful for creating small for loops in your views . |
21,045 | function sendHTTPS ( $ data , $ timeout = 0 , $ response_timeout = 30 , $ cookies = NULL ) { return $ this -> send ( $ data , $ timeout , $ response_timeout , $ cookies ) ; } | sends the SOAP request and gets the SOAP response via HTTPS using CURL |
21,046 | function decodeSimple ( $ value , $ type , $ typens ) { if ( ( ! isset ( $ type ) ) || $ type == 'string' || $ type == 'long' || $ type == 'unsignedLong' ) { return ( string ) $ value ; } if ( $ type == 'int' || $ type == 'integer' || $ type == 'short' || $ type == 'byte' ) { return ( int ) $ value ; } if ( $ type == 'float' || $ type == 'double' || $ type == 'decimal' ) { return ( double ) $ value ; } if ( $ type == 'boolean' ) { if ( strtolower ( $ value ) == 'false' || strtolower ( $ value ) == 'f' ) { return false ; } return ( boolean ) $ value ; } if ( $ type == 'base64' || $ type == 'base64Binary' ) { $ this -> debug ( 'Decode base64 value' ) ; return base64_decode ( $ value ) ; } if ( $ type == 'nonPositiveInteger' || $ type == 'negativeInteger' || $ type == 'nonNegativeInteger' || $ type == 'positiveInteger' || $ type == 'unsignedInt' || $ type == 'unsignedShort' || $ type == 'unsignedByte' ) { return ( int ) $ value ; } if ( $ type == 'array' ) { return array ( ) ; } return ( string ) $ value ; } | decodes simple types into PHP variables |
21,047 | public function configure ( SimpleDoctrineMappingLocator $ locator ) { $ path = $ locator -> getPaths ( ) [ 0 ] ; $ resourcePathExploded = explode ( '/' , $ path ) ; $ resourcePathRoot = array_shift ( $ resourcePathExploded ) ; if ( strpos ( $ resourcePathRoot , '@' ) === 0 ) { $ mappingFileBundle = ltrim ( $ resourcePathRoot , '@' ) ; $ bundle = $ this -> kernel -> getBundle ( $ mappingFileBundle ) ; if ( $ bundle instanceof BundleInterface ) { $ resourcePathRoot = $ bundle -> getPath ( ) ; } } array_unshift ( $ resourcePathExploded , $ resourcePathRoot ) ; $ path = implode ( '/' , $ resourcePathExploded ) ; if ( ! file_exists ( $ path ) ) { throw new ConfigurationInvalidException ( 'Mapping file "' . $ path . '" does not exist' ) ; } $ locator -> setPaths ( [ $ path ] ) ; } | If there is a parameter named like the driver locator path replace it with the value of such parameter . |
21,048 | public function getRoute ( ) : ? RouteInterface { if ( ! is_null ( $ this -> getApp ( ) ) ) { return $ this -> getApp ( ) -> getService ( 'routing' ) -> getCurrentRoute ( ) ; } return null ; } | Get the Route object of the current path . |
21,049 | protected function redirect ( string $ url , int $ httpResponseCode = 302 ) : void { header ( 'Location: ' . $ url , true , $ httpResponseCode ) ; exit ; } | Redirection to a specific URL . |
21,050 | protected function reload ( array $ get = [ ] , bool $ merge = false ) : void { $ path = parse_url ( $ _SERVER [ "REQUEST_URI" ] , PHP_URL_PATH ) ; { $ query = [ ] ; if ( $ merge ) { parse_str ( parse_url ( $ _SERVER [ "REQUEST_URI" ] , PHP_URL_QUERY ) , $ query ) ; } $ query = array_merge ( $ query , $ get ) ; $ queryString = http_build_query ( $ query ) ; } $ this -> redirect ( $ path . ( ! empty ( $ queryString ) ? '?' . $ queryString : '' ) ) ; } | Reload current page . |
21,051 | protected function render ( string $ name , array $ variables = [ ] ) : string { $ templateEngine = $ this -> getApp ( ) -> getService ( 'templating' ) ; return $ templateEngine -> render ( $ name , $ variables ) ; } | Do render of templates . |
21,052 | protected function renderResponse ( string $ name , array $ variables = [ ] , ResponseInterface $ response = null ) : ResponseInterface { if ( is_null ( $ response ) ) { $ response = new Response ; } header_remove ( ) ; $ rendering = $ this -> render ( $ name , $ variables ) ; foreach ( headers_list ( ) as $ header ) { $ header = explode ( ':' , $ header , 2 ) ; $ response = $ response -> withAddedHeader ( $ header [ 0 ] , $ header [ 1 ] ?? '' ) ; } if ( $ response -> getBody ( ) -> isWritable ( ) ) { $ response -> getBody ( ) -> write ( $ rendering ) ; } else { $ body = new Stream ; $ body -> write ( $ rendering ) ; $ response = $ response -> withBody ( $ body ) ; } return $ response ; } | Do render of templates in Response object . |
21,053 | public function getQueryParts ( ) { $ this -> queryParts = [ 'graphs' => $ this -> extractGraphs ( $ this -> getQuery ( ) ) , 'sub_type' => $ this -> determineSubType ( $ this -> getQuery ( ) ) , ] ; $ this -> unsetEmptyValues ( $ this -> queryParts ) ; return $ this -> queryParts ; } | Return parts of the query on which this instance based on . It overrides the parent function and sets all values to null . |
21,054 | public function toPascalCase ( string $ string ) : string { $ string = Transliterator :: urlize ( ( string ) $ string ) ; $ string = str_replace ( '-' , '' , ucwords ( $ string , '-' ) ) ; return $ string ; } | Helper to convert strings to PascalCase |
21,055 | public function convertCamelCase ( $ string , $ separator = '-' ) : string { $ string = ( string ) $ string ; $ separator = ( string ) $ separator ; return strtolower ( preg_replace ( '/([a-zA-Z])(?=[A-Z])/' , '$1' . $ separator , $ string ) ) ; } | Helper to convert CamelCaseStrings to hyphen - case - strings |
21,056 | public function convertToString ( $ input , $ separator = ' ' ) : string { $ separator = ( string ) $ separator ; $ string = is_array ( $ input ) ? implode ( $ separator , $ input ) : ( string ) $ input ; return trim ( preg_replace ( '/(\s)+/' , ' ' , $ string ) ) ; } | Helper to make sure we got a string back |
21,057 | public function initialize ( ) { if ( $ this -> _multiFactorFlag === false ) { parent :: initialize ( ) ; return ; } if ( ! ( isset ( $ this -> _multiFactorStages ) ) || ! ( is_array ( $ this -> _multiFactorStages ) ) || ! ( isset ( $ this -> _multiFactorStages [ 'current' ] ) ) || ! ( is_int ( $ this -> _multiFactorStages [ 'current' ] ) ) || ! ( isset ( $ this -> _multiFactorStages [ 1 ] ) ) || ! ( is_array ( $ this -> _multiFactorStages [ 1 ] ) ) || ! ( isset ( $ this -> keyLength ) ) ) { throw new UserCredentialException ( 'The multi factor stages register is initialized with an an unknown state' , 2100 ) ; } $ currentStage = $ this -> _multiFactorStages [ 'current' ] ; if ( $ currentStage == 1 ) { $ this -> _multiFactorStages [ 1 ] [ 'statuss' ] = false ; parent :: initialize ( ) ; return ; } elseif ( $ currentStage != 2 ) { throw new UserCredentialException ( 'The current stage of the multi factor auth process is in an unknown state' , 2101 ) ; } $ userTotpProfile = $ this -> userTotpProfile ; if ( ! ( is_array ( $ userTotpProfile ) ) || ! ( isset ( $ userTotpProfile [ 'enc_key' ] ) ) || ! ( is_string ( $ userTotpProfile [ 'enc_key' ] ) ) || ! ( isset ( $ userTotpProfile [ 'totp_timestamp' ] ) ) || ! ( $ userTotpProfile [ 'totp_timestamp' ] instanceof \ DateTime ) || ! ( isset ( $ userTotpProfile [ 'totp_timelimit' ] ) ) || ! ( is_int ( $ userTotpProfile [ 'totp_timelimit' ] ) ) || ! ( isset ( $ this -> verificationHash ) ) || ! ( is_string ( $ this -> verificationHash ) ) || ! ( isset ( $ this -> oneTimeToken ) ) || ! ( is_string ( $ this -> oneTimeToken ) ) || ! ( isset ( $ this -> currentOneTimeToken ) ) || ! ( is_string ( $ this -> currentOneTimeToken ) ) ) { throw new UserCredentialException ( 'The user TOTP profile is not initialized properly' , 2102 ) ; } } | initialize the service bootstrap before any processing |
21,058 | public function authenticate ( ) { $ currentStage = $ this -> _multiFactorStages [ 'current' ] ; if ( $ currentStage == 1 ) { $ this -> _multiFactorStages [ 1 ] [ 'statuss' ] = parent :: authenticate ( ) ; if ( $ this -> _multiFactorStages [ 1 ] [ 'statuss' ] === true ) { $ this -> _multiFactorStages [ 2 ] = array ( 'enc_key' => \ openssl_random_pseudo_bytes ( $ this -> getEncKeyLength ( ) ) , 'statuss' => false ) ; } return $ this -> _multiFactorStages ; } elseif ( $ currentStage != 2 ) { throw new UserCredentialException ( 'The current stage of the multi factor auth process is in an unknown state' , 2101 ) ; } $ totpTimestamp = $ this -> userTotpProfile [ 'totp_timestamp' ] ; $ totpTimelimit = $ this -> userTotpProfile [ 'totp_timelimit' ] ; $ currDateTime = new \ DateTime ( ) ; $ totpTimeElapsed = $ currDateTime -> getTimestamp ( ) - $ totpTimestamp -> getTimestamp ( ) ; $ encKey = $ this -> userTotpProfile [ 'enc_key' ] ; $ verificationHash = $ this -> getVerificationHash ( ) ; $ comparisonHash = \ crypt ( $ this -> getCurrentPassword ( ) , $ encKey ) ; $ currentOneTimeToken = $ this -> getCurrentOneTimeToken ( ) ; $ oneTimeToken = $ this -> oneTimeToken ; $ verificationEqualsComparison = false ; if ( ! \ function_exists ( 'hash_equals' ) ) { if ( $ verificationHash === $ comparisonHash ) { $ verificationEqualsComparison = true ; } } else { if ( \ hash_equals ( $ verificationHash , $ comparisonHash ) ) { $ verificationEqualsComparison = true ; } } if ( ! ( $ totpTimeElapsed < $ totpTimelimit ) || ! ( $ verificationEqualsComparison === true ) || ! ( \ password_verify ( $ oneTimeToken , $ currentOneTimeToken ) ) ) { return false ; } else { return true ; } } | authenticate the user after initialization |
21,059 | public function setEncKeyLength ( $ keyLength ) { $ keyLengthCast = ( int ) $ keyLength ; if ( ! ( $ keyLengthCast > 0 ) ) { throw new UserCredentialException ( 'The encryption key length must be an integer' , 2105 ) ; } $ this -> keyLength = $ keyLengthCast ; } | Set the encryption key length |
21,060 | public function getOneTimeToken ( $ unhashed = false ) { if ( ( bool ) $ unhashed === true ) { return $ this -> oneTimeToken ; } else { return \ password_hash ( $ this -> oneTimeToken , \ PASSWORD_DEFAULT ) ; } } | Return the verification token |
21,061 | public function push ( $ view , array $ data = [ ] , $ callback = null , ? string $ queue = null ) : ReceiptContract { $ method = $ this -> shouldBeQueued ( ) ? 'queue' : 'send' ; return $ this -> { $ method } ( $ view , $ data , $ callback , $ queue ) ; } | Allow Orchestra Platform to either use send or queue based on settings . |
21,062 | public function send ( $ view , array $ data = [ ] , $ callback = null ) : ReceiptContract { $ mailer = $ this -> getMailer ( ) ; if ( $ view instanceof MailableContract ) { $ this -> updateFromOnMailable ( $ view ) -> send ( $ mailer ) ; } else { $ mailer -> send ( $ view , $ data , $ callback ) ; } return new Receipt ( $ mailer , false ) ; } | Force Orchestra Platform to send email directly . |
21,063 | public function queue ( $ view , array $ data = [ ] , $ callback = null , ? string $ queue = null ) : ReceiptContract { $ mailer = $ this -> getMailer ( ) ; if ( $ view instanceof MailableContract ) { $ this -> updateFromOnMailable ( $ view ) -> queue ( $ this -> queue ) ; } else { $ callback = $ this -> buildQueueCallable ( $ callback ) ; $ with = \ compact ( 'view' , 'data' , 'callback' ) ; $ this -> queue -> push ( 'orchestra.mail@handleQueuedMessage' , $ with , $ queue ) ; } return new Receipt ( $ mailer , true ) ; } | Force Orchestra Platform to send email using queue . |
21,064 | protected function updateFromOnMailable ( MailableContract $ message ) : MailableContract { if ( ! empty ( $ this -> from [ 'address' ] ) ) { $ message -> from ( $ this -> from [ 'address' ] , $ this -> from [ 'name' ] ) ; } return $ message ; } | Update from on mailable . |
21,065 | public function configureIlluminateMailer ( MailerContract $ mailer ) : MailerContract { $ from = $ this -> memory -> get ( 'email.from' ) ; if ( \ is_array ( $ from ) && ! empty ( $ from [ 'address' ] ) ) { $ this -> from = $ from ; $ mailer -> alwaysFrom ( $ from [ 'address' ] , $ from [ 'name' ] ) ; } if ( $ this -> queue instanceof QueueContract ) { $ mailer -> setQueue ( $ this -> queue ) ; } $ mailer -> setSwiftMailer ( new Swift_Mailer ( $ this -> transport -> driver ( ) ) ) ; return $ mailer ; } | Setup mailer . |
21,066 | public function getServices ( ) : ServiceContainer { if ( is_null ( $ this -> services ) ) { $ this -> services = new ServiceContainer ( ) ; $ this -> services -> setConstraints ( [ 'caching' => '\Psr\SimpleCache\CacheInterface' , 'events' => '\Psr\EventManager\EventManagerInterface' , 'flashbag' => '\Berlioz\Core\Services\FlashBag' , 'logging' => '\Psr\Log\LoggerInterface' , 'routing' => '\Berlioz\Core\Services\Routing\RouterInterface' , 'templating' => '\Berlioz\Core\Services\Template\TemplateInterface' ] ) ; $ this -> services -> registerServices ( [ 'events' => [ 'class' => '\Berlioz\Core\Services\Events\EventManager' ] , 'flashbag' => [ 'class' => '\Berlioz\Core\Services\FlashBag' ] , 'logging' => [ 'class' => '\Berlioz\Core\Services\Logger' ] , 'routing' => [ 'class' => '\Berlioz\Core\Services\Routing\Router' ] , 'templating' => [ 'class' => '\Berlioz\Core\Services\Template\DefaultEngine' ] ] ) ; $ this -> services -> registerServices ( $ this -> getConfig ( ) -> get ( 'app.services' ) ) ; $ this -> services -> register ( 'app' , $ this ) ; } return $ this -> services ; } | Get service container . |
21,067 | public function addExtension ( ExtensionInterface $ extension ) : App { try { if ( ! $ extension -> isInitialized ( ) ) { $ extension -> init ( $ this ) ; } } catch ( \ Exception $ e ) { throw new RuntimeException ( sprintf ( 'Unable to load extension "%s"' , get_class ( $ extension ) ) ) ; } return $ this ; } | Add extension . |
21,068 | private function registerController ( string $ controllerClassName ) { $ controllerAnnotation = $ this -> getControllerAnnotation ( $ controllerClassName ) ; if ( $ controllerAnnotation instanceof Controller ) { $ controllerName = trim ( $ controllerClassName , "\\" ) ; $ this -> app [ "$controllerName" ] = function ( Application $ app ) use ( $ controllerName ) { return new $ controllerName ( $ app ) ; } ; $ this -> processClassAnnotation ( $ controllerAnnotation ) ; } } | Register the controller using the controller definition parsed from annotation . |
21,069 | protected function getDatalistValue ( array $ names = array ( ) ) { $ services = \ hypeJunction \ Integration :: getServiceProvider ( ) ; foreach ( $ names as $ name ) { $ values [ $ name ] = $ services -> datalist -> get ( $ name ) ; } return $ values ; } | Retreive values from datalists table |
21,070 | public function setup ( ) { $ input_keys = array_keys ( ( array ) elgg_get_config ( 'input' ) ) ; $ request_keys = array_keys ( ( array ) $ _REQUEST ) ; $ keys = array_unique ( array_merge ( $ input_keys , $ request_keys ) ) ; foreach ( $ keys as $ key ) { if ( $ key ) { $ this -> params -> $ key = get_input ( $ key ) ; } } } | Populate params from input values |
21,071 | public function getReportedShippingCollections ( ) { try { return $ this -> encoder -> decode ( $ this -> getData ( self :: FIELD_REPORTED_SHIPPING_COLLECTIONS ) ) ? : [ ] ; } catch ( \ InvalidArgumentException $ e ) { $ this -> _logger -> error ( $ e -> getMessage ( ) ) ; return [ ] ; } } | Get all shipments for the order |
21,072 | protected function authenticateOnServer ( $ authUrl , $ username , $ password ) { $ response = $ this -> sendDigestAuthentication ( $ authUrl , $ username , $ password ) ; $ httpCode = $ response -> getHttpCode ( ) ; if ( 200 !== $ httpCode ) { throw new \ Exception ( 'Response with Status Code [' . $ httpCode . '].' , 500 ) ; } } | Using digest authentication to authenticate user on the server . |
21,073 | public function getRights ( ) { $ rights = array ( 'graphUpdate' => false , 'tripleQuerying' => false , 'tripleUpdate' => false ) ; $ graph = 'http://saft/' . hash ( 'sha1' , rand ( 0 , time ( ) ) . microtime ( true ) ) . '/' ; try { $ this -> query ( 'CREATE GRAPH <' . $ graph . '>' ) ; $ this -> query ( 'DROP GRAPH <' . $ graph . '>' ) ; $ rights [ 'graphUpdate' ] = true ; } catch ( \ Exception $ e ) { } try { $ this -> query ( 'SELECT ?g { GRAPH ?g {?s ?p ?o} } LIMIT 1' ) ; $ rights [ 'tripleQuerying' ] = true ; } catch ( \ Exception $ e ) { } try { if ( $ rights [ 'graphUpdate' ] ) { $ this -> query ( 'CREATE GRAPH <' . $ graph . '>' ) ; $ this -> query ( 'INSERT DATA { GRAPH <' . $ graph . '> { <' . $ graph . '1> <' . $ graph . '2> "42" } }' ) ; $ this -> query ( 'WITH <' . $ graph . '> DELETE { ?s ?p ?o }' ) ; $ this -> query ( 'DROP GRAPH <' . $ graph . '>' ) ; $ rights [ 'tripleUpdate' ] = true ; } } catch ( \ Exception $ e ) { try { $ this -> query ( 'DROP GRAPH <' . $ graph . '>' ) ; } catch ( \ Exception $ e ) { } } return $ rights ; } | Checks what rights the current user has to query and update graphs and triples . Be aware that method could polute your store by creating test graphs . |
21,074 | public function isGraphAvailable ( Node $ graph ) { $ graphs = $ this -> getGraphs ( ) ; return isset ( $ graphs [ $ graph -> getUri ( ) ] ) ; } | Checks if a certain graph is available in the store . |
21,075 | public function openConnection ( ) { if ( null == $ this -> httpClient ) { return false ; } $ configuration = array_merge ( array ( 'authUrl' => '' , 'password' => '' , 'queryUrl' => '' , 'username' => '' ) , $ this -> configuration ) ; if ( $ this -> RdfHelpers -> simpleCheckURI ( $ configuration [ 'authUrl' ] ) ) { $ this -> authenticateOnServer ( $ configuration [ 'authUrl' ] , $ configuration [ 'username' ] , $ configuration [ 'password' ] ) ; } if ( false === $ this -> RdfHelpers -> simpleCheckURI ( $ configuration [ 'queryUrl' ] ) ) { throw new \ Exception ( 'Parameter queryUrl is not an URI or empty: ' . $ configuration [ 'queryUrl' ] ) ; } } | Establish a connection to the endpoint and authenticate . |
21,076 | public function sendDigestAuthentication ( $ url , $ username , $ password = null ) { $ this -> httpClient -> setDigestAuthentication ( $ username , $ password ) ; return $ this -> httpClient -> get ( $ url ) ; } | Send digest authentication to the server via GET . |
21,077 | public function sendSparqlSelectQuery ( $ url , $ query ) { $ class = get_class ( $ this -> httpClient ) ; $ phpVersionToOld = version_compare ( phpversion ( ) , '5.5.11' , '<=' ) ; if ( $ phpVersionToOld && false === strpos ( $ class , 'Mockery' ) ) { $ this -> httpClient = new $ class ( ) ; } $ this -> httpClient -> setHeader ( 'Accept' , 'application/sparql-results+json' ) ; $ this -> httpClient -> setHeader ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ; return $ this -> httpClient -> post ( $ url , array ( 'query' => $ query ) ) ; } | Sends a SPARQL select query to the server . |
21,078 | public function sendSparqlUpdateQuery ( $ url , $ query ) { $ class = get_class ( $ this -> httpClient ) ; $ phpVersionToOld = version_compare ( phpversion ( ) , '5.5.11' , '<=' ) ; if ( $ phpVersionToOld && false === strpos ( $ class , 'Mockery' ) ) { $ this -> httpClient = new $ class ; } $ this -> httpClient -> setHeader ( 'Accept' , 'application/sparql-results+json' ) ; $ this -> httpClient -> setHeader ( 'Content-Type' , 'application/sparql-update' ) ; return $ this -> httpClient -> get ( $ url , array ( 'query' => $ query ) ) ; } | Sends a SPARQL update query to the server . |
21,079 | public function transformResultToArray ( $ receivedResult ) { if ( is_object ( $ receivedResult ) ) { return json_decode ( json_encode ( $ receivedResult ) , true ) ; } else { return json_decode ( $ receivedResult , true ) ; } } | Transforms server result to aray . |
21,080 | public function getProductTaxClasses ( ) { $ classes = [ ] ; $ taxCollection = $ this -> taxClass -> getCollection ( ) ; $ taxCollection -> setClassTypeFilter ( ClassModel :: TAX_CLASS_TYPE_PRODUCT ) ; foreach ( $ taxCollection as $ tax ) { $ classes [ ] = [ 'id' => $ tax -> getId ( ) , 'key' => $ tax -> getClassName ( ) ] ; } return $ classes ; } | Retrieves all product related tax classes for Merchant API to pick up |
21,081 | public function getCustomerTaxClasses ( ) { $ classes = [ ] ; $ defaultTaxId = $ this -> customerGroup -> getNotLoggedInGroup ( ) -> getTaxClassId ( ) ; $ taxCollection = $ this -> taxClass -> getCollection ( ) ; $ taxCollection -> setClassTypeFilter ( ClassModel :: TAX_CLASS_TYPE_CUSTOMER ) ; foreach ( $ taxCollection as $ tax ) { $ classes [ ] = [ 'id' => $ tax -> getId ( ) , 'key' => $ tax -> getClassName ( ) , 'is_default' => intval ( $ defaultTaxId == $ tax -> getId ( ) ) , ] ; } return $ classes ; } | Retrieves all customer related tax classes for Merchant API to pick up |
21,082 | public function getTaxRates ( ) { $ rates = [ ] ; foreach ( $ this -> taxRates as $ rate ) { $ zipCodeType = self :: ZIP_CODE_TYPE_ALL ; $ zipCodePattern = '' ; $ zipCodeRangeFrom = '' ; $ zipCodeRangeTo = '' ; if ( $ rate -> getZipIsRange ( ) ) { $ zipCodeType = self :: ZIP_CODE_TYPE_RANGE ; $ zipCodeRangeFrom = $ rate -> getZipFrom ( ) ; $ zipCodeRangeTo = $ rate -> getZipTo ( ) ; } elseif ( $ rate -> getTaxPostcode ( ) && $ rate -> getTaxPostcode ( ) != '*' ) { $ zipCodeType = self :: ZIP_CODE_TYPE_PATTERN ; $ zipCodePattern = $ rate -> getTaxPostcode ( ) ; } $ state = '' ; $ regionId = $ rate -> getTaxRegionId ( ) ; if ( $ regionId ) { $ region = $ this -> regionCollection -> getItemById ( $ regionId ) ; $ state = $ this -> regionHelper -> getIsoStateByMagentoRegion ( new DataObject ( [ 'region_code' => $ region -> getCode ( ) , 'country_id' => $ rate -> getTaxCountryId ( ) ] ) ) ; } $ rates [ ] = [ 'id' => $ rate -> getId ( ) , 'key' => $ rate -> getId ( ) , 'display_name' => $ rate -> getCode ( ) , 'tax_percent' => round ( $ rate -> getRate ( ) , 4 ) , 'country' => $ rate -> getTaxCountryId ( ) , 'state' => $ state , 'zipcode_type' => $ zipCodeType , 'zipcode_pattern' => $ zipCodePattern , 'zipcode_range_from' => $ zipCodeRangeFrom , 'zipcode_range_to' => $ zipCodeRangeTo ] ; } return $ rates ; } | Retrieve Magento tax rates for Merchant API to pick up |
21,083 | public function getTaxRules ( ) { $ rules = [ ] ; foreach ( $ this -> taxRules as $ rule ) { $ _rule = [ 'id' => $ rule -> getId ( ) , 'name' => $ rule -> getCode ( ) , 'priority' => $ rule -> getPriority ( ) , 'product_tax_classes' => [ ] , 'customer_tax_classes' => [ ] , 'tax_rates' => [ ] , ] ; foreach ( array_unique ( $ rule -> getProductTaxClasses ( ) ) as $ taxClass ) { $ _rule [ 'product_tax_classes' ] [ ] = [ 'id' => $ taxClass , 'key' => $ taxClass ] ; } foreach ( array_unique ( $ rule -> getCustomerTaxClasses ( ) ) as $ taxClass ) { $ _rule [ 'customer_tax_classes' ] [ ] = [ 'id' => $ taxClass , 'key' => $ taxClass ] ; } foreach ( array_unique ( $ rule -> getRates ( ) ) as $ taxRates ) { $ _rule [ 'tax_rates' ] [ ] = [ 'id' => $ taxRates , 'key' => $ taxRates ] ; } $ rules [ ] = $ _rule ; } return $ rules ; } | Retrieve Magento tax rules for Merchant API to pick up |
21,084 | private function _returnHash ( string $ hash , int $ length ) { try { return substr ( $ hash , 0 , $ length ) ; } catch ( \ Exception $ e ) { } return false ; } | Hashes a string |
21,085 | public function pathHash ( string $ path , int $ length = 8 ) { return $ this -> _returnHash ( sha1_file ( $ this -> _generalizeResource ( $ path ) ) , $ length ) ; } | Returns a shorten sha1 value of a file path . Fails silent |
21,086 | public function resourceHash ( $ resource , int $ length = 8 ) : string { return $ this -> _returnHash ( $ resource -> getResource ( ) -> getSha1 ( ) , $ length ) ; } | Returns a shorten sha1 value of a file property . Fails silent |
21,087 | public function makeFiles ( $ input , array $ attributes = array ( ) , array $ config = array ( ) ) { $ files = array ( ) ; $ uploads = hypeApps ( ) -> uploader -> handle ( $ input , $ attributes , $ config ) ; foreach ( $ uploads as $ upload ) { if ( $ upload -> file instanceof \ ElggEntity ) { $ files [ ] = $ upload -> file ; } } return $ files ; } | Create new file entities |
21,088 | public static function handle ( $ input , array $ attributes = array ( ) , array $ config = array ( ) ) { return hypeApps ( ) -> uploader -> handle ( $ input , $ attributes , $ config ) ; } | Static counterpart of makeFiles but returns data for processed uploads |
21,089 | protected function newFTPException ( $ message ) { return new FTPException ( sprintf ( "%s://%s:%s@%s:%d " . $ message , $ this -> authenticator -> getScheme ( ) , $ this -> authenticator -> getPasswordAuthentication ( ) -> getUsername ( ) , $ this -> authenticator -> getPasswordAuthentication ( ) -> getPassword ( ) , $ this -> authenticator -> getHost ( ) , $ this -> authenticator -> getPort ( ) ) ) ; } | Construct a new FTP exception . |
21,090 | function ResetCacheArray ( ) { reset ( $ this -> _sql_tables_schema [ 'cache' ] ) ; while ( list ( $ valid_key , $ valid_format ) = @ each ( $ this -> _sql_tables_schema [ 'cache' ] ) ) { $ pos = mb_strpos ( mb_strtoupper ( $ valid_format ) , 'DEFAULT' ) ; $ value = "" ; if ( $ pos !== FALSE ) { $ value = trim ( substr ( $ valid_format , $ pos + strlen ( "DEFAULT" ) ) ) ; if ( ( "'" == substr ( $ value , 0 , 1 ) ) && ( "'" == substr ( $ value , - 1 ) ) ) { $ value = substr ( $ value , 1 , - 1 ) ; } } $ this -> _cache_data [ $ valid_key ] = $ value ; } } | Reset the cache array |
21,091 | function ResetConfigArray ( $ array_to_reset = '' ) { if ( ! is_array ( $ array_to_reset ) ) { $ array_to_reset = $ this -> _sql_tables_schema [ 'config' ] ; } reset ( $ array_to_reset ) ; while ( list ( $ valid_key , $ valid_format ) = @ each ( $ array_to_reset ) ) { $ pos = mb_strpos ( mb_strtoupper ( $ valid_format ) , 'DEFAULT' ) ; $ value = "" ; if ( $ pos !== FALSE ) { $ value = trim ( substr ( $ valid_format , $ pos + strlen ( "DEFAULT" ) ) ) ; if ( ( "'" == substr ( $ value , 0 , 1 ) ) && ( "'" == substr ( $ value , - 1 ) ) ) { $ value = substr ( $ value , 1 , - 1 ) ; } } $ this -> _config_data [ $ valid_key ] = $ value ; } } | Reset the config array |
21,092 | function ResetTempUserArray ( ) { $ temp_user_array = array ( ) ; reset ( $ this -> _sql_tables_schema [ 'users' ] ) ; while ( list ( $ valid_key , $ valid_format ) = @ each ( $ this -> _sql_tables_schema [ 'users' ] ) ) { $ pos = mb_strpos ( mb_strtoupper ( $ valid_format ) , 'DEFAULT' ) ; $ value = "" ; if ( $ pos !== FALSE ) { $ value = trim ( substr ( $ valid_format , $ pos + strlen ( "DEFAULT" ) ) ) ; if ( ( "'" == substr ( $ value , 0 , 1 ) ) && ( "'" == substr ( $ value , - 1 ) ) ) { $ value = substr ( $ value , 1 , - 1 ) ; } } $ temp_user_array [ $ valid_key ] = $ value ; } $ temp_user_array [ 'request_prefix_pin' ] = $ this -> GetDefaultRequestPrefixPin ( ) ; return $ temp_user_array ; } | Reset the temporary user array |
21,093 | function ResetUserArray ( ) { $ this -> _user_data = array ( ) ; $ this -> _user_data = $ this -> ResetTempUserArray ( ) ; $ this -> SetUserDataReadFlag ( false ) ; } | Reset the user array |
21,094 | function GetDetailedUsersArray ( ) { $ users_array = array ( ) ; $ result = $ this -> GetNextUserArray ( TRUE ) ; if ( isset ( $ result [ 'user' ] ) ) { $ users_array [ $ result [ 'user' ] ] = $ result ; } do { if ( $ result = $ this -> GetNextUserArray ( ) ) { if ( isset ( $ result [ 'user' ] ) ) { $ users_array [ $ result [ 'user' ] ] = $ result ; } } } while ( FALSE !== $ result ) ; return $ users_array ; } | Completely new edition 2014 - 07 - 21 |
21,095 | function ImportTokensFile ( $ file , $ original_name = '' , $ cipher_password = '' , $ key_mac = "" ) { if ( ! file_exists ( $ file ) ) { $ result = FALSE ; } else { $ data1000 = @ file_get_contents ( $ file , FALSE , NULL , 0 , 1000 ) ; $ file_name = ( '' != $ original_name ) ? $ original_name : $ file ; if ( FALSE !== mb_strpos ( mb_strtolower ( $ data1000 ) , mb_strtolower ( '"urn:ietf:params:xml:ns:keyprov:pskc"' ) ) ) { $ result = $ this -> ImportTokensFromPskc ( $ file , $ cipher_password , $ key_mac ) ; } elseif ( FALSE !== mb_strpos ( mb_strtolower ( $ data1000 ) , mb_strtolower ( 'LOGGING START' ) ) ) { $ result = $ this -> ImportYubikeyTraditional ( $ file ) ; } elseif ( ( FALSE !== mb_strpos ( mb_strtolower ( $ data1000 ) , mb_strtolower ( 'AUTHENEXDB' ) ) ) && ( '.sql' == mb_strtolower ( substr ( $ file_name , - 4 ) ) ) ) { $ result = $ this -> ImportTokensFromAuthenexSql ( $ file ) ; } elseif ( ( FALSE !== mb_strpos ( mb_strtolower ( $ data1000 ) , mb_strtolower ( 'SafeWord Authenticator Records' ) ) ) && ( '.dat' == mb_strtolower ( substr ( $ file_name , - 4 ) ) ) ) { $ result = $ this -> ImportTokensFromAlpineDat ( $ file ) ; } elseif ( FALSE !== mb_strpos ( mb_strtolower ( $ data1000 ) , mb_strtolower ( '<ProductName>eTPass' ) ) ) { $ result = $ this -> ImportTokensFromAlpineXml ( $ file ) ; } elseif ( '.xml' == mb_strtolower ( substr ( $ file_name , - 4 ) ) ) { $ result = $ this -> ImportTokensFromXml ( $ file ) ; } else { $ result = $ this -> ImportTokensFromCsv ( $ file ) ; } } return $ result ; } | End of SelfRegisterHardwareToken |
21,096 | function qrcode ( $ data = '' , $ file_name = '' , $ image_type = "P" , $ ecc_level = "Q" , $ module_size = 4 , $ version = 0 , $ structure_m = 0 , $ structure_n = 0 , $ parity = 0 , $ original_data = '' ) { $ result = '' ; $ qrcode_folder = $ this -> GetQrCodeFolder ( ) ; $ path = $ qrcode_folder . 'data' ; $ image_path = $ qrcode_folder . 'image' ; if ( ! ( file_exists ( $ path ) && file_exists ( $ image_path ) ) ) { $ this -> WriteLog ( "Error: QRcode files or folders are not available" , FALSE , FALSE , 39 , 'System' , '' , 3 ) ; } else { $ result = MultiotpQrcode ( $ data , $ file_name , $ image_type , $ ecc_level , $ module_size , $ version , $ structure_m , $ structure_n , $ parity , $ original_data , $ path , $ image_path ) ; $ output_name = NULL ; ob_start ( ) ; if ( ( '' != trim ( $ file_name ) ) && ( 'binary' != trim ( $ file_name ) ) && ( '' != $ this -> GetLinuxFileMode ( ) ) ) { if ( file_exists ( $ file_name ) ) { @ chmod ( $ file_name , octdec ( $ this -> GetLinuxFileMode ( ) ) ) ; } } } return $ result ; } | This method is a stub that calls the MultiotpQrcode with the good pathes |
21,097 | function authenticate ( $ username , $ password , $ prevent_rebind = false ) { if ( $ username == NULL || $ password == NULL ) { return ( false ) ; } $ this -> _bind = @ ldap_bind ( $ this -> _conn , $ username . $ this -> _account_suffix , $ password ) ; $ this -> _bind_paged = @ ldap_bind ( $ this -> _conn_paged , $ username . $ this -> _account_suffix , $ password ) ; if ( ! $ this -> _bind ) { return ( false ) ; } if ( $ this -> _ad_username != NULL && ! $ prevent_rebind ) { $ this -> _bind = @ ldap_bind ( $ this -> _conn , $ this -> _ad_username . $ this -> _account_suffix , $ this -> _ad_password ) ; $ this -> _bind_paged = @ ldap_bind ( $ this -> _conn_paged , $ this -> _ad_username . $ this -> _account_suffix , $ this -> _ad_password ) ; if ( ! $ this -> _bind ) { $ this -> _error = TRUE ; $ this -> _error_message = 'FATAL: AD rebind failed.' ; exit ( ) ; } } return ( true ) ; } | validate a users login credentials |
21,098 | function group_add_group ( $ parent , $ child ) { $ parent_group = $ this -> group_info ( $ parent , array ( "cn" ) ) ; if ( $ parent_group [ 0 ] [ "dn" ] == NULL ) { return ( false ) ; } $ parent_dn = $ parent_group [ 0 ] [ "dn" ] ; $ child_group = $ this -> group_info ( $ child , array ( "cn" ) ) ; if ( $ child_group [ 0 ] [ "dn" ] == NULL ) { return ( false ) ; } $ child_dn = $ child_group [ 0 ] [ "dn" ] ; $ add = array ( ) ; $ add [ "member" ] = $ child_dn ; $ result = @ ldap_mod_add ( $ this -> _conn , $ parent_dn , $ add ) ; if ( $ result == false ) { return ( false ) ; } return ( true ) ; } | Add a group to a group |
21,099 | function group_add_user ( $ group , $ user ) { $ user_info = $ this -> user_info ( $ user , array ( "cn" ) ) ; if ( $ user_info [ 0 ] [ "dn" ] == NULL ) { return ( false ) ; } $ user_dn = $ user_info [ 0 ] [ "dn" ] ; $ group_info = $ this -> group_info ( $ group , array ( "cn" ) ) ; if ( $ group_info [ 0 ] [ "dn" ] == NULL ) { return ( false ) ; } $ group_dn = $ group_info [ 0 ] [ "dn" ] ; $ add = array ( ) ; $ add [ "member" ] = $ user_dn ; $ result = @ ldap_mod_add ( $ this -> _conn , $ group_dn , $ add ) ; if ( $ result == false ) { return ( false ) ; } return ( true ) ; } | Add a user to a group |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.