user-profile.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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('user-menu.php');
  17. require_once('templating.php');
  18. require_once('data/User.php');
  19. require_once('data/RemoteUser.php');
  20. require_once('data/TagCloud.php');
  21. require_once('data/Server.php');
  22. if (!isset($_GET['user']) && $logged_in == false) {
  23. displayError("Error", "User not set. You shouldn't be here.");
  24. }
  25. try {
  26. if(strstr($_GET['user'], '@')) {
  27. $user = new RemoteUser($_GET['user']);
  28. } else {
  29. $user = new User($_GET['user']);
  30. }
  31. } catch (Exception $e) {
  32. $user = null;
  33. }
  34. if (isset($user->name)) {
  35. $smarty->assign('geo', Server::getLocationDetails($user->location_uri));
  36. try {
  37. $aUserScrobbles = $user->getScrobbles(10);
  38. $smarty->assign('scrobbles', $aUserScrobbles);
  39. } catch (Exception $e) {}
  40. try {
  41. $aUserNowPlaying = $user->getNowPlaying(10);
  42. $smarty->assign('nowplaying', $aUserNowPlaying);
  43. } catch (Exception $e) {}
  44. if ($user->hasLoved()) {
  45. $recommendedArtists = $user->getRecommended(10);
  46. $smarty->assign('recommendedArtists', $recommendedArtists);
  47. if($user->remote) {
  48. // Just get the 10 most recently loved artists from a remote user
  49. $lovedArtists = $user->getLovedArtists(10);
  50. $smarty->assign('lovedArtists', $lovedArtists);
  51. } else {
  52. $lovedArtists = TagCloud::generateTagCloud('loved', 'artist', 10, 'userid', $user->uniqueid);
  53. $smarty->assign('lovedArtists', $lovedArtists);
  54. }
  55. }
  56. $smarty->assign('isme', ($this_user->name == $user->name));
  57. $smarty->assign('me', $user);
  58. $smarty->assign('pagetitle', $user->name);
  59. $smarty->assign('awesomenumber', $user->uniqueid);
  60. $smarty->assign('extra_head_links', array(
  61. array(
  62. 'rel' => 'alternate',
  63. 'type' => 'application/rss+xml',
  64. 'title' => 'RSS 1.0 Feed (Recent plays)',
  65. 'href' => $base_url . '/rdf.php?fmt=rss&page=' . rawurlencode(str_replace($base_url, '', $user->getURL('recent-tracks')))
  66. ),
  67. array(
  68. 'rel' => 'alternate',
  69. 'type' => 'application/rss+xml',
  70. 'title' => 'RSS 1.0 Feed (Journal)',
  71. 'href' => $user->journal_rss
  72. ),
  73. array(
  74. 'rel' => 'meta',
  75. 'type' => 'application/rdf+xml',
  76. 'title' => 'FOAF',
  77. 'href' => $base_url . '/rdf.php?fmt=xml&page=' . rawurlencode(str_replace($base_url, '', $user->getURL()))
  78. )
  79. ));
  80. $neighbours = $user->getNeighbours(9);
  81. if (!empty($neighbours)) {
  82. $smarty->assign('neighbours', $neighbours);
  83. $smarty->assign('sideblocks', array('sidebar-neighbours.tpl'));
  84. }
  85. $submenu = user_menu($user, 'Overview');
  86. $smarty->assign('submenu', $submenu);
  87. $smarty->display('user-profile.tpl');
  88. } else {
  89. displayError("User not found", "User not found, shall I call in a missing persons report?");
  90. }