Merge branch 'master' of git://anongit.kde.org/owncloud

This commit is contained in:
Michael Gapczynski 2011-08-25 17:22:25 -04:00
commit fbf9d62742
6 changed files with 81 additions and 53 deletions

View File

@ -27,5 +27,14 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#collection li { padding-right:10px; }
#searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; }
#collection tr.collapsed td.album, #collection tr.collapsed td.title { color:#ddd; }
a.expander { float:right; display:block; }
a.expander { }
tr.active { background-color:#eee; }
tr.artist, tr.artist td {
border-top: 1px solid lightgrey;
}
tr.album td.artist {
padding-left: 20px;
}
tr.song td.artist {
padding-left: 40px;
}

View File

@ -85,7 +85,7 @@ Collection={
tr.data('artistData',artist);
tr.find('td.artist a').click(function(event){
event.preventDefault();
PlayList.add(artist,true);
PlayList.add(artist);
PlayList.play(0);
Collection.parent.find('tr').removeClass('active');
$('tr[data-artist="'+artist.name+'"]').addClass('active');
@ -100,6 +100,8 @@ Collection={
Collection.showArtist(tr.data('artist'));
}
});
tr.find('td.artist').addClass('buttons');
Collection.addButtons(tr,artist);
tr.children('td.artist').append(expander);
tr.attr('data-artist',artist.name);
Collection.parent.find('tbody').append(tr);
@ -124,7 +126,7 @@ Collection={
newRow.find('td.album a').text(album.name);
newRow.find('td.album a').click(function(event){
event.preventDefault();
PlayList.add(album,true);
PlayList.add(album);
PlayList.play(0);
Collection.parent.find('tr').removeClass('active');
$('tr[data-album="'+album.name+'"]').addClass('active');
@ -134,9 +136,10 @@ Collection={
newRow.find('td.album a').text('');
}
newRow.find('td.title a').text(song.name);
Collection.addButtons(newRow,song);
newRow.find('td.title a').click(function(event){
event.preventDefault();
PlayList.add(song,true);
PlayList.add(song);
PlayList.play(0);
Collection.parent.find('tr').removeClass('active');
$('tr[data-title="'+song.name+'"]').addClass('active');
@ -192,16 +195,26 @@ Collection={
song.song_playcount++;
}
},
addButtons:function(parent){
parent.children('button.add').click(function(){
var type=$(this).parent().data('type');
PlayList.add($(this).parent().data(type));
addButtons:function(parent,data){
buttons = parent.find('.buttons');
if(buttons.find('.add').length<=0) {
buttons.append('<img class="add" src="'+OC.imagePath('core','actions/play-add')+'"/>');
}
if(buttons.find('.play').length<=0) {
buttons.append('<img class="play" src="'+OC.imagePath('core','actions/play')+'"/>');
}
buttons.find('.add').unbind('click');
buttons.find('.add').click(function(event){
event.preventDefault();
PlayList.add(data,true);
PlayList.render();
});
parent.children('button.play').click(function(){
var type=$(this).parent().data('type');
var oldSize=PlayList.items.length;
PlayList.add($(this).parent().data(type));
PlayList.play(oldSize);
buttons.find('.play').unbind('click');
buttons.find('.play').click(function(event){
event.preventDefault();
PlayList.add(data);
PlayList.play(0,0);
PlayList.render();
});
},
find:function(artistName,albumName,songName){

View File

@ -5,10 +5,8 @@ var PlayList={
player:null,
volume:0.8,
active:false,
tempPlaylist:[],
isTemp:true,
next:function(){
var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
var items=PlayList.items;
var next=PlayList.current+1;
if(next>=items.length){
next=0;
@ -17,7 +15,7 @@ var PlayList={
PlayList.render();
},
previous:function(){
var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
var items=PlayList.items;
var next=PlayList.current-1;
if(next<0){
next=items.length-1;
@ -26,7 +24,7 @@ var PlayList={
PlayList.render();
},
play:function(index,time,ready){
var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
var items=PlayList.items;
if(index==null){
index=PlayList.current;
}
@ -34,8 +32,11 @@ var PlayList={
PlayList.current=index;
if(PlayList.player){
if(PlayList.player.data('jPlayer').options.supplied!=items[index].type){//the the audio type changes we need to reinitialize jplayer
PlayList.player.jPlayer("play",time);
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
PlayList.player.jPlayer("destroy");
PlayList.init(items[index].type,function(){PlayList.play(null,time,ready)});
PlayList.save(); // so that the init don't lose the playlist
PlayList.init(items[index].type,null); // init calls load that calls play
}else{
PlayList.player.jPlayer("setMedia", items[PlayList.current]);
items[index].playcount++;
@ -60,7 +61,10 @@ var PlayList={
}
}
}else{
PlayList.init(items[index].type,PlayList.play);
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
PlayList.save(); // so that the init don't lose the playlist
PlayList.init(items[index].type,null); // init calls load that calls play
}
}
},
@ -100,37 +104,30 @@ var PlayList={
swfPath:OC.linkTo('media','js'),
});
},
add:function(song,temp,dontReset){
add:function(song,dontReset){
if(!dontReset){
PlayList.tempPlaylist=[];//clear the temp playlist
PlayList.items=[];//clear the playlist
}
PlayList.isTemp=temp;
PlayList.isTemp=true;
if(!song){
return;
}
if(song.substr){//we are passed a string, asume it's a url to a song
PlayList.addFile(song,temp,true);
PlayList.addFile(song,true);
}
if(song.albums){//a artist object was passed, add all albums inside it
$.each(song.albums,function(index,album){
PlayList.add(album,temp,true);
PlayList.add(album,true);
});
}
if(song.songs){//a album object was passed, add all songs inside it
} else if(song.songs){//a album object was passed, add all songs inside it
$.each(song.songs,function(index,song){
PlayList.add(song,temp,true);
PlayList.add(song,true);
});
}
if(song.path){
var type=musicTypeFromFile(song.path);
var item={name:song.name,type:type,artist:song.artist,album:song.album,length:song.length,playcount:song.playCount};
item[type]=PlayList.urlBase+encodeURIComponent(song.path);
if(PlayList.isTemp){
PlayList.tempPlaylist.push(item);
}else{
PlayList.items.push(item);
}
PlayList.items.push(item);
}
},
addFile:function(path){
@ -145,6 +142,7 @@ var PlayList={
PlayList.items.push(item);
},
remove:function(index){
alert('remove');
PlayList.items.splice(index,1);
PlayList.render();
},
@ -160,10 +158,14 @@ var PlayList={
if(typeof localStorage !== 'undefined' && localStorage){
localStorage.setItem(oc_current_user+'oc_playlist_items',JSON.stringify(PlayList.items));
localStorage.setItem(oc_current_user+'oc_playlist_current',PlayList.current);
var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
var volume=PlayList.player.data('jPlayer').options.volume*100;
localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
if(PlayList.player) {
if(PlayList.player.data('jPlayer')) {
var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
var volume=PlayList.player.data('jPlayer').options.volume*100;
localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
}
}
if(PlayList.active){
localStorage.setItem(oc_current_user+'oc_playlist_active','false');
}

View File

@ -25,9 +25,9 @@
<div id="rightcontent">
<div id="scan">
<p id="scancount" style="display:none"><span class="songCount">0</span> <?php echo $l->t('Songs scanned')?>
<p id="scancount" style="display:none"><span class="songCount">0</span> <?php echo $l->t('Songs scanned')?></p>
<input type="button" class="start" value="<?php echo $l->t('Rescan Collection')?>" />
<input type="button" class="stop" style="display:none" value="<?php echo $l->t('Pause')?>" /></p>
<input type="button" class="stop" style="display:none" value="<?php echo $l->t('Pause')?>" />
<div id="scanprogressbar"></div>
</div>

View File

@ -191,13 +191,17 @@ class OC_User {
$run = true;
OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid ));
if( $run && self::checkPassword( $uid, $password )){
$_SESSION['user_id'] = $uid;
OC_Crypt::init($uid,$password);
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid ));
return true;
}
else{
if( $run ){
$uid=self::checkPassword( $uid, $password );
if($uid){
$_SESSION['user_id'] = $uid;
OC_Crypt::init($uid,$password);
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid ));
return true;
}else{
return false;
}
}else{
return false;
}
}
@ -292,8 +296,8 @@ class OC_User {
foreach(self::$_usedBackends as $backend){
if($backend->implementsActions(OC_USER_BACKEND_CHECK_PASSWORD)){
$result=$backend->checkPassword( $uid, $password );
if($result===true){
return true;
if($result){
return $result;
}
}
}

View File

@ -103,13 +103,13 @@ class OC_User_Database extends OC_User_Backend {
* Check if the password is correct without logging in the user
*/
public function checkPassword( $uid, $password ){
$query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users WHERE uid = ? AND password = ?" );
$query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users WHERE uid LIKE ? AND password = ?" );
$result = $query->execute( array( $uid, sha1( $password )));
if( $result->numRows() > 0 ){
return true;
}
else{
$row=$result->fetchRow();
return $row['uid'];
}else{
return false;
}
}