Example #1
0
 /**
  * Adds all ownCloud-specific properties
  *
  * @param string $path
  * @param \Sabre\DAV\INode $node
  * @param array $requestedProperties
  * @param array $returnedProperties
  * @return void
  */
 public function beforeGetProperties($path, \Sabre\DAV\INode $node, array &$requestedProperties, array &$returnedProperties)
 {
     if ($node instanceof OC_Connector_Sabre_Node) {
         $fileIdPropertyName = '{' . self::NS_OWNCLOUD . '}id';
         $permissionsPropertyName = '{' . self::NS_OWNCLOUD . '}permissions';
         if (array_search($fileIdPropertyName, $requestedProperties)) {
             unset($requestedProperties[array_search($fileIdPropertyName, $requestedProperties)]);
         }
         if (array_search($permissionsPropertyName, $requestedProperties)) {
             unset($requestedProperties[array_search($permissionsPropertyName, $requestedProperties)]);
         }
         /** @var $node OC_Connector_Sabre_Node */
         $fileId = $node->getFileId();
         if (!is_null($fileId)) {
             $returnedProperties[200][$fileIdPropertyName] = $fileId;
         }
         $permissions = $node->getDavPermissions();
         if (!is_null($permissions)) {
             $returnedProperties[200][$permissionsPropertyName] = $permissions;
         }
     }
     if ($node instanceof OC_Connector_Sabre_File) {
         /** @var $node OC_Connector_Sabre_File */
         $directDownloadUrl = $node->getDirectDownload();
         if (isset($directDownloadUrl['url'])) {
             $directDownloadUrlPropertyName = '{' . self::NS_OWNCLOUD . '}downloadURL';
             $returnedProperties[200][$directDownloadUrlPropertyName] = $directDownloadUrl['url'];
         }
     }
     if ($node instanceof OC_Connector_Sabre_Directory) {
         $sizePropertyName = '{' . self::NS_OWNCLOUD . '}size';
         /** @var $node OC_Connector_Sabre_Directory */
         $returnedProperties[200][$sizePropertyName] = $node->getSize();
     }
 }
Example #2
0
 /**
  * Adds all ownCloud-specific properties
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if ($node instanceof \OC\Connector\Sabre\Node) {
         $propFind->handle(self::FILEID_PROPERTYNAME, function () use($node) {
             return $node->getFileId();
         });
         $propFind->handle(self::PERMISSIONS_PROPERTYNAME, function () use($node) {
             return $node->getDavPermissions();
         });
         $propFind->handle(self::GETETAG_PROPERTYNAME, function () use($node) {
             return $node->getEtag();
         });
     }
     if ($node instanceof \OC\Connector\Sabre\File) {
         $propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function () use($node) {
             /** @var $node \OC\Connector\Sabre\File */
             $directDownloadUrl = $node->getDirectDownload();
             if (isset($directDownloadUrl['url'])) {
                 return $directDownloadUrl['url'];
             }
             return false;
         });
     }
     if ($node instanceof \OC\Connector\Sabre\Directory) {
         $propFind->handle(self::SIZE_PROPERTYNAME, function () use($node) {
             return $node->getSize();
         });
     }
 }
Example #3
0
 /**
  * Adds all ownCloud-specific properties
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
         $propFind->handle(self::FILEID_PROPERTYNAME, function () use($node) {
             return $node->getFileId();
         });
         $propFind->handle(self::INTERNAL_FILEID_PROPERTYNAME, function () use($node) {
             return $node->getInternalFileId();
         });
         $propFind->handle(self::PERMISSIONS_PROPERTYNAME, function () use($node) {
             $perms = $node->getDavPermissions();
             if ($this->isPublic) {
                 // remove mount information
                 $perms = str_replace(['S', 'M'], '', $perms);
             }
             return $perms;
         });
         $propFind->handle(self::GETETAG_PROPERTYNAME, function () use($node) {
             return $node->getEtag();
         });
     }
     if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
         $propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function () use($node) {
             /** @var $node \OCA\DAV\Connector\Sabre\File */
             $directDownloadUrl = $node->getDirectDownload();
             if (isset($directDownloadUrl['url'])) {
                 return $directDownloadUrl['url'];
             }
             return false;
         });
     }
     if ($node instanceof \OCA\DAV\Connector\Sabre\Directory) {
         $propFind->handle(self::SIZE_PROPERTYNAME, function () use($node) {
             return $node->getSize();
         });
     }
     $propFind->handle(self::OWNER_ID_PROPERTYNAME, function () use($node) {
         $owner = $node->getOwner();
         return $owner->getUID();
     });
     $propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function () use($node) {
         $owner = $node->getOwner();
         $displayName = $owner->getDisplayName();
         return $displayName;
     });
 }
Example #4
0
 /**
  * Adds all ownCloud-specific properties
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if ($node instanceof \OC\Connector\Sabre\Node) {
         $propFind->handle(self::FILEID_PROPERTYNAME, function () use($node) {
             return $node->getFileId();
         });
         $propFind->handle(self::PERMISSIONS_PROPERTYNAME, function () use($node) {
             $perms = $node->getDavPermissions();
             if ($this->isPublic) {
                 // remove mount information
                 $perms = str_replace(['S', 'M'], '', $perms);
             }
             return $perms;
         });
         $propFind->handle(self::GETETAG_PROPERTYNAME, function () use($node) {
             return $node->getEtag();
         });
     }
     if ($node instanceof \OC\Connector\Sabre\File) {
         $propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function () use($node) {
             /** @var $node \OC\Connector\Sabre\File */
             try {
                 $directDownloadUrl = $node->getDirectDownload();
                 if (isset($directDownloadUrl['url'])) {
                     return $directDownloadUrl['url'];
                 }
             } catch (StorageNotAvailableException $e) {
                 // return empty download link when storage not available
                 return false;
             }
             return false;
         });
     }
     if ($node instanceof \OC\Connector\Sabre\Directory) {
         $propFind->handle(self::SIZE_PROPERTYNAME, function () use($node) {
             return $node->getSize();
         });
     }
 }
Example #5
0
 /**
  * Adds all ownCloud-specific properties
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     $httpRequest = $this->server->httpRequest;
     if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
         $propFind->handle(self::FILEID_PROPERTYNAME, function () use($node) {
             return $node->getFileId();
         });
         $propFind->handle(self::INTERNAL_FILEID_PROPERTYNAME, function () use($node) {
             return $node->getInternalFileId();
         });
         $propFind->handle(self::PERMISSIONS_PROPERTYNAME, function () use($node) {
             $perms = $node->getDavPermissions();
             if ($this->isPublic) {
                 // remove mount information
                 $perms = str_replace(['S', 'M'], '', $perms);
             }
             return $perms;
         });
         $propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function () use($node, $httpRequest) {
             return $node->getSharePermissions($httpRequest->getRawServerValue('PHP_AUTH_USER'));
         });
         $propFind->handle(self::GETETAG_PROPERTYNAME, function () use($node) {
             return $node->getETag();
         });
         $propFind->handle(self::OWNER_ID_PROPERTYNAME, function () use($node) {
             $owner = $node->getOwner();
             return $owner->getUID();
         });
         $propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function () use($node) {
             $owner = $node->getOwner();
             $displayName = $owner->getDisplayName();
             return $displayName;
         });
         $propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function () use($node) {
             if ($node->getPath() === '/') {
                 return $this->config->getSystemValue('data-fingerprint', '');
             }
         });
     }
     if ($node instanceof \OCA\DAV\Files\FilesHome) {
         $propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function () use($node) {
             return $this->config->getSystemValue('data-fingerprint', '');
         });
     }
     if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
         $propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function () use($node) {
             /** @var $node \OCA\DAV\Connector\Sabre\File */
             try {
                 $directDownloadUrl = $node->getDirectDownload();
                 if (isset($directDownloadUrl['url'])) {
                     return $directDownloadUrl['url'];
                 }
             } catch (StorageNotAvailableException $e) {
                 return false;
             } catch (ForbiddenException $e) {
                 return false;
             }
             return false;
         });
         $propFind->handle(self::CHECKSUMS_PROPERTYNAME, function () use($node) {
             $checksum = $node->getChecksum();
             if ($checksum === NULL || $checksum === '') {
                 return null;
             }
             return new ChecksumList($checksum);
         });
     }
     if ($node instanceof \OCA\DAV\Connector\Sabre\Directory) {
         $propFind->handle(self::SIZE_PROPERTYNAME, function () use($node) {
             return $node->getSize();
         });
     }
 }