Commit 8371dc7a authored by michael_davey's avatar michael_davey

make use of new fields in new tiki_registration_fields table
parent be543560
......@@ -16,7 +16,7 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
exit;
}
require_once('lib/tikilib.php'); # httpScheme()
require_once('lib/tikilib.php'); # httpScheme(), get_user_preference
require_once('lib/webmail/tikimaillib.php');
if (!isset($Debug)) $Debug = false;
......@@ -152,15 +152,19 @@ class RegistrationLib extends TikiLib {
}
function get_customfields() {
$query = "select `id`, `field` as `value`, `name` as `prefName` from `tiki_registration_fields`";
$result = $this->query($query);
$ret = array();
function get_customfields($user=false) {
global $tikilib;
$query = "select `id`, `field` as `prefName`, `name` as `label`, `type`, `show`, `size` from `tiki_registration_fields`";
$result = $this->query($query);
$ret = array();
while ($res = $result->fetchRow()) {
$ret[] = $res;
}
return $ret;
while ($res = $result->fetchRow()) {
if ($user) {
$res['value'] = $tikilib->get_user_preference($user, $res['prefName'], '');
}
$ret[] = $res;
}
return $ret;
}
/**
......
......@@ -37,9 +37,11 @@
{* Custom fields *}
{section name=ir loop=$customfields}
<tr><td class="form">{tr}{$customfields[ir].prefName}{/tr}:</td>
<td class="form"><input type="text" name="{$customfields[ir].prefName}" value="{$customfields[ir].value}" /></td>
{if $customfields[ir].show}
<tr><td class="form">{tr}{$customfields[ir].label}{/tr}:</td>
<td class="form"><input type="{$customfields[ir].type}" name="{$customfields[ir].prefName}" value="{$customfields[ir].value}" size="{$customfields[ir].size}" /></td>
</tr>
{/if}
{/section}
<tr><td class="formcolor">&nbsp;</td><td class="formcolor"><input type="submit" name="register" value="{tr}register{/tr}" /></td></tr>
......@@ -51,4 +53,4 @@
<tr><td class="formcolor"><a class="link" href="javascript:genPass('genepass','pass1','pass2');">{tr}Generate a password{/tr}</a></td>
<td class="formcolor"><input id='genepass' type="text" /></td></tr>
</table>
{/if}
\ No newline at end of file
{/if}
......@@ -22,7 +22,9 @@
{* Custom fields *}
{section name=ir loop=$customfields}
<tr><td class="form">{tr}{$customfields[ir].prefName}{/tr}:</td><td>{$customfields[ir].value}</td></tr>
{if $customfields[ir].show}
<tr><td class="form">{tr}{$customfields[ir].label}{/tr}:</td><td>{$customfields[ir].value}</td></tr>
{/if}
{/section}
<tr><td class="form">{tr}Avatar{/tr}:</td><td>{$avatar}</td></tr>
......
......@@ -94,9 +94,11 @@
{* Custom fields *}
{section name=ir loop=$customfields}
<tr><td class="form">{$customfields[ir].prefName}:</td>
<td class="form"><input type="text" name="{$customfields[ir].prefName}" value="{$customfields[ir].value}" /></td>
{if $customfields[ir].show}
<tr><td class="form">{$customfields[ir].label}:</td>
<td class="form"><input type="{$customfields[ir].type}" name="{$customfields[ir].prefName}" value="{$customfields[ir].value}" size="{$customfields[ir].size}" /></td>
</tr>
{/if}
{/section}
<tr><td colspan="2" class="button"><input type="submit" name="info" value="{tr}Change information{/tr}" /></td></tr>
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-user_information.php,v 1.31 2005-09-23 08:35:04 michael_davey Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-user_information.php,v 1.32 2005-09-23 10:39:16 michael_davey Exp $
// Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -30,11 +30,7 @@ $smarty->assign('userwatch', $userwatch);
// Custom fields
$customfields = array();
$customfields = $registrationlib->get_customfields();
foreach ($customfields as $custpref=>$prefvalue ) {
$customfields[$custpref]['value'] = $tikilib->get_user_preference($userwatch, $customfields[$custpref]['prefName'], $customfields[$custpref]['value']);
}
$customfields = $registrationlib->get_customfields($userwatch);
$smarty->assign_by_ref('customfields', $customfields);
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-user_preferences.php,v 1.74 2005-09-23 08:35:04 michael_davey Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-user_preferences.php,v 1.75 2005-09-23 10:39:16 michael_davey Exp $
// Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
......@@ -29,11 +27,6 @@ if (!$user) {
$userwatch = $user;
// Custom fields
$customfields = array();
$customfields = $registrationlib->get_customfields();
$smarty->assign_by_ref('customfields', $customfields);
if (isset($_REQUEST["view_user"])) {
if ($_REQUEST["view_user"] <> $user) {
if ($tiki_p_admin == 'y') {
......@@ -49,6 +42,11 @@ if (isset($_REQUEST["view_user"])) {
}
}
// Custom fields
$customfields = array();
$customfields = $registrationlib->get_customfields($userwatch);
$smarty->assign_by_ref('customfields', $customfields);
$smarty->assign('userwatch', $userwatch);
$foo = parse_url($_SERVER["REQUEST_URI"]);
......@@ -127,13 +125,6 @@ if (isset($_REQUEST["prefs"])) {
$tikilib->set_user_preference($userwatch, 'mailCharset', $_REQUEST['mailCharset']);
// Custom fields
foreach ($customfields as $custpref=>$prefvalue ) {
//print $customfields[$custpref]['prefName'];
//print $_REQUEST[$customfields[$custpref]['prefName']];
$tikilib->set_user_preference($userwatch, $customfields[$custpref]['prefName'], $_REQUEST[$customfields[$custpref]['prefName']]);
}
header ("location: tiki-user_preferences.php?view_user=$userwatch");
die;
}
......@@ -169,6 +160,13 @@ if (isset($_REQUEST['info'])) {
$tikilib->set_user_preference($userwatch, 'lon', $lon);
}
// Custom fields
foreach ($customfields as $custpref=>$prefvalue ) {
// print $customfields[$custpref]['prefName'];
// print $_REQUEST[$customfields[$custpref]['prefName']];
$tikilib->set_user_preference($userwatch, $customfields[$custpref]['prefName'], $_REQUEST[$customfields[$custpref]['prefName']]);
}
$tikilib->set_user_preference($userwatch, 'country', $_REQUEST["country"]);
$cookietab = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment