idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
13,600
private function prepareStatement ( Builder $ query , $ sql ) { $ connection = $ query -> getConnection ( ) ; $ pdo = $ connection -> getPdo ( ) ; return $ pdo -> prepare ( $ sql ) ; }
Get prepared statement .
13,601
private function bindValues ( & $ values , $ statement , $ parameter ) { $ count = count ( $ values ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( is_object ( $ values [ $ i ] ) ) { if ( $ values [ $ i ] instanceof DateTime ) { $ values [ $ i ] = $ values [ $ i ] -> format ( 'Y-m-d H:i:s' ) ; } else { $ values [ $...
Bind values to PDO statement .
13,602
public function saveLob ( Builder $ query , $ sql , array $ values , array $ binaries ) { $ id = 0 ; $ parameter = 0 ; $ statement = $ this -> prepareStatement ( $ query , $ sql ) ; $ parameter = $ this -> bindValues ( $ values , $ statement , $ parameter ) ; $ countBinary = count ( $ binaries ) ; for ( $ i = 0 ; $ i <...
Save Query with Blob returning primary key value .
13,603
public function autoIncrement ( $ table , $ column , $ triggerName , $ sequenceName ) { if ( ! $ table || ! $ column || ! $ triggerName || ! $ sequenceName ) { return false ; } if ( $ this -> connection -> getConfig ( 'prefix_schema' ) ) { $ table = $ this -> connection -> getConfig ( 'prefix_schema' ) . '.' . $ table ...
Function to create auto increment trigger for a table .
13,604
protected function wrapValue ( $ value ) { $ value = Str :: upper ( $ value ) ; return $ this -> isReserved ( $ value ) ? '"' . $ value . '"' : $ value ; }
Wrap value if reserved word .
13,605
protected function parseConfig ( array $ config ) { $ config = $ this -> setHost ( $ config ) ; $ config = $ this -> setPort ( $ config ) ; $ config = $ this -> setProtocol ( $ config ) ; $ config = $ this -> setServiceId ( $ config ) ; $ config = $ this -> setTNS ( $ config ) ; $ config = $ this -> setCharset ( $ conf...
Parse configurations .
13,606
protected function setServiceId ( array $ config ) { $ config [ 'service' ] = empty ( $ config [ 'service_name' ] ) ? $ service_param = 'SID = ' . $ config [ 'database' ] : $ service_param = 'SERVICE_NAME = ' . $ config [ 'service_name' ] ; return $ config ; }
Set service id from config .
13,607
protected function checkMultipleHostDsn ( array $ config ) { $ host = is_array ( $ config [ 'host' ] ) ? $ config [ 'host' ] : explode ( ',' , $ config [ 'host' ] ) ; $ count = count ( $ host ) ; if ( $ count > 1 ) { $ address = '' ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ address .= '(ADDRESS = (PROTOCOL = ' . $ ...
Set DSN host from config .
13,608
public function get ( $ propertyName ) { return isset ( $ this -> result [ $ propertyName ] ) ? $ this -> result [ $ propertyName ] [ 1 ] : null ; }
Returns the current value for a property .
13,609
public function get404Properties ( ) { $ result = [ ] ; foreach ( $ this -> result as $ propertyName => $ stuff ) { if ( 404 === $ stuff [ 0 ] ) { $ result [ ] = $ propertyName ; } } if ( ! $ result ) { $ result [ ] = '{http://sabredav.org/ns}idk' ; } return $ result ; }
Returns all propertynames that have a 404 status and thus don t have a value yet .
13,610
protected function sendSyncCollectionResponse ( $ syncToken , $ collectionUrl , array $ added , array $ modified , array $ deleted , array $ properties ) { $ fullPaths = [ ] ; foreach ( array_merge ( $ added , $ modified ) as $ item ) { $ fullPath = $ collectionUrl . '/' . $ item ; $ fullPaths [ ] = $ fullPath ; } $ re...
Sends the response to a sync - collection request .
13,611
public function propFind ( $ url , array $ properties , $ depth = 0 ) { $ dom = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ dom -> formatOutput = true ; $ root = $ dom -> createElementNS ( 'DAV:' , 'd:propfind' ) ; $ prop = $ dom -> createElement ( 'd:prop' ) ; foreach ( $ properties as $ property ) { list ( $ namespace ...
Does a PROPFIND request .
13,612
public function propPatch ( $ url , array $ properties ) { $ propPatch = new Xml \ Request \ PropPatch ( ) ; $ propPatch -> properties = $ properties ; $ xml = $ this -> xml -> write ( '{DAV:}propertyupdate' , $ propPatch ) ; $ url = $ this -> getAbsoluteUrl ( $ url ) ; $ request = new HTTP \ Request ( 'PROPPATCH' , $ ...
Updates a list of properties on the server .
13,613
public function options ( ) { $ request = new HTTP \ Request ( 'OPTIONS' , $ this -> getAbsoluteUrl ( '' ) ) ; $ response = $ this -> send ( $ request ) ; $ dav = $ response -> getHeader ( 'Dav' ) ; if ( ! $ dav ) { return [ ] ; } $ features = explode ( ',' , $ dav ) ; foreach ( $ features as & $ v ) { $ v = trim ( $ v...
Performs an HTTP options request .
13,614
public function request ( $ method , $ url = '' , $ body = null , array $ headers = [ ] ) { $ url = $ this -> getAbsoluteUrl ( $ url ) ; $ response = $ this -> send ( new HTTP \ Request ( $ method , $ url , $ headers , $ body ) ) ; return [ 'body' => $ response -> getBodyAsString ( ) , 'statusCode' => ( int ) $ respons...
Performs an actual HTTP request and returns the result .
13,615
public function parseMultiStatus ( $ body ) { $ multistatus = $ this -> xml -> expect ( '{DAV:}multistatus' , $ body ) ; $ result = [ ] ; foreach ( $ multistatus -> getResponses ( ) as $ response ) { $ result [ $ response -> getHref ( ) ] = $ response -> getResponseProperties ( ) ; } return $ result ; }
Parses a WebDAV multistatus response body .
13,616
public function getChild ( $ name ) { $ obj = $ this -> carddavBackend -> getCard ( $ this -> addressBookInfo [ 'id' ] , $ name ) ; if ( ! $ obj ) { throw new DAV \ Exception \ NotFound ( 'Card not found' ) ; } return new Card ( $ this -> carddavBackend , $ this -> addressBookInfo , $ obj ) ; }
Returns a card .
13,617
public function getChildren ( ) { $ objs = $ this -> carddavBackend -> getCards ( $ this -> addressBookInfo [ 'id' ] ) ; $ children = [ ] ; foreach ( $ objs as $ obj ) { $ obj [ 'acl' ] = $ this -> getChildACL ( ) ; $ children [ ] = new Card ( $ this -> carddavBackend , $ this -> addressBookInfo , $ obj ) ; } return $ ...
Returns the full list of cards .
13,618
public function getChild ( $ name ) { if ( 'inbox' === $ name && $ this -> caldavBackend instanceof Backend \ SchedulingSupport ) { return new Schedule \ Inbox ( $ this -> caldavBackend , $ this -> principalInfo [ 'uri' ] ) ; } if ( 'outbox' === $ name && $ this -> caldavBackend instanceof Backend \ SchedulingSupport )...
Returns a single calendar by name .
13,619
public function getChildren ( ) { $ calendars = $ this -> caldavBackend -> getCalendarsForUser ( $ this -> principalInfo [ 'uri' ] ) ; $ objs = [ ] ; foreach ( $ calendars as $ calendar ) { if ( $ this -> caldavBackend instanceof Backend \ SharingSupport ) { $ objs [ ] = new SharedCalendar ( $ this -> caldavBackend , $...
Returns a list of calendars .
13,620
public function createExtendedCollection ( $ name , MkCol $ mkCol ) { $ isCalendar = false ; $ isSubscription = false ; foreach ( $ mkCol -> getResourceType ( ) as $ rt ) { switch ( $ rt ) { case '{DAV:}collection' : case '{http://calendarserver.org/ns/}shared-owner' : break ; case '{urn:ietf:params:xml:ns:caldav}calen...
Creates a new calendar or subscription .
13,621
public function shareReply ( $ href , $ status , $ calendarUri , $ inReplyTo , $ summary = null ) { if ( ! $ this -> caldavBackend instanceof Backend \ SharingSupport ) { throw new DAV \ Exception \ NotImplemented ( 'Sharing support is not implemented by this backend.' ) ; } return $ this -> caldavBackend -> shareReply...
This method is called when a user replied to a request to share .
13,622
public function httpGet ( RequestInterface $ request , ResponseInterface $ response ) { $ queryParams = $ request -> getQueryParameters ( ) ; if ( ! array_key_exists ( 'mount' , $ queryParams ) ) { return ; } $ currentUri = $ request -> getAbsoluteUrl ( ) ; list ( $ currentUri ) = explode ( '?' , $ currentUri ) ; $ thi...
beforeMethod event handles . This event handles intercepts GET requests ending with ?mount .
13,623
public function davMount ( ResponseInterface $ response , $ uri ) { $ response -> setStatus ( 200 ) ; $ response -> setHeader ( 'Content-Type' , 'application/davmount+xml' ) ; ob_start ( ) ; echo '<?xml version="1.0"?>' , "\n" ; echo "<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n" ; echo ' <dm:url>' , htm...
Generates the davmount response .
13,624
public function getChildForPrincipal ( array $ principalInfo ) { $ owner = $ principalInfo [ 'uri' ] ; $ acl = [ [ 'privilege' => '{DAV:}all' , 'principal' => '{DAV:}owner' , 'protected' => true , ] , ] ; list ( , $ principalBaseName ) = Uri \ split ( $ owner ) ; $ path = $ this -> storagePath . '/' . $ principalBaseNa...
Returns a principals collection of files .
13,625
public function getPrincipalsByPrefix ( $ prefixPath ) { $ fields = [ 'uri' , ] ; foreach ( $ this -> fieldMap as $ key => $ value ) { $ fields [ ] = $ value [ 'dbField' ] ; } $ result = $ this -> pdo -> query ( 'SELECT ' . implode ( ',' , $ fields ) . ' FROM ' . $ this -> tableName ) ; $ principals = [ ] ; while ( $ ...
Returns a list of principals based on a prefix .
13,626
public function getPrincipalByPath ( $ path ) { $ fields = [ 'id' , 'uri' , ] ; foreach ( $ this -> fieldMap as $ key => $ value ) { $ fields [ ] = $ value [ 'dbField' ] ; } $ stmt = $ this -> pdo -> prepare ( 'SELECT ' . implode ( ',' , $ fields ) . ' FROM ' . $ this -> tableName . ' WHERE uri = ?' ) ; $ stmt -> exec...
Returns a specific principal specified by it s path . The returned structure should be the exact same as from getPrincipalsByPrefix .
13,627
public function updatePrincipal ( $ path , DAV \ PropPatch $ propPatch ) { $ propPatch -> handle ( array_keys ( $ this -> fieldMap ) , function ( $ properties ) use ( $ path ) { $ query = 'UPDATE ' . $ this -> tableName . ' SET ' ; $ first = true ; $ values = [ ] ; foreach ( $ properties as $ key => $ value ) { $ dbFie...
Updates one ore more webdav properties on a principal .
13,628
public function getGroupMemberSet ( $ principal ) { $ principal = $ this -> getPrincipalByPath ( $ principal ) ; if ( ! $ principal ) { throw new DAV \ Exception ( 'Principal not found' ) ; } $ stmt = $ this -> pdo -> prepare ( 'SELECT principals.uri as uri FROM ' . $ this -> groupMembersTableName . ' AS groupmembers L...
Returns the list of members for a group - principal .
13,629
public function setGroupMemberSet ( $ principal , array $ members ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT id, uri FROM ' . $ this -> tableName . ' WHERE uri IN (? ' . str_repeat ( ', ? ' , count ( $ members ) ) . ');' ) ; $ stmt -> execute ( array_merge ( [ $ principal ] , $ members ) ) ; $ memberIds = [ ] ; $ ...
Updates the list of group members for a group principal .
13,630
public function createPrincipal ( $ path , MkCol $ mkCol ) { $ stmt = $ this -> pdo -> prepare ( 'INSERT INTO ' . $ this -> tableName . ' (uri) VALUES (?)' ) ; $ stmt -> execute ( [ $ path ] ) ; $ this -> updatePrincipal ( $ path , $ mkCol ) ; }
Creates a new principal .
13,631
public function initialize ( Server $ server ) { $ this -> server = $ server ; $ server -> on ( 'beforeMethod:*' , [ $ this , 'beforeMethod' ] ) ; $ server -> on ( 'beforeCreateFile' , [ $ this , 'beforeCreateFile' ] ) ; }
Initialize the plugin .
13,632
public function beforeMethod ( RequestInterface $ request , ResponseInterface $ response ) { if ( ! $ tempLocation = $ this -> isTempFile ( $ request -> getPath ( ) ) ) { return ; } switch ( $ request -> getMethod ( ) ) { case 'GET' : return $ this -> httpGet ( $ request , $ response , $ tempLocation ) ; case 'PUT' : r...
This method is called before any HTTP method handler .
13,633
public function beforeCreateFile ( $ uri , $ data , ICollection $ parent , $ modified ) { if ( $ tempPath = $ this -> isTempFile ( $ uri ) ) { $ hR = $ this -> server -> httpResponse ; $ hR -> setHeader ( 'X-Sabre-Temp' , 'true' ) ; file_put_contents ( $ tempPath , $ data ) ; return false ; } return ; }
This method is invoked if some subsystem creates a new file .
13,634
public function httpGet ( RequestInterface $ request , ResponseInterface $ hR , $ tempLocation ) { if ( ! file_exists ( $ tempLocation ) ) { return ; } $ hR -> setHeader ( 'Content-Type' , 'application/octet-stream' ) ; $ hR -> setHeader ( 'Content-Length' , filesize ( $ tempLocation ) ) ; $ hR -> setHeader ( 'X-Sabre-...
This method handles the GET method for temporary files . If the file doesn t exist it will return false which will kick in the regular system for the GET method .
13,635
public function httpPut ( RequestInterface $ request , ResponseInterface $ hR , $ tempLocation ) { $ hR -> setHeader ( 'X-Sabre-Temp' , 'true' ) ; $ newFile = ! file_exists ( $ tempLocation ) ; if ( ! $ newFile && ( $ this -> server -> httpRequest -> getHeader ( 'If-None-Match' ) ) ) { throw new Exception \ Preconditio...
This method handles the PUT method .
13,636
public function httpDelete ( RequestInterface $ request , ResponseInterface $ hR , $ tempLocation ) { if ( ! file_exists ( $ tempLocation ) ) { return ; } unlink ( $ tempLocation ) ; $ hR -> setHeader ( 'X-Sabre-Temp' , 'true' ) ; $ hR -> setStatus ( 204 ) ; return false ; }
This method handles the DELETE method .
13,637
public function httpPropfind ( RequestInterface $ request , ResponseInterface $ hR , $ tempLocation ) { if ( ! file_exists ( $ tempLocation ) ) { return ; } $ hR -> setHeader ( 'X-Sabre-Temp' , 'true' ) ; $ hR -> setStatus ( 207 ) ; $ hR -> setHeader ( 'Content-Type' , 'application/xml; charset=utf-8' ) ; $ properties ...
This method handles the PROPFIND method .
13,638
public function shareResource ( $ path , array $ sharees ) { $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; if ( ! $ node instanceof ISharedNode ) { throw new Forbidden ( 'Sharing is not allowed on this node' ) ; } $ acl = $ this -> server -> getPlugin ( 'acl' ) ; if ( $ acl ) { $ acl -> checkPrivileg...
Updates the list of sharees on a shared resource .
13,639
public function propFind ( PropFind $ propFind , INode $ node ) { if ( $ node instanceof ISharedNode ) { $ propFind -> handle ( '{DAV:}share-access' , function ( ) use ( $ node ) { return new Property \ ShareAccess ( $ node -> getShareAccess ( ) ) ; } ) ; $ propFind -> handle ( '{DAV:}invite' , function ( ) use ( $ nod...
This event is triggered when properties are requested for nodes .
13,640
public function httpPost ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; $ contentType = $ request -> getHeader ( 'Content-Type' ) ; if ( null === $ contentType ) { return ; } if ( false === strpos ( $ contentType , 'application/davsharing+xml' ) ) { return ; } $ mess...
We intercept this to handle POST requests on shared resources .
13,641
public function htmlActionsPanel ( INode $ node , & $ output , $ path ) { if ( ! $ node instanceof ISharedNode ) { return ; } $ aclPlugin = $ this -> server -> getPlugin ( 'acl' ) ; if ( $ aclPlugin ) { if ( ! $ aclPlugin -> checkPrivileges ( $ path , '{DAV:}share' , \ Sabre \ DAVACL \ Plugin :: R_PARENT , false ) ) { ...
This method is used to generate HTML output for the DAV \ Browser \ Plugin .
13,642
public function browserPostAction ( $ path , $ action , $ postVars ) { if ( 'share' !== $ action ) { return ; } if ( empty ( $ postVars [ 'href' ] ) ) { throw new BadRequest ( 'The "href" POST parameter is required' ) ; } if ( empty ( $ postVars [ 'access' ] ) ) { throw new BadRequest ( 'The "access" POST parameter is ...
This method is triggered for POST actions generated by the browser plugin .
13,643
public function getBaseUri ( ) { if ( is_null ( $ this -> baseUri ) ) { $ this -> baseUri = $ this -> guessBaseUri ( ) ; } return $ this -> baseUri ; }
Returns the base responding uri .
13,644
public function guessBaseUri ( ) { $ pathInfo = $ this -> httpRequest -> getRawServerValue ( 'PATH_INFO' ) ; $ uri = $ this -> httpRequest -> getRawServerValue ( 'REQUEST_URI' ) ; if ( ! empty ( $ pathInfo ) ) { if ( $ pos = strpos ( $ uri , '?' ) ) { $ uri = substr ( $ uri , 0 , $ pos ) ; } $ decodedUri = HTTP \ decod...
This method attempts to detect the base uri . Only the PATH_INFO variable is considered .
13,645
public function addPlugin ( ServerPlugin $ plugin ) { $ this -> plugins [ $ plugin -> getPluginName ( ) ] = $ plugin ; $ plugin -> initialize ( $ this ) ; }
Adds a plugin to the server .
13,646
public function getPlugin ( $ name ) { if ( isset ( $ this -> plugins [ $ name ] ) ) { return $ this -> plugins [ $ name ] ; } return null ; }
Returns an initialized plugin by it s name .
13,647
public function invokeMethod ( RequestInterface $ request , ResponseInterface $ response , $ sendResponse = true ) { $ method = $ request -> getMethod ( ) ; if ( ! $ this -> emit ( 'beforeMethod:' . $ method , [ $ request , $ response ] ) ) { return ; } if ( self :: $ exposeVersion ) { $ response -> setHeader ( 'X-Sabr...
Handles a http request and execute a method based on its name .
13,648
public function getAllowedMethods ( $ path ) { $ methods = [ 'OPTIONS' , 'GET' , 'HEAD' , 'DELETE' , 'PROPFIND' , 'PUT' , 'PROPPATCH' , 'COPY' , 'MOVE' , 'REPORT' , ] ; try { $ this -> tree -> getNodeForPath ( $ path ) ; } catch ( Exception \ NotFound $ e ) { $ methods [ ] = 'MKCOL' ; } foreach ( $ this -> plugins as $...
Returns an array with all the supported HTTP methods for a specific uri .
13,649
public function calculateUri ( $ uri ) { if ( '' != $ uri && '/' != $ uri [ 0 ] && strpos ( $ uri , '://' ) ) { $ uri = parse_url ( $ uri , PHP_URL_PATH ) ; } $ uri = Uri \ normalize ( preg_replace ( '|/+|' , '/' , $ uri ) ) ; $ baseUri = Uri \ normalize ( $ this -> getBaseUri ( ) ) ; if ( 0 === strpos ( $ uri , $ base...
Turns a URI such as the REQUEST_URI into a local path .
13,650
public function getHTTPDepth ( $ default = self :: DEPTH_INFINITY ) { $ depth = $ this -> httpRequest -> getHeader ( 'Depth' ) ; if ( is_null ( $ depth ) ) { return $ default ; } if ( 'infinity' == $ depth ) { return self :: DEPTH_INFINITY ; } if ( ! ctype_digit ( $ depth ) ) { return $ default ; } return ( int ) $ dep...
Returns the HTTP depth header .
13,651
public function getHTTPRange ( ) { $ range = $ this -> httpRequest -> getHeader ( 'range' ) ; if ( is_null ( $ range ) ) { return null ; } if ( ! preg_match ( '/^bytes=([0-9]*)-([0-9]*)$/i' , $ range , $ matches ) ) { return null ; } if ( '' === $ matches [ 1 ] && '' === $ matches [ 2 ] ) { return null ; } return [ '' ...
Returns the HTTP range header .
13,652
public function getHTTPPrefer ( ) { $ result = [ 'respond-async' => false , 'return' => null , 'wait' => null , 'handling' => false , ] ; if ( $ prefer = $ this -> httpRequest -> getHeader ( 'Prefer' ) ) { $ result = array_merge ( $ result , HTTP \ parsePrefer ( $ prefer ) ) ; } elseif ( 't' == $ this -> httpRequest ->...
Returns the HTTP Prefer header information .
13,653
public function getCopyAndMoveInfo ( RequestInterface $ request ) { if ( ! $ request -> getHeader ( 'Destination' ) ) { throw new Exception \ BadRequest ( 'The destination header was not supplied' ) ; } $ destination = $ this -> calculateUri ( $ request -> getHeader ( 'Destination' ) ) ; $ overwrite = $ request -> getH...
Returns information about Copy and Move requests .
13,654
public function getProperties ( $ path , $ propertyNames ) { $ result = $ this -> getPropertiesForPath ( $ path , $ propertyNames , 0 ) ; if ( isset ( $ result [ 0 ] [ 200 ] ) ) { return $ result [ 0 ] [ 200 ] ; } else { return [ ] ; } }
Returns a list of properties for a path .
13,655
public function getPropertiesForChildren ( $ path , $ propertyNames ) { $ result = [ ] ; foreach ( $ this -> getPropertiesForPath ( $ path , $ propertyNames , 1 ) as $ k => $ row ) { if ( 0 === $ k ) { continue ; } $ result [ $ row [ 'href' ] ] = $ row [ 200 ] ; } return $ result ; }
A kid - friendly way to fetch properties for a node s children .
13,656
public function getHTTPHeaders ( $ path ) { $ propertyMap = [ '{DAV:}getcontenttype' => 'Content-Type' , '{DAV:}getcontentlength' => 'Content-Length' , '{DAV:}getlastmodified' => 'Last-Modified' , '{DAV:}getetag' => 'ETag' , ] ; $ properties = $ this -> getProperties ( $ path , array_keys ( $ propertyMap ) ) ; $ header...
Returns a list of HTTP headers for a particular resource .
13,657
private function generatePathNodes ( PropFind $ propFind , array $ yieldFirst = null ) { if ( null !== $ yieldFirst ) { yield $ yieldFirst ; } $ newDepth = $ propFind -> getDepth ( ) ; $ path = $ propFind -> getPath ( ) ; if ( self :: DEPTH_INFINITY !== $ newDepth ) { -- $ newDepth ; } $ propertyNames = $ propFind -> g...
Small helper to support PROPFIND with DEPTH_INFINITY .
13,658
public function getPropertiesForMultiplePaths ( array $ paths , array $ propertyNames = [ ] ) { $ result = [ ] ; $ nodes = $ this -> tree -> getMultipleNodes ( $ paths ) ; foreach ( $ nodes as $ path => $ node ) { $ propFind = new PropFind ( $ path , $ propertyNames ) ; $ r = $ this -> getPropertiesByNode ( $ propFind ...
Returns a list of properties for a list of paths .
13,659
public function createFile ( $ uri , $ data , & $ etag = null ) { list ( $ dir , $ name ) = Uri \ split ( $ uri ) ; if ( ! $ this -> emit ( 'beforeBind' , [ $ uri ] ) ) { return false ; } $ parent = $ this -> tree -> getNodeForPath ( $ dir ) ; if ( ! $ parent instanceof ICollection ) { throw new Exception \ Conflict ( ...
This method is invoked by sub - systems creating a new file .
13,660
public function updateFile ( $ uri , $ data , & $ etag = null ) { $ node = $ this -> tree -> getNodeForPath ( $ uri ) ; $ modified = false ; if ( ! $ this -> emit ( 'beforeWriteContent' , [ $ uri , $ node , & $ data , & $ modified ] ) ) { return false ; } $ etag = $ node -> put ( $ data ) ; if ( $ modified ) { $ etag =...
This method is invoked by sub - systems updating a file .
13,661
public function createCollection ( $ uri , MkCol $ mkCol ) { list ( $ parentUri , $ newName ) = Uri \ split ( $ uri ) ; try { $ parent = $ this -> tree -> getNodeForPath ( $ parentUri ) ; } catch ( Exception \ NotFound $ e ) { throw new Exception \ Conflict ( 'Parent node does not exist' ) ; } if ( ! $ parent instanceo...
Use this method to create a new collection .
13,662
public function updateProperties ( $ path , array $ properties ) { $ propPatch = new PropPatch ( $ properties ) ; $ this -> emit ( 'propPatch' , [ $ path , $ propPatch ] ) ; $ propPatch -> commit ( ) ; return $ propPatch -> getResult ( ) ; }
This method updates a resource s properties .
13,663
public function getResourceTypeForNode ( INode $ node ) { $ result = [ ] ; foreach ( $ this -> resourceTypeMapping as $ className => $ resourceType ) { if ( $ node instanceof $ className ) { $ result [ ] = $ resourceType ; } } return $ result ; }
Returns an array with resourcetypes for a node .
13,664
public function generateMultiStatus ( $ fileProperties , $ strip404s = false ) { $ w = $ this -> xml -> getWriter ( ) ; $ w -> openMemory ( ) ; $ w -> contextUri = $ this -> baseUri ; $ w -> startDocument ( ) ; $ w -> startElement ( '{DAV:}multistatus' ) ; foreach ( $ fileProperties as $ entry ) { $ href = $ entry [ 'h...
Generates a WebDAV propfind response body based on a list of nodes .
13,665
public function httpGet ( RequestInterface $ request , ResponseInterface $ response ) { $ node = $ this -> server -> tree -> getNodeForPath ( $ request -> getPath ( ) ) ; if ( $ node instanceof DAV \ IFile ) { return ; } $ subRequest = clone $ request ; $ subRequest -> setMethod ( 'PROPFIND' ) ; $ this -> server -> inv...
This method intercepts GET requests to non - files and changes it into an HTTP PROPFIND request .
13,666
public function childExists ( $ name ) { try { $ this -> getChild ( $ name ) ; return true ; } catch ( DAV \ Exception \ NotFound $ e ) { return false ; } }
Returns whether or not the child node exists .
13,667
public function httpOptions ( RequestInterface $ request , ResponseInterface $ response ) { $ methods = $ this -> server -> getAllowedMethods ( $ request -> getPath ( ) ) ; $ response -> setHeader ( 'Allow' , strtoupper ( implode ( ', ' , $ methods ) ) ) ; $ features = [ '1' , '3' , 'extended-mkcol' ] ; foreach ( $ thi...
HTTP OPTIONS .
13,668
public function httpHead ( RequestInterface $ request , ResponseInterface $ response ) { $ subRequest = clone $ request ; $ subRequest -> setMethod ( 'GET' ) ; $ subRequest -> setHeader ( 'X-Sabre-Original-Method' , 'HEAD' ) ; try { $ this -> server -> invokeMethod ( $ subRequest , $ response , false ) ; } catch ( Exce...
HTTP HEAD .
13,669
public function httpDelete ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; if ( ! $ this -> server -> emit ( 'beforeUnbind' , [ $ path ] ) ) { return false ; } $ this -> server -> tree -> delete ( $ path ) ; $ this -> server -> emit ( 'afterUnbind' , [ $ path ] ) ; $ ...
HTTP Delete .
13,670
public function httpPropFind ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; $ requestBody = $ request -> getBodyAsString ( ) ; if ( strlen ( $ requestBody ) ) { try { $ propFindXml = $ this -> server -> xml -> expect ( '{DAV:}propfind' , $ requestBody ) ; } catch ( P...
WebDAV PROPFIND .
13,671
public function httpPropPatch ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; try { $ propPatch = $ this -> server -> xml -> expect ( '{DAV:}propertyupdate' , $ request -> getBody ( ) ) ; } catch ( ParseException $ e ) { throw new BadRequest ( $ e -> getMessage ( ) , ...
WebDAV PROPPATCH .
13,672
public function httpPut ( RequestInterface $ request , ResponseInterface $ response ) { $ body = $ request -> getBodyAsStream ( ) ; $ path = $ request -> getPath ( ) ; if ( $ request -> getHeader ( 'Content-Range' ) ) { throw new Exception \ BadRequest ( 'Content-Range on PUT requests are forbidden.' ) ; } if ( ( $ exp...
HTTP PUT method .
13,673
public function httpMkcol ( RequestInterface $ request , ResponseInterface $ response ) { $ requestBody = $ request -> getBodyAsString ( ) ; $ path = $ request -> getPath ( ) ; if ( $ requestBody ) { $ contentType = $ request -> getHeader ( 'Content-Type' ) ; if ( null === $ contentType || ( 0 !== strpos ( $ contentTyp...
WebDAV MKCOL .
13,674
public function httpMove ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; $ moveInfo = $ this -> server -> getCopyAndMoveInfo ( $ request ) ; if ( $ moveInfo [ 'destinationExists' ] ) { if ( ! $ this -> server -> emit ( 'beforeUnbind' , [ $ moveInfo [ 'destination' ] ]...
WebDAV HTTP MOVE method .
13,675
public function httpCopy ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; $ copyInfo = $ this -> server -> getCopyAndMoveInfo ( $ request ) ; if ( ! $ this -> server -> emit ( 'beforeBind' , [ $ copyInfo [ 'destination' ] ] ) ) { return false ; } if ( $ copyInfo [ 'des...
WebDAV HTTP COPY method .
13,676
public function httpReport ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; $ result = $ this -> server -> xml -> parse ( $ request -> getBody ( ) , $ request -> getUrl ( ) , $ rootElementName ) ; if ( $ this -> server -> emit ( 'report' , [ $ rootElementName , $ resul...
HTTP REPORT method implementation .
13,677
public function propFindNode ( PropFind $ propFind , INode $ node ) { if ( $ node instanceof IProperties && $ propertyNames = $ propFind -> get404Properties ( ) ) { $ nodeProperties = $ node -> getProperties ( $ propertyNames ) ; foreach ( $ nodeProperties as $ propertyName => $ propertyValue ) { $ propFind -> set ( $ ...
Fetches properties for a node .
13,678
public function exception ( $ e ) { $ logLevel = \ Psr \ Log \ LogLevel :: CRITICAL ; if ( $ e instanceof \ Sabre \ DAV \ Exception ) { $ code = $ e -> getHTTPCode ( ) ; if ( $ code >= 400 && $ code < 500 ) { $ logLevel = \ Psr \ Log \ LogLevel :: INFO ; } else { $ logLevel = \ Psr \ Log \ LogLevel :: ERROR ; } } $ thi...
Listens for exception events and automatically logs them .
13,679
public function addReport ( $ report ) { $ report = ( array ) $ report ; foreach ( $ report as $ r ) { if ( ! preg_match ( '/^{([^}]*)}(.*)$/' , $ r ) ) { throw new DAV \ Exception ( 'Reportname must be in clark-notation' ) ; } $ this -> reports [ ] = $ r ; } }
Adds a report to this property .
13,680
public function getAddressBooksForUser ( $ principalUri ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT id, uri, displayname, principaluri, description, synctoken FROM ' . $ this -> addressBooksTableName . ' WHERE principaluri = ?' ) ; $ stmt -> execute ( [ $ principalUri ] ) ; $ addressBooks = [ ] ; foreach ( $ stmt -...
Returns the list of addressbooks for a specific user .
13,681
public function updateAddressBook ( $ addressBookId , \ Sabre \ DAV \ PropPatch $ propPatch ) { $ supportedProperties = [ '{DAV:}displayname' , '{' . CardDAV \ Plugin :: NS_CARDDAV . '}addressbook-description' , ] ; $ propPatch -> handle ( $ supportedProperties , function ( $ mutations ) use ( $ addressBookId ) { $ upd...
Updates properties for an address book .
13,682
public function deleteAddressBook ( $ addressBookId ) { $ stmt = $ this -> pdo -> prepare ( 'DELETE FROM ' . $ this -> cardsTableName . ' WHERE addressbookid = ?' ) ; $ stmt -> execute ( [ $ addressBookId ] ) ; $ stmt = $ this -> pdo -> prepare ( 'DELETE FROM ' . $ this -> addressBooksTableName . ' WHERE id = ?' ) ; $ ...
Deletes an entire addressbook and all its contents .
13,683
public function getCards ( $ addressbookId ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT id, uri, lastmodified, etag, size FROM ' . $ this -> cardsTableName . ' WHERE addressbookid = ?' ) ; $ stmt -> execute ( [ $ addressbookId ] ) ; $ result = [ ] ; while ( $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ) { $ row ...
Returns all cards for a specific addressbook id .
13,684
public function getCard ( $ addressBookId , $ cardUri ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT id, carddata, uri, lastmodified, etag, size FROM ' . $ this -> cardsTableName . ' WHERE addressbookid = ? AND uri = ? LIMIT 1' ) ; $ stmt -> execute ( [ $ addressBookId , $ cardUri ] ) ; $ result = $ stmt -> fetch ( \ ...
Returns a specific card .
13,685
public function createCard ( $ addressBookId , $ cardUri , $ cardData ) { $ stmt = $ this -> pdo -> prepare ( 'INSERT INTO ' . $ this -> cardsTableName . ' (carddata, uri, lastmodified, addressbookid, size, etag) VALUES (?, ?, ?, ?, ?, ?)' ) ; $ etag = md5 ( $ cardData ) ; $ stmt -> execute ( [ $ cardData , $ cardUri ,...
Creates a new card .
13,686
public function deleteCard ( $ addressBookId , $ cardUri ) { $ stmt = $ this -> pdo -> prepare ( 'DELETE FROM ' . $ this -> cardsTableName . ' WHERE addressbookid = ? AND uri = ?' ) ; $ stmt -> execute ( [ $ addressBookId , $ cardUri ] ) ; $ this -> addChange ( $ addressBookId , $ cardUri , 3 ) ; return 1 === $ stmt ->...
Deletes a card .
13,687
public function getChangesForAddressBook ( $ addressBookId , $ syncToken , $ syncLevel , $ limit = null ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT synctoken FROM ' . $ this -> addressBooksTableName . ' WHERE id = ?' ) ; $ stmt -> execute ( [ $ addressBookId ] ) ; $ currentToken = $ stmt -> fetchColumn ( 0 ) ; if (...
The getChanges method returns all the changes that have happened since the specified syncToken in the specified address book .
13,688
protected function addChange ( $ addressBookId , $ objectUri , $ operation ) { $ stmt = $ this -> pdo -> prepare ( 'INSERT INTO ' . $ this -> addressBookChangesTableName . ' (uri, synctoken, addressbookid, operation) SELECT ?, synctoken, ?, ? FROM ' . $ this -> addressBooksTableName . ' WHERE id = ?' ) ; $ stmt -> exec...
Adds a change record to the addressbookchanges table .
13,689
public function updateCalendarObject ( $ calendarId , $ objectUri , $ calendarData ) { $ stmt = $ this -> pdo -> prepare ( 'UPDATE simple_calendarobjects SET calendardata = ? WHERE calendarid = ? AND uri = ?' ) ; $ stmt -> execute ( [ $ calendarData , $ calendarId , $ objectUri ] ) ; return '"' . md5 ( $ calendarData )...
Updates an existing calendarobject based on it s uri .
13,690
public function propFind ( DAV \ PropFind $ propFind , DAV \ INode $ node ) { $ propFind -> handle ( '{DAV:}supportedlock' , function ( ) { return new DAV \ Xml \ Property \ SupportedLock ( ) ; } ) ; $ propFind -> handle ( '{DAV:}lockdiscovery' , function ( ) use ( $ propFind ) { return new DAV \ Xml \ Property \ LockD...
This method is called after most properties have been found it allows us to add in any Lock - related properties .
13,691
public function httpLock ( RequestInterface $ request , ResponseInterface $ response ) { $ uri = $ request -> getPath ( ) ; $ existingLocks = $ this -> getLocks ( $ uri ) ; if ( $ body = $ request -> getBodyAsString ( ) ) { $ existingLock = null ; foreach ( $ existingLocks as $ existingLock ) { if ( LockInfo :: EXCLUSI...
Locks an uri .
13,692
public function getTimeoutHeader ( ) { $ header = $ this -> server -> httpRequest -> getHeader ( 'Timeout' ) ; if ( $ header ) { if ( 0 === stripos ( $ header , 'second-' ) ) { $ header = ( int ) ( substr ( $ header , 7 ) ) ; } elseif ( 0 === stripos ( $ header , 'infinite' ) ) { $ header = LockInfo :: TIMEOUT_INFINITE...
Returns the contents of the HTTP Timeout header .
13,693
protected function generateLockResponse ( LockInfo $ lockInfo ) { return $ this -> server -> xml -> write ( '{DAV:}prop' , [ '{DAV:}lockdiscovery' => new DAV \ Xml \ Property \ LockDiscovery ( [ $ lockInfo ] ) , ] ) ; }
Generates the response for successful LOCK requests .
13,694
protected function parseLockRequest ( $ body ) { $ result = $ this -> server -> xml -> expect ( '{DAV:}lockinfo' , $ body ) ; $ lockInfo = new LockInfo ( ) ; $ lockInfo -> owner = $ result -> owner ; $ lockInfo -> token = DAV \ UUIDUtil :: getUUID ( ) ; $ lockInfo -> scope = $ result -> scope ; return $ lockInfo ; }
Parses a webdav lock xml body and returns a new Sabre \ DAV \ Locks \ LockInfo object .
13,695
public function getETag ( ) { return '"' . sha1 ( fileinode ( $ this -> path ) . filesize ( $ this -> path ) . filemtime ( $ this -> path ) ) . '"' ; }
Returns the ETag for a file .
13,696
public function put ( $ calendarData ) { if ( is_resource ( $ calendarData ) ) { $ calendarData = stream_get_contents ( $ calendarData ) ; } $ etag = $ this -> caldavBackend -> updateCalendarObject ( $ this -> calendarInfo [ 'id' ] , $ this -> objectData [ 'uri' ] , $ calendarData ) ; $ this -> objectData [ 'calendarda...
Updates the ICalendar - formatted object .
13,697
public function getContentType ( ) { $ mime = 'text/calendar; charset=utf-8' ; if ( isset ( $ this -> objectData [ 'component' ] ) && $ this -> objectData [ 'component' ] ) { $ mime .= '; component=' . $ this -> objectData [ 'component' ] ; } return $ mime ; }
Returns the mime content - type .
13,698
public function getChildren ( ) { $ children = [ ] ; $ notifications = $ this -> caldavBackend -> getNotificationsForPrincipal ( $ this -> principalUri ) ; foreach ( $ notifications as $ notification ) { $ children [ ] = new Node ( $ this -> caldavBackend , $ this -> principalUri , $ notification ) ; } return $ childre...
Returns all notifications for a principal .
13,699
public static function textMatch ( $ haystack , $ needle , $ collation , $ matchType = 'contains' ) { switch ( $ collation ) { case 'i;ascii-casemap' : $ haystack = str_replace ( range ( 'a' , 'z' ) , range ( 'A' , 'Z' ) , $ haystack ) ; $ needle = str_replace ( range ( 'a' , 'z' ) , range ( 'A' , 'Z' ) , $ needle ) ; ...
Checks if a needle occurs in a haystack ; ) .