_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q27100
PDO.deleteCard
train
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->rowCount()...
php
{ "resource": "" }
q27101
PDO.getChangesForAddressBook
train
public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { // Current synctoken $stmt = $this->pdo->prepare('SELECT synctoken FROM '.$this->addressBooksTableName.' WHERE id = ?'); $stmt->execute([$addressBookId]); $currentToken = $stmt->fetchCol...
php
{ "resource": "" }
q27102
PDO.addChange
train
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->execute([ ...
php
{ "resource": "" }
q27103
SimplePDO.updateCalendarObject
train
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).'"'; ...
php
{ "resource": "" }
q27104
Plugin.propFind
train
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\Proper...
php
{ "resource": "" }
q27105
Plugin.httpLock
train
public function httpLock(RequestInterface $request, ResponseInterface $response) { $uri = $request->getPath(); $existingLocks = $this->getLocks($uri); if ($body = $request->getBodyAsString()) { // This is a new lock request $existingLock = null; // Chec...
php
{ "resource": "" }
q27106
Plugin.getTimeoutHeader
train
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')) { $hea...
php
{ "resource": "" }
q27107
Plugin.generateLockResponse
train
protected function generateLockResponse(LockInfo $lockInfo) { return $this->server->xml->write('{DAV:}prop', [ '{DAV:}lockdiscovery' => new DAV\Xml\Property\LockDiscovery([$lockInfo]), ]); }
php
{ "resource": "" }
q27108
Plugin.parseLockRequest
train
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 = $resul...
php
{ "resource": "" }
q27109
File.getETag
train
public function getETag() { return '"'.sha1( fileinode($this->path). filesize($this->path). filemtime($this->path) ).'"'; }
php
{ "resource": "" }
q27110
CalendarObject.put
train
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['calendar...
php
{ "resource": "" }
q27111
CalendarObject.getContentType
train
public function getContentType() { $mime = 'text/calendar; charset=utf-8'; if (isset($this->objectData['component']) && $this->objectData['component']) { $mime .= '; component='.$this->objectData['component']; } return $mime; }
php
{ "resource": "" }
q27112
Collection.getChildren
train
public function getChildren() { $children = []; $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri); foreach ($notifications as $notification) { $children[] = new Node( $this->caldavBackend, $this->principalUri...
php
{ "resource": "" }
q27113
StringUtil.textMatch
train
public static function textMatch($haystack, $needle, $collation, $matchType = 'contains') { switch ($collation) { case 'i;ascii-casemap': // default strtolower takes locale into consideration // we don't want this. $haystack = str_replace(range('a'...
php
{ "resource": "" }
q27114
StringUtil.ensureUTF8
train
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; } }
php
{ "resource": "" }
q27115
File.getData
train
protected function getData() { if (!file_exists($this->locksFile)) { return []; } // opening up the file, and creating a shared lock $handle = fopen($this->locksFile, 'r'); flock($handle, LOCK_SH); // Reading data until the eof $data = stream_get...
php
{ "resource": "" }
q27116
File.putData
train
protected function putData(array $newData) { // opening up the file, and creating an exclusive lock $handle = fopen($this->locksFile, 'a+'); flock($handle, LOCK_EX); // We can only truncate and rewind once the lock is acquired. ftruncate($handle, 0); rewind($handle);...
php
{ "resource": "" }
q27117
AbstractPrincipalCollection.getChildren
train
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) { ...
php
{ "resource": "" }
q27118
ResourceType.add
train
public function add($type) { $this->value[] = $type; $this->value = array_unique($this->value); }
php
{ "resource": "" }
q27119
IMipPlugin.mail
train
protected function mail($to, $subject, $body, array $headers) { mail($to, $subject, $body, implode("\r\n", $headers)); }
php
{ "resource": "" }
q27120
Acl.serializeAce
train
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':...
php
{ "resource": "" }
q27121
Node.getName
train
public function getName() { if ($this->overrideName) { return $this->overrideName; } list(, $name) = Uri\split($this->path); return $name; }
php
{ "resource": "" }
q27122
Node.setName
train
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, $n...
php
{ "resource": "" }
q27123
PDO.updateCalendar
train
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) = $...
php
{ "resource": "" }
q27124
PDO.createCalendarObject
train
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) = $...
php
{ "resource": "" }
q27125
PDO.getDenormalizedData
train
protected function getDenormalizedData($calendarData) { $vObject = VObject\Reader::read($calendarData); $componentType = null; $component = null; $firstOccurence = null; $lastOccurence = null; $uid = null; foreach ($vObject->getComponents() as $component) { ...
php
{ "resource": "" }
q27126
PDO.getChangesForCalendar
train
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, $in...
php
{ "resource": "" }
q27127
PDO.addChange
train
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([ $objectUri...
php
{ "resource": "" }
q27128
PDO.getSubscriptionsForUser
train
public function getSubscriptionsForUser($principalUri) { $fields = array_values($this->subscriptionPropertyMap); $fields[] = 'id'; $fields[] = 'uri'; $fields[] = 'source'; $fields[] = 'principaluri'; $fields[] = 'lastmodified'; // Making fields a comma-delimi...
php
{ "resource": "" }
q27129
PDO.createSubscription
train
public function createSubscription($principalUri, $uri, array $properties) { $fieldNames = [ 'principaluri', 'uri', 'source', 'lastmodified', ]; if (!isset($properties['{http://calendarserver.org/ns/}source'])) { throw new Forbidde...
php
{ "resource": "" }
q27130
PDO.updateSubscription
train
public function updateSubscription($subscriptionId, DAV\PropPatch $propPatch) { $supportedProperties = array_keys($this->subscriptionPropertyMap); $supportedProperties[] = '{http://calendarserver.org/ns/}source'; $propPatch->handle($supportedProperties, function ($mutations) use ($subscript...
php
{ "resource": "" }
q27131
PDO.getSchedulingObject
train
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->fetch(\P...
php
{ "resource": "" }
q27132
PDO.getSchedulingObjects
train
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(\PDO:...
php
{ "resource": "" }
q27133
PDO.deleteSchedulingObject
train
public function deleteSchedulingObject($principalUri, $objectUri) { $stmt = $this->pdo->prepare('DELETE FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?'); $stmt->execute([$principalUri, $objectUri]); }
php
{ "resource": "" }
q27134
PDO.createSchedulingObject
train
public function createSchedulingObject($principalUri, $objectUri, $objectData) { $stmt = $this->pdo->prepare('INSERT INTO '.$this->schedulingObjectTableName.' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)'); $stmt->execute([$principalUri, $objectData, $objectU...
php
{ "resource": "" }
q27135
PDO.updateInvites
train
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); ...
php
{ "resource": "" }
q27136
PDO.getInvites
train
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 = <<<SQL...
php
{ "resource": "" }
q27137
PDO.propFind
train
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); $...
php
{ "resource": "" }
q27138
PDO.propPatch
train
public function propPatch($path, PropPatch $propPatch) { $propPatch->handleRemaining(function ($properties) use ($path) { if ('pgsql' === $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { $updateSql = <<<SQL INSERT INTO {$this->tableName} (path, name, valuetype, value) VALUES (...
php
{ "resource": "" }
q27139
PDO.move
train
public function move($source, $destination) { // I don't know a way to write this all in a single sql query that's // also compatible across db engines, so we're letting PHP do all the // updates. Much slower, but it should still be pretty fast in most // cases. $select = $th...
php
{ "resource": "" }
q27140
Directory.childExists
train
public function childExists($name) { if ('.' == $name || '..' == $name) { throw new DAV\Exception\Forbidden('Permission denied to . and ..'); } $path = $this->path.'/'.$name; return file_exists($path); }
php
{ "resource": "" }
q27141
Directory.delete
train
public function delete() { // Deleting all children foreach ($this->getChildren() as $child) { $child->delete(); } // Removing the directory itself rmdir($this->path); return true; }
php
{ "resource": "" }
q27142
Directory.moveInto
train
public function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) { // We only support FSExt\Directory or FSExt\File objects, so // anything else we want to quickly reject. if (!$sourceNode instanceof self && !$sourceNode instanceof File) { return false; } ...
php
{ "resource": "" }
q27143
Plugin.initialize
train
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); if ($th...
php
{ "resource": "" }
q27144
Plugin.httpGetEarly
train
public function httpGetEarly(RequestInterface $request, ResponseInterface $response) { $params = $request->getQueryParameters(); if (isset($params['sabreAction']) && 'info' === $params['sabreAction']) { return $this->httpGet($request, $response); } }
php
{ "resource": "" }
q27145
Plugin.httpGet
train
public function httpGet(RequestInterface $request, ResponseInterface $response) { // We're not using straight-up $_GET, because we want everything to be // unit testable. $getVars = $request->getQueryParameters(); // CSP headers $response->setHeader('Content-Security-Policy'...
php
{ "resource": "" }
q27146
Plugin.httpPOST
train
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' !== $contentTy...
php
{ "resource": "" }
q27147
Plugin.generatePluginListing
train
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>...
php
{ "resource": "" }
q27148
Plugin.htmlActionsPanel
train
public function htmlActionsPanel(DAV\INode $node, &$output, $path) { if (!$node instanceof DAV\ICollection) { return; } // We also know fairly certain that if an object is a non-extended // SimpleCollection, we won't need to show the panel either. if ('Sabre\\DAV...
php
{ "resource": "" }
q27149
Plugin.getLocalAssetPath
train
protected function getLocalAssetPath($assetName) { $assetDir = __DIR__.'/assets/'; $path = $assetDir.$assetName; // Making sure people aren't trying to escape from the base path. $path = str_replace('\\', '/', $path); if (false !== strpos($path, '/../') || '/..' === strrchr(...
php
{ "resource": "" }
q27150
Plugin.serveAsset
train
protected function serveAsset($assetName) { $assetPath = $this->getLocalAssetPath($assetName); // Rudimentary mime type detection $mime = 'application/octet-stream'; $map = [ 'ico' => 'image/vnd.microsoft.icon', 'png' => 'image/png', 'css' => 'tex...
php
{ "resource": "" }
q27151
Plugin.mapResourceType
train
private function mapResourceType(array $resourceTypes, $node) { if (!$resourceTypes) { if ($node instanceof DAV\IFile) { return [ 'string' => 'File', 'icon' => 'file', ]; } else { return [ ...
php
{ "resource": "" }
q27152
File.loadFile
train
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) =...
php
{ "resource": "" }
q27153
File.getDigestHash
train
public function getDigestHash($realm, $username) { return isset($this->users[$realm.':'.$username]) ? $this->users[$realm.':'.$username] : false; }
php
{ "resource": "" }
q27154
Principal.getAlternateUriSet
train
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'])) { ...
php
{ "resource": "" }
q27155
Principal.getName
train
public function getName() { $uri = $this->principalProperties['uri']; list(, $name) = Uri\split($uri); return $name; }
php
{ "resource": "" }
q27156
Principal.getProperties
train
public function getProperties($requestedProperties) { $newProperties = []; foreach ($requestedProperties as $propName) { if (isset($this->principalProperties[$propName])) { $newProperties[$propName] = $this->principalProperties[$propName]; } } ...
php
{ "resource": "" }
q27157
SharingPlugin.propFindEarly
train
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() ...
php
{ "resource": "" }
q27158
SharingPlugin.propPatch
train
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:...
php
{ "resource": "" }
q27159
ICSExportPlugin.httpGet
train
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, [...
php
{ "resource": "" }
q27160
ICSExportPlugin.mergeObjects
train
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 { ...
php
{ "resource": "" }
q27161
Tree.getNodeForPath
train
public function getNodeForPath($path) { $path = trim($path, '/'); if (isset($this->cache[$path])) { return $this->cache[$path]; } // Is it the root node? if (!strlen($path)) { return $this->rootNode; } // Attempting to fetch its paren...
php
{ "resource": "" }
q27162
Tree.nodeExists
train
public function nodeExists($path) { try { // The root always exists if ('' === $path) { return true; } list($parent, $base) = Uri\split($path); $parentNode = $this->getNodeForPath($parent); if (!$parentNode instanceof ...
php
{ "resource": "" }
q27163
Tree.copy
train
public function copy($sourcePath, $destinationPath) { $sourceNode = $this->getNodeForPath($sourcePath); // grab the dirname and basename components list($destinationDir, $destinationName) = Uri\split($destinationPath); $destinationParent = $this->getNodeForPath($destinationDir); ...
php
{ "resource": "" }
q27164
Tree.move
train
public function move($sourcePath, $destinationPath) { list($sourceDir) = Uri\split($sourcePath); list($destinationDir, $destinationName) = Uri\split($destinationPath); if ($sourceDir === $destinationDir) { // If this is a 'local' rename, it means we can just trigger a rename. ...
php
{ "resource": "" }
q27165
Tree.delete
train
public function delete($path) { $node = $this->getNodeForPath($path); $node->delete(); list($parent) = Uri\split($path); $this->markDirty($parent); }
php
{ "resource": "" }
q27166
Tree.getChildren
train
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; ...
php
{ "resource": "" }
q27167
Tree.markDirty
train
public function markDirty($path) { // We don't care enough about sub-paths // flushing the entire cache $path = trim($path, '/'); foreach ($this->cache as $nodePath => $node) { if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) { ...
php
{ "resource": "" }
q27168
Tree.getMultipleNodes
train
public function getMultipleNodes($paths) { // Finding common parents $parents = []; foreach ($paths as $path) { list($parent, $node) = Uri\split($path); if (!isset($parents[$parent])) { $parents[$parent] = [$node]; } else { ...
php
{ "resource": "" }
q27169
File.put
train
public function put($data) { file_put_contents($this->path, $data); clearstatcache(true, $this->path); return $this->getETag(); }
php
{ "resource": "" }
q27170
File.patch
train
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; c...
php
{ "resource": "" }
q27171
Plugin.getCalendarHomeForPrincipal
train
public function getCalendarHomeForPrincipal($principalUrl) { // The default behavior for most sabre/dav servers is that there is a // principals root node, which contains users directly under it. // // This function assumes that there are two components in a principal // path...
php
{ "resource": "" }
q27172
Plugin.report
train
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; ...
php
{ "resource": "" }
q27173
Plugin.httpMkCalendar
train
public function httpMkCalendar(RequestInterface $request, ResponseInterface $response) { $body = $request->getBodyAsString(); $path = $request->getPath(); $properties = []; if ($body) { try { $mkcalendar = $this->server->xml->expect( ...
php
{ "resource": "" }
q27174
Plugin.calendarMultiGetReport
train
public function calendarMultiGetReport($report) { $needsJson = 'application/calendar+json' === $report->contentType; $timeZones = []; $propertyList = []; $paths = array_map( [$this->server, 'calculateUri'], $report->hrefs ); foreach ($this->...
php
{ "resource": "" }
q27175
Plugin.getSupportedPrivilegeSet
train
public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { if ($node instanceof ICalendar) { $supportedPrivilegeSet['{DAV:}read']['aggregates']['{'.self::NS_CALDAV.'}read-free-busy'] = [ 'abstract' => false, 'aggregates' => [], ...
php
{ "resource": "" }
q27176
Plugin.htmlActionsPanel
train
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"...
php
{ "resource": "" }
q27177
CalendarQueryValidator.validate
train
public function validate(VObject\Component\VCalendar $vObject, array $filters) { // The top level object is always a component filter. // We'll parse it manually, as it's pretty simple. if ($vObject->name !== $filters['name']) { return false; } return ...
php
{ "resource": "" }
q27178
CalendarQueryValidator.validateCompFilters
train
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; } ...
php
{ "resource": "" }
q27179
CalendarQueryValidator.validateParamFilters
train
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; } el...
php
{ "resource": "" }
q27180
CalendarQueryValidator.validateTextMatch
train
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-conditio...
php
{ "resource": "" }
q27181
CalendarQueryValidator.validateTimeRange
train
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'...
php
{ "resource": "" }
q27182
GuessContentType.propFind
train
public function propFind(PropFind $propFind, INode $node) { $propFind->handle('{DAV:}getcontenttype', function () use ($propFind) { list(, $fileName) = Uri\split($propFind->getPath()); return $this->getContentType($fileName); }); }
php
{ "resource": "" }
q27183
GuessContentType.getContentType
train
protected function getContentType($fileName) { // Just grabbing the extension $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); if (isset($this->extensionMap[$extension])) { return $this->extensionMap[$extension]; } return 'application/octe...
php
{ "resource": "" }
q27184
PDO.getDigestHash
train
public function getDigestHash($realm, $username) { $stmt = $this->pdo->prepare('SELECT digesta1 FROM '.$this->tableName.' WHERE username = ?'); $stmt->execute([$username]); return $stmt->fetchColumn() ?: null; }
php
{ "resource": "" }
q27185
PropPatch.handleRemaining
train
public function handleRemaining(callable $callback) { $properties = $this->getRemainingMutations(); if (!$properties) { // Nothing to do, don't register callback return; } foreach ($properties as $propertyName) { // HTTP Accepted $this...
php
{ "resource": "" }
q27186
PropPatch.setResultCode
train
public function setResultCode($properties, $resultCode) { foreach ((array) $properties as $propertyName) { $this->result[$propertyName] = $resultCode; } if ($resultCode >= 400) { $this->failed = true; } }
php
{ "resource": "" }
q27187
PropPatch.getRemainingMutations
train
public function getRemainingMutations() { $remaining = []; foreach ($this->mutations as $propertyName => $propValue) { if (!isset($this->result[$propertyName])) { $remaining[] = $propertyName; } } return $remaining; }
php
{ "resource": "" }
q27188
PropPatch.commit
train
public function commit() { // First we validate if every property has a handler foreach ($this->mutations as $propertyName => $value) { if (!isset($this->result[$propertyName])) { $this->failed = true; $this->result[$propertyName] = 403; } ...
php
{ "resource": "" }
q27189
PropPatch.doCallBackSingleProp
train
private function doCallBackSingleProp($propertyName, callable $callback) { $result = $callback($this->mutations[$propertyName]); if (is_bool($result)) { if ($result) { if (is_null($this->mutations[$propertyName])) { // Delete $resul...
php
{ "resource": "" }
q27190
PropPatch.doCallBackMultiProp
train
private function doCallBackMultiProp(array $propertyList, callable $callback) { $argument = []; foreach ($propertyList as $propertyName) { $argument[$propertyName] = $this->mutations[$propertyName]; } $result = $callback($argument); if (is_array($result)) { ...
php
{ "resource": "" }
q27191
HtmlOutputHelper.xmlName
train
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="'.$...
php
{ "resource": "" }
q27192
SupportedPrivilegeSet.serializePriv
train
private function serializePriv(Writer $writer, $privName, $privilege) { $writer->startElement('{DAV:}supported-privilege'); $writer->startElement('{DAV:}privilege'); $writer->writeElement($privName); $writer->endElement(); // privilege if (!empty($privilege['abstract'])) { ...
php
{ "resource": "" }
q27193
Card.get
train
public function get() { // Pre-populating 'carddata' is optional. If we don't yet have it // already, we fetch it from the backend. if (!isset($this->cardData['carddata'])) { $this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']); ...
php
{ "resource": "" }
q27194
Card.put
train
public function put($cardData) { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); } // Converting to UTF-8, if needed $cardData = DAV\StringUtil::ensureUTF8($cardData); $etag = $this->carddavBackend->updateCard($this->addressBookInfo['id...
php
{ "resource": "" }
q27195
Card.getETag
train
public function getETag() { if (isset($this->cardData['etag'])) { return $this->cardData['etag']; } else { $data = $this->get(); if (is_string($data)) { return '"'.md5($data).'"'; } else { // We refuse to calculate the m...
php
{ "resource": "" }
q27196
Plugin.beforeMethod
train
public function beforeMethod(RequestInterface $request, ResponseInterface $response) { if ($this->currentPrincipal) { // We already have authentication information. This means that the // event has already fired earlier, and is now likely fired for a // sub-request. ...
php
{ "resource": "" }
q27197
Plugin.check
train
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) { $resu...
php
{ "resource": "" }
q27198
Plugin.challenge
train
public function challenge(RequestInterface $request, ResponseInterface $response) { foreach ($this->backends as $backend) { $backend->challenge($request, $response); } }
php
{ "resource": "" }
q27199
AddressBookHome.getChild
train
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'); }
php
{ "resource": "" }