playlist unique au compte connecté
This commit is contained in:
parent
43921099be
commit
4638bc989c
@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
| a PHP script and you can easily do that on your own.
|
| a PHP script and you can easily do that on your own.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
$config['base_url'] = '/~boutaric/SAEWEB2.2/ci/';
|
$config['base_url'] = '/~brigitte/SAEWEB2.2/ci/';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -6,6 +6,7 @@ class Albums extends CI_Controller {
|
|||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->model('model_music');
|
$this->load->model('model_music');
|
||||||
|
$this->load->library('session');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(){
|
public function index(){
|
||||||
@ -24,7 +25,8 @@ class Albums extends CI_Controller {
|
|||||||
$search = $_POST['recherche'];
|
$search = $_POST['recherche'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$playlists = $this->model_music->getPlaylist();
|
$mail = $this->session->userdata('mail');
|
||||||
|
$playlists = $this->model_music->getPlaylist($mail);
|
||||||
$albums = $this->model_music->searchAlbums($search, $selectedGenre);
|
$albums = $this->model_music->searchAlbums($search, $selectedGenre);
|
||||||
$this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]);
|
$this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]);
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
@ -38,7 +40,8 @@ class Albums extends CI_Controller {
|
|||||||
if (empty($songs)) {
|
if (empty($songs)) {
|
||||||
$songs = [];
|
$songs = [];
|
||||||
}
|
}
|
||||||
$playlists = $this->model_music->getPlaylist();
|
$mail = $this->session->userdata('mail');
|
||||||
|
$playlists = $this->model_music->getPlaylist($mail);
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
$this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]);
|
$this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]);
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
|
@ -3,22 +3,25 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
|
|
||||||
class artistes extends CI_Controller {
|
class artistes extends CI_Controller {
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->model('model_music');
|
$this->load->model('model_music');
|
||||||
}
|
$this->load->library('session');
|
||||||
public function index(){
|
}
|
||||||
$artistes = $this->model_music->getArtists();
|
public function index(){
|
||||||
$playlists = $this->model_music->getPlaylist();
|
$artistes = $this->model_music->getArtists();
|
||||||
$this->load->view('layout/header');
|
$mail = $this->session->userdata('mail');
|
||||||
$this->load->view('artistes_list',['artistes'=>$artistes, 'playlists' => $playlists]);
|
$playlists = $this->model_music->getPlaylist($mail);
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/header');
|
||||||
}
|
$this->load->view('artistes_list',['artistes'=>$artistes, 'playlists' => $playlists]);
|
||||||
|
$this->load->view('layout/footer');
|
||||||
|
}
|
||||||
|
|
||||||
public function view($AlbumsOfArtistId){
|
public function view($AlbumsOfArtistId){
|
||||||
$artistes = $this->model_music->getArtists();
|
$artistes = $this->model_music->getArtists();
|
||||||
$AlbumsOfArtists = $this->model_music->getAlbumsOfArtist($AlbumsOfArtistId);
|
$AlbumsOfArtists = $this->model_music->getAlbumsOfArtist($AlbumsOfArtistId);
|
||||||
$playlists = $this->model_music->getPlaylist();
|
$mail = $this->session->userdata('mail');
|
||||||
|
$playlists = $this->model_music->getPlaylist($mail);
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
$this->load->view('albums_artist_list', ['AlbumsOfArtists' => $AlbumsOfArtists, 'playlists' => $playlists, 'artist_id' => $AlbumsOfArtistId, 'artistes' => $artistes]);
|
$this->load->view('albums_artist_list', ['AlbumsOfArtists' => $AlbumsOfArtists, 'playlists' => $playlists, 'artist_id' => $AlbumsOfArtistId, 'artistes' => $artistes]);
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
|
@ -9,9 +9,9 @@ class Connexion extends CI_Controller{
|
|||||||
$this->load->model('model_music');
|
$this->load->model('model_music');
|
||||||
}
|
}
|
||||||
public function index(){
|
public function index(){
|
||||||
$this->load->view('layout/header');
|
//$this->load->view('layout/header');
|
||||||
$this->load->view('login');
|
$this->load->view('login');
|
||||||
$this->load->view('layout/footer');
|
//$this->load->view('layout/footer');
|
||||||
}
|
}
|
||||||
public function login() {
|
public function login() {
|
||||||
|
|
||||||
@ -26,10 +26,11 @@ class Connexion extends CI_Controller{
|
|||||||
$result = $this->model_music->getLogin($login,$password);
|
$result = $this->model_music->getLogin($login,$password);
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
$this->session->set_userdata('logged', true);
|
$this->session->set_userdata('logged', true);
|
||||||
|
$this->session->set_userdata('mail', $login);
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
redirect('albums');
|
redirect('albums');
|
||||||
} else {
|
} else {
|
||||||
$this->load->view('layout/header');
|
//$this->load->view('layout/header');
|
||||||
$this->load->view('login');
|
$this->load->view('login');
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
echo "Invalid login or password";
|
echo "Invalid login or password";
|
||||||
|
@ -6,10 +6,12 @@ class Playlist extends CI_Controller {
|
|||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->model('model_music');
|
$this->load->model('model_music');
|
||||||
|
$this->load->library('session');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(){
|
public function index(){
|
||||||
$playlists = $this->model_music->getPlaylist();
|
$mail = $this->session->userdata('mail');
|
||||||
|
$playlists = $this->model_music->getPlaylist($mail);
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
$this->load->view('playlist_list', ['playlists' => $playlists]);
|
$this->load->view('playlist_list', ['playlists' => $playlists]);
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
@ -25,7 +27,8 @@ class Playlist extends CI_Controller {
|
|||||||
public function SongPlaylist($playlist_id){
|
public function SongPlaylist($playlist_id){
|
||||||
$songPlaylists = $this->model_music->getSongOfPlaylist($playlist_id);
|
$songPlaylists = $this->model_music->getSongOfPlaylist($playlist_id);
|
||||||
$songs = $this->model_music->getSongOfAlbum($playlist_id);
|
$songs = $this->model_music->getSongOfAlbum($playlist_id);
|
||||||
$playlists = $this->model_music->getPlaylist(); // Récupère toutes les playlists
|
$mail = $this->session->userdata('mail');
|
||||||
|
$playlists = $this->model_music->getPlaylist($mail); // Récupère toutes les playlists
|
||||||
$id_playlist = null; // Initialise $id_playlist à null
|
$id_playlist = null; // Initialise $id_playlist à null
|
||||||
foreach ($playlists as $playlist_item) {
|
foreach ($playlists as $playlist_item) {
|
||||||
if ($playlist_item->id == $playlist_id) {
|
if ($playlist_item->id == $playlist_id) {
|
||||||
@ -37,7 +40,8 @@ class Playlist extends CI_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function delete($playlist_id) {
|
public function delete($playlist_id) {
|
||||||
$delete = $this->model_music->deletePlaylist($playlist_id);
|
$mail = $this->session->userdata('mail');
|
||||||
|
$delete = $this->model_music->deletePlaylist($playlist_id, $mail);
|
||||||
redirect('playlist');
|
redirect('playlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +58,9 @@ class Playlist extends CI_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function createPlaylistController() {
|
public function createPlaylistController() {
|
||||||
|
$mail = $this->session->userdata('mail');
|
||||||
$name_playlist = $this->input->post('name_playlist');
|
$name_playlist = $this->input->post('name_playlist');
|
||||||
$create = $this->model_music->createPlaylist($name_playlist);
|
$create = $this->model_music->createPlaylist($name_playlist, $mail);
|
||||||
redirect('playlist');
|
redirect('playlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +72,12 @@ class Playlist extends CI_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function duplicate($playlist_id){
|
public function duplicate($playlist_id){
|
||||||
|
$mail = $this->session->userdata('mail');
|
||||||
// Charger le modèle si ce n'est pas déjà fait
|
// Charger le modèle si ce n'est pas déjà fait
|
||||||
$this->load->model('model_music');
|
$this->load->model('model_music');
|
||||||
|
|
||||||
// Dupliquer la playlist avec l'ID spécifié
|
// Dupliquer la playlist avec l'ID spécifié
|
||||||
$this->model_music->duplicatePlaylist($playlist_id);
|
$this->model_music->duplicatePlaylist($playlist_id, $mail);
|
||||||
|
|
||||||
// Rediriger l'utilisateur vers la page des playlists
|
// Rediriger l'utilisateur vers la page des playlists
|
||||||
redirect('playlist');
|
redirect('playlist');
|
||||||
|
@ -42,24 +42,26 @@ class Model_music extends CI_Model {
|
|||||||
return $query->result();
|
return $query->result();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPlaylist(){
|
public function getPlaylist($mail){
|
||||||
$query = $this->db->query(
|
$query = $this->db->query(
|
||||||
"SELECT playlist.id, playlist.name
|
"SELECT playlist.id, playlist.name
|
||||||
FROM playlist
|
FROM playlist NATURAL JOIN Login
|
||||||
|
where playlist.mail = ?
|
||||||
Group by playlist.id
|
Group by playlist.id
|
||||||
"
|
",
|
||||||
|
array($mail)
|
||||||
);
|
);
|
||||||
return $query->result();
|
return $query->result();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deletePlaylist($playlist_id){
|
public function deletePlaylist($playlist_id, $mail){
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
"DELETE FROM SongPlaylist WHERE id = ?", array($playlist_id)
|
"DELETE FROM SongPlaylist WHERE id = ?" , array($playlist_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Ensuite, supprimer l'enregistrement dans playlist
|
// Ensuite, supprimer l'enregistrement dans playlist
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
"DELETE FROM playlist WHERE id = ?", array($playlist_id)
|
"DELETE FROM playlist WHERE id = ? AND playlist.mail = ?", array($playlist_id, $mail)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +73,12 @@ class Model_music extends CI_Model {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPlaylist($name_playlist){
|
public function createPlaylist($name_playlist, $mail){
|
||||||
$name_playlist_escaped = $this->db->escape($name_playlist);
|
$name_playlist_escaped = $this->db->escape($name_playlist);
|
||||||
$query = $this->db->query(
|
$query = $this->db->query(
|
||||||
"INSERT INTO playlist (name) VALUES ($name_playlist_escaped);
|
"INSERT INTO playlist (name, mail) VALUES (?, ?);
|
||||||
"
|
",
|
||||||
|
array($name_playlist_escaped, $mail)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,27 +220,28 @@ class Model_music extends CI_Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function duplicatePlaylist($playlist_id){
|
public function duplicatePlaylist($playlist_id, $mail){
|
||||||
// Récupérer les informations de la playlist à dupliquer
|
// Récupérer les informations de la playlist à dupliquer
|
||||||
$playlist = $this->db->get_where('playlist', array('id' => $playlist_id))->row();
|
$playlist = $this->db->get_where('playlist', array('id' => $playlist_id))->row();
|
||||||
|
|
||||||
// Créer une nouvelle entrée pour la playlist avec les mêmes informations
|
// Créer une nouvelle entrée pour la playlist avec les mêmes informations
|
||||||
$data = array(
|
$data = array(
|
||||||
'name' => $playlist->name . ' (Copy)',
|
'name' => $playlist->name . ' (Copy)',
|
||||||
);
|
'mail' => $mail
|
||||||
|
);
|
||||||
$this->db->insert('playlist', $data);
|
|
||||||
|
$this->db->insert('playlist', $data);
|
||||||
// Récupérer l'ID de la nouvelle playlist
|
|
||||||
$new_playlist_id = $this->db->insert_id();
|
// Récupérer l'ID de la nouvelle playlist
|
||||||
|
$new_playlist_id = $this->db->insert_id();
|
||||||
// Dupliquer les chansons de la playlist originale dans la nouvelle playlist
|
|
||||||
$this->db->query(
|
// Dupliquer les chansons de la playlist originale dans la nouvelle playlist
|
||||||
"INSERT INTO SongPlaylist (id, name)
|
$this->db->query(
|
||||||
SELECT ?, name
|
"INSERT INTO SongPlaylist (id, name)
|
||||||
FROM SongPlaylist
|
SELECT ?, name
|
||||||
WHERE id = ?",
|
FROM SongPlaylist
|
||||||
array($new_playlist_id, $playlist_id));
|
WHERE id = ?",
|
||||||
|
array($new_playlist_id, $playlist_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<nav class="menu">
|
<nav class="menu">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?= anchor('https://dwarves.iut-fbleau.fr/~boutaric/SAEWEB2.2/ci/','Home'); ?></li>
|
<li><?= anchor('https://dwarves.iut-fbleau.fr/~brigitte/SAEWEB2.2/ci/','Home'); ?></li>
|
||||||
<li><?= anchor('albums','Albums'); ?></li>
|
<li><?= anchor('albums','Albums'); ?></li>
|
||||||
<li><?= anchor('artistes','Artistes'); ?> </li>
|
<li><?= anchor('artistes','Artistes'); ?> </li>
|
||||||
<?php if ($this->session->userdata('logged')): ?>
|
<?php if ($this->session->userdata('logged')): ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user