2013-05-27 08:00:58 +00:00
< ?
class Collages {
public static function increase_subscriptions ( $CollageID ) {
2013-08-28 23:08:41 +00:00
$QueryID = G :: $DB -> get_query_id ();
G :: $DB -> query ( "
2013-06-06 08:01:03 +00:00
UPDATE collages
SET Subscribers = Subscribers + 1
WHERE ID = '$CollageID' " );
2013-08-28 23:08:41 +00:00
G :: $DB -> set_query_id ( $QueryID );
2013-05-27 08:00:58 +00:00
}
public static function decrease_subscriptions ( $CollageID ) {
2013-08-28 23:08:41 +00:00
$QueryID = G :: $DB -> get_query_id ();
G :: $DB -> query ( "
2013-06-06 08:01:03 +00:00
UPDATE collages
SET Subscribers = IF ( Subscribers < 1 , 0 , Subscribers - 1 )
WHERE ID = '$CollageID' " );
2013-08-28 23:08:41 +00:00
G :: $DB -> set_query_id ( $QueryID );
2013-05-27 08:00:58 +00:00
}
2013-06-18 08:00:48 +00:00
public static function create_personal_collage () {
2013-08-28 23:08:41 +00:00
G :: $DB -> query ( "
2013-06-18 08:00:48 +00:00
SELECT
COUNT ( ID )
FROM collages
2013-08-28 23:08:41 +00:00
WHERE UserID = '" . G::$LoggedUser[' ID '] . "'
2013-06-18 08:00:48 +00:00
AND CategoryID = '0'
AND Deleted = '0' " );
2013-08-28 23:08:41 +00:00
list ( $CollageCount ) = G :: $DB -> next_record ();
2013-06-18 08:00:48 +00:00
2013-08-28 23:08:41 +00:00
if ( $CollageCount >= G :: $LoggedUser [ 'Permissions' ][ 'MaxCollages' ]) {
// TODO: fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
list ( $CollageID ) = G :: $DB -> next_record ();
2013-06-18 08:00:48 +00:00
header ( 'Location: collage.php?id=' . $CollageID );
die ();
}
2013-08-28 23:08:41 +00:00
$NameStr = db_string ( G :: $LoggedUser [ 'Username' ] . " 's personal collage " . ( $CollageCount > 0 ? ' no. ' . ( $CollageCount + 1 ) : '' ));
2014-02-27 08:00:30 +00:00
$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].' );
2013-08-28 23:08:41 +00:00
G :: $DB -> query ( "
2013-06-18 08:00:48 +00:00
INSERT INTO collages
( Name , Description , CategoryID , UserID )
VALUES
2013-08-28 23:08:41 +00:00
( '$NameStr' , '$Description' , '0' , " . G:: $LoggedUser['ID'] . " ) " );
$CollageID = G :: $DB -> inserted_id ();
2013-06-18 08:00:48 +00:00
header ( 'Location: collage.php?id=' . $CollageID );
die ();
}
2013-06-06 08:01:03 +00:00
}