$onerow->name = 'input_' . $onereln['name'];
 $onerow->id = $id . $onerow->name;
 $onerow->color = '';
 $onerow->type = $defn['type'];
 $onerow->marker = '';
 $onerow->classname = $onereln['name'];
 $addtext = '';
 $onerow->hidden = RRUtils::myCreateInputHidden($id, 'feu_hidden_' . $onereln['name'], implode(';', array($onereln['name'], $defn['type'], $onereln['required'])));
 switch ($defn['type']) {
     case 0:
         // text
         $onerow->control = $this->CreateInputText($id, 'feu_' . $onerow->name, '', $defn['length'], $defn['maxlength'], $addtext);
         break;
     case 1:
         // checkbox
         $onerow->control = RRUtils::myCreateInputCheckbox($id, 'feu_' . $onerow->name, 1, 0, $addtext);
         break;
     case 2:
         // email
         $onerow->control = $this->CreateInputText($id, 'feu_' . $onerow->name, '', $defn['length'], $defn['maxlength'], $addtext);
         break;
     case 3:
         // text area
         $onerow->control = $this->CreateTextArea(false, $id, '', 'feu_' . $onerow->name);
         break;
     case 4:
         // dropdown
         $onerow->control = $this->CreateInputDropdown($id, 'feu_' . $onerow->name, $this->GetSelectOptions($defn['name'], 1), -1, -1, $addtext);
         break;
     case 5:
         $selected = explode(',', $val);
$smarty->assign('input_expireage', $this->CreateInputDropdown($id, 'input_expireage', $months, -1, $this->GetPreference('expireage_months', 260)));
$smarty->assign('prompt_sessiontimeout', $this->Lang('prompt_sessiontimeout'));
$smarty->assign('input_sessiontimeout', $this->CreateInputText($id, 'input_sessiontimeout', $this->GetPreference('user_session_expires'), 6, 6));
$smarty->assign('prompt_requireonegroup', $this->Lang('prompt_requireonegroup'));
$smarty->assign('input_requireonegroup', RRUtils::myCreateInputCheckbox($id, 'input_requireonegroup', 1, $this->GetPreference('require_onegroup')));
$smarty->assign('prompt_feusers_specific_permissions', $this->Lang('prompt_feusers_specific_permissions'));
$smarty->assign('input_feusers_specific_permissions', RRUtils::myCreateInputCheckbox($id, 'input_feusers_specific_permissions', 1, $this->GetPreference('feusers_specific_permissions')));
$smarty->assign('info_feusers_specific_permissions', $this->Lang('info_feusers_specific_permissions'));
$smarty->assign('prompt_dfltgroup', $this->Lang('prompt_dfltgroup'));
$groups1 = $this->GetGroupList();
$groups = array_merge(array("None" => -1), $groups1);
$smarty->assign('input_dfltgroup', $this->CreateInputDropDown($id, 'input_dfltgroup', $groups, -1, $this->GetPreference('default_group')));
$smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', $this->Lang('submit'), '', '', $this->Lang('confirm_submitprefs')));
$smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', $this->Lang('cancel')));
$smarty->assign('prompt_allow_repeated_logins', $this->Lang('prompt_allow_repeated_logins'));
$smarty->assign('input_allow_repeated_logins', RRUtils::myCreateInputCheckbox($id, 'input_allow_repeated_logins', 1, $this->GetPreference('allow_repeated_logins')));
$smarty->assign('prompt_image_destination_path', $this->Lang('prompt_image_destination_path'));
$smarty->assign('input_image_destination_path', $this->CreateInputText($id, 'input_image_destination_path', $this->GetPreference('image_destination_path'), 40));
$smarty->assign('prompt_allowed_image_extensions', $this->Lang('prompt_allowed_image_extensions'));
$smarty->assign('input_allowed_image_extensions', $this->CreateInputText($id, 'input_allowed_image_extensions', $this->GetPreference('allowed_image_extensions'), 40, 40));
$notification_list = array();
$notification_list[$this->Lang('OnLogin')] = 'OnLogin';
$notification_list[$this->Lang('OnLogout')] = 'OnLogout';
$notification_list[$this->Lang('OnExpireUser')] = 'OnExpireUser';
$notification_list[$this->Lang('OnCreateUser')] = 'OnCreateUser';
$notification_list[$this->Lang('OnDeleteUser')] = 'OnDeleteUser';
$notification_list[$this->Lang('OnUpdateUser')] = 'OnUpdateUser';
$notification_list[$this->Lang('OnCreateGroup')] = 'OnCreateGroup';
$notification_list[$this->Lang('OnUpdateGroup')] = 'OnUpdateGroup';
$notification_list[$this->Lang('OnDeleteGroup')] = 'OnDeleteGroup';
$smarty->assign('prompt_notifications', $this->Lang('prompt_notifications'));
            $parms['end_year'] = is_array($attribs) && isset($attribs['endyear']) ? $attribs['endyear'] : "+10";
            $str = '{html_select_date ';
            foreach ($parms as $key => $value) {
                $str .= $key . '="' . $value . '" ';
            }
            $str .= '}';
            $onerow->control = $this->ProcessTemplateFromData($str);
            break;
    }
    $rowarray[] = $onerow;
}
if (isset($params['input_username'])) {
    $smarty->assign('edittext', $this->Lang('editing_user'));
    $smarty->assign('username', trim($params['input_username']));
}
$smarty->assign('hidden', RRUtils::myCreateInputHidden($id, 'step1_params', $params));
$smarty->assign('controls', $rowarray);
$smarty->assign('controlcount', count($rowarray));
$smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', $this->Lang('submit')));
$smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', $this->Lang('cancel')));
$smarty->assign('back', $this->CreateInputSubmit($id, 'back', $this->Lang('back')));
if (isset($params['user_id'])) {
    $smarty->assign('title', $this->Lang('edituser'));
    $smarty->assign('hidden2', $this->CreateInputHidden($id, 'user_id', $params['user_id']));
    $smarty->assign('startform', $this->CreateFormStart($id, 'do_edituser3', $returnid, 'post', 'multipart/form-data'));
} else {
    $smarty->assign('title', $this->Lang('adduser'));
    $smarty->assign('startform', $this->CreateFormStart($id, 'do_adduser3', $returnid, 'post', 'multipart/form-data'));
}
$smarty->assign('endform', $this->CreateFormEnd());
echo $this->ProcessTemplate('adduser2.tpl');
    $this->_DisplayErrorPage($id, $params, $returnid, $result[1]);
    return;
}
$smarty->assign('userinfo', $userinfo[1]);
$smarty->assign('email_address', $this->GetEmail($uid));
$groups = $this->GetMemberGroupsArray($uid);
if (!$groups) {
    // This user isn't a member of any groups
    return;
}
// now we have the groups, we build a union of all of the groups properties
$prop2 = array();
foreach ($groups as $grprecord) {
    $gid = $grprecord['groupid'];
    $proprelations = $this->GetGroupPropertyRelations($gid);
    $prop2 = RRUtils::array_merge_by_name_required($prop2, $proprelations);
    uasort($prop2, array('cge_array', 'compare_elements_by_sortorder_key'));
}
// now we merge in all of the property definitions
$defns = $this->GetPropertyDefns();
$prop3 = array();
foreach ($prop2 as $oneprop) {
    foreach ($defns as $onedefn) {
        if ($onedefn['name'] == $oneprop['name']) {
            $oneprop['prompt'] = $onedefn['prompt'];
            $oneprop['type'] = $onedefn['type'];
            break;
        }
    }
    $prop3[] = $oneprop;
}
 public static function myCreateInputHidden($id, $name, $value = '', $addtext = '', $delim = ',')
 {
     if (is_array($value)) {
         $val = RRUtils::implode_with_key($value);
     } else {
         $val = $value;
     }
     $val = str_replace('"', '"', $val);
     $text = '<input type="hidden" name="' . $id . $name . '" value="' . $val . '"';
     if ($addtext != '') {
         $text .= ' ' . $addtext;
     }
     $text .= " />\n";
     return $text;
 }
if (isset($params['cancel'])) {
    $this->RedirectToTab($id, 'users');
}
$user_id = (int) $params['user_id'];
// get field definitions.
$defns = $this->GetPropertyDefns();
// get the property relations for the selected group(s).
$parms1 = cge_array::explode_with_key($params['step1_params']);
$groupprops = array();
$groupids = array();
foreach ($parms1 as $key => $value) {
    if (startswith($key, 'memberof_')) {
        $gid = (int) substr($key, strlen('memberof_'));
        $groupids[] = $gid;
        $relns = $this->GetGroupPropertyRelations($gid);
        $groupprops = RRUtils::array_merge_by_name_required($groupprops, $relns);
        uasort($groupprops, array('cge_array', 'compare_elements_by_sortorder_key'));
    }
}
$groupprops = cge_array::to_hash($groupprops, 'name');
// get the field info
$fieldlist = array();
foreach ($params as $k => $v) {
    if (preg_match('/^hidden_/', $k)) {
        $fldname = substr($k, strlen('hidden_'));
        $fieldlist[$fldname] = $v;
    }
}
// now merge form values for each of the fields
foreach ($groupprops as $fldname => $reln) {
    $v = '';
 function GetUserPropertyRelations($uid)
 {
     $groups = $this->GetMemberGroupsArray($uid);
     if (!is_array($groups) || count($groups) == 0) {
         return;
     }
     $uprops = array();
     for ($a = 0; $a < count($groups); $a++) {
         $gid = $groups[$a]['groupid'];
         $relns = $this->GetGroupPropertyRelations($gid);
         $uprops = RRUtils::array_merge_by_name_required($uprops, $relns);
         usort($uprops, array('cge_array', 'compare_elements_by_sortorder_key'));
     }
     return $uprops;
 }