diff --git a/CodeIgniter-3.1.13/application/controllers/Playlists.php b/CodeIgniter-3.1.13/application/controllers/Playlists.php index d41ec45..a6c0763 100644 --- a/CodeIgniter-3.1.13/application/controllers/Playlists.php +++ b/CodeIgniter-3.1.13/application/controllers/Playlists.php @@ -341,6 +341,24 @@ class Playlists extends CI_Controller { redirect('playlists/view/' . $playlist_id); } + + public function add_track_to_playlist($track_id, $playlist_id) { + // Vérifier si l'utilisateur est connecté + if (!$this->session->userdata('user_id')) { + redirect('utilisateur/connexion'); + } + + // Récupérer le song_id à partir du track_id + $song_id = $this->Model_playlist->get_song_id_by_track_id($track_id); + + $data = array( + 'playlist_id' => $playlist_id, + 'song_id' => $song_id + ); + $this->Model_playlist->add_song_to_playlist($data); + + redirect('playlists/view/' . $playlist_id); + } public function add_artist($playlist_id) { diff --git a/CodeIgniter-3.1.13/application/models/Model_playlist.php b/CodeIgniter-3.1.13/application/models/Model_playlist.php index 80a329d..34e884b 100644 --- a/CodeIgniter-3.1.13/application/models/Model_playlist.php +++ b/CodeIgniter-3.1.13/application/models/Model_playlist.php @@ -121,6 +121,15 @@ class Model_playlist extends CI_Model { return $this->db->get()->result(); } + public function get_song_id_by_track_id($track_id) { + $this->db->select('songId'); + $this->db->from('track'); + $this->db->where('id', $track_id); + $query = $this->db->get(); + $result = $query->row_array(); + return $result['songId']; + } + public function add_album_to_playlist($data) { return $this->db->insert('playlist_album', $data); } diff --git a/CodeIgniter-3.1.13/application/views/artiste_details.php b/CodeIgniter-3.1.13/application/views/artiste_details.php index 58c8b21..85e4b62 100644 --- a/CodeIgniter-3.1.13/application/views/artiste_details.php +++ b/CodeIgniter-3.1.13/application/views/artiste_details.php @@ -1,22 +1,21 @@ -
Genre le plus utilisé par l'artiste : genreName; ?>
-Genre le plus utilisé par l'artiste : genreName; ?>
+Année : year; ?>
+Genre : genreName; ?>
+ jpeg)): ?> + + + Aucune couverture disponible + -Année : year; ?>
-Genre : genreName; ?>
- jpeg)): ?> - - - Aucune couverture disponible - - - session->userdata('user_id')): ?> + session->userdata('user_id')): ?>Vous n'avez pas encore de playlist. Créez-en une pour ajouter cet album !
-