More language strings renamed, TODOs.txt updated:
[mailer.git] / inc / modules / guest / what-register.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/10/2003 *
4  * ===================                          Last change: 11/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-register.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Registration form                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Anmeldeformular                                  *
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('register')) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('register'));
50         return;
51 } elseif (!isExtensionActive('country')) {
52         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('country'));
53         return;
54 }
55
56 // Is the form sent and all went fine?
57 //* DEBUG: */ debugOutput('isFormSent=' . intval(isFormSent()) . ',isRegistrationDataComplete=' . intval(isRegistrationDataComplete()) . ',isAdmin=' . intval(isAdmin()));
58 if ((isFormSent()) && (isRegistrationDataComplete())) {
59         // Do the registration here
60         doRegistration();
61
62         // Output success registration
63         loadTemplate('admin_settings_saved', false, '{--REGISTRATION_DONE--}');
64 } else {
65         // Do this only if form is sent
66         if (isFormSent()) {
67                 if (postRequestParameter('agree') == '!') {
68                         registerOutputFailedMessage('HAVE_TO_AGREE');
69                 } // END - if
70
71                 if (postRequestParameter('email') == '!') {
72                         registerOutputFailedMessage('ENTER_EMAIL');
73                         setPostRequestParameter('email', '');
74                 } elseif (postRequestParameter('email') == '?') {
75                         registerOutputFailedMessage('GUEST_EMAIL_ALREADY_DB');
76                         setPostRequestParameter('email', '');
77                 }
78
79                 if (postRequestParameter('surname') == '!') {
80                         registerOutputFailedMessage('ENTER_SURNAME');
81                         setPostRequestParameter('surname', '');
82                 } // END - if
83
84                 if (postRequestParameter('family') == '!') {
85                         registerOutputFailedMessage('ENTER_FAMILY');
86                         setPostRequestParameter('family', '');
87                 } // END - if
88
89                 if ((postRequestParameter('pass1') == '!') && (postRequestParameter('pass2') == '!')) {
90                         registerOutputFailedMessage('ENTER_BOTH_PASSWORDS');
91                 } elseif (postRequestParameter('pass1') == '!') {
92                         registerOutputFailedMessage('ENTER_PASS1');
93                 } elseif (postRequestParameter('pass2') == '!') {
94                         registerOutputFailedMessage('ENTER_PASS2');
95                 }
96
97                 if ((isset($GLOBALS['registration_short_password'])) && ($GLOBALS['registration_short_password'] === true)) {
98                         registerOutputFailedMessage('SHORT_PASS', ': ' . getConfig('pass_len'));
99                 } // END - if
100
101                 if ((isset($GLOBALS['registration_ip_timeout'])) && ($GLOBALS['registration_ip_timeout'] === true)) {
102                         registerOutputFailedMessage('REMOTE_ADDR_TIMEOUT');
103                 } // END - if
104
105                 if ((!empty($GLOBALS['register_selected_cats'])) && ($GLOBALS['register_selected_cats'] < getConfig('least_cats'))) {
106                         registerOutputFailedMessage('', '{--CATS_LEAST--}');
107                 } // END - if
108         } // END - if
109
110         // Generate birthday selection
111         switch (getLanguage()) {
112                 case 'de': // German date format
113                         $content['birthday_selection'] = addSelectionBox('day', postRequestParameter('day')).addSelectionBox('month', postRequestParameter('month')).addSelectionBox('year', postRequestParameter('year'));
114                         break;
115
116                 default: // Default is the US date format... :)
117                         $content['birthday_selection'] = addSelectionBox('month', postRequestParameter('month')).addSelectionBox('day', postRequestParameter('day')).addSelectionBox('year', postRequestParameter('year'));
118                         break;
119         }
120
121         // Adds a table for the guests with all visible categories
122         $content['category_selection'] = registerGenerateCategoryTable('guest', true);
123
124         // Adds maximum receiveable mails list... :)
125         $content['max_receive_list'] = addMaxReceiveList('guest', '', true);
126
127         // Shall I display the refid or shall I make it editable?
128         if (getConfig('display_refid') == 'Y') {
129                 // Load "hide" form template
130                 $content['refid_content'] = loadTemplate('guest_register_refid_hide', true);
131         } else {
132                 // Load template to enter it
133                 $content['refid_content'] = loadTemplate('guest_register_refid', true);
134         }
135
136         // You may want to modify the register_header.tpl.xx file and not this script when you add your scripts etc. :-)
137         $content['header_content'] = loadTemplate('register_header', true);
138
139         // Other values
140         $content['surname']   = SQL_ESCAPE(postRequestParameter('surname'));
141         $content['family']    = SQL_ESCAPE(postRequestParameter('family'));
142         $content['street_nr'] = SQL_ESCAPE(postRequestParameter('street_nr'));
143         $content['zip']       = '';
144         if (isPostRequestParameterSet('zip')) {
145                 $content['zip']       = bigintval(postRequestParameter('zip'));
146         } // END - if
147         $content['city']      = SQL_ESCAPE(postRequestParameter('city'));
148         $content['email']     = SQL_ESCAPE(postRequestParameter('email'));
149
150         // The admin may see all
151         $whereStatement = "WHERE `is_active`='Y'";
152         if (isAdmin()) $whereStatement = '';
153
154         // Prepare country selection box
155         $OUT  = '<select name="country_code" class="guest_select" size="1">';
156         $OUT .= generateOptionList('countries', 'id', 'descr', postRequestParameter('country_code'), 'code', $whereStatement);
157         $OUT .= '</select>';
158         $content['country'] = $OUT;
159
160         // Set must-fillout fields
161         $content = runFilterChain('register_must_fillout', $content);
162
163         // Display registration form
164         loadTemplate('guest_register', false, $content);
165 }
166
167 // [EOF]
168 ?>