예제 #1
0
파일: hooks.php 프로젝트: hjimmy/owncloud
 /**
  * @brief mark file as renamed so that we know the original source after the file was renamed
  * @param array $params with the old path and the new path
  */
 public static function preRename($params)
 {
     $user = \OCP\User::getUser();
     $view = new \OC_FilesystemView('/');
     $util = new Util($view, $user);
     list($ownerOld, $pathOld) = $util->getUidAndFilename($params['oldpath']);
     // we only need to rename the keys if the rename happens on the same mountpoint
     // otherwise we perform a stream copy, so we get a new set of keys
     $mp1 = $view->getMountPoint('/' . $user . '/files/' . $params['oldpath']);
     $mp2 = $view->getMountPoint('/' . $user . '/files/' . $params['newpath']);
     $type = $view->is_dir('/' . $user . '/files/' . $params['oldpath']) ? 'folder' : 'file';
     if ($mp1 === $mp2) {
         self::$renamedFiles[$params['oldpath']] = array('uid' => $ownerOld, 'path' => $pathOld, 'type' => $type, 'operation' => 'rename');
     }
 }