diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-19 22:29:01 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-19 22:29:01 -0400 |
commit | 82d81e8d39ce69211ec6b29fe3f803c57714b8dd (patch) | |
tree | 09dbd675480a02fd626f6634e083f3d6a01b4404 /apps/media | |
parent | f893d21660695d1d1cd594c102e2bcba6919dee3 (diff) | |
parent | 5eca531f99f9615d1a09bbb0b03dda2063901aa7 (diff) | |
download | nextcloud-server-82d81e8d39ce69211ec6b29fe3f803c57714b8dd.tar.gz nextcloud-server-82d81e8d39ce69211ec6b29fe3f803c57714b8dd.zip |
Merge branch 'share_api'
Conflicts:
apps/contacts/lib/vcard.php
apps/files/index.php
lib/files.php
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 |