diff --git a/ci/application/controllers/Deconnexion.php b/ci/application/controllers/Deconnexion.php index 6b03e4e..c4226cf 100644 --- a/ci/application/controllers/Deconnexion.php +++ b/ci/application/controllers/Deconnexion.php @@ -9,6 +9,7 @@ class Deconnexion extends CI_Controller { public function index() { $this->session->unset_userdata('logged'); + $this->session->unset_userdata('mail'); $this->session->sess_destroy(); redirect('welcome'); } diff --git a/ci/application/controllers/Enregistrer.php b/ci/application/controllers/Enregistrer.php index 4f1edea..90f56f0 100644 --- a/ci/application/controllers/Enregistrer.php +++ b/ci/application/controllers/Enregistrer.php @@ -25,6 +25,7 @@ class Enregistrer extends CI_Controller{ } $this->model_music->SignUp($pseudo,$login,$password); $this->session->set_userdata('logged', true); + $this->session->set_userdata('mail', $login); $this->load->view('layout/header'); redirect('albums'); } diff --git a/ci/application/controllers/Playlist.php b/ci/application/controllers/Playlist.php index 978afb9..33e601b 100644 --- a/ci/application/controllers/Playlist.php +++ b/ci/application/controllers/Playlist.php @@ -50,12 +50,6 @@ class Playlist extends CI_Controller { redirect("playlist/SongPlaylist/$id_playlist"); } - public function MenuCreate() { - $this->load->view('layout/header'); - $this->load->view('create_playlist'); - $this->load->view('layout/footer'); - - } public function createPlaylistController() { $mail = $this->session->userdata('mail'); @@ -64,6 +58,17 @@ class Playlist extends CI_Controller { redirect('playlist'); } + public function createRandomPlaylist() { + $mail = $this->session->userdata('mail'); + $name_playlist = $this->input->post('name_playlist_random'); + $num_songs = (int) $this->input->post('num_songs'); + if ($num_songs < 1 || $num_songs > 2000) { + return; + } + $this->model_music->createPlaylistRandom($name_playlist, $num_songs, $mail); + redirect('playlist'); + } + public function addSongToPlaylist(){ $songName = $this->input->post('song'); $playlistId = $this->input->post('playlist'); diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index e1bc847..6b76f14 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -244,4 +244,20 @@ class Model_music extends CI_Model { array($new_playlist_id, $playlist_id)); } + public function createPlaylistRandom($name_playlist, $num_songs, $mail) { + $data = array( + 'name' => $name_playlist, + 'mail' => $mail + ); + $this->db->insert('playlist', $data); + $new_playlist_id = $this->db->insert_id(); + + // Sélectionner le nombre de chansons aléatoires spécifié + $query = $this->db->query("SELECT id, name FROM song ORDER BY RAND() LIMIT ?", array($num_songs)); + $songs = $query->result(); + + foreach ($songs as $song) { + $this->db->query("INSERT INTO SongPlaylist (id, name) VALUES (?, ?)", array($new_playlist_id, $song->name)); + } + } } diff --git a/ci/application/views/errors/cli/error_404.php b/ci/application/views/errors/cli/error_404.php new file mode 100644 index 0000000..6984b61 --- /dev/null +++ b/ci/application/views/errors/cli/error_404.php @@ -0,0 +1,8 @@ + + +An uncaught Exception was encountered + +Type: +Message: +Filename: getFile(), "\n"; ?> +Line Number: getLine(); ?> + + + +Backtrace: +getTrace() as $error): ?> + + File: + Line: + Function: + + + + diff --git a/ci/application/views/errors/cli/error_general.php b/ci/application/views/errors/cli/error_general.php new file mode 100644 index 0000000..6984b61 --- /dev/null +++ b/ci/application/views/errors/cli/error_general.php @@ -0,0 +1,8 @@ + + +A PHP Error was encountered + +Severity: +Message: +Filename: +Line Number: + + + +Backtrace: + + + File: + Line: + Function: + + + + diff --git a/ci/application/views/errors/html/error_404.php b/ci/application/views/errors/html/error_404.php new file mode 100644 index 0000000..756ea9d --- /dev/null +++ b/ci/application/views/errors/html/error_404.php @@ -0,0 +1,64 @@ + + + + +404 Page Not Found + + + +
+

+ +
+ + \ No newline at end of file diff --git a/ci/application/views/errors/html/error_db.php b/ci/application/views/errors/html/error_db.php new file mode 100644 index 0000000..f5a43f6 --- /dev/null +++ b/ci/application/views/errors/html/error_db.php @@ -0,0 +1,64 @@ + + + + +Database Error + + + +
+

+ +
+ + \ No newline at end of file diff --git a/ci/application/views/errors/html/error_exception.php b/ci/application/views/errors/html/error_exception.php new file mode 100644 index 0000000..8784886 --- /dev/null +++ b/ci/application/views/errors/html/error_exception.php @@ -0,0 +1,32 @@ + + +
+ +

An uncaught Exception was encountered

+ +

Type:

+

Message:

+

Filename: getFile(); ?>

+

Line Number: getLine(); ?>

+ + + +

Backtrace:

+ getTrace() as $error): ?> + + + +

+ File:
+ Line:
+ Function: +

+ + + + + + +
\ No newline at end of file diff --git a/ci/application/views/errors/html/error_general.php b/ci/application/views/errors/html/error_general.php new file mode 100644 index 0000000..fc3b2eb --- /dev/null +++ b/ci/application/views/errors/html/error_general.php @@ -0,0 +1,64 @@ + + + + +Error + + + +
+

+ +
+ + \ No newline at end of file diff --git a/ci/application/views/errors/html/error_php.php b/ci/application/views/errors/html/error_php.php new file mode 100644 index 0000000..b146f9c --- /dev/null +++ b/ci/application/views/errors/html/error_php.php @@ -0,0 +1,33 @@ + + +
+ +

A PHP Error was encountered

+ +

Severity:

+

Message:

+

Filename:

+

Line Number:

+ + + +

Backtrace:

+ + + + +

+ File:
+ Line:
+ Function: +

+ + + + + + + +
\ No newline at end of file diff --git a/ci/application/views/playlist_list.php b/ci/application/views/playlist_list.php index 5e68110..f1f96a9 100644 --- a/ci/application/views/playlist_list.php +++ b/ci/application/views/playlist_list.php @@ -1,35 +1,37 @@
-
-
-
- alt="Description de l'image 2"> -
-

Créer une nouvelle Playlist

-
- - - -
-
-
-
-
- alt="Description de l'image 2"> -
-

Créer une playlist aléatoire

- - - - +
+
+
+ Description de l'image 2 +
+

Créer une nouvelle Playlist Vide

+ + + + + +
+
+
+
+
+ Description de l'image 2 +
+

Créer une Playlist Aléatoire

+
+ + + + + +
+
+
+
-
-
-
- - - + "; @@ -44,5 +46,4 @@ foreach($playlists as $playlist){ echo ""; echo ""; } -echo ""; -?> +?>