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"> </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); }
/** * 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 </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; }
function userProfileForm($userfieldprettynames, $profileInfoRows, $editID = false, $showProfileInfo = true) { $i = 0; $userinfo = "<table>"; foreach ($profileInfoRows as $field => $value) { if ($field == 'user_password') { $userinfo .= "<tr><td>{$userfieldprettynames[$i]}</td><td><input type='password' name='{$field}'/></td></tr>"; $field .= '2'; $userinfo .= "<tr><td>{$userfieldprettynames[$i++]} (Verify)</td><td><input type='password' name='{$field}'/></td></tr>"; } else { if ($field == 'user_activated') { $value = $value == 1 ? "checked" : ""; $userinfo .= "<tr><td>{$userfieldprettynames[$i++]}</td><td><input type='checkbox' name='{$field}' {$value} /></td></tr>"; } else { if ($field == 'user_loginmethod') { $ldapsel = $imapsel = $adssel = $dbsel = ""; ${$profileInfoRows[$field] . 'sel'} = " selected = 'selected' "; $userinfo .= "<tr><td>{$userfieldprettynames[$i++]}</td><td><select id='{$field}' name='{$field}'>\n\t\t\t<option></option>\n\t\t\t<option {$ldapsel}>ldap</option>\n\t\t\t<option {$imapsel}>imap</option>\n\t\t\t<option {$adssel}>ads</option>\n\t\t\t<option {$dbsel}>db</option>\n\t\t\t</select>\n\t\t\t</td></tr>"; } else { if (!$editID && $field == 'user_id' || !$editID && $field == 'user_regdate') { $userinfo .= "<tr><td>{$userfieldprettynames[$i++]}</td><td>{$value}</td></tr>"; } else { $userinfo .= "<tr><td>{$userfieldprettynames[$i++]}</td><td><input type='text' name='{$field}' value='{$value}'/></td></tr>"; } } } } } if ($showProfileInfo) { global $sourceFolder, $moduleFolder; require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php"; require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformgenerate.php"; $containsFileUploadFields = false; $userId = $profileInfoRows['user_id']; $dynamicFields = getFormElementsHtmlAsArray(0, $userId, $jsValidationFunctions, $containsFileUploadFields); $dynamicFields = join($dynamicFields, "</tr>\n<tr>"); if ($dynamicFields != '') { $dynamicFields = "<tr>{$dynamicFields}</tr>"; } $userinfo .= $dynamicFields; } return $userinfo . "</table>"; }
/** * * 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 </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; }