diff options
Diffstat (limited to 'apps/media')
-rw-r--r-- | apps/media/js/loader.js | 4 | ||||
-rw-r--r-- | apps/media/lib/share/album.php | 0 | ||||
-rw-r--r-- | apps/media/lib/share/artist.php | 65 | ||||
-rw-r--r-- | apps/media/lib/share/song.php | 65 |
4 files changed, 132 insertions, 2 deletions
diff --git a/apps/media/js/loader.js b/apps/media/js/loader.js index 393f8ba914e..ffe9c1cdd61 100644 --- a/apps/media/js/loader.js +++ b/apps/media/js/loader.js @@ -45,8 +45,8 @@ $(document).ready(function() { // FileActions.register('application/ogg','Add to playlist','',addAudio); if(typeof FileActions!=='undefined'){ - FileActions.register('audio','Play','',playAudio); - FileActions.register('application/ogg','','Play',playAudio); + FileActions.register('audio','Play', FileActions.PERMISSION_READ, '',playAudio); + FileActions.register('application/ogg', FileActions.PERMISSION_READ, '','Play',playAudio); FileActions.setDefault('audio','Play'); FileActions.setDefault('application/ogg','Play'); } diff --git a/apps/media/lib/share/album.php b/apps/media/lib/share/album.php new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/apps/media/lib/share/album.php diff --git a/apps/media/lib/share/artist.php b/apps/media/lib/share/artist.php new file mode 100644 index 00000000000..7218fa1a279 --- /dev/null +++ b/apps/media/lib/share/artist.php @@ -0,0 +1,65 @@ +<?php +/** +* ownCloud +* +* @author Michael Gapczynski +* @copyright 2012 Michael Gapczynski mtgap@owncloud.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + +class OC_Share_Backend_Artist extends OCP\Share_Backend { + + public function getSource($item, $uid) { + $query = OCP\DB::prepare('SELECT artist_id FROM *PREFIX*media_artists WHERE artist_id = ? AND song_user = ?'); + $result = $query->execute(array($item, $uid))->fetchRow(); + if (is_array($result)) { + return array('item' => $item, 'file' => $result['song_path']); + } + return false; + } + + public function generateTarget($item, $uid, $exclude = null) { + // TODO Make sure target path doesn't exist already + return '/Shared'.$item; + } + + public function formatItems($items, $format) { + $ids = array(); + foreach ($items as $id => $info) { + $ids[] = $id; + } + $ids = "'".implode("','", $ids)."'"; + switch ($format) { + case self::FORMAT_SOURCE_PATH: + $query = OCP\DB::prepare('SELECT path FROM *PREFIX*fscache WHERE id IN ('.$ids.')'); + return $query->execute()->fetchAll(); + case self::FORMAT_FILE_APP: + $query = OCP\DB::prepare('SELECT id, path, name, ctime, mtime, mimetype, size, encrypted, versioned, writable FROM *PREFIX*fscache WHERE id IN ('.$ids.')'); + $result = $query->execute(); + $files = array(); + while ($file = $result->fetchRow()) { + // Set target path + $file['path'] = $items[$file['id']]['item_target']; + $file['name'] = basename($file['path']); + // TODO Set permissions: $file['writable'] + $files[] = $file; + } + return $files; + } + } + +} + +?>
\ No newline at end of file diff --git a/apps/media/lib/share/song.php b/apps/media/lib/share/song.php new file mode 100644 index 00000000000..fc69975f353 --- /dev/null +++ b/apps/media/lib/share/song.php @@ -0,0 +1,65 @@ +<?php +/** +* ownCloud +* +* @author Michael Gapczynski +* @copyright 2012 Michael Gapczynski mtgap@owncloud.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + +class OC_Share_Backend_Song extends OCP\Share_Backend { + + public function getSource($item, $uid) { + $query = OCP\DB::prepare('SELECT song_path FROM *PREFIX*media_songs WHERE song_id = ? AND song_user = ?'); + $result = $query->execute(array($item, $uid))->fetchRow(); + if (is_array($result)) { + return array('item' => $item, 'file' => $result['song_path']); + } + return false; + } + + public function generateTarget($item, $uid, $exclude = null) { + // TODO Make sure target path doesn't exist already + return '/Shared'.$item; + } + + public function formatItems($items, $format) { + $ids = array(); + foreach ($items as $id => $info) { + $ids[] = $id; + } + $ids = "'".implode("','", $ids)."'"; + switch ($format) { + case self::FORMAT_SOURCE_PATH: + $query = OCP\DB::prepare('SELECT path FROM *PREFIX*fscache WHERE id IN ('.$ids.')'); + return $query->execute()->fetchAll(); + case self::FORMAT_FILE_APP: + $query = OCP\DB::prepare('SELECT id, path, name, ctime, mtime, mimetype, size, encrypted, versioned, writable FROM *PREFIX*fscache WHERE id IN ('.$ids.')'); + $result = $query->execute(); + $files = array(); + while ($file = $result->fetchRow()) { + // Set target path + $file['path'] = $items[$file['id']]['item_target']; + $file['name'] = basename($file['path']); + // TODO Set permissions: $file['writable'] + $files[] = $file; + } + return $files; + } + } + +} + +?>
\ No newline at end of file |