]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-rallyes.php
bbaec5f4718c45857b82c2def5a9382c2786052e
[mailer.git] / inc / modules / guest / 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 - 2011 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         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('guest', __FILE__);
45
46 if ((!isExtensionActive('rallye')) && (!isAdmin())) {
47         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=rallye%}');
48         return;
49 } // END - if
50
51 // Open div tag
52 outputHtml('<div align="center">');
53
54 // Check for possible running rallyes
55 $ADD = " AND d.is_active='Y'";
56 if (isAdmin()) $ADD = '';
57
58 $result = SQL_QUERY("SELECT
59         d.id, d.admin_id, a.login, d.title, d.descr, d.template, d.start_time, d.end_time, d.min_users, d.min_prices
60 FROM
61         `{?_MYSQL_PREFIX?}_rallye_data` AS d
62 INNER JOIN
63         `{?_MYSQL_PREFIX?}_admins` AS a
64 ON
65         d.admin_id=a.id
66 WHERE
67         d.notified='Y'" . $ADD . "
68 ORDER BY
69         d.end_time
70 LIMIT 1", __FILE__, __LINE__);
71
72 if (SQL_NUMROWS($result) == 1) {
73         // Found some (normally one...
74         list($id, $adminId, $login, $title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
75
76         $expired = false;
77         if ($end < time()) {
78                 // Rallye is expired
79                 $content['extras'] = '{--RALLYE_HAS_EXPIRED--}';
80                 $expired = true;
81         } elseif (time() >= ($end - getOneDay())) {
82                 // Rallye will expire in less one day!
83                 $content['extras'] = '{--RALLYE_EXPIRE_ONE_DAY--}';
84         } else {
85                 $content['extras'] = '<a href="{%url=modules.php?module=index&amp;what=register%}">{--RALLYE_REGISTER_NOW--}</a>';
86         }
87
88         // Set admin line (currently set to impressum, later to contact form)
89         // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;id=' . $adminId . '%}">' . $login . '</a>';
90
91         // Set title
92         $content['title'] = $title;
93
94         // Handle description...
95         if ((empty($descr)) && (!empty($templ))) {
96                 // Use description from template
97                 $content['descr'] = loadTemplate('rallye_' . $templ, true);
98         } else {
99                 // Use description from database
100                 $content['descr'] = $descr;
101         }
102
103         // Set start and end time
104         $content['start'] = generateDateTime($start, 1);
105         $content['end']   = generateDateTime($end  , 1);
106
107         // Determine min_users
108         $content['min_users'] = determineReferalRallyeMinimumUsers($min_users);
109
110         // Determine min prices (now in function)
111         $content['min_prices'] = determineReferalRallyeMinimumPrices($min_prices);
112
113         if ($expired === true) {
114                 $content['prices']       = addReferalRallyeWinners('guest', $id);
115                 $content['top_users']    = '<div align="center" class="big">' . $content['extras'] . '</div>';
116                 $content['can_win_this'] = '{--RALLYE_OUR_WINNERS_ARE--}';
117         } else {
118                 $content['prices']       = addReferalRallyePrices($id, 'html');
119                 $content['top_users']    = addReferalRallyeTopUsers('guest', $id, getMemberId());
120                 $content['can_win_this'] = '{--RALLYE_YOU_CAN_WIN--}';
121         }
122
123         // And load final template
124         loadTemplate('guest_show_rallye', false, $content);
125 } else {
126         // No rallye found so far
127         loadTemplate('guest_rallye_404');
128 }
129
130 // Close the div tag
131 outputHtml('</div>');
132
133 // [EOF]
134 ?>