Create new User field
Geschrieben von gozoc am 23. Juni 2009 15:15
<?php
/*---------------------------------------------------------+
| BS-Fusion - Content Management System
| Version 1.00.x
+----------------------------------------------------------+
| Copyright © 2009 Manuel Kurz
| http://www.bs-fusion.org/
+----------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license (version 3). You can redistribute
| it and/or modify it under the terms of this license which
| you can read by viewing the included agpl-3.0.txt or
| online at http://www.gnu.org/licenses/agpl-3.0.html.
| Removal of this copyright header is strictly prohibited
| without written permission from the original author(s).
+----------------------------------------------------------+
| Code based on PHP-Fusion
| http://www.php-fusion.co.uk/
+----------------------------------------------------------*/
if (!defined("IN_FUSION")) exit;

// for admin data
$uf_name=$locale['uf_user_feldname_name'];
$uf_desc=$locale['uf_user_feldname_desc'];

// table field name
$uf_dbfield="user_feldname"; // The user_ prefix must be maintained

// table field properties
$uf_dbdata="VARCHAR(16) NOT NULL DEFAULT ''";

// Leave blank if no table field must be created.
//If this line is filled, a table field in the table DB_PREFIX_users inserted.
// field to where
$uf_group=2;
// 1 = Information, 2=Contact, 3=Other Informations

// Required field ??
$uf_user_feldname_mandory=0; // 0=No, 1=Yes


switch($uf_methode) {
########## Display in Userprofil #############
case 'display':
if ($data['user_feldname']!='') {
// Number of array is Userfieldgroup
$uf_display[$uf_group].='<tr><td width="35%">'.$locale['uf_user_feldname'].':</td><td> '.$data['user_feldname'].'</td></tr>';
}
break;

############# Display in membersadmin ##############
case 'admin':
// Number of array is Userfieldgroup
$uf_display[$uf_group].="<tr>
<td class='tbl1' align='left' style='width:30%;'>".$locale['uf_user_feldname'].(!$uf_user_feldname_mandory ? '' : '<span style="color:#ff0000">*</span>').":</td>
<td class='tbl2' align='left'><input type='text' name='user_feldname' class='textbox' value='".$data['user_feldname']."' style='width:200px;'></td>
</tr>";
break;

############### Display in edit_profile.php ###########
case 'input':
// Number of array is Userfieldgroup
$uf_display[$uf_group].="<tr>
<td class='tbl1' align='left' style='width:30%;'>".$locale['uf_user_feldname'].(!$uf_user_feldname_mandory ? '' : '<span style="color:#ff0000">*</span>').":</td>
<td class='tbl2' align='left'><input type='text' name='user_feldname' class='textbox' value='".$userdata['user_feldname']."' style='width:200px;'></td>
</tr>";
break;

########### Display in register.php #############
case 'register':
// if required field
if ($uf_user_feldname_mandory) {
$uf_display[0].="<tr>
<td class='tbl1' align='left' style='width:30%;'>".$locale['uf_user_feldname'].(!$uf_user_feldname_mandory ? '' : '<span style="color:#ff0000">*</span>').":</td>
<td class='tbl2' align='left'><input type='text' name='user_feldname' class='textbox' style='width:200px;'></td>
</tr>";
} else {
$uf_display[$uf_group].="<tr>
<td class='tbl1' align='left' style='width:30%;'>".$locale['uf_user_feldname'].":</td>
<td class='tbl2' align='left'><input type='text' name='user_feldname' class='textbox' style='width:200px;'></td>
</tr>";
}
$javascript.=$uf_user_feldname_mandory?"if(frm.user_feldname.value=='') {alert('".$locale['uf_user_feldname_mandory']."');
return false;}":"";
break;

################ Check the data ############
case 'validate_update':
$user_feldname = isset($_POST['user_feldname']) && strlen($_POST['user_feldname'])<=16 ? stripinput(trim($_POST['user_feldname'])) : '';
if ($uf_user_feldname_mandory && $user_feldname=='' && !iADMIN) {
$error.=$locale['uf_user_feldname_mandory'];
}
$usr_db_values.=",user_feldname='".$user_feldname."'";
break;

########### Check new entry ############
case 'validate_insert':
$user_aim = isset($_POST['user_feldname']) && strlen($_POST['user_feldname'])<=16 ? stripinput(trim($_POST['user_feldname'])) : '';
if ($uf_user_feldname_mandory && $user_feldname=='') {
$error.=$locale['uf_user_feldname_mandory'];
}
$usr_db_fields.= ',user_feldname;
$usr_db_values.= ",'".$user_feldname."'";
$usr_register[] = array("user_feldname"=>$user_feldname);
break;
default:
break;
}

################## Important ########################
feldname -> must be selected and used in all areas of this file

/**
The file must be saved under user_feldname.php in
/includes/userfields/ directory .

The languages should be included in definitions of the language file
/locale/your_language/userfields.php .

If your cms in multilingual mode, you have to adjust the language variables in all the different language userfields.php (in language directories).

About the admin area you can then decide, whether there is a registration field or not.
**/
?>