Пример #1
0
function getProfileForm($userId, $userName, $userFullname, $forEditRegistrant = false)
{
    global $urlRequestRoot, $moduleFolder, $cmsFolder, $sourceFolder, $templateFolder;
    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php";
    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformgenerate.php";
    require_once "{$sourceFolder}/upload.lib.php";
    $fakeModuleComponentId = $userId;
    $profileimgname = getUploadedFiles($fakeModuleComponentId, 'profile');
    if ($profileimgname == NULL) {
        $profileimgname = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/images/no-img.jpg";
    } else {
        $profileimgname = "./+profile&fileget={$profileimgname[0]['upload_filename']}";
    }
    $profileimg = "<img id=profileimg src='{$profileimgname}' alt='Profile Image' title='Profile Image' height=120 width=100><br/>";
    $profileimgupload = getFileUploadField('profileimage', 'profile', 512 * 1024);
    $jsValidationFunctions = array();
    $containsFileUploadFields = false;
    $dynamicFields = getFormElementsHtmlAsArray(0, $userId, $jsValidationFunctions, $containsFileUploadFields);
    $dynamicFields = join($dynamicFields, "</tr>\n<tr>");
    if ($dynamicFields != '') {
        $dynamicFields = "<tr>{$dynamicFields}</tr>";
    }
    $jsValidationFunctions = join($jsValidationFunctions, ' && ');
    $captchaValidation = '';
    if (!$forEditRegistrant) {
        $captchaQuery = 'SELECT `form_usecaptcha` FROM `form_desc` WHERE `page_modulecomponentid` = 0';
        $captchaResult = mysql_query($captchaQuery);
        $captchaRow = mysql_fetch_row($captchaResult);
        if (isset($captchaRow[0]) && $captchaRow[0] == 1) {
            $captchaValidation = getCaptchaHtml();
        }
    }
    $fValidatorPath = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/scripts/formValidator.js";
    $ValidatorPath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/form/validation.js";
    $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}";
    $formAction = './+profile';
    if ($forEditRegistrant) {
        $formAction = './+admin&subaction=editsiteregistrants&subsubaction=editregistrant';
    }
    global $ICONS;
    global $STARTSCRIPTS;
    $STARTSCRIPTS .= "document.getElementsByName('profileimage[]')[0].disabled=true;";
    $profileForm = <<<PREF

<script language="javscript" type="text/javascript" src="{$ValidatorPath}"></script>
<script language="javascript" type="text/javascript" src="{$fValidatorPath}"></script>
<link rel="stylesheet" type="text/css" media="all" href="{$calpath}/form/calendar/calendar.css" title="Aqua" />
<script language="javascript" type="text/javascript" src="{$calpath}/form/calendar/calendar.js"></script>
<script language="javascript" type="text/javascript">
\twindow.addEvent("domready", function() {
\t\tvar exValidatorA = new fValidator("registrationform");
\t});

\tfunction checkPassword(inputhandler) {
\t\tinputhandler2=document.getElementById("user_newpassword");
\t\tif(inputhandler.value!=inputhandler2.value)\t{
\t\t\talert("The password you typed in the New Password field does not match the one in the Confirmation Box.");
\t\t\tinputhandler.value="";
\t\t\tinputhandler2.value="";
\t\t\tinputhandler2.focus();
\t\t\treturn false;
\t\t}
\t\treturn true;
\t}

\tfunction checkProfileForm(inputhandler) {
\t\tif(inputhandler.user_newpassword.value.length!=0) {
\t\t\tif(inputhandler.user_password.value.length==0) {
\t\t\t\talert("Please enter your current password in order to change to a new one.");
\t\t\t\treturn false;
\t\t\t}
\t\t}

\t\tif(checkPassword(inputhandler.user_newrepassword)==false)
\t\t\treturn false;

\t\treturn {$jsValidationFunctions};
\t}
\t
\tfunction toggle_img_upform()
\t{
\t\tvar obj1=document.getElementsByName('profileimage[]')[0];
\t\tvar obj2=document.getElementById('upnewradio');
\t\tobj1.disabled=(obj2.checked==true?false:true); 
\t}
\t

</script>
<div class="cms-registrationform">
\t<form id="cms-registrationform" class="fValidator-form" method="POST" name="user_profile_usrFrm" onsubmit="return checkProfileForm(this)" action="{$formAction}" enctype="multipart/form-data">
\t\t<fieldset style="width:80%">
\t\t\t<legend>{$ICONS['User Profile']['small']}Profile Preferences</legend>

\t\t\t<table>
\t\t\t\t<tr>
\t\t\t\t<td colspan=2 style="text-align:center">{$profileimg}</td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_name" class="labelrequired">Name</label></td>
\t\t\t\t\t<td><input name="user_name" id="user_name" class="fValidate['required']" type="text" value="{$userName}"></td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_fullname" class="labelrequired">Full Name</label></td>
\t\t\t\t\t<td><input name="user_fullname" id="user_fullname" class="fValidate['required']" type="text" value="{$userFullname}"></td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td>Profile image</td>
\t\t\t\t\t<td>
\t\t\t\t\t<input type="radio" name="profileimgaction" value="usecurrent" checked onclick="toggle_img_upform()"> Use existing image<br/>
\t\t\t\t\t<input id='upnewradio' type="radio" name="profileimgaction" value="uploadnew" onclick="toggle_img_upform()"> Upload new image<br/>
\t\t\t\t\t<input type="radio" name="profileimgaction" value="noimage" onclick="toggle_img_upform()"> Remove your image
\t\t\t\t\t</td>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="profileimage">Upload new profile image (maximum size is 512 KB)</td>
\t\t\t\t\t<td>{$profileimgupload}</td>
\t\t\t\t</tr>
PREF;
    if (!$forEditRegistrant) {
        $profileForm .= <<<PREF
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_password" class="labelrequired">Current Password (Only for changing password)</label></td>
\t\t\t\t\t<td><input name="user_password" id="user_password" class="" type="password"></td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><label for="user_newpassword" class="labelrequired">New Password</label></td>
\t\t\t\t\t<td>  <input name="user_newpassword" id="user_newpassword" class="fValidate['']" type="password"></td>
\t\t\t\t</tr>
\t\t\t\t<tr> <td><label for="user_newrepassword" class="labelrequired">Re-enter New Password</label></td>
\t\t\t\t\t<td> <input name="user_newrepassword" id="user_newrepassword" class="fValidate['=user_newpassword']" type="password"></td>
\t\t\t\t</tr>
PREF;
    }
    $profileForm .= <<<PREF
\t\t\t\t\t{$dynamicFields}
\t\t\t\t\t{$captchaValidation}
\t\t\t\t<tr>
\t\t\t\t\t<td colspan="2">&nbsp;</td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td><input type="submit" name="btnSubmitProfile" id="submitbutton" value="Save Profile"></td>
\t\t\t\t\t<td></td>
\t\t\t\t</tr>
\t\t\t</table>
PREF;
    if ($forEditRegistrant) {
        $profileForm .= '<input type="hidden" name="useremail" value="' . getUserEmail($userId) . '" />';
    }
    $profileForm .= <<<PREF
\t\t</fieldset>
\t</form>
</div>
PREF;
    // TODO: implement getProfileNewsletterList completely. return $profileForm . getProfileGroupsAndFormsList($userId) . getProfileNewsletterList($userId);
    return $profileForm . getProfileForms($userId) . getProfileGroupsAndFormsList($userId) . getFormDeadlines($userId);
}
Пример #2
0
/** 
 *
 * Return the registration form for registering in the site
 *
 * @return $body A variale that containes the registration Form with all the validation constraints.
 *
 */
function getRegistrationForm()
{
    global $urlRequestRoot, $moduleFolder, $cmsFolder, $sourceFolder, $templateFolder;
    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php";
    require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformgenerate.php";
    $jsPath2 = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/form/validation.js";
    //validation.js
    $jsPath = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/formValidator.js";
    //validation.js
    $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}";
    $jsPathMooTools = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/mootools-1.11-allCompressed.js";
    $body = '<script language="javascript" type="text/javascript" src="' . $jsPath2 . '"></script>';
    $body .= '<link rel="stylesheet" type="text/css" media="all" href="' . $calpath . '/form/calendar/calendar.css" title="Aqua" />' . '<script type="text/javascript" src="' . $calpath . '/form/calendar/calendar.js"></script>';
    /// Get the CAPTCHA that is used at the end of the form.
    $captchaHtml = getCaptchaHtml();
    $jsValidationFunctions = array();
    $containsFileUploadFields = false;
    /// Get the dynamic fields that has been added to the registration form in the profile form fields.
    $dynamicFields = getFormElementsHtmlAsArray(0, 0, $jsValidationFunctions, $containsFileUploadFields);
    $dynamicFields = join($dynamicFields, "</tr>\n<tr>");
    if ($dynamicFields != '') {
        $dynamicFields = "<tr>{$dynamicFields}</tr>";
    }
    $jsValidationFunctions = join($jsValidationFunctions, ' && ');
    $email_val = "";
    $name_val = "";
    $fullname_val = "";
    if (isset($_POST['user_email'])) {
        $email_val = escape($_POST['user_email']);
    }
    if (isset($_POST['user_name'])) {
        $name_val = escape($_POST['user_name']);
    }
    if (isset($_POST['user_email'])) {
        $fullname_val = escape($_POST['user_fullname']);
    }
    $reg_str = <<<REG
<script language="javascript">
\t\t\tfunction checkPassword(inputhandler2) {
\t\t\t\tinputhandler1=inputhandler2.form.user_password;
\t\t\t\tif(inputhandler1.value!=inputhandler2.value) {
\t\t\t\t\talert("Passwords do not match");
\t\t\t\t\tinputhandler2.value="";
\t\t\t\t\tinputhandler1.value="";
\t\t\t\t\tinputhandler1.focus();
\t\t\t\t\treturn false;
\t\t\t\t}
\t\t\t\treturn true;
\t\t\t}
\t\t\tfunction checkRegistrationForm(inputhandler) {
\t\t\t\tif(inputhandler.user_password.value.length==0) {
\t\t\t\t\talert("Blank password not allowed.");
\t\t\t\t\treturn false;
\t\t\t\t}
\t\t\t\tif(inputhandler.user_name.value.length==0) {
\t\t\t\t\talert("Blank 'User name' not allowed.");
\t\t\t\t\treturn false;
\t\t\t\t}
\t\t\t\tif(inputhandler.user_fullname.value.length==0) {
\t\t\t\t\talert("Blank 'Full name' not allowed.");
\t\t\t\t\treturn false;
\t\t\t\t}
\t\t\t\treturn (checkEmail(this.user_email)&&checkPassword(this.user_repassword));
\t\t\t}
</script>
<form class="cms-registrationform"  method="POST" name="user_reg_usrFrm" onsubmit="return checkRegistrationForm(this)" action="./+login&subaction=register" enctype="multipart/form-data">
\t<fieldset>
\t<legend> Sign Up</legend>
\t\t<table border="0" cellspacing="0" cellpadding="0">
\t       <tr>\t<td><label for="user_email" class="labelrequired">Email *</label></td>
\t\t\t\t<td><input name="user_email" id="user_email" class="required" value='{$email_val}' onchange="if(this.length!=0) return checkEmail(this);" type="text"></td>
           </tr>
           <tr>\t<td><label for="user_password" class="labelrequired">Password *</label></td>
\t     \t\t<td>  <input name="user_password" id="user_password" class="required" type="password"></td>
\t     \t</tr>
\t\t\t<tr> <td><label for="user_repassword" class="labelrequired">Re-enter Password *</label></td>
\t   \t\t\t<td> <input name="user_repassword" id="user_repassword" class="required" onchange="if(this.length!=0) return checkPassword(this);" type="password"></td>
  \t\t\t</tr>
  \t\t\t<tr>
  \t\t\t\t<td><label for="user_name" class="labelrequired">User name *</label></td>
\t\t\t\t<td><input name="user_name" id="user_name" class="required" value='{$name_val}' type="text"></td>
   \t\t\t</tr>
   \t\t\t<tr>
   \t\t\t\t<td><label for="user_fullname" class="labelrequired">Full Name *</label></td>
   \t\t\t\t<td><input name="user_fullname" id="user_fullname" class="required" value='{$fullname_val}' type="text"></td>
   \t\t\t</tr>
\t\t\t{$dynamicFields}
   \t\t\t{$captchaHtml}
   \t\t\t<tr>
\t\t\t\t<td colspan="2">* - Required Fields&nbsp;</td>
\t\t\t</tr>

\t\t\t<tr>
\t\t\t\t<td><input type="submit" id="submitbutton" value="Sign Up"></td>
\t\t\t\t<td><a href="./+login&subaction=register&reSendKey=1">Resend Activation link?</a> <a href="./+login">Login?</a></td>
\t\t\t</tr>
\t\t</table>
\t</fieldset>
</form>
REG;
    $body .= $reg_str;
    $body .= <<<SCRIPT
\t\t\t<script language="javascript" type="text/javascript">
\t\t\t<!--
\t\t\t\tfunction validate_form(thisform) {
\t\t\t\t\treturn ({$jsValidationFunctions});
\t\t\t\t}
\t\t\t-->
\t\t\t</script>
SCRIPT;
    return $body;
}
Пример #3
0
/**
 * The actual registration form!!! For which we made all this preparation...
 * @param $action is the form action
 *
 * In case it is blank, it means this function was called by actionView
 * in that case, action is "."
 *
 * In case it is ./+editregistrants&subaction=editregistrant&useremail=<useremail>, it means
 * this function was called by edit registrants
 *
 * @uses getFormElementInputField to get the input fields
 *
 * TODO : If the form is associated with a group, the form HAS to give the user the option to unregister from it.
 */
function generateRegistrationForm($moduleCompId, $userId, $action = "", $disableCaptcha = false)
{
    if ($action != '') {
        $userId = getUserIdFromEmail(escape($_GET['useremail']));
    } else {
        $action = './+view';
    }
    if (!isset($userId)) {
        displayerror('Could not load information for user with e-mail address ' . safe_html(escape($_GET['useremail'])));
        return '';
    }
    /// Initialize the form body
    global $cmsFolder;
    global $moduleFolder;
    global $urlRequestRoot;
    $jsPath2 = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/form/validation.js";
    //validation.js
    $jsPath = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/formValidator.js";
    //validation.js
    $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}";
    $jsPathMooTools = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/mootools-1.11-allCompressed.js";
    $body = '<script language="javascript" type="text/javascript" src="' . $jsPath2 . '"></script>';
    /// Get HTML for all the fields for the form
    $jsValidationFunctions = array();
    $containsFileUploadFields = false;
    $formElements = getFormElementsHtmlAsArray($moduleCompId, $userId, $jsValidationFunctions, $containsFileUploadFields);
    $jsValidationFunctions = join($jsValidationFunctions, ' && ');
    $body .= '<link rel="stylesheet" type="text/css" media="all" href="' . $calpath . '/form/calendar/calendar.css" title="Aqua" />' . '<script type="text/javascript" src="' . $calpath . '/form/calendar/calendar.js"></script>';
    $body .= '<br /><br /><div class="registrationform"><form class="fValidator-form cms-registrationform" action="' . $action . '" method="post"';
    if ($containsFileUploadFields) {
        $body .= ' enctype="multipart/form-data"';
    }
    $body .= '>';
    /// SELECT form details
    $formQuery = 'SELECT `form_heading`, `form_headertext`, `form_footertext`, `form_usecaptcha` FROM `form_desc` WHERE ' . "`page_modulecomponentid` = '{$moduleCompId}'";
    $formResult = mysql_query($formQuery);
    if (!$formResult) {
        displayerror('E52 : Invalid query: ' . mysql_error());
        return false;
    }
    if ($formRow = mysql_fetch_assoc($formResult)) {
        $body .= '<fieldset><legend><h2>' . $formRow['form_heading'] . '</h2></legend><br /><div style="text-align:center;font-size:20px;">' . $formRow['form_headertext'] . '</div><br />';
    } else {
        displayerror('Could not load form data.');
        return '';
    }
    $body .= "\n<table cellspacing=\"8px\"><tr>";
    $body .= join($formElements, "</tr>\n<tr>") . '</tr>';
    if (!$disableCaptcha && $formRow['form_usecaptcha'] == 1) {
        $body .= getCaptchaHtml();
    }
    $req_query = "SELECT count(*) FROM `form_elementdesc` WHERE `form_elementisrequired`=1 AND `page_modulecomponentid`='{$moduleCompId}'";
    $res_req = mysql_fetch_array(mysql_query($req_query)) or displayerror("Error at registrationformgenerate.lib.php Line 85 " . mysql_error());
    if ($res_req[0] > 0) {
        $body .= '<tr>' . '<td colspan="2">* - Required Fields&nbsp;</td></tr>';
    }
    $body .= '</table></fieldset>' . '<br /><div style="text-align:center"><input type="submit" name="submitreg_form_' . $moduleCompId . '" value="Submit" />' . '<br /><br />' . $formRow['form_footertext'] . '</div></form></div>';
    $body .= <<<SCRIPT
\t\t\t<script language="javascript" type="text/javascript">
\t\t\t<!--
\t\t\t\tfunction validate_form(thisform) {
\t\t\t\t\treturn ({$jsValidationFunctions});
\t\t\t\t}
\t\t\t-->
\t\t\t</script>
SCRIPT;
    return $body;
}
Пример #4
0
echo $com_name;
?>
</td></tr>
<tr><td>ホームページのURL</td>
<td><input type="text" size="100" name="url_home" value="<?php 
echo $com_home;
?>
"/></td></tr>
<tr><td>時刻表のURL</td>
<td><input type="text" size="100" name="url_search" value="<?php 
echo $com_search;
?>
"/></td></tr>
<tr><td colspan="2"><div id="securimage">
<?php 
echo getCaptchaHtml($is_show_register);
?>
</div></td></tr>
<tr><td colspan="2"><input type="submit" value="登録する"></td></tr>
</table>
</form>
<?php 
if (!$is_show_register) {
    echo "--> ";
}
echo $content;
?>
<br/>
<h3>登録の手順</h3>
登録は誰でも自由に出来ます<br/>
(1) バス会社を名称から検索する<br/>