diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-25 17:08:18 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-25 17:08:18 -0400 |
commit | 30b58f56771aa54304069d40a62070c06f5308fc (patch) | |
tree | e0bb2bba21c561f96d27bb9cfc09d714aa21d332 /apps/media | |
parent | 4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78 (diff) | |
parent | f25ccaff59c135d7f1f22196bf266916ef131b35 (diff) | |
download | nextcloud-server-30b58f56771aa54304069d40a62070c06f5308fc.tar.gz nextcloud-server-30b58f56771aa54304069d40a62070c06f5308fc.zip |
Merge branch 'master' into share_api
Conflicts:
apps/calendar/js/loader.js
apps/contacts/index.php
apps/contacts/js/loader.js
apps/files/js/files.js
apps/files_sharing/sharedstorage.php
lib/filesystemview.php
Diffstat (limited to 'apps/media')
-rw-r--r-- | apps/media/appinfo/version | 2 | ||||
-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 | ||||
-rw-r--r-- | apps/media/lib_ampache.php | 1 | ||||
-rw-r--r-- | apps/media/lib_collection.php | 3 | ||||
-rw-r--r-- | apps/media/lib_media.php | 6 |
7 files changed, 135 insertions, 7 deletions
diff --git a/apps/media/appinfo/version b/apps/media/appinfo/version index e6adf3fc7bb..44bb5d1f743 100644 --- a/apps/media/appinfo/version +++ b/apps/media/appinfo/version @@ -1 +1 @@ -0.4
\ No newline at end of file +0.4.1
\ No newline at end of file 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 diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index d35cca150b2..d5a093338cc 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -271,7 +271,6 @@ class OC_MEDIA_AMPACHE{ </root>"); return; } - global $SITEROOT; $filter=$params['filter']; $albums=OC_MEDIA_COLLECTION::getAlbums($filter); $artist=OC_MEDIA_COLLECTION::getArtistName($filter); diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index e65930f551d..cacab8e959f 100644 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -27,7 +27,6 @@ class OC_MEDIA_COLLECTION{ public static $uid; private static $artistIdCache=array(); private static $albumIdCache=array(); - private static $songIdCache=array(); private static $queries=array(); /** @@ -152,7 +151,7 @@ class OC_MEDIA_COLLECTION{ return $artistId; }else{ $query=OCP\DB::prepare("INSERT INTO `*PREFIX*media_artists` (`artist_name`) VALUES (?)"); - $result=$query->execute(array($name)); + $query->execute(array($name)); return self::getArtistId($name);; } } diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 9e687a4af2c..54502f42575 100644 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -27,12 +27,12 @@ class OC_MEDIA{ * @param array $params, parameters passed from OC_Hook */ public static function loginListener($params){ - if(isset($_POST['user']) and $_POST['password']){ - $name=$_POST['user']; + if(isset($params['uid']) and $params['password']){ + $name=$params['uid']; $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?"); $uid=$query->execute(array($name))->fetchAll(); if(count($uid)==0){ - $password=hash('sha256',$_POST['password']); + $password=hash('sha256',$params['password']); $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_users (user_id, user_password_sha256) VALUES (?, ?);"); $query->execute(array($name,$password)); } |