[svn r17075] Fixed bug in user fields, not displayed the default value in profile and add user, and you could modify this values (See FS#3307)

skala
Cristian Fasanando 17 years ago
parent 6dbfa47f8f
commit b4d8351ee7
  1. 5
      documentation/changelog.html
  2. 49
      main/admin/user_add.php
  3. 38
      main/inc/lib/usermanager.lib.php

@ -94,9 +94,10 @@
<li>Fixed bug whereby the repeated agenda items in groups were visible to all (FS#3095)</li>
<li>Fixed bug whereby e-mails sent did not have the standard syntax (SVN#16708)</li>
<li>Fixed bug whereby an empty institution name gave a useless output in the header (SVN#16710)</li>
<li>Fixed bug whereby questions ordering was broken when deleting one question in the middle (SVN#16879)</li>
<li>Fixed bug whereby questions ordering was broken when deleting one question in the middle (SVN#16879)</li>
<li>Fixed bug in user fields, not displayed the default value in profile and add user, and you could modify this values
<li>Fixed bug in link (see FS#3306)</li>
<li>Improved display of human resource manager option (see FS#3304)</li>
<li>Improved display of human resource manager option (see FS#3304)</li>
</ul>
<br />
<h3>CSS changes</h3>

@ -1,4 +1,4 @@
<?php // $Id: user_add.php 17058 2008-12-03 21:07:59Z yannoo $
<?php // $Id: user_add.php 17075 2008-12-04 22:49:14Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -188,10 +188,9 @@ $form->addGroup($group, 'max_member_group', null, '', false);
$form->addElement('radio','active',get_lang('ActiveAccount'),get_lang('Active'),1);
$form->addElement('radio','active','',get_lang('Inactive'),0);
// EXTRA FIELDS
$extra = UserManager::get_extra_fields(0,50,5,'ASC');
$extra_data = UserManager::get_extra_user_data(0,true);
foreach($extra as $id => $field_details)
{
switch($field_details[2])
@ -241,6 +240,49 @@ foreach($extra as $id => $field_details)
$form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3]);
$form->applyFilter('theme', 'trim');
break;
case USER_FIELD_TYPE_DOUBLE_SELECT:
foreach ($field_details[8] as $key=>$element)
{
if ($element[2][0] == '*')
{
$values['*'][$element[0]] = str_replace('*','',$element[2]);
}
else
{
$values[0][$element[0]] = $element[2];
}
}
$group='';
$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1],'',$values[0],'');
$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1].'*','',$values['*'],'');
$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]);
// recoding the selected values for double : if the user has selected certain values, we have to assign them to the correct select form
if (key_exists('extra_'.$field_details[1], $extra_data))
{
// exploding all the selected values (of both select forms)
$selected_values = explode(';',$extra_data['extra_'.$field_details[1]]);
$extra_data['extra_'.$field_details[1]] =array();
// looping through the selected values and assigning the selected values to either the first or second select form
foreach ($selected_values as $key=>$selected_value)
{
if (key_exists($selected_value,$values[0]))
{
$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1]] = $selected_value;
}
else
{
$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1].'*'] = $selected_value;
}
}
}
break;
case USER_FIELD_TYPE_DIVIDER:
$form->addElement('static',$field_details[1], '<br /><strong>'.$field_details[3].'</strong>');
break;
}
}
@ -258,6 +300,7 @@ $defaults['expiration_date']['F']=date('m',$time);
$defaults['expiration_date']['Y']=date('Y',$time);
$defaults['radio_expiration_date'] = 0;
$defaults['status'] = STUDENT;
$defaults = array_merge($defaults,$extra_data);
$form->setDefaults($defaults);
// Submit button
$form->addElement('submit', 'submit', get_lang('Add'));

@ -1,4 +1,4 @@
<?php // $Id: usermanager.lib.php 16750 2008-11-14 20:56:14Z yannoo $
<?php // $Id: usermanager.lib.php 17075 2008-12-04 22:49:14Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -867,6 +867,7 @@ class UserManager
{
while($rowf = Database::fetch_array($resf))
{
$fields[$rowf['id']] = array(
0=>$rowf['id'],
1=>$rowf['field_variable'],
@ -893,10 +894,11 @@ class UserManager
2=>(empty($rowo['option_display_text'])?'':$rowo['option_display_text']),
3=>$rowo['option_order']
);
}
}
}
}
}
return $fields;
}
@ -1087,26 +1089,20 @@ class UserManager
field_display_text = '".Database::escape_string($fieldtitle)."',
field_default_value = '".Database::escape_string($fielddefault)."',
tms = FROM_UNIXTIME($time)
WHERE field_id = '".Database::escape_string($fieldid)."'";
//$result = api_sql_query($sql,__FILE__,__LINE__);
WHERE id = '".Database::escape_string($fieldid)."'";
$result = api_sql_query($sql,__FILE__,__LINE__);
// we create an array with all the options (will be used later in the script)
if($fieldtype == USER_FIELD_TYPE_DOUBLE_SELECT)
{
if ($fieldtype == USER_FIELD_TYPE_DOUBLE_SELECT) {
$twolist = explode('|', $fieldoptions);
$counter = 0;
foreach ($twolist as $individual_list)
{
foreach ($twolist as $individual_list) {
$splitted_individual_list = split(';',$individual_list);
foreach ($splitted_individual_list as $individual_list_option)
{
foreach ($splitted_individual_list as $individual_list_option) {
//echo 'counter:'.$counter;
if ($counter == 0)
{
if ($counter == 0) {
$list[] = trim($individual_list_option);
}
else
{
} else {
$list[] = str_repeat('*',$counter).trim($individual_list_option);
}
}
@ -1122,6 +1118,7 @@ class UserManager
// Remove all the field options (and also the choices of the user) that are NOT in the new list of options
$sql = "SELECT * FROM $table_field_options WHERE option_value NOT IN ('".implode("','", $list)."') AND field_id = '".Database::escape_string($fieldid)."'";
$result = api_sql_query($sql,__FILE__,__LINE__);
$return['deleted_options'] = 0;
while ($row = Database::fetch_array($result))
{
// deleting the option
@ -1145,7 +1142,6 @@ class UserManager
{
$key = array_search(trim($row['option_display_text']),$list);
unset($list[$key]);
echo 'unset '.$key.$list[$key];
}
}
@ -1210,14 +1206,22 @@ class UserManager
" AND user_id=".$user_id;
$resu = api_sql_query($sqlu,__FILE__,__LINE__);
$fval = '';
// get default value
$sql_df = "SELECT field_default_value as fval_df " .
" FROM $t_uf " .
" WHERE id=".$row['id'];
$res_df = api_sql_query($sql_df,__FILE__,__LINE__);
if(Database::num_rows($resu)>0)
{
$rowu = Database::fetch_array($resu);
$rowu = Database::fetch_array($resu);
$fval = $rowu['fval'];
if($row['type'] == USER_FIELD_TYPE_SELECT_MULTIPLE)
{
$fval = split(';',$rowu['fval']);
}
} else {
$row_df = Database::fetch_array($res_df);
$fval = $row_df['fval_df'];
}
if($prefix)
{

Loading…
Cancel
Save