diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index 0cd825f3e5..b49e52f0bd 100755 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -42,7 +42,8 @@ function handleRemove($name) { function handleGetThumbnails($albumname) { OCP\Response::enableCaching(3600 * 24); // 24 hour - $thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.urldecode($albumname).'.png'; + $view = OCP\App::getStorage('gallery'); + $thumbnail = $view->fopen(urldecode($albumname).'.png', 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail)); OCP\Response::sendFile($thumbnail); } diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php index 1223320120..304757b9e9 100755 --- a/apps/gallery/ajax/sharing.php +++ b/apps/gallery/ajax/sharing.php @@ -80,7 +80,8 @@ function handleGetThumbnail($token, $imgpath) { function handleGetAlbumThumbnail($token, $albumname) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png'; + $view = OCP\App::getStorage('gallery'); + $file = $view->fopen($albumname.'.png', 'r'); $image = new OC_Image($file); if ($image->valid()) { $image->centerCrop(); @@ -93,7 +94,8 @@ function handleGetAlbumThumbnail($token, $albumname) function handleGetPhoto($token, $photo) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$owner.'/files'.urldecode($photo); + $view = OCP\App::getStorage('files'); + $file = $view->fopen(urldecode($photo), 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($file)); OCP\Response::sendFile($file); } diff --git a/apps/gallery/index.php b/apps/gallery/index.php index e47fb3db5d..a9fe200c4e 100755 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -27,10 +27,6 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('gallery'); OCP\App::setActiveNavigationEntry( 'gallery_index' ); -if (!file_exists(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) { - mkdir(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery'); -} - if (!isset($_GET['view'])) { $result = OC_Gallery_Album::find(OCP\USER::getUser()); diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index ac6cacbe01..7b9036742a 100755 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -92,9 +92,8 @@ class OC_Gallery_Album { } public static function changeThumbnailPath($oldname, $newname) { - - $thumbpath = OC::$CONFIG_DATADIRECTORY.'/../gallery/'; - rename($thumbpath.$oldname.'.png', $thumbpath.$newname.'.png'); + $view = OCP\App::getStorage('gallery'); + $view->rename($oldname.'.png', $newname.'.png'); } public static function getAlbumSize($id){ diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 99384af621..b4b37236b0 100755 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -68,17 +68,17 @@ class OC_Gallery_Photo { public static function getThumbnail($image_name, $owner = null) { if (!$owner) $owner = OCP\USER::getUser(); - $save_dir = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'; - $save_dir .= dirname($image_name). '/'; - $image_path = $image_name; - $thumb_file = $save_dir . basename($image_name); - if (!is_dir($save_dir)) { - mkdir($save_dir, 0777, true); + $view = OCP\App::getStorage('gallery'); + $save_dir = dirname($image_name); + if (!$view->is_dir($save_dir)) { + $view->mkdir($save_dir); } - if (file_exists($thumb_file)) { - $image = new OC_Image($thumb_file); + $view->chroot($view->getRoot().'/'.$save_dir); + $thumb_file = basename($image_name); + if ($view->file_exists($thumb_file)) { + $image = new OC_Image($view->fopen($thumb_file, 'r')); } else { - $image_path = OC_Filesystem::getLocalFile($image_path); + $image_path = OC_Filesystem::getLocalFile($image_name); if(!file_exists($image_path)) { return null; } @@ -86,7 +86,7 @@ class OC_Gallery_Photo { if ($image->valid()) { $image->centerCrop(200); $image->fixOrientation(); - $image->save($thumb_file); + $image->save($view->getLocalFile($thumb_file)); } } if ($image->valid()) { diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 7a137cb3f5..e11ba1da45 100755 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -81,7 +81,8 @@ class OC_Gallery_Scanner { $image->destroy(); } } - imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery/' . $albumName.'.png'); + $view = OCP\App::getStorage('gallery'); + imagepng($thumbnail, $view->getLocalFile($albumName.'.png')); imagedestroy($thumbnail); }