Used EL code {%template,LoadTemplate=foo%} instead of loadTemplate('foo', TRUE);
[mailer.git] / inc / modules / member / what-rallyes.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/29/2004 *
4  * ===================                          Last change: 08/22/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-rallyes.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Ref rallyes                                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ref-Rallyes                                      *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         exit();
41 } elseif (!isMember()) {
42         redirectToIndexMemberOnlyModule();
43 }
44
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
47
48 if ((!isExtensionActive('rallye')) && (!isAdmin())) {
49         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=rallye%}');
50         return;
51 } // END - if
52
53 // Check for possible running rallyes
54 $ADD = " AND `d`.`is_active`='Y'";
55 if (isAdmin()) $ADD = '';
56
57 $result = SQL_QUERY("SELECT
58         `d`.`id`,
59         `d`.`admin_id`,
60         `a`.`login`,
61         `d`.`title`,
62         `d`.`descr`,
63         `d`.`template`,
64         `d`.`start_time`,
65         `d`.`end_time`,
66         `d`.`min_users`,
67         `d`.`min_prices`
68 FROM
69         `{?_MYSQL_PREFIX?}_rallye_data` AS `d`
70 INNER JOIN
71         `{?_MYSQL_PREFIX?}_admins` AS `a`
72 ON
73         `d`.`admin_id`=`a`.`id`
74 WHERE
75         `d`.`notified`='Y'
76         " . $ADD . "
77 ORDER BY
78         `d`.`end_time` ASC
79 LIMIT 1", __FILE__, __LINE__);
80
81 if (SQL_NUMROWS($result) == 1) {
82         // Found some (normally one...
83         $content = SQL_FETCHARRAY($result);
84
85         $expired = FALSE;
86         if (($content['end_time'] < time()) && (getTotalConfirmedUser() >= $content['min_users']) && (getTotalRallyeWinners($content['id']) >= $content['min_prices'])) {
87                 // Rallye is expired
88                 $content['extras'] = '{--RALLYE_HAS_EXPIRED--}';
89                 $expired = TRUE;
90         } elseif (time() >= ($content['end_time'] - getOneDay())) {
91                 // Rallye will expire in less one day!
92                 $content['extras'] = '{--RALLYE_EXPIRE_ONE_DAY--}';
93         } else {
94                 // Link to referral links page
95                 $content['extras'] = '<a href="{%url=modules.php?module=login&amp;what=reflinks%}">{--RALLYE_GET_REFERRAL_LINK--}</a>';
96         }
97
98         // Set admin line (currently set to impressum, later to contact form)
99         // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;id=' . $content['admin_id'] . '%}">' . $content['login'] . '</a>';
100
101         // Handle description...
102         if ((empty($content['descr'])) && (!empty($content['template']))) {
103                 // Use description from template
104                 $content['descr'] = '{%template,LoadTemplate=rallye_' . $content['template'] . '%}';
105         } // END - if
106
107         // Set start and end time
108         $content['start_time'] = generateDateTime($content['start_time'], 1);
109         $content['end_time']   = generateDateTime($content['end_time']  , 1);
110
111         if ($expired === TRUE) {
112                 $content['prices']       = addReferralRallyeWinners('member', $content['id']);
113                 $content['top_users']    = '<div align="center" class="big">' . $content['extras'] . '</div>';
114                 $content['can_win_this'] = '{--RALLYE_OUR_WINNERS_ARE--}';
115         } else {
116                 $content['prices']       = addReferralRallyePrices($content['id'], 'html');
117                 $content['top_users']    = addReferralRallyeTopUsers('member', $content['id'], getMemberId());
118                 $content['can_win_this'] = '{--RALLYE_YOU_CAN_WIN--}';
119         }
120
121         // And load final template
122         loadTemplate('member_show_rallye', FALSE, $content);
123 } else {
124         // No rallye found so far
125         loadTemplate('member_rallye_404');
126 }
127
128 // Free result
129 SQL_FREERESULT($result);
130
131 // [EOF]
132 ?>