Used EL code {%template,LoadTemplate=foo%} instead of loadTemplate('foo', TRUE);
[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  * -------------------------------------------------------------------- *
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 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('guest', __FILE__);
45
46 if (!isExtensionActive('register')) {
47         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=register%}');
48         return;
49 } elseif (!isExtensionActive('country')) {
50         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=country%}');
51         return;
52 }
53
54 // Is the form sent and all went fine?
55 //* DEBUG: */ debugOutput('isFormSent=' . intval(isFormSent()) . ',isRegistrationDataComplete=' . intval(isRegistrationDataComplete()) . ',isAdmin=' . intval(isAdmin()));
56 if ((isFormSent()) && (isRegistrationDataComplete())) {
57         // Do the registration here
58         doUserRegistration();
59
60         // Output success registration
61         displayMessage('{--REGISTRATION_DONE--}');
62 } else {
63         // Do this only if form is sent
64         if (isFormSent()) {
65                 if (postRequestElement('agree') == '!') {
66                         registerOutputFailedMessage('HAVE_TO_AGREE');
67                 } // END - if
68
69                 if (postRequestElement('email') == '!') {
70                         registerOutputFailedMessage('ENTER_EMAIL');
71                         setPostRequestElement('email', '');
72                 } elseif (postRequestElement('email') == '?') {
73                         registerOutputFailedMessage('GUEST_EMAIL_IS_ALREADY_REGISTERED');
74                         setPostRequestElement('email', '');
75                 }
76
77                 if (postRequestElement('surname') == '!') {
78                         registerOutputFailedMessage('ENTER_SURNAME');
79                         setPostRequestElement('surname', '');
80                 } // END - if
81
82                 if (postRequestElement('family') == '!') {
83                         registerOutputFailedMessage('ENTER_FAMILY');
84                         setPostRequestElement('family', '');
85                 } // END - if
86
87                 if ((postRequestElement('password1') == '!') && (postRequestElement('password2') == '!')) {
88                         registerOutputFailedMessage('ENTER_BOTH_PASSWORDS');
89                 } elseif (postRequestElement('password1') == '!') {
90                         registerOutputFailedMessage('ENTER_PASSWORD1');
91                 } elseif (postRequestElement('password2') == '!') {
92                         registerOutputFailedMessage('ENTER_PASSWORD2');
93                 }
94
95                 if ((isset($GLOBALS['registration_short_password'])) && ($GLOBALS['registration_short_password'] === TRUE)) {
96                         registerOutputFailedMessage('GUEST_SHORT_PASS', ': ' . getPassLen());
97                 } // END - if
98
99                 if ((isset($GLOBALS['registration_ip_timeout'])) && ($GLOBALS['registration_ip_timeout'] === TRUE)) {
100                         registerOutputFailedMessage('REMOTE_ADDR_TIMEOUT');
101                 } // END - if
102
103                 if ((!empty($GLOBALS['registration_selected_cats'])) && ($GLOBALS['registration_selected_cats'] < getLeastCats())) {
104                         registerOutputFailedMessage('', '{--CHOOSE_MORE_CATEGORIES--}');
105                 } // END - if
106         } // END - if
107
108         // Generate birthday selection
109         switch (getLanguage()) {
110                 case 'de': // German date format
111                         $content['birthday_selection'] = addSelectionBox('day', postRequestElement('day')).addSelectionBox('month', postRequestElement('month')).addSelectionBox('year', postRequestElement('year'));
112                         break;
113
114                 default: // Default is the US date format... :)
115                         $content['birthday_selection'] = addSelectionBox('month', postRequestElement('month')).addSelectionBox('day', postRequestElement('day')).addSelectionBox('year', postRequestElement('year'));
116                         break;
117         } // END - switch
118
119         // Shall I display the refid or shall I make it editable?
120         if (isDisplayRefidEnabled()) {
121                 // Load "hide" form template
122                 $content['refid_content'] = loadTemplate('guest_register_refid_hide', TRUE);
123         } else {
124                 // Load template to enter it
125                 $content['refid_content'] = loadTemplate('guest_register_refid', TRUE);
126         }
127
128         // ZIP codes are numerical values
129         $content['zip'] = '';
130         if ((isPostRequestElementSet('zip')) && (postRequestElement('zip') > 0)) {
131                 $content['zip'] = bigintval(postRequestElement('zip'));
132         } // END - if
133
134         // Other values
135         foreach (array('gender', 'surname', 'family', 'street_nr', 'city', 'email') as $entry) {
136                 $content[$entry] = SQL_ESCAPE(postRequestElement($entry));
137         } // END - foreach
138
139         // Set must-fillout fields
140         $content = runFilterChain('register_must_fillout', $content);
141
142         // Display registration form
143         loadTemplate('guest_register', FALSE, $content);
144 }
145
146 // [EOF]
147 ?>