本文整理汇总了PHP中OC\Files\Filesystem::getOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getOwner方法的具体用法?PHP Filesystem::getOwner怎么用?PHP Filesystem::getOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getOwner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUidAndFilename
/**
* get the UID of the owner of the file and the path to the file relative to
* owners files folder
*
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
*/
public static function getUidAndFilename($filename)
{
$uid = Filesystem::getOwner($filename);
$userManager = \OC::$server->getUserManager();
// if the user with the UID doesn't exists, e.g. because the UID points
// to a remote user with a federated cloud ID we use the current logged-in
// user. We need a valid local user to create the versions
if (!$userManager->userExists($uid)) {
$uid = User::getUser();
}
Filesystem::initMountPoints($uid);
if ($uid != User::getUser()) {
$info = Filesystem::getFileInfo($filename);
$ownerView = new View('/' . $uid . '/files');
try {
$filename = $ownerView->getPath($info['fileid']);
// make sure that the file name doesn't end with a trailing slash
// can for example happen single files shared across servers
$filename = rtrim($filename, '/');
} catch (NotFoundException $e) {
$filename = null;
}
}
return [$uid, $filename];
}
示例2: correctFolders
/**
* Correct the parent folders' ETags for all users shared the file at $target
*
* @param string $target
*/
public static function correctFolders($target)
{
$uid = \OCP\User::getUser();
$uidOwner = \OC\Files\Filesystem::getOwner($target);
$info = \OC\Files\Filesystem::getFileInfo($target);
// Correct Shared folders of other users shared with
$users = \OCP\Share::getUsersItemShared('file', $info['fileid'], $uidOwner, true);
if (!empty($users)) {
while (!empty($users)) {
$reshareUsers = array();
foreach ($users as $user) {
if ($user !== $uidOwner) {
$etag = \OC\Files\Filesystem::getETag('');
\OCP\Config::setUserValue($user, 'files_sharing', 'etag', $etag);
// Look for reshares
$reshareUsers = array_merge($reshareUsers, \OCP\Share::getUsersItemShared('file', $info['fileid'], $user, true));
}
}
$users = $reshareUsers;
}
// Correct folders of shared file owner
$target = substr($target, 8);
if ($uidOwner !== $uid && ($source = \OC_Share_Backend_File::getSource($target))) {
\OC\Files\Filesystem::initMountPoints($uidOwner);
$source = '/' . $uidOwner . '/' . $source['path'];
\OC\Files\Cache\Updater::correctFolder($source, $info['mtime']);
}
}
}
示例3: getUidAndFilename
public static function getUidAndFilename($filename)
{
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
if ($uid != \OCP\User::getUser()) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
$ownerView = new \OC\Files\View('/' . $uid . '/files');
$filename = $ownerView->getPath($info['fileid']);
}
return array($uid, $filename);
}
示例4: getUidAndFilename
/**
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
*/
public static function getUidAndFilename($filename)
{
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
if ($uid != \OCP\User::getUser()) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
$ownerView = new \OC\Files\View('/' . $uid . '/files');
try {
$filename = $ownerView->getPath($info['fileid']);
} catch (NotFoundException $e) {
$filename = null;
}
}
return [$uid, $filename];
}
示例5: update
/**
* update keyfiles and share keys recursively
*
* @param int $fileSource file source id
*/
private function update($fileSource)
{
$path = \OC\Files\Filesystem::getPath($fileSource);
$info = \OC\Files\Filesystem::getFileInfo($path);
$owner = \OC\Files\Filesystem::getOwner($path);
$view = new \OC\Files\View('/' . $owner . '/files');
$ownerPath = $view->getPath($info->getId());
$absPath = '/' . $owner . '/files' . $ownerPath;
$mount = $this->mountManager->find($path);
$mountPoint = $mount->getMountPoint();
// if a folder was shared, get a list of all (sub-)folders
if ($this->view->is_dir($absPath)) {
$allFiles = $this->util->getAllFiles($absPath, $mountPoint);
} else {
$allFiles = array($absPath);
}
$encryptionModule = $this->encryptionManager->getDefaultEncryptionModule();
foreach ($allFiles as $path) {
$usersSharing = $this->file->getAccessList($path);
$encryptionModule->update($path, $this->uid, $usersSharing);
}
}
示例6: getUidAndFilename
/**
* get the UID of the owner of the file and the path to the file relative to
* owners files folder
*
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
*/
public static function getUidAndFilename($filename)
{
$uid = Filesystem::getOwner($filename);
$userManager = \OC::$server->getUserManager();
// if the user with the UID doesn't exists, e.g. because the UID points
// to a remote user with a federated cloud ID we use the current logged-in
// user. We need a valid local user to move the file to the right trash bin
if (!$userManager->userExists($uid)) {
$uid = User::getUser();
}
Filesystem::initMountPoints($uid);
if ($uid != User::getUser()) {
$info = Filesystem::getFileInfo($filename);
$ownerView = new View('/' . $uid . '/files');
try {
$filename = $ownerView->getPath($info['fileid']);
} catch (NotFoundException $e) {
$filename = null;
}
}
return [$uid, $filename];
}
示例7: correctFolders
/**
* Correct the parent folders' ETags for all users shared the file at $target
*
* @param string $target
*/
public static function correctFolders($target)
{
$uid = \OCP\User::getUser();
$uidOwner = \OC\Files\Filesystem::getOwner($target);
$info = \OC\Files\Filesystem::getFileInfo($target);
$checkedUser = array($uidOwner);
// Correct Shared folders of other users shared with
$users = \OCP\Share::getUsersItemShared('file', $info['fileid'], $uidOwner, true);
if (!empty($users)) {
while (!empty($users)) {
$reshareUsers = array();
foreach ($users as $user) {
if (!in_array($user, $checkedUser)) {
$etag = \OC\Files\Filesystem::getETag('');
\OCP\Config::setUserValue($user, 'files_sharing', 'etag', $etag);
// Look for reshares
$reshareUsers = array_merge($reshareUsers, \OCP\Share::getUsersItemShared('file', $info['fileid'], $user, true));
$checkedUser[] = $user;
}
}
$users = $reshareUsers;
}
}
}
示例8: file_delete
/**
* @brief Store the delete hook events
* @param array $params The hook params
*/
public static function file_delete($params)
{
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($params['path'])));
$subject = '%s deleted';
Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 2);
if (substr($params['path'], 0, 8) == '/Shared/') {
$uidOwner = \OC\Files\Filesystem::getOwner($params['path']);
$realfile = substr($params['path'], 7);
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($realfile)));
$subject = '%s deleted by %s';
Data::send('files', $subject, array($realfile, \OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 7, Data::PRIORITY_HIGH);
}
}
示例9: getSharesFromItem
public static function getSharesFromItem($target)
{
$result = array();
$owner = \OC\Files\Filesystem::getOwner($target);
\OC\Files\Filesystem::initMountPoints($owner);
$info = \OC\Files\Filesystem::getFileInfo($target);
$ownerView = new \OC\Files\View('/' . $owner . '/files');
if ($owner != \OCP\User::getUser()) {
$path = $ownerView->getPath($info['fileid']);
} else {
$path = $target;
}
$ids = array();
while ($path !== dirname($path)) {
$info = $ownerView->getFileInfo($path);
if ($info instanceof \OC\Files\FileInfo) {
$ids[] = $info['fileid'];
} else {
\OCP\Util::writeLog('sharing', 'No fileinfo available for: ' . $path, \OCP\Util::WARN);
}
$path = dirname($path);
}
if (!empty($ids)) {
$idList = array_chunk($ids, 99, true);
foreach ($idList as $subList) {
$statement = "SELECT `share_with`, `share_type`, `file_target` FROM `*PREFIX*share` WHERE `file_source` IN (" . implode(',', $subList) . ") AND `share_type` IN (0, 1, 2)";
$query = \OCP\DB::prepare($statement);
$r = $query->execute();
$result = array_merge($result, $r->fetchAll());
}
}
return $result;
}
示例10: getSourcePathAndOwner
/**
* Return the source
*
* @param string $path
* @return array
*/
protected function getSourcePathAndOwner($path)
{
$uidOwner = Filesystem::getOwner($path);
if ($uidOwner !== $this->currentUser) {
Filesystem::initMountPoints($uidOwner);
$info = Filesystem::getFileInfo($path);
if ($info !== false) {
$ownerView = new View('/' . $uidOwner . '/files');
$path = $ownerView->getPath((int) $info['fileid']);
}
}
return array($path, $uidOwner);
}
示例11: getOwnerPath
/**
* get owner and path relative to data/<owner>/files
*
* @param string $path path to file for current user
* @return array ['owner' => $owner, 'path' => $path]
* @throw \InvalidArgumentException
*/
protected function getOwnerPath($path)
{
$info = Filesystem::getFileInfo($path);
$owner = Filesystem::getOwner($path);
$view = new View('/' . $owner . '/files');
$path = $view->getPath($info->getId());
if ($path === null) {
throw new \InvalidArgumentException('No file found for ' . $info->getId());
}
return array($owner, $path);
}
示例12: getUidAndFilename
/**
* get file owner and path
* @param string $filename
* @return string[] with the owner's uid and the owner's path
*/
private static function getUidAndFilename($filename) {
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
$filename = (strpos($filename, '/') !== 0) ? '/' . $filename : $filename;
if ($uid != \OCP\User::getUser()) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
if (!$info) {
return array($uid, '/files' . $filename);
}
$ownerView = new \OC\Files\View('/' . $uid . '/files');
$filename = $ownerView->getPath($info['fileid']);
}
return array($uid, '/files' . $filename);
}
示例13: getSourcePathAndOwner
/**
* Return the source
*
* @param string $path
* @return array
*/
public static function getSourcePathAndOwner($path)
{
$uidOwner = \OC\Files\Filesystem::getOwner($path);
if ($uidOwner != \OCP\User::getUser()) {
\OC\Files\Filesystem::initMountPoints($uidOwner);
$info = \OC\Files\Filesystem::getFileInfo($path);
$ownerView = new \OC\Files\View('/' . $uidOwner . '/files');
$path = $ownerView->getPath($info['fileid']);
}
return array($path, $uidOwner);
}
示例14: setSharedFileKeyfiles
/**
* @brief Encrypt keyfile to multiple users
* @param Session $session
* @param array $users list of users which should be able to access the file
* @param string $filePath path of the file to be shared
* @return bool
*/
public function setSharedFileKeyfiles(Session $session, array $users, $filePath)
{
// Make sure users are capable of sharing
$filteredUids = $this->filterShareReadyUsers($users);
// If we're attempting to share to unready users
if (!empty($filteredUids['unready'])) {
\OCP\Util::writeLog('Encryption library', 'Sharing to these user(s) failed as they are unready for encryption:"' . print_r($filteredUids['unready'], 1), \OCP\Util::WARN);
return false;
}
// Get public keys for each user, ready for generating sharekeys
$userPubKeys = Keymanager::getPublicKeys($this->view, $filteredUids['ready']);
// Note proxy status then disable it
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
// Get the current users's private key for decrypting existing keyfile
$privateKey = $session->getPrivateKey();
$fileOwner = \OC\Files\Filesystem::getOwner($filePath);
// Decrypt keyfile
$plainKeyfile = $this->decryptKeyfile($filePath, $privateKey);
// Re-enc keyfile to (additional) sharekeys
$multiEncKey = Crypt::multiKeyEncrypt($plainKeyfile, $userPubKeys);
// Save the recrypted key to it's owner's keyfiles directory
// Save new sharekeys to all necessary user directory
if (!Keymanager::setFileKey($this->view, $this, $filePath, $multiEncKey['data']) || !Keymanager::setShareKeys($this->view, $this, $filePath, $multiEncKey['keys'])) {
\OCP\Util::writeLog('Encryption library', 'Keyfiles could not be saved for users sharing ' . $filePath, \OCP\Util::ERROR);
return false;
}
// Return proxy to original status
\OC_FileProxy::$enabled = $proxyStatus;
return true;
}
示例15: shareFiles
/**
* Share selected files with selected users
*/
public function shareFiles()
{
$this->prepareUsersForShare();
$files = array();
foreach ($this->files as $id) {
$files[] = $file = $this->files->getById($id)[0];
$fileOwner = \OC\Files\Filesystem::getOwner($file['path']);
$sharetype = $file['mimetype'] == 2 ? 'folder' : 'file';
$sharedWith = \OCP\Share::getUsersItemShared($sharetype, $file['fileid'], $fileOwner, false, true);
foreach ($this->subscriberToShare as $userid) {
if (isset($file['fileid']) && is_array($file) && !in_array($userid, $sharedWith) && !($userid == $this->author) && ($fileOwner == $this->author || $file['permissions'] >= 16)) {
\OCP\Share::shareItem($sharetype, $file['fileid'], \OCP\Share::SHARE_TYPE_USER, $userid, 1);
}
}
}
$this->forSend['messagedata']['attachlinks'] = Helper::makeAttachLinks($this->files, $files);
}