]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-rallyes.php
Even more rewrites/fixes from EL branch (please report any broken part after you...
[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  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('guest', __FILE__);
47
48 if ((!isExtensionActive('rallye')) && (!isAdmin())) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('rallye'));
50         return;
51 } // END - if
52
53 // Open div tag
54 outputHtml('<div align="center">');
55
56 // Check for possible running rallyes
57 $ADD = " AND d.is_active='Y'";
58 if (isAdmin()) $ADD = '';
59
60 $result = SQL_QUERY("SELECT
61         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
62 FROM
63         `{?_MYSQL_PREFIX?}_rallye_data` AS d
64 INNER JOIN
65         `{?_MYSQL_PREFIX?}_admins` AS a
66 ON
67         d.admin_id=a.id
68 WHERE
69         d.notified='Y'" . $ADD . "
70 ORDER BY
71         d.end_time
72 LIMIT 1", __FILE__, __LINE__);
73
74 if (SQL_NUMROWS($result) == 1) {
75         // Found some (normally one...
76         list($id, $adminId, $login, $title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
77
78         $expired = false;
79         if ($end < time()) {
80                 // Rallye is expired
81                 $content['extras'] = getMessage('RALLYE_HAS_EXPIRED');
82                 $expired = true;
83         } elseif (time() >= ($end - getConfig('ONE_DAY'))) {
84                 // Rallye will expire in less one day!
85                 $content['extras'] = getMessage('RALLYE_EXPIRE_ONE_DAY');
86         } else {
87                 $content['extras'] = '<a href="{%url=modules.php?module=index&amp;what=register%}">{--RALLYE_REGISTER_NOW--}</a>';
88         }
89
90         // Set admin line (currently set to impressum, later to contact form)
91         // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;admin=' . $adminId . '%}">' . $login . '</a>';
92
93         // Set title
94         $content['title'] = $title;
95
96         // Handle description...
97         if ((empty($descr)) && (!empty($templ))) {
98                 // Use description from template
99                 $content['descr'] = loadTemplate('rallye_' . $templ, true);
100         } else {
101                 // Use description from database
102                 $content['descr'] = $descr;
103         }
104
105         // Set start and end time
106         $content['start'] = generateDateTime($start, 1);
107         $content['end']   = generateDateTime($end  , 1);
108
109         // Determine min_users
110         $content['min_users'] = determineReferalRallyeMinimumUsers($min_users);
111
112         // Determine min prices (now in function)
113         $content['min_prices'] = determineReferalRallyeMinimumPrices($min_prices);
114
115         if ($expired === true) {
116                 $content['prices']       = addReferalRallyeWinners($id);
117                 $content['top_users']    = '<div align="center" class="big">' . $content['extras'] . '</div>';
118                 $content['can_win_this'] = getMessage('RALLYE_OUR_WINNERS_ARE');
119         } else {
120                 $content['prices']       = addReferalRallyePrices($id, 'html');
121                 $content['top_users']    = addReferalRallyeTopUsers($id, getMemberId());
122                 $content['can_win_this'] = getMessage('RALLYE_YOU_CAN_WIN');
123         }
124
125         // And load final template
126         loadTemplate('guest_rallye_show', false, $content);
127 } else {
128         // No rallye found so far
129         loadTemplate('guest_no_rallyes');
130 }
131
132 // Close the div tag
133 outputHtml('</div>');
134
135 // [EOF]
136 ?>