Skip to content

Commit

Permalink
Watch later and favorite will appear first
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Jun 17, 2024
1 parent 69edd8b commit 15cc5ea
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion objects/playlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ public static function getAllFromPlaylistsID($playlists_id)
return $videosP;
}

public static function getUserSpecialPlaylist($users_id, $type){

$sql = "SELECT pl.* FROM " . static::getTableName() . " pl WHERE users_id = ? ";
if($type=='favorite'){
$sql .= " AND status = 'favorite' ";
}else{
$sql .= " AND status = 'watch_later' ";
}


$res = sqlDAL::readSql($sql, 'i', [$users_id], true);
$row = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
return $row;

}

/**
*
* @global array $global
Expand Down Expand Up @@ -166,7 +183,14 @@ public static function getAllFromUser($userId, $publicOnly = true, $status = fal
}

$sql .= self::getSqlFromPost("pl.");
//var_dump($sql, $formats, $values);

$sql = preg_replace('/ORDER +BY +pl.`created` +DESC/i', 'ORDER BY CASE
WHEN pl.status = \'favorite\' THEN 1
WHEN pl.status = \'watch_later\' THEN 1
ELSE 2
END, pl.created DESC', $sql);

//var_dump($sql, $formats, $values, getCurrentPage());exit;
$TimeLog1 = "playList getAllFromUser 1($userId)";
TimeLogStart($TimeLog1);
$cacheName = md5($sql . json_encode($values));
Expand Down Expand Up @@ -901,6 +925,9 @@ public function save()
if (!User::isLogged()) {
return false;
}

_error_log('Playlist::save '.json_encode(debug_backtrace()));

$this->clearEmptyLists();
if (empty($this->getUsers_id()) || !PlayLists::canManageAllPlaylists()) {
$users_id = User::getId();
Expand Down

0 comments on commit 15cc5ea

Please sign in to comment.