Beispiel #1
0
 public function action_log()
 {
     $user = $this->is_logged();
     if ($user === false) {
         $try = new User_lif();
         $try->set_username_user_lif($_POST['user']);
         $try->set_password_user_lif($_POST['pw']);
         $this->_id = $try->attempt();
         if ($this->_id) {
             $user = new User_lif();
             $user->set_id_user_lif($this->_id);
             $user->load();
             Session::put('user', $user);
             return Redirect::to_action('home@index');
         }
         $this->_error_form = "Identifiant ou mot de passe éronné, veuillez réessayer svp.";
         return Redirect::to_action('login')->with('error_msg', $this->_error_form);
     }
 }
Beispiel #2
0
 public function action_index()
 {
     $user = $this->is_logged();
     if ($user === false) {
         return Redirect::to_action('login');
     } else {
         $song_count = Song::count();
         $album_count = Album::count();
         $band_count = band::count();
         $playlist_count = Playlist::count();
         $user_count = User_lif::count();
         $best_year_song = DB::query('SELECT date_song, count(*) as count FROM song GROUP BY date_song HAVING count ORDER BY count DESC LIMIT 1');
         $max_in_playlist = DB::query('SELECT count(s.id_song) as count, b.name_band,  s.`title_song` FROM song s JOIN songplaylist so ON s.id_song = so.id_song JOIN songalbum son ON s.id_song = son.id_song JOIN album a ON son.id_album = a.id_album JOIN band b ON a.id_band = b.id_band GROUP BY s.title_song HAVING count ORDER BY count DESC LIMIT 3');
         //var_dump($best_year_song);
     }
     return View::make('stats.index')->with('song_count', $song_count)->with('album_count', $album_count)->with('best_year_song', $best_year_song)->with('playlist_count', $playlist_count)->with('user_count', $user_count)->with('max_in_playlist', $max_in_playlist)->with('band_count', $band_count);
 }
Beispiel #3
0
 public function action_add_user()
 {
     if ($_POST['user'] != "") {
         $this->_username = $_POST['user'];
     } else {
         $this->_error_form = true;
     }
     if ($_POST['name'] != "" and $this->_error_form == false) {
         $this->_name = $_POST['name'];
     } else {
         $this->_error_form = true;
     }
     if ($_POST['fname'] != "" and $this->_error_form == false) {
         $this->_fname = $_POST['fname'];
     } else {
         $this->_error_form = true;
     }
     if ($_POST['pw'] != "" and $this->_error_form == false) {
         $this->_password = Hash::make($_POST['pw']);
     } else {
         $this->_error_form = true;
     }
     if ($this->_error_form == true) {
         $this->_client_msg = "Veuillez remplir tous les champs svp";
         return Redirect::to_action('signin')->with('error_msg', $this->_client_msg);
     } else {
         $user = new User_lif(null, $this->_username, $this->_password, $this->_name, $this->_fname, null);
         if ($user->check_exists() == false and $this->_error_form == false) {
             $user->set_id_user_lif($user->add());
             $user->load();
             Session::put('user', $user);
             $this->_client_msg = "Enregistrement réussi ! Bienvenue" . $this->_username;
             return Redirect::to_action('home@index');
         } else {
             $this->_client_msg = "Le nom d'utilisteur est déjà utilisé. Veuillez en saisir un nouveau.";
             return Redirect::to_action('signin')->with('error_msg', $this->_client_msg);
         }
     }
 }
Beispiel #4
0
 public function action_add_user_to_playlist()
 {
     $user = $this->is_logged();
     if ($user === false) {
         return Redirect::to_action('login');
     } else {
         $username = new User_lif(null, $_POST['username']);
         if ($username->check_exists($_POST['username'])) {
             $username->load_from_username();
             $ap = new adminPlaylist($username->get_id_user_lif(), $_POST['id_playlist']);
             if ($ap->check_exists() == null) {
                 $ap->set_code_admin('I');
                 $ap->add();
                 if ($ap->check_exists() == 1) {
                     echo 1;
                 } else {
                     echo 0;
                 }
             } else {
                 echo -1;
             }
         } else {
             echo -2;
         }
     }
 }