2 /************************************************************************
3 * MXChange v0.2.1 Start: 07/10/2004 *
4 * =============== Last change: 07/10/2004 *
6 * -------------------------------------------------------------------- *
7 * File : register_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Special functions for register extension *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Spezielle Funktion fuer register-Erweiterung *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
45 function ifRequiredRegisterFieldsAreSet (&$array) {
46 // By default all is fine
48 foreach ($array as $key => $value) {
49 // Check all fields that must register
50 $result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_must_register` WHERE `field_name`='".$key."' AND `field_required`='Y' LIMIT 1",
51 __FUNCTION__, __LINE__);
52 if (SQL_NUMROWS($result) == 1) {
53 // Check if extension country is not found (you have to enter the 2-chars long country code) or
54 // if extensions is present check if country code was selected
55 // 01 2 21 12 3 32 234 5 54 4 43 34 4 4 5 5432 2 3 3210
56 $country = ((!isExtensionActive('country')) || ((isExtensionActive('country')) && (((empty($value)) && ($key == 'cntry')) || (($key == 'country_code') && (!empty($value)))) && (!empty($array['country_code']))));
57 if ((empty($value)) && ($country === false)) {
58 // Required field not set
65 SQL_FREERESULT($result);
72 // Generates a 'category table' for the registration form
73 function registerGenerateCategoryTable ($mode, $return=false) {
76 // Guests are mostly not interested in how many members has
77 // choosen an individual category
78 $AND = "WHERE `visible`='Y' ";
80 // Admins are allowed to see every category...
81 if (isAdmin()) $AND = '';
83 // Look for categories
84 $result = SQL_QUERY("SELECT `id`, `cat`, `visible` FROM `{?_MYSQL_PREFIX?}_cats` ".$AND." ORDER BY `sort` ASC",
85 __FUNCTION__, __LINE__);
87 if (SQL_NUMROWS($result) > 0) {
88 // List alle visible modules (or all to the admin)
90 $OUT .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
91 while ($content = SQL_FETCHARRAY($result)) {
92 // Is the array element not set?
93 if (!isPostRequestElementSet('cat', $content['id'])) {
95 setRequestPostElement('cat', array($content['id'] => ''));
98 // Prepare array for the template
101 'cat' => $content['cat'],
104 'id' => $content['id'],
107 if ((postRequestElement('cat', $content['id']) == 'Y') || ((getConfig('register_default') == 'Y') && (!isPostRequestElementSet('cat', $content['id'])))) {
108 $content['def_y'] = ' checked="checked"';
110 $content['def_n'] = ' checked="checked"';
113 // Load template and switch color
114 $OUT .= loadTemplate('guest_cat_row', true, $content);
117 $OUT .= "</table>\n";
120 SQL_FREERESULT($result);
122 // No categories setted up so far...
123 $OUT .= loadTemplate('admin_settings_saved', true, getMessage('NO_CATEGORIES_VISIBLE'));
126 if ($return === true) {
127 // Return generated HTML code
130 // Output directly (default)
135 // Outputs a 'failed message'
136 function registerOutputFailedMessage ($messageId, $extra='') {
137 if (empty($messageId)) {
138 outputHtml('<div class="register_failed">' . $extra . '</div>');
140 outputHtml('<div class="register_failed">{--' . $messageId . '--}' . $extra . '</div>');
144 // Run a filter for must-fillout fields
145 function FILTER_REGISTER_MUST_FILLOUT ($content) {
146 // Get all fields for output
147 $result = SQL_QUERY("SELECT `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC",
148 __FUNCTION__, __LINE__);
150 // Walk through all entries
151 while ($row = SQL_FETCHARRAY($result)) {
152 // Must the user fill out this element?
154 if ($row['field_required'] == 'Y') $value = "<span class=\\\"guest_failed\\\"> (*)</span>";
157 $content['must_fillout_'.strtolower($row['field_name']).''] = $value;
161 SQL_FREERESULT($result);