当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::isUpdatable方法代码示例

本文整理汇总了PHP中OC\Files\Filesystem::isUpdatable方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::isUpdatable方法的具体用法?PHP Filesystem::isUpdatable怎么用?PHP Filesystem::isUpdatable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Filesystem的用法示例。


在下文中一共展示了Filesystem::isUpdatable方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: put

 /**
  * Updates the data
  *
  * The data argument is a readable stream resource.
  *
  * After a succesful put operation, you may choose to return an ETag. The
  * etag must always be surrounded by double-quotes. These quotes must
  * appear in the actual string you're returning.
  *
  * Clients may use the ETag from a PUT request to later on make sure that
  * when they update the file, the contents haven't changed in the mean
  * time.
  *
  * If you don't plan to store the file byte-by-byte, and you return a
  * different object on a subsequent GET you are strongly recommended to not
  * return an ETag, and just return null.
  *
  * @param resource $data
  * @throws Sabre_DAV_Exception_Forbidden
  * @return string|null
  */
 public function put($data)
 {
     if (!\OC\Files\Filesystem::isUpdatable($this->path)) {
         throw new \Sabre_DAV_Exception_Forbidden();
     }
     // mark file as partial while uploading (ignored by the scanner)
     $partpath = $this->path . '.part';
     \OC\Files\Filesystem::file_put_contents($partpath, $data);
     //detect aborted upload
     if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {
         if (isset($_SERVER['CONTENT_LENGTH'])) {
             $expected = $_SERVER['CONTENT_LENGTH'];
             $actual = \OC\Files\Filesystem::filesize($partpath);
             if ($actual != $expected) {
                 \OC\Files\Filesystem::unlink($partpath);
                 throw new Sabre_DAV_Exception_BadRequest('expected filesize ' . $expected . ' got ' . $actual);
             }
         }
     }
     // rename to correct path
     \OC\Files\Filesystem::rename($partpath, $this->path);
     //allow sync clients to send the mtime along in a header
     $mtime = OC_Request::hasModificationTime();
     if ($mtime !== false) {
         if (\OC\Files\Filesystem::touch($this->path, $mtime)) {
             header('X-OC-MTime: accepted');
         }
     }
     return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:51,代码来源:file.php

示例2: setName

 /**
  * @brief Renames the node
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     // rename is only allowed if the update privilege is granted
     if (!\OC\Files\Filesystem::isUpdatable($this->path)) {
         throw new \Sabre_DAV_Exception_Forbidden();
     }
     list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
     list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
     $newPath = $parentPath . '/' . $newName;
     $oldPath = $this->path;
     \OC\Files\Filesystem::rename($this->path, $newPath);
     $this->path = $newPath;
     $query = OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertypath` = ?' . ' WHERE `userid` = ? AND `propertypath` = ?');
     $query->execute(array($newPath, OC_User::getUser(), $oldPath));
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:20,代码来源:node.php

示例3: getPermissions

 /**
  * Determine permissions for a given file path
  * @param string $path
  * @return int
  */
 function getPermissions($path)
 {
     // add read permissions
     $permissions = \OCP\PERMISSION_READ;
     // get directory
     $fileInfo = pathinfo($path);
     $dir = $fileInfo['dirname'] . '/';
     // add update permissions
     if (Filesystem::isUpdatable($dir)) {
         $permissions |= \OCP\PERMISSION_UPDATE;
     }
     // add delete permissions
     if (Filesystem::isDeletable($dir)) {
         $permissions |= \OCP\PERMISSION_DELETE;
     }
     // add share permissions
     if (Filesystem::isSharable($dir)) {
         $permissions |= \OCP\PERMISSION_SHARE;
     }
     // return
     return $permissions;
 }
开发者ID:amin-hedayati,项目名称:search_lucene,代码行数:27,代码来源:luceneresult.php

示例4: createFile

 /**
  * Creates a new file in the directory
  *
  * Data will either be supplied as a stream resource, or in certain cases
  * as a string. Keep in mind that you may have to support either.
  *
  * After succesful creation of the file, you may choose to return the ETag
  * of the new file here.
  *
  * The returned ETag must be surrounded by double-quotes (The quotes should
  * be part of the actual string).
  *
  * If you cannot accurately determine the ETag, you should not return it.
  * If you don't store the file exactly as-is (you're transforming it
  * somehow) you should also not return an ETag.
  *
  * This means that if a subsequent GET to this new file does not exactly
  * return the same contents of what was submitted here, you are strongly
  * recommended to omit the ETag.
  *
  * @param string $name Name of the file
  * @param resource|string $data Initial payload
  * @throws Sabre_DAV_Exception_Forbidden
  * @return null|string
  */
 public function createFile($name, $data = null)
 {
     if ($name === 'Shared' && empty($this->path)) {
         throw new \Sabre_DAV_Exception_Forbidden();
     }
     // for chunked upload also updating a existing file is a "createFile"
     // because we create all the chunks before reasamble them to the existing file.
     if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
         // exit if we can't create a new file and we don't updatable existing file
         $info = OC_FileChunking::decodeName($name);
         if (!\OC\Files\Filesystem::isCreatable($this->path) && !\OC\Files\Filesystem::isUpdatable($this->path . '/' . $info['name'])) {
             throw new \Sabre_DAV_Exception_Forbidden();
         }
     } else {
         // For non-chunked upload it is enough to check if we can create a new file
         if (!\OC\Files\Filesystem::isCreatable($this->path)) {
             throw new \Sabre_DAV_Exception_Forbidden();
         }
     }
     $path = $this->path . '/' . $name;
     $node = new OC_Connector_Sabre_File($path);
     return $node->put($data);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:48,代码来源:directory.php

示例5: getPermissions

 public function getPermissions()
 {
     if (count($this->sharing)) {
         if ($this->isPublicShare()) {
             $permissions = \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE;
         } else {
             $permissions = $this->sharing[0]['permissions'];
         }
     } else {
         list($owner, $path) = $this->getOwnerViewAndPath();
         $permissions = 0;
         if (\OC\Files\Filesystem::isReadable($path)) {
             $permissions |= \OCP\PERMISSION_READ;
         }
         if (\OC\Files\Filesystem::isUpdatable($path)) {
             $permissions |= \OCP\PERMISSION_UPDATE;
         }
     }
     return $permissions;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:20,代码来源:file.php

示例6: array

     }
 } else {
     // file doesn't exist yet, so let's create it!
     if ($file == '') {
         OCP\JSON::error(array("data" => array("message" => "Empty Filename")));
         exit;
     }
     \OC\Files\Filesystem::mkdir($dir);
     if (!\OC\Files\Filesystem::touch($dir . '/' . $file)) {
         OCP\JSON::error(array("data" => array("message" => "Error when creating new file!")));
         OCP\Util::writeLog('files_svgedit', "Failed to create file: " . $path, OC_Log::ERROR);
         exit;
     }
 }
 // file should be existing now
 $writable = \OC\Files\Filesystem::isUpdatable($path);
 if ($writable) {
     if ($b64encoded) {
         $b64prefix = 'data:' . $b64type . ';base64,';
         if (strpos($filecontents, $b64prefix) === 0) {
             $filecontents = base64_decode(substr($filecontents, strlen($b64prefix)));
         }
     }
     \OC\Files\Filesystem::file_put_contents($path, $filecontents);
     // Clear statcache
     clearstatcache();
     // Get new mtime
     $newmtime = \OC\Files\Filesystem::filemtime($path);
     OCP\JSON::success(array('data' => array('mtime' => $newmtime)));
 } else {
     // Not writable!
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:31,代码来源:save.php

示例7: isset

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
// Get paramteres
$filecontents = $_POST['filecontents'];
$path = isset($_POST['path']) ? $_POST['path'] : '';
$mtime = isset($_POST['mtime']) ? $_POST['mtime'] : '';
if ($path != '' && $mtime != '') {
    // Get file mtime
    $filemtime = \OC\Files\Filesystem::filemtime($path);
    if ($mtime != $filemtime) {
        // Then the file has changed since opening
        OCP\JSON::error();
        OCP\Util::writeLog('files_texteditor', "File: " . $path . " modified since opening.", OCP\Util::ERROR);
    } else {
        // File same as when opened, save file
        if (\OC\Files\Filesystem::isUpdatable($path)) {
            $filecontents = iconv(mb_detect_encoding($filecontents), "UTF-8", $filecontents);
            \OC\Files\Filesystem::file_put_contents($path, $filecontents);
            // Clear statcache
            clearstatcache();
            // Get new mtime
            $newmtime = \OC\Files\Filesystem::filemtime($path);
            OCP\JSON::success(array('data' => array('mtime' => $newmtime)));
        } else {
            // Not writeable!
            OCP\JSON::error(array('data' => array('message' => 'Insufficient permissions')));
            OCP\Util::writeLog('files_texteditor', "User does not have permission to write to file: " . $path, OCP\Util::ERROR);
        }
    }
} else {
    if ($path == '') {
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:savefile.php

示例8:

     $target = OCP\Files::buildNotExistingFileName($dir . $relativePath, $files['name'][$i]);
 } else {
     $target = \OC\Files\Filesystem::normalizePath($dir . $relativePath . '/' . $files['name'][$i]);
 }
 // relative dir to return to the client
 if (isset($publicDirectory)) {
     // path relative to the public root
     $returnedDir = $publicDirectory . $relativePath;
 } else {
     // full path
     $returnedDir = $dir . $relativePath;
 }
 $returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
 $exists = \OC\Files\Filesystem::file_exists($target);
 if ($exists) {
     $updatable = \OC\Files\Filesystem::isUpdatable($target);
 }
 if (!$exists || $updatable && $resolution === 'replace') {
     // upload and overwrite file
     try {
         if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
             // updated max file size after upload
             $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
             $meta = \OC\Files\Filesystem::getFileInfo($target);
             if ($meta === false) {
                 $error = $l->t('The target folder has been moved or deleted.');
                 $errorCode = 'targetnotfound';
             } else {
                 $data = \OCA\Files\Helper::formatFileInfo($meta);
                 $data['status'] = 'success';
                 $data['originalname'] = $files['name'][$i];
开发者ID:Jook3r,项目名称:core-1,代码行数:31,代码来源:upload.php

示例9: isUpdatable

 /**
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  */
 public static function isUpdatable($path)
 {
     return \OC\Files\Filesystem::isUpdatable($path);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:7,代码来源:filesystem.php

示例10: getDirPermissions

 /**
  * Returns the numeric permissions for the given directory.
  * @param string $dir directory without trailing slash
  * @return numeric permissions
  */
 public static function getDirPermissions($dir)
 {
     $permissions = \OCP\PERMISSION_READ;
     if (\OC\Files\Filesystem::isCreatable($dir . '/')) {
         $permissions |= \OCP\PERMISSION_CREATE;
     }
     if (\OC\Files\Filesystem::isUpdatable($dir . '/')) {
         $permissions |= \OCP\PERMISSION_UPDATE;
     }
     if (\OC\Files\Filesystem::isDeletable($dir . '/')) {
         $permissions |= \OCP\PERMISSION_DELETE;
     }
     if (\OC\Files\Filesystem::isSharable($dir . '/')) {
         $permissions |= \OCP\PERMISSION_SHARE;
     }
     return $permissions;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:22,代码来源:helper.php

示例11: array

    }
}
// make breadcrumb und filelist markup
$list = new OCP\Template('files', 'part.list', '');
$list->assign('files', $files);
$list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
$list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')));
$list->assign('disableSharing', false);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
$permissions = OCP\PERMISSION_READ;
if (\OC\Files\Filesystem::isCreatable($dir . '/')) {
    $permissions |= OCP\PERMISSION_CREATE;
}
if (\OC\Files\Filesystem::isUpdatable($dir . '/')) {
    $permissions |= OCP\PERMISSION_UPDATE;
}
if (\OC\Files\Filesystem::isDeletable($dir . '/')) {
    $permissions |= OCP\PERMISSION_DELETE;
}
if (\OC\Files\Filesystem::isSharable($dir . '/')) {
    $permissions |= OCP\PERMISSION_SHARE;
}
if ($needUpgrade) {
    OCP\Util::addscript('files', 'upgrade');
    $tmpl = new OCP\Template('files', 'upgrade', 'user');
    $tmpl->printPage();
} else {
    // information about storage capacities
    $storageInfo = OC_Helper::getStorageInfo();
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:index.php


注:本文中的OC\Files\Filesystem::isUpdatable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。