Merge pull request #5301 from owncloud/versioning_preview_shared

versioning preview also for shared files
This commit is contained in:
Thomas Müller 2013-10-12 01:32:25 -07:00
commit bff6ca212a
2 changed files with 11 additions and 4 deletions

View File

@ -12,25 +12,32 @@ if(!\OC_App::isEnabled('files_versions')){
} }
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
$user = array_key_exists('user', $_GET) ? $_GET['user'] : '';
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : 44; $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : 44;
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : 44; $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : 44;
$version = array_key_exists('version', $_GET) ? $_GET['version'] : ''; $version = array_key_exists('version', $_GET) ? $_GET['version'] : '';
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
if($user === '') {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('versions-preview', 'No user parameter was passed', \OC_Log::DEBUG);
exit;
}
if($file === '' && $version === '') { if($file === '' && $version === '') {
\OC_Response::setStatus(400); //400 Bad Request \OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG); \OC_Log::write('versions-preview', 'No file parameter was passed', \OC_Log::DEBUG);
exit; exit;
} }
if($maxX === 0 || $maxY === 0) { if($maxX === 0 || $maxY === 0) {
\OC_Response::setStatus(400); //400 Bad Request \OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); \OC_Log::write('versions-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
exit; exit;
} }
try{ try{
$preview = new \OC\Preview(\OC_User::getUser(), 'files_versions'); $preview = new \OC\Preview($user, 'files_versions');
$preview->setFile($file.'.v'.$version); $preview->setFile($file.'.v'.$version);
$preview->setMaxX($maxX); $preview->setMaxX($maxX);
$preview->setMaxY($maxY); $preview->setMaxY($maxY);

View File

@ -260,7 +260,7 @@ class Storage {
$versions[$key]['cur'] = 0; $versions[$key]['cur'] = 0;
$versions[$key]['version'] = $version; $versions[$key]['version'] = $version;
$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version); $versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version);
$versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $filename, 'version' => $version)); $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $filename, 'version' => $version, 'user' => $uid));
$versions[$key]['path'] = $filename; $versions[$key]['path'] = $filename;
$versions[$key]['size'] = $file['size']; $versions[$key]['size'] = $file['size'];
} }