芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/cloud.pulsehost.co.uk/vendor/afterlogic/dav/lib/DAV/FS/Shared/Root.php
getUser(); $this->pdo = new \Afterlogic\DAV\FS\Backend\PDO(); } public function getName() { return \Aurora\System\Enums\FileStorageType::Shared; } /** * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ public function getOwner() { return \Afterlogic\DAV\Constants::PRINCIPALS_PREFIX . $this->UserPublicId; } public static function populateItem($aSharedFile) { $mResult = false; if (is_array($aSharedFile)) { $oItem = null; try { Api::Log('populateItem: owner: ' . basename($aSharedFile['owner']) . '/files/' . $aSharedFile['storage'] . '/' . trim($aSharedFile['path'], '/')); $oItem = \Afterlogic\DAV\Server::getNodeForPath('files/' . $aSharedFile['storage'] . '/' . trim($aSharedFile['path'], '/'), basename($aSharedFile['owner'])); } catch (\Sabre\DAV\Exception\NotFound $oEx) { Api::Log('populateItem: item not found'); } if ($oItem instanceof \Afterlogic\Dav\FS\File || $oItem instanceof \Afterlogic\Dav\FS\Directory) { $oItem->setAccess((int) $aSharedFile['access']); $oItem->setUser(basename($aSharedFile['owner'])); if ($oItem instanceof \Afterlogic\DAV\FS\Directory) { $mResult = new Directory($aSharedFile['uid'], $oItem); } else { $mResult = new File($aSharedFile['uid'], $oItem); } if ($mResult) { list($sRelativeNodePath, ) = split($aSharedFile['path']); if ($sRelativeNodePath === '/') { $sRelativeNodePath = ''; } $mResult->setRelativeNodePath($sRelativeNodePath); $mResult->setOwnerPublicId(basename($aSharedFile['owner'])); $mResult->setSharePath($aSharedFile['share_path']); $mResult->setAccess((int) $aSharedFile['access']); $mResult->setGroupId($aSharedFile['group_id']); $mResult->setInitiator($aSharedFile['initiator']); if (isset($aSharedFile['properties'])) { $mResult->setDbProperties(\json_decode($aSharedFile['properties'], true)); } } } } return $mResult; } public static function hasHistoryDirectory(&$name) { $bHasHistory = false; if (substr($name, -5) === '.hist') { $bHasHistory = true; $name = substr($name, 0, strpos($name, '.hist')); } return $bHasHistory; } protected function populateAccess(&$oChild, $aSharedFile) { // NoAccess = 0; // Write = 1; // Read = 2; // Reshare = 3; $iAccess = $oChild->getAccess(); if ($oChild->getGroupId() === 0 && $iAccess === Access::NoAccess) { return; } if ((int) $aSharedFile['group_id'] === 0) { $oChild->setAccess($aSharedFile['access']); } else { if ($aSharedFile['access'] !== Access::Read) { if ($iAccess < $aSharedFile['access']) { $oChild->setAccess($aSharedFile['access']); } } elseif ($iAccess !== Access::Write || $iAccess !== Access::Reshare) { $oChild->setAccess($aSharedFile['access']); } } } public function getChild($name) { $oChild = false; $new_name = $name; $pathinfo = pathinfo($new_name); if (isset($pathinfo['extension']) && $pathinfo['extension'] === 'hist') { $new_name = $pathinfo['filename']; } // $aSharedFile = $this->pdo->getSharedFileByUid( // \Afterlogic\DAV\Constants::PRINCIPALS_PREFIX . $this->UserPublicId, // $new_name // ); $aSharedFiles = $this->pdo->getSharedFilesByUid( Constants::PRINCIPALS_PREFIX . $this->getUser(), $new_name ); foreach ($aSharedFiles as $aSharedFile) { if (is_array($aSharedFile)) { if ($aSharedFile['owner'] !== $aSharedFile['principaluri']) { if (self::hasHistoryDirectory($name)) { $aSharedFile['path'] = $aSharedFile['path'] . '.hist'; $aSharedFile['uid'] = $aSharedFile['uid'] . '.hist'; } if ($oChild) { $sPath = '/' . ltrim($oChild->getRelativePath() . '/' . $oChild->getName(), '/'); if ($aSharedFile['path'] === $sPath) { $this->populateAccess($oChild, $aSharedFile); } } else { $oChild = Root::populateItem($aSharedFile); } } } else { $aSharedFile = $this->pdo->getSharedFileBySharePath( Constants::PRINCIPALS_PREFIX . Server::getUser(), '/' . trim($name, '/') ); if ($aSharedFile) { $oChild = Server::getNodeForPath('files/personal/' . trim($name, '/')); } } } return $oChild; } public function getChildren() { return $this->getSharedChildren(); } public function createFile($name, $data = null, $rangeType = 0, $offset = 0, $extendedProps = []) { $oFile = $this->getChild($name); if ($oFile instanceof File) { $oFile->put($data); } else { throw new \Sabre\DAV\Exception\Forbidden(); } } public function getRelativeNodePath() { return ''; } public function getLastModified() { return 0; } }