BioTorrents.de’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 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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
  9. `collages`
  10. SET
  11. `Subscribers` = `Subscribers` + 1
  12. WHERE
  13. `ID` = '$CollageID'
  14. ");
  15. G::$DB->set_query_id($QueryID);
  16. }
  17. public static function decrease_subscriptions($CollageID)
  18. {
  19. $QueryID = G::$DB->get_query_id();
  20. G::$DB->query("
  21. UPDATE
  22. `collages`
  23. SET
  24. `Subscribers` = IF(
  25. `Subscribers` < 1,
  26. 0,
  27. `Subscribers` - 1
  28. )
  29. WHERE
  30. `ID` = '$CollageID'
  31. ");
  32. G::$DB->set_query_id($QueryID);
  33. }
  34. public static function create_personal_collage()
  35. {
  36. G::$DB->query("
  37. SELECT
  38. COUNT(`ID`)
  39. FROM
  40. `collages`
  41. WHERE
  42. `UserID` = '".G::$LoggedUser['ID']."' AND `CategoryID` = '0' AND `Deleted` = '0'
  43. ");
  44. list($CollageCount) = G::$DB->next_record();
  45. if ($CollageCount >= G::$LoggedUser['Permissions']['MaxCollages']) {
  46. // todo: Fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
  47. list($CollageID) = G::$DB->next_record();
  48. header("Location: collage.php?id=$CollageID");
  49. error();
  50. }
  51. $NameStr = db_string(G::$LoggedUser['Username']."'s personal collage".($CollageCount > 0 ? ' no. '.($CollageCount + 1) : ''));
  52. $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].');
  53. G::$DB->query("
  54. INSERT INTO `collages`(
  55. `Name`,
  56. `Description`,
  57. `CategoryID`,
  58. `UserID`
  59. )
  60. VALUES(
  61. '$NameStr',
  62. '$Description',
  63. '0',
  64. ".G::$LoggedUser['ID']."
  65. )
  66. ");
  67. $CollageID = G::$DB->inserted_id();
  68. header("Location: collage.php?id=$CollageID");
  69. error();
  70. }
  71. }