idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
13,700 | public static function ensureUTF8 ( $ input ) { $ encoding = mb_detect_encoding ( $ input , [ 'UTF-8' , 'ISO-8859-1' ] , true ) ; if ( 'ISO-8859-1' === $ encoding ) { return utf8_encode ( $ input ) ; } else { return $ input ; } } | This method takes an input string checks if it s not valid UTF - 8 and attempts to convert it to UTF - 8 if it s not . |
13,701 | protected function getData ( ) { if ( ! file_exists ( $ this -> locksFile ) ) { return [ ] ; } $ handle = fopen ( $ this -> locksFile , 'r' ) ; flock ( $ handle , LOCK_SH ) ; $ data = stream_get_contents ( $ handle ) ; flock ( $ handle , LOCK_UN ) ; fclose ( $ handle ) ; $ data = unserialize ( $ data ) ; if ( ! $ data ... | Loads the lockdata from the filesystem . |
13,702 | protected function putData ( array $ newData ) { $ handle = fopen ( $ this -> locksFile , 'a+' ) ; flock ( $ handle , LOCK_EX ) ; ftruncate ( $ handle , 0 ) ; rewind ( $ handle ) ; fwrite ( $ handle , serialize ( $ newData ) ) ; flock ( $ handle , LOCK_UN ) ; fclose ( $ handle ) ; } | Saves the lockdata . |
13,703 | public function getChildren ( ) { if ( $ this -> disableListing ) { throw new DAV \ Exception \ MethodNotAllowed ( 'Listing members of this collection is disabled' ) ; } $ children = [ ] ; foreach ( $ this -> principalBackend -> getPrincipalsByPrefix ( $ this -> principalPrefix ) as $ principalInfo ) { $ children [ ] =... | Return the list of users . |
13,704 | public function add ( $ type ) { $ this -> value [ ] = $ type ; $ this -> value = array_unique ( $ this -> value ) ; } | Adds a resourcetype value to this property . |
13,705 | protected function mail ( $ to , $ subject , $ body , array $ headers ) { mail ( $ to , $ subject , $ body , implode ( "\r\n" , $ headers ) ) ; } | This function is responsible for sending the actual email . |
13,706 | private function serializeAce ( Writer $ writer , array $ ace ) { $ writer -> startElement ( '{DAV:}ace' ) ; switch ( $ ace [ 'principal' ] ) { case '{DAV:}authenticated' : $ principal = new Principal ( Principal :: AUTHENTICATED ) ; break ; case '{DAV:}unauthenticated' : $ principal = new Principal ( Principal :: UNAU... | Serializes a single access control entry . |
13,707 | public function getName ( ) { if ( $ this -> overrideName ) { return $ this -> overrideName ; } list ( , $ name ) = Uri \ split ( $ this -> path ) ; return $ name ; } | Returns the name of the node . |
13,708 | public function setName ( $ name ) { if ( $ this -> overrideName ) { throw new Forbidden ( 'This node cannot be renamed' ) ; } list ( $ parentPath ) = Uri \ split ( $ this -> path ) ; list ( , $ newName ) = Uri \ split ( $ name ) ; $ newPath = $ parentPath . '/' . $ newName ; rename ( $ this -> path , $ newPath ) ; $ t... | Renames the node . |
13,709 | public function updateCalendar ( $ calendarId , \ Sabre \ DAV \ PropPatch $ propPatch ) { if ( ! is_array ( $ calendarId ) ) { throw new \ InvalidArgumentException ( 'The value passed to $calendarId is expected to be an array with a calendarId and an instanceId' ) ; } list ( $ calendarId , $ instanceId ) = $ calendarId... | Updates properties for a calendar . |
13,710 | public function createCalendarObject ( $ calendarId , $ objectUri , $ calendarData ) { if ( ! is_array ( $ calendarId ) ) { throw new \ InvalidArgumentException ( 'The value passed to $calendarId is expected to be an array with a calendarId and an instanceId' ) ; } list ( $ calendarId , $ instanceId ) = $ calendarId ; ... | Creates a new calendar object . |
13,711 | protected function getDenormalizedData ( $ calendarData ) { $ vObject = VObject \ Reader :: read ( $ calendarData ) ; $ componentType = null ; $ component = null ; $ firstOccurence = null ; $ lastOccurence = null ; $ uid = null ; foreach ( $ vObject -> getComponents ( ) as $ component ) { if ( 'VTIMEZONE' !== $ compone... | Parses some information from calendar objects used for optimized calendar - queries . |
13,712 | public function getChangesForCalendar ( $ calendarId , $ syncToken , $ syncLevel , $ limit = null ) { if ( ! is_array ( $ calendarId ) ) { throw new \ InvalidArgumentException ( 'The value passed to $calendarId is expected to be an array with a calendarId and an instanceId' ) ; } list ( $ calendarId , $ instanceId ) = ... | The getChanges method returns all the changes that have happened since the specified syncToken in the specified calendar . |
13,713 | protected function addChange ( $ calendarId , $ objectUri , $ operation ) { $ stmt = $ this -> pdo -> prepare ( 'INSERT INTO ' . $ this -> calendarChangesTableName . ' (uri, synctoken, calendarid, operation) SELECT ?, synctoken, ?, ? FROM ' . $ this -> calendarTableName . ' WHERE id = ?' ) ; $ stmt -> execute ( [ $ obj... | Adds a change record to the calendarchanges table . |
13,714 | public function getSubscriptionsForUser ( $ principalUri ) { $ fields = array_values ( $ this -> subscriptionPropertyMap ) ; $ fields [ ] = 'id' ; $ fields [ ] = 'uri' ; $ fields [ ] = 'source' ; $ fields [ ] = 'principaluri' ; $ fields [ ] = 'lastmodified' ; $ fields = implode ( ', ' , $ fields ) ; $ stmt = $ this -> ... | Returns a list of subscriptions for a principal . |
13,715 | public function createSubscription ( $ principalUri , $ uri , array $ properties ) { $ fieldNames = [ 'principaluri' , 'uri' , 'source' , 'lastmodified' , ] ; if ( ! isset ( $ properties [ '{http://calendarserver.org/ns/}source' ] ) ) { throw new Forbidden ( 'The {http://calendarserver.org/ns/}source property is requir... | Creates a new subscription for a principal . |
13,716 | public function updateSubscription ( $ subscriptionId , DAV \ PropPatch $ propPatch ) { $ supportedProperties = array_keys ( $ this -> subscriptionPropertyMap ) ; $ supportedProperties [ ] = '{http://calendarserver.org/ns/}source' ; $ propPatch -> handle ( $ supportedProperties , function ( $ mutations ) use ( $ subscr... | Updates a subscription . |
13,717 | public function getSchedulingObject ( $ principalUri , $ objectUri ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT uri, calendardata, lastmodified, etag, size FROM ' . $ this -> schedulingObjectTableName . ' WHERE principaluri = ? AND uri = ?' ) ; $ stmt -> execute ( [ $ principalUri , $ objectUri ] ) ; $ row = $ stmt ... | Returns a single scheduling object . |
13,718 | public function getSchedulingObjects ( $ principalUri ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT id, calendardata, uri, lastmodified, etag, size FROM ' . $ this -> schedulingObjectTableName . ' WHERE principaluri = ?' ) ; $ stmt -> execute ( [ $ principalUri ] ) ; $ result = [ ] ; foreach ( $ stmt -> fetchAll ( \ ... | Returns all scheduling objects for the inbox collection . |
13,719 | public function deleteSchedulingObject ( $ principalUri , $ objectUri ) { $ stmt = $ this -> pdo -> prepare ( 'DELETE FROM ' . $ this -> schedulingObjectTableName . ' WHERE principaluri = ? AND uri = ?' ) ; $ stmt -> execute ( [ $ principalUri , $ objectUri ] ) ; } | Deletes a scheduling object . |
13,720 | public function createSchedulingObject ( $ principalUri , $ objectUri , $ objectData ) { $ stmt = $ this -> pdo -> prepare ( 'INSERT INTO ' . $ this -> schedulingObjectTableName . ' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)' ) ; $ stmt -> execute ( [ $ principalUri , $ object... | Creates a new scheduling object . This should land in a users inbox . |
13,721 | public function updateInvites ( $ calendarId , array $ sharees ) { if ( ! is_array ( $ calendarId ) ) { throw new \ InvalidArgumentException ( 'The value passed to $calendarId is expected to be an array with a calendarId and an instanceId' ) ; } $ currentInvites = $ this -> getInvites ( $ calendarId ) ; list ( $ calend... | Updates the list of shares . |
13,722 | public function getInvites ( $ calendarId ) { if ( ! is_array ( $ calendarId ) ) { throw new \ InvalidArgumentException ( 'The value passed to getInvites() is expected to be an array with a calendarId and an instanceId' ) ; } list ( $ calendarId , $ instanceId ) = $ calendarId ; $ query = <<<SQLSELECT principaluri,... | Returns the list of people whom a calendar is shared with . |
13,723 | public function propFind ( $ path , PropFind $ propFind ) { if ( ! $ propFind -> isAllProps ( ) && 0 === count ( $ propFind -> get404Properties ( ) ) ) { return ; } $ query = 'SELECT name, value, valuetype FROM ' . $ this -> tableName . ' WHERE path = ?' ; $ stmt = $ this -> pdo -> prepare ( $ query ) ; $ stmt -> execu... | Fetches properties for a path . |
13,724 | public function propPatch ( $ path , PropPatch $ propPatch ) { $ propPatch -> handleRemaining ( function ( $ properties ) use ( $ path ) { if ( 'pgsql' === $ this -> pdo -> getAttribute ( \ PDO :: ATTR_DRIVER_NAME ) ) { $ updateSql = <<<SQLINSERT INTO {$this->tableName} (path, name, valuetype, value)VALUES (:path, :na... | Updates properties for a path . |
13,725 | public function move ( $ source , $ destination ) { $ select = $ this -> pdo -> prepare ( 'SELECT id, path FROM ' . $ this -> tableName . ' WHERE path = ? OR path LIKE ?' ) ; $ select -> execute ( [ $ source , $ source . '/%' ] ) ; $ update = $ this -> pdo -> prepare ( 'UPDATE ' . $ this -> tableName . ' SET path = ? ... | This method is called after a successful MOVE . |
13,726 | public function childExists ( $ name ) { if ( '.' == $ name || '..' == $ name ) { throw new DAV \ Exception \ Forbidden ( 'Permission denied to . and ..' ) ; } $ path = $ this -> path . '/' . $ name ; return file_exists ( $ path ) ; } | Checks if a child exists . |
13,727 | public function delete ( ) { foreach ( $ this -> getChildren ( ) as $ child ) { $ child -> delete ( ) ; } rmdir ( $ this -> path ) ; return true ; } | Deletes all files in this directory and then itself . |
13,728 | public function moveInto ( $ targetName , $ sourcePath , DAV \ INode $ sourceNode ) { if ( ! $ sourceNode instanceof self && ! $ sourceNode instanceof File ) { return false ; } return rename ( $ sourceNode -> path , $ this -> path . '/' . $ targetName ) ; } | Moves a node into this collection . |
13,729 | public function initialize ( DAV \ Server $ server ) { $ this -> server = $ server ; $ this -> server -> on ( 'method:GET' , [ $ this , 'httpGetEarly' ] , 90 ) ; $ this -> server -> on ( 'method:GET' , [ $ this , 'httpGet' ] , 200 ) ; $ this -> server -> on ( 'onHTMLActionsPanel' , [ $ this , 'htmlActionsPanel' ] , 200... | Initializes the plugin and subscribes to events . |
13,730 | public function httpGetEarly ( RequestInterface $ request , ResponseInterface $ response ) { $ params = $ request -> getQueryParameters ( ) ; if ( isset ( $ params [ 'sabreAction' ] ) && 'info' === $ params [ 'sabreAction' ] ) { return $ this -> httpGet ( $ request , $ response ) ; } } | This method intercepts GET requests that have ?sabreAction = info appended to the URL . |
13,731 | public function httpGet ( RequestInterface $ request , ResponseInterface $ response ) { $ getVars = $ request -> getQueryParameters ( ) ; $ response -> setHeader ( 'Content-Security-Policy' , "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';" ) ; $ sabreAction = isset ( $ getVars [ 'sabreAction' ]... | This method intercepts GET requests to collections and returns the html . |
13,732 | public function httpPOST ( RequestInterface $ request , ResponseInterface $ response ) { $ contentType = $ request -> getHeader ( 'Content-Type' ) ; list ( $ contentType ) = explode ( ';' , $ contentType ) ; if ( 'application/x-www-form-urlencoded' !== $ contentType && 'multipart/form-data' !== $ contentType ) { return... | Handles POST requests for tree operations . |
13,733 | public function generatePluginListing ( ) { $ html = $ this -> generateHeader ( 'Plugins' ) ; $ html .= '<section><h1>Plugins</h1>' ; $ html .= '<table class="propTable">' ; foreach ( $ this -> server -> getPlugins ( ) as $ plugin ) { $ info = $ plugin -> getPluginInfo ( ) ; $ html .= '<tr><th>' . $ info [ 'name' ] . '... | Generates the plugins page . |
13,734 | public function htmlActionsPanel ( DAV \ INode $ node , & $ output , $ path ) { if ( ! $ node instanceof DAV \ ICollection ) { return ; } if ( 'Sabre\\DAV\\SimpleCollection' === get_class ( $ node ) ) { return ; } $ output .= <<<HTML<form method="post" action=""><h3>Create new folder</h3><input type="hidden" name="sab... | This method is used to generate the actions panel output for collections . |
13,735 | protected function getLocalAssetPath ( $ assetName ) { $ assetDir = __DIR__ . '/assets/' ; $ path = $ assetDir . $ assetName ; $ path = str_replace ( '\\' , '/' , $ path ) ; if ( false !== strpos ( $ path , '/../' ) || '/..' === strrchr ( $ path , '/' ) ) { throw new DAV \ Exception \ NotFound ( 'Path does not exist, o... | This method returns a local pathname to an asset . |
13,736 | protected function serveAsset ( $ assetName ) { $ assetPath = $ this -> getLocalAssetPath ( $ assetName ) ; $ mime = 'application/octet-stream' ; $ map = [ 'ico' => 'image/vnd.microsoft.icon' , 'png' => 'image/png' , 'css' => 'text/css' , ] ; $ ext = substr ( $ assetName , strrpos ( $ assetName , '.' ) + 1 ) ; if ( iss... | This method reads an asset from disk and generates a full http response . |
13,737 | private function mapResourceType ( array $ resourceTypes , $ node ) { if ( ! $ resourceTypes ) { if ( $ node instanceof DAV \ IFile ) { return [ 'string' => 'File' , 'icon' => 'file' , ] ; } else { return [ 'string' => 'Unknown' , 'icon' => 'cog' , ] ; } } $ types = [ '{http://calendarserver.org/ns/}calendar-proxy-writ... | Maps a resource type to a human - readable string and icon . |
13,738 | public function loadFile ( $ filename ) { foreach ( file ( $ filename , FILE_IGNORE_NEW_LINES ) as $ line ) { if ( 2 !== substr_count ( $ line , ':' ) ) { throw new DAV \ Exception ( 'Malformed htdigest file. Every line should contain 2 colons' ) ; } list ( $ username , $ realm , $ A1 ) = explode ( ':' , $ line ) ; if ... | Loads an htdigest - formatted file . This method can be called multiple times if more than 1 file is used . |
13,739 | public function getDigestHash ( $ realm , $ username ) { return isset ( $ this -> users [ $ realm . ':' . $ username ] ) ? $ this -> users [ $ realm . ':' . $ username ] : false ; } | Returns a users information . |
13,740 | public function getAlternateUriSet ( ) { $ uris = [ ] ; if ( isset ( $ this -> principalProperties [ '{DAV:}alternate-URI-set' ] ) ) { $ uris = $ this -> principalProperties [ '{DAV:}alternate-URI-set' ] ; } if ( isset ( $ this -> principalProperties [ '{http://sabredav.org/ns}email-address' ] ) ) { $ uris [ ] = 'mailt... | Returns a list of alternative urls for a principal . |
13,741 | public function getName ( ) { $ uri = $ this -> principalProperties [ 'uri' ] ; list ( , $ name ) = Uri \ split ( $ uri ) ; return $ name ; } | Returns this principals name . |
13,742 | public function getProperties ( $ requestedProperties ) { $ newProperties = [ ] ; foreach ( $ requestedProperties as $ propName ) { if ( isset ( $ this -> principalProperties [ $ propName ] ) ) { $ newProperties [ $ propName ] = $ this -> principalProperties [ $ propName ] ; } } return $ newProperties ; } | Returns a list of properties . |
13,743 | public function propFindEarly ( DAV \ PropFind $ propFind , DAV \ INode $ node ) { if ( $ node instanceof ISharedCalendar ) { $ propFind -> handle ( '{' . Plugin :: NS_CALENDARSERVER . '}invite' , function ( ) use ( $ node ) { return new Xml \ Property \ Invite ( $ node -> getInvites ( ) ) ; } ) ; } } | This event is triggered when properties are requested for a certain node . |
13,744 | public function propPatch ( $ path , DAV \ PropPatch $ propPatch ) { $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; if ( ! $ node instanceof ISharedCalendar ) { return ; } if ( \ Sabre \ DAV \ Sharing \ Plugin :: ACCESS_SHAREDOWNER === $ node -> getShareAccess ( ) || \ Sabre \ DAV \ Sharing \ Plugin :... | This method is trigged when a user attempts to update a node s properties . |
13,745 | public function httpGet ( RequestInterface $ request , ResponseInterface $ response ) { $ queryParams = $ request -> getQueryParameters ( ) ; if ( ! array_key_exists ( 'export' , $ queryParams ) ) { return ; } $ path = $ request -> getPath ( ) ; $ node = $ this -> server -> getProperties ( $ path , [ '{DAV:}resourcetyp... | Intercepts GET requests on calendar urls ending with ?export . |
13,746 | public function mergeObjects ( array $ properties , array $ inputObjects ) { $ calendar = new VObject \ Component \ VCalendar ( ) ; $ calendar -> VERSION = '2.0' ; if ( DAV \ Server :: $ exposeVersion ) { $ calendar -> PRODID = '-//SabreDAV//SabreDAV ' . DAV \ Version :: VERSION . '//EN' ; } else { $ calendar -> PRODID... | Merges all calendar objects and builds one big iCalendar blob . |
13,747 | public function getNodeForPath ( $ path ) { $ path = trim ( $ path , '/' ) ; if ( isset ( $ this -> cache [ $ path ] ) ) { return $ this -> cache [ $ path ] ; } if ( ! strlen ( $ path ) ) { return $ this -> rootNode ; } list ( $ parentName , $ baseName ) = Uri \ split ( $ path ) ; if ( '' === $ parentName ) { $ node = ... | Returns the INode object for the requested path . |
13,748 | public function nodeExists ( $ path ) { try { if ( '' === $ path ) { return true ; } list ( $ parent , $ base ) = Uri \ split ( $ path ) ; $ parentNode = $ this -> getNodeForPath ( $ parent ) ; if ( ! $ parentNode instanceof ICollection ) { return false ; } return $ parentNode -> childExists ( $ base ) ; } catch ( Exce... | This function allows you to check if a node exists . |
13,749 | public function copy ( $ sourcePath , $ destinationPath ) { $ sourceNode = $ this -> getNodeForPath ( $ sourcePath ) ; list ( $ destinationDir , $ destinationName ) = Uri \ split ( $ destinationPath ) ; $ destinationParent = $ this -> getNodeForPath ( $ destinationDir ) ; if ( ! $ destinationParent instanceof ICopyTarg... | Copies a file from path to another . |
13,750 | public function move ( $ sourcePath , $ destinationPath ) { list ( $ sourceDir ) = Uri \ split ( $ sourcePath ) ; list ( $ destinationDir , $ destinationName ) = Uri \ split ( $ destinationPath ) ; if ( $ sourceDir === $ destinationDir ) { $ sourceNode = $ this -> getNodeForPath ( $ sourcePath ) ; $ sourceNode -> setNa... | Moves a file from one location to another . |
13,751 | public function delete ( $ path ) { $ node = $ this -> getNodeForPath ( $ path ) ; $ node -> delete ( ) ; list ( $ parent ) = Uri \ split ( $ path ) ; $ this -> markDirty ( $ parent ) ; } | Deletes a node from the tree . |
13,752 | public function getChildren ( $ path ) { $ node = $ this -> getNodeForPath ( $ path ) ; $ basePath = trim ( $ path , '/' ) ; if ( '' !== $ basePath ) { $ basePath .= '/' ; } foreach ( $ node -> getChildren ( ) as $ child ) { $ this -> cache [ $ basePath . $ child -> getName ( ) ] = $ child ; yield $ child ; } } | Returns a list of childnodes for a given path . |
13,753 | public function markDirty ( $ path ) { $ path = trim ( $ path , '/' ) ; foreach ( $ this -> cache as $ nodePath => $ node ) { if ( '' === $ path || $ nodePath == $ path || 0 === strpos ( $ nodePath , $ path . '/' ) ) { unset ( $ this -> cache [ $ nodePath ] ) ; } } } | This method is called with every tree update . |
13,754 | public function getMultipleNodes ( $ paths ) { $ parents = [ ] ; foreach ( $ paths as $ path ) { list ( $ parent , $ node ) = Uri \ split ( $ path ) ; if ( ! isset ( $ parents [ $ parent ] ) ) { $ parents [ $ parent ] = [ $ node ] ; } else { $ parents [ $ parent ] [ ] = $ node ; } } $ result = [ ] ; foreach ( $ parents... | This method tells the tree system to pre - fetch and cache a list of children of a single parent . |
13,755 | public function put ( $ data ) { file_put_contents ( $ this -> path , $ data ) ; clearstatcache ( true , $ this -> path ) ; return $ this -> getETag ( ) ; } | Updates the data . |
13,756 | public function patch ( $ data , $ rangeType , $ offset = null ) { switch ( $ rangeType ) { case 1 : $ f = fopen ( $ this -> path , 'a' ) ; break ; case 2 : $ f = fopen ( $ this -> path , 'c' ) ; fseek ( $ f , $ offset ) ; break ; case 3 : $ f = fopen ( $ this -> path , 'c' ) ; fseek ( $ f , $ offset , SEEK_END ) ; bre... | Updates the file based on a range specification . |
13,757 | public function getCalendarHomeForPrincipal ( $ principalUrl ) { $ parts = explode ( '/' , trim ( $ principalUrl , '/' ) ) ; if ( 2 !== count ( $ parts ) ) { return ; } if ( 'principals' !== $ parts [ 0 ] ) { return ; } return self :: CALENDAR_ROOT . '/' . $ parts [ 1 ] ; } | Returns the path to a principal s calendar home . |
13,758 | public function report ( $ reportName , $ report , $ path ) { switch ( $ reportName ) { case '{' . self :: NS_CALDAV . '}calendar-multiget' : $ this -> server -> transactionType = 'report-calendar-multiget' ; $ this -> calendarMultiGetReport ( $ report ) ; return false ; case '{' . self :: NS_CALDAV . '}calendar-query'... | This functions handles REPORT requests specific to CalDAV . |
13,759 | public function httpMkCalendar ( RequestInterface $ request , ResponseInterface $ response ) { $ body = $ request -> getBodyAsString ( ) ; $ path = $ request -> getPath ( ) ; $ properties = [ ] ; if ( $ body ) { try { $ mkcalendar = $ this -> server -> xml -> expect ( '{urn:ietf:params:xml:ns:caldav}mkcalendar' , $ bod... | This function handles the MKCALENDAR HTTP method which creates a new calendar . |
13,760 | public function calendarMultiGetReport ( $ report ) { $ needsJson = 'application/calendar+json' === $ report -> contentType ; $ timeZones = [ ] ; $ propertyList = [ ] ; $ paths = array_map ( [ $ this -> server , 'calculateUri' ] , $ report -> hrefs ) ; foreach ( $ this -> server -> getPropertiesForMultiplePaths ( $ pat... | This function handles the calendar - multiget REPORT . |
13,761 | public function getSupportedPrivilegeSet ( INode $ node , array & $ supportedPrivilegeSet ) { if ( $ node instanceof ICalendar ) { $ supportedPrivilegeSet [ '{DAV:}read' ] [ 'aggregates' ] [ '{' . self :: NS_CALDAV . '}read-free-busy' ] = [ 'abstract' => false , 'aggregates' => [ ] , ] ; } } | This method is triggered whenever a subsystem reqeuests the privileges that are supported on a particular node . |
13,762 | public function htmlActionsPanel ( DAV \ INode $ node , & $ output ) { if ( ! $ node instanceof CalendarHome ) { return ; } $ output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new calendar</h3> <input type="hidden" name="sabreAction" value="mkcol" /> <input type="... | This method is used to generate HTML output for the DAV \ Browser \ Plugin . This allows us to generate an interface users can use to create new calendars . |
13,763 | public function validate ( VObject \ Component \ VCalendar $ vObject , array $ filters ) { if ( $ vObject -> name !== $ filters [ 'name' ] ) { return false ; } return $ this -> validateCompFilters ( $ vObject , $ filters [ 'comp-filters' ] ) && $ this -> validatePropFilters ( $ vObject , $ filters [ 'prop-filters' ] ) ... | Verify if a list of filters applies to the calendar data object . |
13,764 | protected function validateCompFilters ( VObject \ Component $ parent , array $ filters ) { foreach ( $ filters as $ filter ) { $ isDefined = isset ( $ parent -> { $ filter [ 'name' ] } ) ; if ( $ filter [ 'is-not-defined' ] ) { if ( $ isDefined ) { return false ; } else { continue ; } } if ( ! $ isDefined ) { return f... | This method checks the validity of comp - filters . |
13,765 | protected function validateParamFilters ( VObject \ Property $ parent , array $ filters ) { foreach ( $ filters as $ filter ) { $ isDefined = isset ( $ parent [ $ filter [ 'name' ] ] ) ; if ( $ filter [ 'is-not-defined' ] ) { if ( $ isDefined ) { return false ; } else { continue ; } } if ( ! $ isDefined ) { return fals... | This method checks the validity of param - filters . |
13,766 | protected function validateTextMatch ( $ check , array $ textMatch ) { if ( $ check instanceof VObject \ Node ) { $ check = $ check -> getValue ( ) ; } $ isMatching = \ Sabre \ DAV \ StringUtil :: textMatch ( $ check , $ textMatch [ 'value' ] , $ textMatch [ 'collation' ] ) ; return $ textMatch [ 'negate-condition' ] x... | This method checks the validity of a text - match . |
13,767 | protected function validateTimeRange ( VObject \ Node $ component , $ start , $ end ) { if ( is_null ( $ start ) ) { $ start = new DateTime ( '1900-01-01' ) ; } if ( is_null ( $ end ) ) { $ end = new DateTime ( '3000-01-01' ) ; } switch ( $ component -> name ) { case 'VEVENT' : case 'VTODO' : case 'VJOURNAL' : return $... | Validates if a component matches the given time range . |
13,768 | public function propFind ( PropFind $ propFind , INode $ node ) { $ propFind -> handle ( '{DAV:}getcontenttype' , function ( ) use ( $ propFind ) { list ( , $ fileName ) = Uri \ split ( $ propFind -> getPath ( ) ) ; return $ this -> getContentType ( $ fileName ) ; } ) ; } | Our PROPFIND handler . |
13,769 | protected function getContentType ( $ fileName ) { $ extension = strtolower ( substr ( $ fileName , strrpos ( $ fileName , '.' ) + 1 ) ) ; if ( isset ( $ this -> extensionMap [ $ extension ] ) ) { return $ this -> extensionMap [ $ extension ] ; } return 'application/octet-stream' ; } | Simple method to return the contenttype . |
13,770 | public function getDigestHash ( $ realm , $ username ) { $ stmt = $ this -> pdo -> prepare ( 'SELECT digesta1 FROM ' . $ this -> tableName . ' WHERE username = ?' ) ; $ stmt -> execute ( [ $ username ] ) ; return $ stmt -> fetchColumn ( ) ? : null ; } | Returns the digest hash for a user . |
13,771 | public function handleRemaining ( callable $ callback ) { $ properties = $ this -> getRemainingMutations ( ) ; if ( ! $ properties ) { return ; } foreach ( $ properties as $ propertyName ) { $ this -> result [ $ propertyName ] = 202 ; $ this -> propertyUpdateCallbacks [ ] = [ $ properties , $ callback , ] ; } } | Call this function if you wish to handle _all_ properties that haven t been handled by anything else yet . Note that you effectively claim with this that you promise to process _all_ properties that are coming in . |
13,772 | public function setResultCode ( $ properties , $ resultCode ) { foreach ( ( array ) $ properties as $ propertyName ) { $ this -> result [ $ propertyName ] = $ resultCode ; } if ( $ resultCode >= 400 ) { $ this -> failed = true ; } } | Sets the result code for one or more properties . |
13,773 | public function getRemainingMutations ( ) { $ remaining = [ ] ; foreach ( $ this -> mutations as $ propertyName => $ propValue ) { if ( ! isset ( $ this -> result [ $ propertyName ] ) ) { $ remaining [ ] = $ propertyName ; } } return $ remaining ; } | Returns the list of properties that don t have a result code yet . |
13,774 | public function commit ( ) { foreach ( $ this -> mutations as $ propertyName => $ value ) { if ( ! isset ( $ this -> result [ $ propertyName ] ) ) { $ this -> failed = true ; $ this -> result [ $ propertyName ] = 403 ; } } foreach ( $ this -> propertyUpdateCallbacks as $ callbackInfo ) { if ( $ this -> failed ) { break... | Performs the actual update and calls all callbacks . |
13,775 | private function doCallBackSingleProp ( $ propertyName , callable $ callback ) { $ result = $ callback ( $ this -> mutations [ $ propertyName ] ) ; if ( is_bool ( $ result ) ) { if ( $ result ) { if ( is_null ( $ this -> mutations [ $ propertyName ] ) ) { $ result = 204 ; } else { $ result = 200 ; } } else { $ result =... | Executes a property callback with the single - property syntax . |
13,776 | private function doCallBackMultiProp ( array $ propertyList , callable $ callback ) { $ argument = [ ] ; foreach ( $ propertyList as $ propertyName ) { $ argument [ $ propertyName ] = $ this -> mutations [ $ propertyName ] ; } $ result = $ callback ( $ argument ) ; if ( is_array ( $ result ) ) { foreach ( $ propertyLis... | Executes a property callback with the multi - property syntax . |
13,777 | public function xmlName ( $ element ) { list ( $ ns , $ localName ) = XmlService :: parseClarkNotation ( $ element ) ; if ( isset ( $ this -> namespaceMap [ $ ns ] ) ) { $ propName = $ this -> namespaceMap [ $ ns ] . ':' . $ localName ; } else { $ propName = $ element ; } return '<span title="' . $ this -> h ( $ elemen... | This method takes an xml element in clark - notation and turns it into a shortened version with a prefix if it was a known namespace . |
13,778 | private function serializePriv ( Writer $ writer , $ privName , $ privilege ) { $ writer -> startElement ( '{DAV:}supported-privilege' ) ; $ writer -> startElement ( '{DAV:}privilege' ) ; $ writer -> writeElement ( $ privName ) ; $ writer -> endElement ( ) ; if ( ! empty ( $ privilege [ 'abstract' ] ) ) { $ writer -> w... | Serializes a property . |
13,779 | public function get ( ) { if ( ! isset ( $ this -> cardData [ 'carddata' ] ) ) { $ this -> cardData = $ this -> carddavBackend -> getCard ( $ this -> addressBookInfo [ 'id' ] , $ this -> cardData [ 'uri' ] ) ; } return $ this -> cardData [ 'carddata' ] ; } | Returns the VCard - formatted object . |
13,780 | public function put ( $ cardData ) { if ( is_resource ( $ cardData ) ) { $ cardData = stream_get_contents ( $ cardData ) ; } $ cardData = DAV \ StringUtil :: ensureUTF8 ( $ cardData ) ; $ etag = $ this -> carddavBackend -> updateCard ( $ this -> addressBookInfo [ 'id' ] , $ this -> cardData [ 'uri' ] , $ cardData ) ; $... | Updates the VCard - formatted object . |
13,781 | public function getETag ( ) { if ( isset ( $ this -> cardData [ 'etag' ] ) ) { return $ this -> cardData [ 'etag' ] ; } else { $ data = $ this -> get ( ) ; if ( is_string ( $ data ) ) { return '"' . md5 ( $ data ) . '"' ; } else { return null ; } } } | Returns an ETag for this object . |
13,782 | public function beforeMethod ( RequestInterface $ request , ResponseInterface $ response ) { if ( $ this -> currentPrincipal ) { return ; } $ authResult = $ this -> check ( $ request , $ response ) ; if ( $ authResult [ 0 ] ) { $ this -> currentPrincipal = $ authResult [ 1 ] ; $ this -> loginFailedReasons = null ; retu... | This method is called before any HTTP method and forces users to be authenticated . |
13,783 | public function check ( RequestInterface $ request , ResponseInterface $ response ) { if ( ! $ this -> backends ) { throw new \ Sabre \ DAV \ Exception ( 'No authentication backends were configured on this server.' ) ; } $ reasons = [ ] ; foreach ( $ this -> backends as $ backend ) { $ result = $ backend -> check ( $ r... | Checks authentication credentials and logs the user in if possible . |
13,784 | public function challenge ( RequestInterface $ request , ResponseInterface $ response ) { foreach ( $ this -> backends as $ backend ) { $ backend -> challenge ( $ request , $ response ) ; } } | This method sends authentication challenges to the user . |
13,785 | public function getChild ( $ name ) { foreach ( $ this -> getChildren ( ) as $ child ) { if ( $ name == $ child -> getName ( ) ) { return $ child ; } } throw new DAV \ Exception \ NotFound ( 'Addressbook with name \'' . $ name . '\' could not be found' ) ; } | Returns a single addressbook by name . |
13,786 | public function getChildren ( ) { $ addressbooks = $ this -> carddavBackend -> getAddressBooksForUser ( $ this -> principalUri ) ; $ objs = [ ] ; foreach ( $ addressbooks as $ addressbook ) { $ objs [ ] = new AddressBook ( $ this -> carddavBackend , $ addressbook ) ; } return $ objs ; } | Returns a list of addressbooks . |
13,787 | public function httpGet ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; try { $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; } catch ( DAV \ Exception \ NotFound $ e ) { return ; } if ( ! $ node instanceof INode ) { return ; } $ writer = $ this -> se... | This event is triggered before the usual GET request handler . |
13,788 | public function propFindEarly ( DAV \ PropFind $ propFind , DAV \ INode $ node ) { $ ns = '{' . self :: NS_CARDDAV . '}' ; if ( $ node instanceof IAddressBook ) { $ propFind -> handle ( $ ns . 'max-resource-size' , $ this -> maxResourceSize ) ; $ propFind -> handle ( $ ns . 'supported-address-data' , function ( ) { ret... | Adds all CardDAV - specific properties . |
13,789 | public function report ( $ reportName , $ dom , $ path ) { switch ( $ reportName ) { case '{' . self :: NS_CARDDAV . '}addressbook-multiget' : $ this -> server -> transactionType = 'report-addressbook-multiget' ; $ this -> addressbookMultiGetReport ( $ dom ) ; return false ; case '{' . self :: NS_CARDDAV . '}addressboo... | This functions handles REPORT requests specific to CardDAV . |
13,790 | protected function getAddressbookHomeForPrincipal ( $ principal ) { list ( , $ principalId ) = Uri \ split ( $ principal ) ; return self :: ADDRESSBOOK_ROOT . '/' . $ principalId ; } | Returns the addressbook home for a given principal . |
13,791 | public function addressbookMultiGetReport ( $ report ) { $ contentType = $ report -> contentType ; $ version = $ report -> version ; if ( $ version ) { $ contentType .= '; version=' . $ version ; } $ vcardType = $ this -> negotiateVCard ( $ contentType ) ; $ propertyList = [ ] ; $ paths = array_map ( [ $ this -> server... | This function handles the addressbook - multiget REPORT . |
13,792 | protected function addressbookQueryReport ( $ report ) { $ depth = $ this -> server -> getHTTPDepth ( 0 ) ; if ( 0 == $ depth ) { $ candidateNodes = [ $ this -> server -> tree -> getNodeForPath ( $ this -> server -> getRequestUri ( ) ) , ] ; if ( ! $ candidateNodes [ 0 ] instanceof ICard ) { throw new ReportNotSupporte... | This function handles the addressbook - query REPORT . |
13,793 | public function validateFilters ( $ vcardData , array $ filters , $ test ) { if ( ! $ filters ) { return true ; } $ vcard = VObject \ Reader :: read ( $ vcardData ) ; foreach ( $ filters as $ filter ) { $ isDefined = isset ( $ vcard -> { $ filter [ 'name' ] } ) ; if ( $ filter [ 'is-not-defined' ] ) { if ( $ isDefined ... | Validates if a vcard makes it throught a list of filters . |
13,794 | protected function validateParamFilters ( array $ vProperties , array $ filters , $ test ) { foreach ( $ filters as $ filter ) { $ isDefined = false ; foreach ( $ vProperties as $ vProperty ) { $ isDefined = isset ( $ vProperty [ $ filter [ 'name' ] ] ) ; if ( $ isDefined ) { break ; } } if ( $ filter [ 'is-not-defined... | Validates if a param - filter can be applied to a specific property . |
13,795 | protected function validateTextMatches ( array $ texts , array $ filters , $ test ) { foreach ( $ filters as $ filter ) { $ success = false ; foreach ( $ texts as $ haystack ) { $ success = DAV \ StringUtil :: textMatch ( $ haystack , $ filter [ 'value' ] , $ filter [ 'collation' ] , $ filter [ 'match-type' ] ) ; if ( ... | Validates if a text - filter can be applied to a specific property . |
13,796 | public function propFindLate ( DAV \ PropFind $ propFind , DAV \ INode $ node ) { if ( false === strpos ( ( string ) $ this -> server -> httpRequest -> getHeader ( 'User-Agent' ) , 'Thunderbird' ) ) { return ; } $ contentType = $ propFind -> get ( '{DAV:}getcontenttype' ) ; list ( $ part ) = explode ( ';' , $ contentTy... | This event is triggered when fetching properties . |
13,797 | public function htmlActionsPanel ( DAV \ INode $ node , & $ output ) { if ( ! $ node instanceof AddressBookHome ) { return ; } $ output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new address book</h3> <input type="hidden" name="sabreAction" value="mkcol" /> <input... | This method is used to generate HTML output for the Sabre \ DAV \ Browser \ Plugin . This allows us to generate an interface users can use to create new addressbooks . |
13,798 | protected function negotiateVCard ( $ input , & $ mimeType = null ) { $ result = HTTP \ negotiateContentType ( $ input , [ 'text/x-vcard' , 'text/vcard' , 'text/vcard; version=4.0' , 'text/vcard; version=3.0' , 'application/vcard+json' , ] ) ; $ mimeType = $ result ; switch ( $ result ) { default : case 'text/x-vcard' ... | This helper function performs the content - type negotiation for vcards . |
13,799 | protected function convertVCard ( $ data , $ target , array $ propertiesFilter = null ) { if ( is_resource ( $ data ) ) { $ data = stream_get_contents ( $ data ) ; } $ input = VObject \ Reader :: read ( $ data ) ; if ( ! empty ( $ propertiesFilter ) ) { $ propertiesFilter = array_merge ( [ 'UID' , 'VERSION' , 'FN' ] , ... | Converts a vcard blob to a different version or jcard . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.