Updated copyright notice as there are changes in this year
[mailer.git] / inc / libs / register_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 07/10/2004 *
4  * ===================                          Last change: 07/10/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : register_functions.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Special functions for register extension         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Spezielle Funktion fuer register-Erweiterung     *
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 - 2013 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 // Checks whether all required registration fields are set
44 function ifRequiredRegisterFieldsAreSet (&$array) {
45         // By default all is fine
46         $ret = TRUE;
47         foreach ($array as $key => $value) {
48                 // Check all fields that must register
49                 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_must_register` WHERE `field_name`='%s' AND `field_required`='Y' LIMIT 1",
50                         array($key), __FUNCTION__, __LINE__);
51
52                 // Entry found?
53                 if (SQL_NUMROWS($result) == 1) {
54                         // Check if extension country is not found (you have to enter the 2-chars long country code) or
55                         // if extensions is present check if country code was selected
56                         //         01              2         21    12             3         32    234     5      54    4               43    34                      4    4      5      5432    2      3                      3210
57                         $country = ((!isExtensionActive('country')) || ((isExtensionActive('country')) && (((empty($value)) && ($key == 'cntry')) || (($key == 'country_code') && (!empty($value)))) && (!empty($array['country_code']))));
58                         if ((empty($value)) && ($country === FALSE)) {
59                                 // Required field not set
60                                 $array[$key] = '!';
61                                 $ret = FALSE;
62                         } // END - if
63                 } // END - if
64
65                 // Free result
66                 SQL_FREERESULT($result);
67         } // END - foreach
68
69         // Return result
70         return $ret;
71 }
72
73 // Generates a 'category table' for the registration form
74 function registerGenerateCategoryTable ($mode, $configEntry = 'register_default') {
75         // Init output
76         $OUT = '';
77
78         /*
79          * Guests are mostly not interested in how many members has choosen an
80          * individual category.
81          */
82         $whereStatement = "WHERE `visible`='Y' ";
83
84         // Admins are allowed to see every category...
85         if (isAdmin()) {
86                 $whereStatement = '';
87         } // END - if
88
89         // Look for categories
90         $result = SQL_QUERY('SELECT
91         `id`,
92         `cat`,
93         `visible`
94 FROM
95         `{?_MYSQL_PREFIX?}_cats`
96 ' . $whereStatement . '
97 ORDER BY
98         `sort` ASC',
99                 __FUNCTION__, __LINE__);
100
101         if (!SQL_HASZERONUMS($result)) {
102                 // List alle visible modules (or all to the admin)
103                 $OUT .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
104                 while ($content = SQL_FETCHARRAY($result)) {
105                         // Prepare array for the template
106                         $content['default_yes'] = '';
107                         $content['default_no']  = '';
108
109                         // Mark categories
110                         if ((postRequestElement('cat', $content['id']) == 'Y') || ((getConfig($configEntry) == 'Y') && (!isPostRequestElementSet('cat', $content['id'])))) {
111                                 $content['default_yes'] = ' checked="checked"';
112                         } else {
113                                 $content['default_no']  = ' checked="checked"';
114                         }
115
116                         // Load template and switch color
117                         $OUT .= loadTemplate('guest_cat_row', TRUE, $content);
118                 } // END - while
119                 $OUT .= '</table>';
120
121                 // Free memory
122                 SQL_FREERESULT($result);
123         } else {
124                 // No categories setted up so far...
125                 $OUT .= displayMessage('{--NO_CATEGORIES_VISIBLE--}', TRUE);
126         }
127
128         // Return generated HTML code
129         return $OUT;
130 }
131
132 // Outputs a 'failed message'
133 function registerOutputFailedMessage ($messageId, $extra='') {
134         if (empty($messageId)) {
135                 outputHtml('<div class="bad">' . $extra . '</div>');
136         } else {
137                 outputHtml('<div class="bad">{--' . $messageId . '--}' . $extra . '</div>');
138         }
139 }
140
141 // Checks whether the registration data is complete
142 function isRegistrationDataComplete () {
143         // Init elements
144         $GLOBALS['registration_ip_timeout']     = FALSE;
145         $GLOBALS['registration_short_password'] = FALSE;
146         $GLOBALS['registration_selected_cats']  = '0';
147
148         // Default is okay
149         $isOkay = TRUE;
150
151         // First we only check the submitted data then we continue... :)
152         //
153         // Did he agree to the terms of usage?
154         if (postRequestElement('agree') != 'Y') {
155                 setPostRequestElement('agree', '!');
156                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'agree=N - User did not agree with terms of usage.');
157                 $isOkay = FALSE;
158         } // END - if
159
160         // Did he enter a valid email address? (we really don't care about
161         // that, he has to click on a confirmation link :P )
162         if ((!isAdmin()) && ((!isPostRequestElementSet('email')) || (!isEmailValid(postRequestElement('email'))))) {
163                 setPostRequestElement('email', '!');
164                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter proper email address.');
165                 $isOkay = FALSE;
166         } // END - if
167
168         // And what about surname and family's name?
169         if (!isPostRequestElementSet('surname')) {
170                 setPostRequestElement('surname', '!');
171                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter surname.');
172                 $isOkay = FALSE;
173         } // END - if
174         if (!isPostRequestElementSet('family')) {
175                 setPostRequestElement('family', '!');
176                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter family name.');
177                 $isOkay = FALSE;
178         } // END - if
179
180         // Get temporary array for modification
181         $postArray = postRequestArray();
182
183         // Check for required fields
184         $isOkay = ($isOkay && ifRequiredRegisterFieldsAreSet($postArray));
185
186         // Set it back in request
187         setPostRequestArray($postArray);
188
189         // Are both passwords zero length?
190         if ((strlen(postRequestElement('password1')) == 0) && (strlen(postRequestElement('password2')) == 0) && ($isOkay === TRUE)) {
191                 // Is the extension 'register' newer or equal 0.5.5?
192                 if ((isExtensionInstalledAndNewer('register', '0.5.5')) && (isRegisterGeneratePasswordEmptyEnabled())) {
193                         // Generate a random password
194                         $randomPassword = generatePassword();
195
196                         // Set it in both entries
197                         setPostRequestElement('password1', $randomPassword);
198                         setPostRequestElement('password2', $randomPassword);
199                 } else {
200                         // Not allowed or no recent extension version
201                         setPostRequestElement('password1', '!');
202                         setPostRequestElement('password2', '!');
203
204                         // ... which is both not okay
205                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Random password generation not possible, isExtensionInstalledAndNewer(register, 0.5.5)=' . intval(isExtensionInstalledAndNewer('register', '0.5.5')) . ',isRegisterGeneratePasswordEmptyEnabled()=' . intval(isRegisterGeneratePasswordEmptyEnabled()));
206                         $isOkay = FALSE;
207                 }
208         } // END - if
209
210         // Did he enter his password twice?
211         if (((!isPostRequestElementSet('password1')) || (!isPostRequestElementSet('password2'))) || ((postRequestElement('password1') != postRequestElement('password2')) && (isPostRequestElementSet('password1')) && (isPostRequestElementSet('password2')))) {
212                 if ((postRequestElement('password1') != postRequestElement('password2')) && (isPostRequestElementSet('password1')) && (isPostRequestElementSet('password2'))) {
213                         // Both passwords did not match
214                         setPostRequestElement('password1', '!');
215                         setPostRequestElement('password2', '!');
216                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter same passwords.');
217                 } else {
218                         if (!isPostRequestElementSet('password1')) {
219                                 // Password 1 is empty
220                                 setPostRequestElement('password1', '!');
221                                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter password1.');
222                         } else {
223                                 // Password 2 is empty
224                                 setPostRequestElement('password1', '');
225                         }
226                         if (!isPostRequestElementSet('password2')) {
227                                 // Password 2 is empty
228                                 setPostRequestElement('password2', '!');
229                                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter password2.');
230                         } else {
231                                 // Password 1 is empty
232                                 setPostRequestElement('password2', '');
233                         }
234                 }
235                 $isOkay = FALSE;
236         } // END - if
237
238         // Is the password long enouth?
239         if ((strlen(postRequestElement('password1')) < getPassLen()) && ($isOkay === TRUE)) {
240                 $GLOBALS['registration_short_password'] = TRUE;
241                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did enter a short password.');
242                 $isOkay = FALSE;
243         } // END - if
244
245         // Do this check only when no admin is logged in
246         if (ifPostContainsSelections('cat')) {
247                 // Only continue with array
248                 foreach (postRequestElement('cat') as $id => $answer) {
249                         // Is this category choosen?
250                         if ($answer == 'Y') {
251                                 $GLOBALS['registration_selected_cats']++;
252                         } // END - if
253                 } // END - foreach
254         } // END - if
255
256         // Enougth categories selected?
257         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay) . ',selected=' . $GLOBALS['registration_selected_cats'] . '/' . getLeastCats());
258         $isOkay = (($isOkay) && ($GLOBALS['registration_selected_cats'] >= getLeastCats()));
259
260         // Check if email is taken, if configured
261         if ((isExtensionInstalledAndNewer('other', '0.3.0')) && (isCheckDoubleEmailEnabled()) && (postRequestElement('email') != '!') && (isEmailTaken(postRequestElement('email'))) && (!isAdmin())) {
262                 // Is already used
263                 setPostRequestElement('email', '?');
264                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did enter a already used email address.');
265                 $isOkay = FALSE;
266         } // END - if
267
268         // Check for IP timeout?
269         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay));
270         if ((!isAdmin()) && (getIpTimeout() > 0)) {
271                 // Check his IP number
272                 $GLOBALS['registration_ip_timeout'] = (countSumTotalData(detectRemoteAddr()  , 'user_data', 'userid', 'REMOTE_ADDR', TRUE, ' AND ((UNIX_TIMESTAMP() - `joined`) < {?ip_timeout?} OR (UNIX_TIMESTAMP() - `last_update`) < {?ip_timeout?})') == 1);
273                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay).',timeout='.intval($GLOBALS['registration_ip_timeout']));
274                 $isOkay = (($isOkay) && (!$GLOBALS['registration_ip_timeout']));
275         } // END - if
276
277         // Return result
278         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay) . ' - EXIT!');
279         return $isOkay;
280 }
281
282 // Do the registration
283 function doUserRegistration () {
284         // Do not register an account on absent ext-user
285         if (!isExtensionInstalled('user')) {
286                 // Please report this
287                 reportBug(__FUNCTION__, __LINE__, 'Tried to register a user account without ext-user installed.');
288         } // END - if
289
290         // Init extra SQL data
291         initExtraRegistrationSql();
292
293         // Init filter data
294         $filterData = array(
295                 // Initialization not done by default
296                 'init_done'   => FALSE,
297                 'post_data'   => postRequestArray(),
298                 'blacklisted' => '',
299                 'message'     => '{--PRE_USER_REGISTRATION_FAILED--}',
300         );
301
302         // Run the pre-registration chain
303         $filterData = runFilterChain('pre_user_registration', $filterData);
304
305         // Did the initialization work?
306         if ($filterData['init_done'] === FALSE) {
307                 // Something bad happened!
308                 displayMessage($filterData['message']);
309
310                 // Stop here
311                 return FALSE;
312         } // END - if
313
314         // Create user's account...
315         SQL_QUERY_ESC("INSERT INTO
316         `{?_MYSQL_PREFIX?}_user_data`
317 (
318         `gender`,
319         `surname`,
320         `family`,
321         `street_nr`,
322         %s,
323         `zip`,
324         `city`,
325         `email`,
326         `birth_day`,
327         `birth_month`,
328         `birth_year`,
329         `password`,
330         `max_mails`,
331         `receive_mails`,
332         `refid`,
333         `status`,
334         `user_hash`,
335         `REMOTE_ADDR`,
336         `joined`,
337         `last_update`,
338         `ref_payout`
339         " . $GLOBALS['register_sql_columns'] . "
340 ) VALUES (
341         '%s',
342         '%s',
343         '%s',
344         '%s',
345         '%s',
346         %s,
347         '%s',
348         '%s',
349         %s,
350         %s,
351         %s,
352         '%s',
353         %s,
354         %s,
355         %s,
356         '%s',
357         '%s',
358         '{%%pipe,detectRemoteAddr%%}',
359         UNIX_TIMESTAMP(),
360         UNIX_TIMESTAMP(),
361         {?ref_payout?}
362         " . $GLOBALS['register_sql_data'] . "
363 )",
364         array(
365                 $GLOBALS['register_country_row'],
366                 substr(postRequestElement('gender'), 0, 1),
367                 postRequestElement('surname'),
368                 postRequestElement('family'),
369                 postRequestElement('street_nr'),
370                 $GLOBALS['register_country_data'],
371                 bigintval(postRequestElement('zip')),
372                 postRequestElement('city'),
373                 postRequestElement('email'),
374                 bigintval(postRequestElement('day')),
375                 bigintval(postRequestElement('month')),
376                 bigintval(postRequestElement('year')),
377                 generateHash(postRequestElement('password1')),
378                 bigintval(postRequestElement('max_mails')),
379                 bigintval(postRequestElement('max_mails')),
380                 convertZeroToNull(postRequestElement('refid')),
381                 postRequestElement('status'),
382                 $GLOBALS['register_confirm_hash']
383         ), __FUNCTION__, __LINE__);
384
385         // Get his userid
386         $filterData['register_insert_id'] = SQL_INSERT_ID();
387
388         // Did this work?
389         if (!isValidId($filterData['register_insert_id'])) {
390                 // Something bad happened!
391                 displayMessage('{--USER_NOT_REGISTERED--}');
392
393                 // Stop here
394                 return FALSE;
395         } // END - if
396
397         // Shall we reset random refid? Only possible with latest ext-user
398         if (isExtensionInstalledAndNewer('user', '0.3.4')) {
399                 // Reset all accounts, registration is done
400                 SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0', __FUNCTION__, __LINE__);
401         } // END - if
402
403         // Update referral table
404         updateReferralCounter($filterData['register_insert_id']);
405
406         // Write his welcome-points
407         initReferralSystem();
408         addPointsThroughReferralSystem(
409                 // Subject
410                 'register_welcome',
411                 // User's id number
412                 $filterData['register_insert_id'],
413                 // Points to add
414                 getPointsRegister(),
415                 // Referral id (or NULL if none set)
416                 convertZeroToNull(postRequestElement('refid'))
417         );
418
419         // Write catgories
420         if (ifPostContainsSelections('cat')) {
421                 // Init SQL
422                 $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_user_cats` (`userid`, `cat_id`) VALUES';
423
424                 // Write all entries
425                 foreach (postRequestElement('cat') as $categoryId => $joined) {
426                         // "Join" this group?
427                         if ($joined == 'Y') {
428                                 // Insert category entry
429                                 $sql .= ' (' . $filterData['register_insert_id'] . ', ' . bigintval($categoryId) . '),';
430                         } // END - if
431                 } // END - foreach
432
433                 // Run SQL without last commata
434                 SQL_QUERY(substr($sql, 0, -1), __FUNCTION__, __LINE__);
435         } // END - if
436
437         // Registration phase is done here, so for tester accounts we end here
438         if (((getExtensionVersion('user') >= '0.5.0')) && (isTesterUserName(postRequestElement('surname'))) && (ifTesterAccountsAllowed())) {
439                 // All fine here
440                 return TRUE;
441         } // END - if
442
443         // ... rewrite a zero referral id to the main title
444         if (!isValidId(postRequestElement('refid'))) {
445                 setPostRequestElement('refid', getMainTitle());
446         } // END - if
447
448         // Is ZIP code set?
449         if (isPostRequestElementSet('zip')) {
450                 // Prepare data array for the email template
451                 $content = array(
452                         'hash'     => $GLOBALS['register_confirm_hash'],
453                         'userid'   => $filterData['register_insert_id'],
454                         'gender'   => SQL_ESCAPE(postRequestElement('gender')),
455                         'surname'  => SQL_ESCAPE(postRequestElement('surname')),
456                         'family'   => SQL_ESCAPE(postRequestElement('family')),
457                         'email'    => SQL_ESCAPE(postRequestElement('email')),
458                         'street'   => SQL_ESCAPE(postRequestElement('street_nr')),
459                         'city'     => SQL_ESCAPE(postRequestElement('city')),
460                         'zip'      => bigintval(postRequestElement('zip')),
461                         'country'  => $GLOBALS['register_country_data'],
462                         'refid'    => SQL_ESCAPE(postRequestElement('refid')),
463                         'password' => SQL_ESCAPE(postRequestElement('password1')),
464                 );
465         } else {
466                 // No ZIP code entered
467                 $content = array(
468                         'hash'     => $GLOBALS['register_confirm_hash'],
469                         'userid'   => $filterData['register_insert_id'],
470                         'gender'   => SQL_ESCAPE(postRequestElement('gender')),
471                         'surname'  => SQL_ESCAPE(postRequestElement('surname')),
472                         'family'   => SQL_ESCAPE(postRequestElement('family')),
473                         'email'    => SQL_ESCAPE(postRequestElement('email')),
474                         'street'   => SQL_ESCAPE(postRequestElement('street_nr')),
475                         'city'     => SQL_ESCAPE(postRequestElement('city')),
476                         'zip'      => '',
477                         'country'  => $GLOBALS['register_country_data'],
478                         'refid'    => SQL_ESCAPE(postRequestElement('refid')),
479                         'password' => SQL_ESCAPE(postRequestElement('password1')),
480                 );
481         }
482
483         // Continue with birthday...
484         switch (getLanguage()) {
485                 case 'de':
486                         $content['birthday'] = bigintval(postRequestElement('day')) . '.' . bigintval(postRequestElement('month')) . '.' . bigintval(postRequestElement('year'));
487                         break;
488
489                 default:
490                         $content['birthday'] = bigintval(postRequestElement('month')) . '/' . bigintval(postRequestElement('day')) . '/' . bigintval(postRequestElement('year'));
491                         break;
492         } // END - switch
493
494         // Display information to the user that he got mail and send it away
495         $messageGuest = loadEmailTemplate('guest_register_done', $content, $filterData['register_insert_id'], FALSE);
496
497         // Send mail to user (confirmation link!)
498         sendEmail($filterData['register_insert_id'], '{--GUEST_CONFIRM_LINK_SUBJECT--}', $messageGuest);
499
500         // Send mail to admin
501         sendAdminNotification('{--ADMIN_NEW_ACCOUNT_SUBJECT--}', 'admin_register_done', $content, $filterData['register_insert_id']);
502
503         // All fine
504         return TRUE;
505 }
506
507 // Initialize extra registration SQL
508 function initExtraRegistrationSql () {
509         $GLOBALS['register_sql_columns'] = '';
510         $GLOBALS['register_sql_data']    = '';
511 }
512
513 // Add extra column for registration SQL
514 function addExtraRegistrationColumns ($column) {
515         // Add column
516         $GLOBALS['register_sql_columns'] .= $column;
517 }
518
519 // Add extra data for registration SQL
520 function addExtraRegistrationData ($data) {
521         // Add column
522         $GLOBALS['register_sql_data'] .= $data;
523 }
524
525 //-----------------------------------------------------------------------------
526 //                      Wrapper functions for ext-register
527 //-----------------------------------------------------------------------------
528
529 // Getter for 'display_refid'
530 function getDisplayRefid () {
531         // Is the cache entry set?
532         if (!isset($GLOBALS[__FUNCTION__])) {
533                 // No, so determine it
534                 $GLOBALS[__FUNCTION__] = getConfig('display_refid');
535         } // END - if
536
537         // Return cached entry
538         return $GLOBALS[__FUNCTION__];
539 }
540
541 // Checks whether 'display_refid' is "Y"
542 function isDisplayRefidEnabled () {
543         // Is the cache entry set?
544         if (!isset($GLOBALS[__FUNCTION__])) {
545                 // No, so determine it
546                 $GLOBALS[__FUNCTION__] = (getDisplayRefid() == 'Y');
547         } // END - if
548
549         // Return cached entry
550         return $GLOBALS[__FUNCTION__];
551 }
552
553 // Getter for 'ip_timeout'
554 function getIpTimeout () {
555         // Is the cache entry set?
556         if (!isset($GLOBALS[__FUNCTION__])) {
557                 // No, so determine it
558                 $GLOBALS[__FUNCTION__] = getConfig('ip_timeout');
559         } // END - if
560
561         // Return cached entry
562         return $GLOBALS[__FUNCTION__];
563 }
564
565 // Getter for 'register_default'
566 function getRegisterDefault () {
567         // Is the cache entry set?
568         if (!isset($GLOBALS[__FUNCTION__])) {
569                 // No, so determine it
570                 $GLOBALS[__FUNCTION__] = getConfig('register_default');
571         } // END - if
572
573         // Return cached entry
574         return $GLOBALS[__FUNCTION__];
575 }
576
577 // Checks whether 'register_default' is "YES"
578 function isRegisterDefaultEnabled () {
579         // Is the cache entry set?
580         if (!isset($GLOBALS[__FUNCTION__])) {
581                 // No, so determine it
582                 $GLOBALS[__FUNCTION__] = (getRegisterDefault() == 'Y');
583         } // END - if
584
585         // Return cached entry
586         return $GLOBALS[__FUNCTION__];
587 }
588
589 // Getter for 'register_generate_password_empty'
590 function getRegisterGeneratePasswordEmpty () {
591         // Is the cache entry set?
592         if (!isset($GLOBALS[__FUNCTION__])) {
593                 // No, so determine it
594                 $GLOBALS[__FUNCTION__] = getConfig('register_generate_password_empty');
595         } // END - if
596
597         // Return cached entry
598         return $GLOBALS[__FUNCTION__];
599 }
600
601 // Checks whether 'register_generate_password_empty' is "YES"
602 function isRegisterGeneratePasswordEmptyEnabled () {
603         // Is the cache entry set?
604         if (!isset($GLOBALS[__FUNCTION__])) {
605                 // No, so determine it
606                 $GLOBALS[__FUNCTION__] = (getRegisterGeneratePasswordEmpty() == 'Y');
607         } // END - if
608
609         // Return cached entry
610         return $GLOBALS[__FUNCTION__];
611 }
612
613 // "Getter" for least_cats
614 function getLeastCats () {
615         // Is there cache?
616         if (!isset($GLOBALS[__FUNCTION__])) {
617                 // Determine it
618                 $GLOBALS[__FUNCTION__] = getConfig('least_cats');
619         } // END - if
620
621         // Return cache
622         return $GLOBALS[__FUNCTION__];
623 }
624
625 // ----------------------------------------------------------------------------
626 //                            Template helper functions
627 // ----------------------------------------------------------------------------
628
629 // Template helper for generating a category selection table for admin area with given configuration entry
630 function doTemplateAdminRegisterCategoryTable ($templateName, $clear = FALSE, $configEntry) {
631         // Call the inner function
632         return registerGenerateCategoryTable('admin', $configEntry);
633 }
634
635 // [EOF]
636 ?>