Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

collages.class.php 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class Collages
  3. {
  4. public static function increase_subscriptions($CollageID)
  5. {
  6. $QueryID = G::$DB->get_query_id();
  7. G::$DB->query("
  8. UPDATE collages
  9. SET Subscribers = Subscribers + 1
  10. WHERE ID = '$CollageID'");
  11. G::$DB->set_query_id($QueryID);
  12. }
  13. public static function decrease_subscriptions($CollageID)
  14. {
  15. $QueryID = G::$DB->get_query_id();
  16. G::$DB->query("
  17. UPDATE collages
  18. SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
  19. WHERE ID = '$CollageID'");
  20. G::$DB->set_query_id($QueryID);
  21. }
  22. public static function create_personal_collage()
  23. {
  24. G::$DB->query("
  25. SELECT
  26. COUNT(ID)
  27. FROM collages
  28. WHERE UserID = '" . G::$LoggedUser['ID'] . "'
  29. AND CategoryID = '0'
  30. AND Deleted = '0'");
  31. list($CollageCount) = G::$DB->next_record();
  32. if ($CollageCount >= G::$LoggedUser['Permissions']['MaxCollages']) {
  33. // TODO: fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
  34. list($CollageID) = G::$DB->next_record();
  35. header('Location: collage.php?id='.$CollageID);
  36. die();
  37. }
  38. $NameStr = db_string(G::$LoggedUser['Username'] . "'s personal collage" . ($CollageCount > 0 ? ' no. ' . ($CollageCount + 1) : ''));
  39. $Description = db_string('Personal collage for ' . G::$LoggedUser['Username'] . '. The first 5 albums will appear on his or her [url=' . site_url() . 'user.php?id= ' . G::$LoggedUser['ID'] . ']profile[/url].');
  40. G::$DB->query("
  41. INSERT INTO collages
  42. (Name, Description, CategoryID, UserID)
  43. VALUES
  44. ('$NameStr', '$Description', '0', " . G::$LoggedUser['ID'] . ")");
  45. $CollageID = G::$DB->inserted_id();
  46. header('Location: collage.php?id='.$CollageID);
  47. die();
  48. }
  49. }