artist-signup.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /* GNU FM -- a free network service for sharing your music listening habits
  3. Copyright (C) 2009 Free Software Foundation, Inc
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. require_once('database.php');
  16. require_once('templating.php');
  17. require_once('data/sanitize.php');
  18. require_once('data/Server.php');
  19. if ($logged_in == false) {
  20. $smarty->assign('pageheading', _('Artist Sign-Up'));
  21. $smarty->display('artist-signup.tpl');
  22. die();
  23. }
  24. if(isset($_POST['artist_name']) && !empty($_POST['artist_name'])) {
  25. $already_exists = false;
  26. $name = trim($_POST['artist_name']);
  27. try {
  28. $artist = new Artist($name);
  29. $already_exists = true;
  30. } catch (Exception $e) {
  31. }
  32. $create = false;
  33. if($already_exists) {
  34. $managers = $artist->getManagers();
  35. $smarty->assign('managers', $managers);
  36. if(isset($_POST['confirm_artist']) && empty($managers)) {
  37. if($artist->getListenerCount() > 100) {
  38. $adodb->Execute("INSERT INTO Manages (userid, artist, authorised) VALUES (" . (int) $this_user->uniqueid . ", "
  39. . $adodb->qstr($artist->name) . ", 0)");
  40. $smarty->assign('too_popular', true);
  41. } else {
  42. $adodb->Execute("INSERT INTO Manages (userid, artist, authorised) VALUES (" . (int) $this_user->uniqueid . ", "
  43. . $adodb->qstr($artist->name) . ", 1)");
  44. $smarty->assign('created', true);
  45. }
  46. } elseif(isset($_POST['reject_artist'])) {
  47. $smarty->assign('reject_artist', true);
  48. } else {
  49. $smarty->assign('creating', true);
  50. }
  51. } else {
  52. $adodb->Execute("INSERT INTO Artist (name) VALUES(" . $adodb->qstr($name) . ")");
  53. $artist = new Artist($name, false, true); // Force recaching since this is a new artist
  54. $adodb->Execute("INSERT INTO Manages (userid, artist, authorised) VALUES (" . (int) $this_user->uniqueid . ", "
  55. . $adodb->qstr($artist->name) . ", 1)");
  56. $smarty->assign('created', true);
  57. }
  58. $smarty->assign('artist', $artist);
  59. $smarty->assign('already_exists', $already_exists);
  60. }
  61. $smarty->assign('pageheading', _('Artist Sign-Up'));
  62. $smarty->display('artist-signup.tpl');