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 - 2008 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')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
46 function REGISTER_FILL_MUST_CONSTANTS () {
47 $result = SQL_QUERY("SELECT field_name, field_required FROM `{!_MYSQL_PREFIX!}_must_register` ORDER BY `id`",
48 __FUNCTION__, __LINE__);
50 while ($content = SQL_FETCHARRAY($result)) {
52 if ($content['field_required'] == "Y") $value = "<div class=\\\"guest_failed\\\"> (*)</div>";
53 // @TODO Rewrite these constants
54 $eval = "define('MUST_".strtoupper($content['field_name'])."', \"".$value."\");";
59 SQL_FREERESULT($result);
61 // Also fill other constants
62 define('MUST_GENDER', "<div class=\"guest_failed\"> (*)</div>");
63 define('MUST_ADDY' , "<div class=\"guest_failed\"> (*)</div>");
64 define('MUST_BIRTH' , "<div class=\"guest_failed\"> (*)</div>");
65 define('MUST_MARKER', "<div class=\"guest_failed\"> (*)</div>");
69 function REGISTER_CHECK_REQUIRED_FIELDS (&$array) {
71 foreach ($array as $key => $value) {
72 $result = SQL_QUERY("SELECT field_required FROM `{!_MYSQL_PREFIX!}_must_register` WHERE field_name='".$key."' LIMIT 1",
73 __FUNCTION__, __LINE__);
74 if (SQL_NUMROWS($result) == 1) {
76 list($chk) = SQL_FETCHROW($result);
78 // Check if extension country is not found (you have to enter the 2-chars long country code) or
79 // if extensions is present check if country code was selected
80 // 01 2 21 12 3 32 234 5 54 4 43 34 4 4 5 5432 2 3 3210
81 $country = ((!EXT_IS_ACTIVE("country")) || ((EXT_IS_ACTIVE("country")) && (((empty($value)) && ($key == "cntry")) || (($key == "country_code") && (!empty($value)))) && (!empty($array['country_code']))));
82 if ((empty($value)) && ($chk == "Y") && (!$country))
84 // Required field not set
91 SQL_FREERESULT($result);
97 function REGISTER_OUTPUT_REQUIRE_CHECK (&$array) {
98 $result = SQL_QUERY("SELECT field_name, field_required FROM `{!_MYSQL_PREFIX!}_must_register` ORDER BY `id`", __FUNCTION__, __LINE__);
99 while ($content = SQL_FETCHARRAY($result)) {
100 if (($array[$content['field_name']] == "!") && ($content['field_required'] == "Y")) {
102 $array[$content['field_name']] = "";
103 $OUT = constant('REGISTER_'.strtoupper($content['field_name']).'_REQUIRED');
104 OUTPUT_HTML("<div class=\"register_failed\">".$OUT."</div>");
109 SQL_FREERESULT($result);
113 function REGISTER_ADD_CATEGORY_TABLE ($MODE, $return=false) {
116 // Guests are mostly not interested in how many members has
117 // choosen an individual category
118 $AND = "WHERE `visible`='Y' ";
120 // Admins are allowed to see every category...
121 if (IS_ADMIN()) $AND = "";
123 // Look for categories
124 $result = SQL_QUERY("SELECT id, cat, visible FROM `{!_MYSQL_PREFIX!}_cats` ".$AND." ORDER BY `sort`",
125 __FUNCTION__, __LINE__);
127 if (SQL_NUMROWS($result) > 0) {
128 // List alle visible modules (or all to the admin)
130 $OUT .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
131 while ($content = SQL_FETCHARRAY($result)) {
132 // Is the array element not set?
133 if (!REQUEST_ISSET_POST('cat', $content['id'])) {
135 REQUEST_SET_POST(array('cat', $content['id']), "");
138 // Prepare array for the template
141 'cat' => $content['cat'],
144 'id' => $content['id'],
147 if ((REQUEST_POST('cat', $content['id']) == "Y") || ((getConfig('register_default') == "Y") && (!REQUEST_ISSET_POST('cat', $content['id'])))) {
148 $content['def_y'] = " checked=\"checked\"";
150 $content['def_n'] = " checked=\"checked\"";
153 // Load template and switch color
154 $OUT .= LOAD_TEMPLATE("guest_cat_row", true, $content);
157 $OUT .= "</table>\n";
160 SQL_FREERESULT($result);
162 // No categories setted up so far...
163 $OUT .= LOAD_TEMPLATE("admin_settings_saved", true, getMessage('NO_CATEGORIES_VISIBLE'));
166 if ($return === true) {
167 // Return generated HTML code
170 // Output directly (default)