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; } #collection li { padding-right:10px; }
#searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; } #searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; }
#collection tr.collapsed td.album, #collection tr.collapsed td.title { color:#ddd; } #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.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.data('artistData',artist);
tr.find('td.artist a').click(function(event){ tr.find('td.artist a').click(function(event){
event.preventDefault(); event.preventDefault();
PlayList.add(artist,true); PlayList.add(artist);
PlayList.play(0); PlayList.play(0);
Collection.parent.find('tr').removeClass('active'); Collection.parent.find('tr').removeClass('active');
$('tr[data-artist="'+artist.name+'"]').addClass('active'); $('tr[data-artist="'+artist.name+'"]').addClass('active');
@ -100,6 +100,8 @@ Collection={
Collection.showArtist(tr.data('artist')); Collection.showArtist(tr.data('artist'));
} }
}); });
tr.find('td.artist').addClass('buttons');
Collection.addButtons(tr,artist);
tr.children('td.artist').append(expander); tr.children('td.artist').append(expander);
tr.attr('data-artist',artist.name); tr.attr('data-artist',artist.name);
Collection.parent.find('tbody').append(tr); Collection.parent.find('tbody').append(tr);
@ -124,7 +126,7 @@ Collection={
newRow.find('td.album a').text(album.name); newRow.find('td.album a').text(album.name);
newRow.find('td.album a').click(function(event){ newRow.find('td.album a').click(function(event){
event.preventDefault(); event.preventDefault();
PlayList.add(album,true); PlayList.add(album);
PlayList.play(0); PlayList.play(0);
Collection.parent.find('tr').removeClass('active'); Collection.parent.find('tr').removeClass('active');
$('tr[data-album="'+album.name+'"]').addClass('active'); $('tr[data-album="'+album.name+'"]').addClass('active');
@ -134,9 +136,10 @@ Collection={
newRow.find('td.album a').text(''); newRow.find('td.album a').text('');
} }
newRow.find('td.title a').text(song.name); newRow.find('td.title a').text(song.name);
Collection.addButtons(newRow,song);
newRow.find('td.title a').click(function(event){ newRow.find('td.title a').click(function(event){
event.preventDefault(); event.preventDefault();
PlayList.add(song,true); PlayList.add(song);
PlayList.play(0); PlayList.play(0);
Collection.parent.find('tr').removeClass('active'); Collection.parent.find('tr').removeClass('active');
$('tr[data-title="'+song.name+'"]').addClass('active'); $('tr[data-title="'+song.name+'"]').addClass('active');
@ -192,16 +195,26 @@ Collection={
song.song_playcount++; song.song_playcount++;
} }
}, },
addButtons:function(parent){ addButtons:function(parent,data){
parent.children('button.add').click(function(){ buttons = parent.find('.buttons');
var type=$(this).parent().data('type'); if(buttons.find('.add').length<=0) {
PlayList.add($(this).parent().data(type)); 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(){ buttons.find('.play').unbind('click');
var type=$(this).parent().data('type'); buttons.find('.play').click(function(event){
var oldSize=PlayList.items.length; event.preventDefault();
PlayList.add($(this).parent().data(type)); PlayList.add(data);
PlayList.play(oldSize); PlayList.play(0,0);
PlayList.render();
}); });
}, },
find:function(artistName,albumName,songName){ find:function(artistName,albumName,songName){

View File

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

View File

@ -25,9 +25,9 @@
<div id="rightcontent"> <div id="rightcontent">
<div id="scan"> <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="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 id="scanprogressbar"></div>
</div> </div>

View File

@ -191,13 +191,17 @@ class OC_User {
$run = true; $run = true;
OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid )); OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid ));
if( $run && self::checkPassword( $uid, $password )){ if( $run ){
$_SESSION['user_id'] = $uid; $uid=self::checkPassword( $uid, $password );
OC_Crypt::init($uid,$password); if($uid){
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid )); $_SESSION['user_id'] = $uid;
return true; OC_Crypt::init($uid,$password);
} OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid ));
else{ return true;
}else{
return false;
}
}else{
return false; return false;
} }
} }
@ -292,8 +296,8 @@ class OC_User {
foreach(self::$_usedBackends as $backend){ foreach(self::$_usedBackends as $backend){
if($backend->implementsActions(OC_USER_BACKEND_CHECK_PASSWORD)){ if($backend->implementsActions(OC_USER_BACKEND_CHECK_PASSWORD)){
$result=$backend->checkPassword( $uid, $password ); $result=$backend->checkPassword( $uid, $password );
if($result===true){ if($result){
return true; 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 * Check if the password is correct without logging in the user
*/ */
public function checkPassword( $uid, $password ){ 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 ))); $result = $query->execute( array( $uid, sha1( $password )));
if( $result->numRows() > 0 ){ if( $result->numRows() > 0 ){
return true; $row=$result->fetchRow();
} return $row['uid'];
else{ }else{
return false; return false;
} }
} }