Beispiel #1
0
$email_text = new XoopsFormText('', 'email', 25, 60, $myts->htmlSpecialChars($email));
$email_option = new XoopsFormCheckBox('', 'user_viewemail', $user_viewemail);
$email_option->addOption(1, _US_ALLOWVIEWEMAIL);
$email_tray->addElement($email_text, true);
$email_tray->addElement($email_option);
$reg_form = new XoopsThemeForm(_US_USERREG, 'userinfo', 'register.php', 'post', true);
$uname_size = $xoopsConfigUser['maxuname'] < 25 ? $xoopsConfigUser['maxuname'] : 25;
$reg_form->addElement(new XoopsFormText(_US_NICKNAME, 'uname', $uname_size, $uname_size, $myts->htmlSpecialChars($uname)), true);
$reg_form->addElement($email_tray);
$reg_form->addElement(new XoopsFormPassword(_US_PASSWORD, 'pass', 10, 32, $myts->htmlSpecialChars($pass)), true);
$reg_form->addElement(new XoopsFormPassword(_US_VERIFYPASS, 'vpass', 10, 32, $myts->htmlSpecialChars($vpass)), true);
$reg_form->addElement(new XoopsFormText(_US_WEBSITE, 'url', 25, 255, $myts->htmlSpecialChars($url)));
$tzselected = $timezone_offset != '' ? $timezone_offset : $xoopsConfig['default_TZ'];
$reg_form->addElement(new XoopsFormSelectTimezone(_US_TIMEZONE, 'timezone_offset', $tzselected));
//$reg_form->addElement($avatar_tray);
$reg_form->addElement(new XoopsFormRadioYN(_US_MAILOK, 'user_mailok', $user_mailok));
if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') {
    $disc_tray = new XoopsFormElementTray(_US_DISCLAIMER, '<br />');
    $disc_text = new XoopsFormTextarea('', 'disclaimer', $xoopsConfigUser['reg_disclaimer'], 15, 80);
    $disc_text->setExtra('readonly="readonly"');
    $disc_tray->addElement($disc_text);
    $agree_chk = new XoopsFormCheckBox('', 'agree_disc', $agree_disc);
    $agree_chk->addOption(1, _US_IAGREE);
    $eltname = $agree_chk->getName();
    $eltmsg = str_replace('"', '\\"', stripslashes(sprintf(_FORM_ENTER, _US_IAGREE)));
    $agree_chk->customValidationCode[] = "if ( myform.{$eltname}.checked == false ) { window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }";
    $disc_tray->addElement($agree_chk, true);
    $reg_form->addElement($disc_tray);
}
$reg_form->addElement(new XoopsFormHidden('op', 'newuser'));
$reg_form->addElement(new XoopsFormButton('', 'submitButton', _US_SUBMIT, 'submit'));
function addProfileFields($form, $profileForm)
{
    // add...
    // username
    // full name
    // e-mail
    // timezone
    // password
    global $xoopsUser, $xoopsConfig, $xoopsConfigUser;
    $config_handler =& xoops_gethandler('config');
    $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
    $user_handler =& xoops_gethandler('user');
    $thisUser = $user_handler->get($profileForm);
    // initialize $thisUser
    if ($thisUser) {
        $thisUser_name = $thisUser->getVar('name', 'E');
        $thisUser_uname = $thisUser->getVar('uname');
        $thisUser_timezone_offset = $thisUser->getVar('timezone_offset');
        $thisUser_email = $thisUser->getVar('email');
        $thisUser_uid = $thisUser->getVar('uid');
        $thisUser_viewemail = $thisUser->user_viewemail();
        $thisUser_umode = $thisUser->getVar('umode');
        $thisUser_uorder = $thisUser->getVar('uorder');
        $thisUser_notify_method = $thisUser->getVar('notify_method');
        $thisUser_notify_mode = $thisUser->getVar('notify_mode');
        $thisUser_user_sig = $thisUser->getVar('user_sig', 'E');
        $thisUser_attachsig = $thisUser->getVar('attachsig');
    } else {
        // anon user
        $thisUser_name = $GLOBALS['name'];
        //urldecode($_GET['name']);
        $thisUser_uname = $GLOBALS['uname'];
        //urldecode($_GET['uname']);
        $thisUser_timezone_offset = isset($GLOBALS['timezone_offset']) ? $GLOBALS['timezone_offset'] : $xoopsConfig['default_TZ'];
        // isset($_GET['timezone_offset']) ? urldecode($_GET['timezone_offset']) : $xoopsConfig['default_TZ'];
        $thisUser_email = $GLOBALS['email'];
        //urldecode($_GET['email']);
        $thisUser_viewemail = $GLOBALS['user_viewemail'];
        //urldecode($_GET['viewemail']);
        $thisUser_uid = 0;
        $agree_disc = $GLOBALS['agree_disc'];
    }
    include_once XOOPS_ROOT_PATH . "/language/" . $xoopsConfig['language'] . "/user.php";
    $form->insertBreak(_formulize_ACTDETAILS, "head");
    // Check reg_codes module option to use email address as username
    $module_handler =& xoops_gethandler('module');
    $regcodesModule =& $module_handler->getByDirname("reg_codes");
    $regcodesConfig =& $config_handler->getConfigsByCat(0, $regcodesModule->getVar('mid'));
    // following borrowed from edituser.php
    if ($profileForm == "new") {
        // 'new' should ONLY be coming from the modified register.php file that the registration codes module uses
        // ie: we are assuming registration codes is installed
        $form->addElement(new XoopsFormHidden('userprofile_regcode', $GLOBALS['regcode']));
        $uname_size = $xoopsConfigUser['maxuname'] < 255 ? $xoopsConfigUser['maxuname'] : 255;
        $labelhelptext = _formulize_USERNAME_HELP1;
        // set it to a variable so we can test for its existence; don't want to print this stuff if there's no translation
        $labeltext = $labelhelptext == "" ? _US_NICKNAME : _US_NICKNAME . _formulize_USERNAME_HELP1 . $xoopsConfigUser['minuname'] . _formulize_USERNAME_HELP2 . $uname_size . _formulize_USERNAME_HELP3;
        if ($regcodesConfig['email_as_username'] == 0) {
            // Allow User names to be created
            $uname_label = new XoopsFormText($labeltext, 'userprofile_uname', $uname_size, $uname_size, $thisUser_uname);
            $uname_reqd = 1;
        } else {
            // Usernames are created based on email address
            $uname_label = new XoopsFormHidden('userprofile_uname', $thisUser_uname);
            $uname_reqd = 0;
        }
        $form->addElement($uname_label, $uname_reqd);
    } else {
        $uname_label = new XoopsFormLabel(_US_NICKNAME, $thisUser_uname);
        $form->addElement($uname_label);
    }
    $email_tray = new XoopsFormElementTray(_US_EMAIL, '<br />');
    if ($profileForm == "new" or $xoopsConfigUser['allow_chgmail'] == 1 && $regcodesConfig['email_as_username'] == 0) {
        $email_text = new XoopsFormText('', 'userprofile_email', 30, 255, $thisUser_email);
        $email_tray->addElement($email_text, 1);
    } else {
        $email_text = new XoopsFormLabel('', $thisUser_email);
        $email_tray->addElement($email_text);
    }
    $email_cbox_value = $thisUser_viewemail ? 1 : 0;
    $email_cbox = new XoopsFormCheckBox('', 'userprofile_user_viewemail', $email_cbox_value);
    $email_cbox->addOption(1, _US_ALLOWVIEWEMAIL);
    $email_tray->addElement($email_cbox);
    $form->addElement($email_tray, 1);
    $passlabel = $profileForm == "new" ? _formulize_TYPEPASSTWICE_NEW : _formulize_TYPEPASSTWICE_CHANGE;
    $passlabel .= $xoopsConfigUser['minpass'] . _formulize_PASSWORD_HELP1;
    $pwd_tray = new XoopsFormElementTray(_US_PASSWORD . '<br />' . $passlabel);
    $pwd_text = new XoopsFormPassword('', 'userprofile_password', 10, 32);
    $pwd_text2 = new XoopsFormPassword('', 'userprofile_vpass', 10, 32);
    $pass_required = $profileForm == "new" ? 1 : 0;
    $pwd_tray->addElement($pwd_text, $pass_required);
    $pwd_tray->addElement($pwd_text2, $pass_required);
    $form->addElement($pwd_tray, $pass_required);
    $name_text = new XoopsFormText(_US_REALNAME, 'userprofile_name', 30, 60, $thisUser_name);
    $form->addElement($name_text, 1);
    $timezone_select = new XoopsFormSelectTimezone(_US_TIMEZONE, 'userprofile_timezone_offset', $thisUser_timezone_offset);
    $form->addElement($timezone_select);
    if ($profileForm != "new") {
        $umode_select = new XoopsFormSelect(_formulize_CDISPLAYMODE, 'userprofile_umode', $thisUser_umode);
        $umode_select->addOptionArray(array('nest' => _NESTED, 'flat' => _FLAT, 'thread' => _THREADED));
        $form->addElement($umode_select);
        $uorder_select = new XoopsFormSelect(_formulize_CSORTORDER, 'userprofile_uorder', $thisUser_uorder);
        $uorder_select->addOptionArray(array(XOOPS_COMMENT_OLD1ST => _OLDESTFIRST, XOOPS_COMMENT_NEW1ST => _NEWESTFIRST));
        $form->addElement($uorder_select);
        include_once XOOPS_ROOT_PATH . "/language/" . $xoopsConfig['language'] . '/notification.php';
        include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
        $notify_method_select = new XoopsFormSelect(_NOT_NOTIFYMETHOD, 'userprofile_notify_method', $thisUser_notify_method);
        $notify_method_select->addOptionArray(array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL));
        $form->addElement($notify_method_select);
        $notify_mode_select = new XoopsFormSelect(_NOT_NOTIFYMODE, 'userprofile_notify_mode', $thisUser_notify_mode);
        $notify_mode_select->addOptionArray(array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN));
        $form->addElement($notify_mode_select);
        $sig_tray = new XoopsFormElementTray(_US_SIGNATURE, '<br />');
        include_once XOOPS_ROOT_PATH . '/include/xoopscodes.php';
        $sig_tarea = new XoopsFormDhtmlTextArea('', 'userprofile_user_sig', $thisUser_user_sig);
        $sig_tray->addElement($sig_tarea);
        $sig_cbox_value = $thisUser_attachsig ? 1 : 0;
        $sig_cbox = new XoopsFormCheckBox('', 'userprofile_attachsig', $sig_cbox_value);
        $sig_cbox->addOption(1, _US_SHOWSIG);
        $sig_tray->addElement($sig_cbox);
        $form->addElement($sig_tray);
    } else {
        // display only on new account creation...
        if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') {
            $disc_tray = new XoopsFormElementTray(_US_DISCLAIMER, '<br />');
            $disc_text = new XoopsFormTextarea('', 'disclaimer', trans($xoopsConfigUser['reg_disclaimer']), 8);
            $disc_text->setExtra('readonly="readonly"');
            $disc_tray->addElement($disc_text);
            $agree_chk = new XoopsFormCheckBox('', 'userprofile_agree_disc', $agree_disc);
            $agree_chk->addOption(1, "<span style=\"font-size: 14pt;\">" . _US_IAGREE . "</span>");
            $disc_tray->addElement($agree_chk);
            $form->addElement($disc_tray);
        }
        $form->addElement(new XoopsFormHidden("op", "newuser"));
    }
    $uid_check = new XoopsFormHidden("userprofile_uid", $thisUser_uid);
    $form->addElement($uid_check);
    $form->insertBreak(_formulize_PERSONALDETAILS, "head");
    return $form;
}