function setValidationUTables(&$js, $lNumTables, &$utables) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $CI =& get_instance(); if ($lNumTables == 0) { return; } foreach ($utables as $utable) { foreach ($utable->ufields as $ufield) { $enumType = $ufield->enumFieldType; $strFN = $ufield->strFieldNameInternal; $strFNLabel = htmlspecialchars($ufield->strFieldNameUser); $bRequired = $ufield->bRequired; switch ($enumType) { case CS_FT_CHECKBOX: $CI->form_validation->set_rules($strFN, $strFNLabel, 'trim'); $ufield->bChecked = false; break; case CS_FT_DATE: cusFormSetValDate(true, $bRequired, $strFN, $strFNLabel, true); break; case CS_FT_TEXT255: case CS_FT_TEXT80: case CS_FT_TEXT20: case CS_FT_TEXTLONG: $CI->form_validation->set_rules($strFN, $strFNLabel, 'trim' . ($bRequired ? '|required' : '')); $ufield->txtValue = ''; break; case CS_FT_INTEGER: $CI->form_validation->set_rules($strFN, $strFNLabel, 'trim|integer' . ($bRequired ? '|required' : '')); $ufield->txtValue = ''; break; case CS_FT_CURRENCY: $CI->clsACO->loadCountries(true, true, true, $ufield->lCurrencyACO); $country = $CI->clsACO->countries[0]; $ufield->strCurrencySymbol = $country->strCurrencySymbol; $ufield->strFlagImg = $country->strFlagImg; $CI->form_validation->set_rules($strFN, $strFNLabel, 'callback_verifyCurrency[' . ($bRequired ? 'true' : 'false') . ', ' . $strFN . ', ' . $strFNLabel . ']'); break; case CS_FT_DDL: $CI->form_validation->set_rules($strFN, $strFNLabel, 'callback_verifyDDLSelect[' . ($bRequired ? 'true' : 'false') . ', ' . $strFN . ', ' . $strFNLabel . ']'); break; case CS_FT_DDLMULTI: //echo(__FILE__.' '.__LINE__.'<br>'."\n"); $CI->form_validation->set_rules($strFN, $strFNLabel, 'callback_verifyDDLMultiSelect[' . ($bRequired ? 'true' : 'false') . ', ' . $strFN . ', ' . $strFNLabel . ']'); break; } } } }
function regForm($strHash) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- global $gbDev; global $gclsChapter, $glChapterID, $gbDateFormatUS, $gclsChapterACO; global $gErrMessages; global $gclsChapterVoc; $displayData = array(); $displayData['js'] = ''; $gErrMessages = array(); // load models & helpers $this->load->model('vol_reg/mvol_reg', 'volReg'); $this->load->model('admin/madmin_aco', 'clsACO'); $this->load->model('img_docs/mimage_doc', 'clsImgDoc'); $this->load->model('personalization/muser_fields', 'clsUF'); $this->load->model('admin/mpermissions', 'perms'); $this->load->model('util/mcaptcha', 'clsCaptcha'); $this->load->library('util/dl_date_time', '', 'clsDateTime'); $this->load->helper('img_docs/image_doc'); $this->load->helper('img_docs/link_img_docs'); $this->load->helper('dl_util/time_date'); $this->load->helper('email'); $this->load->helper('captcha'); $this->load->helper('dl_util/custom_forms'); $displayData['formData'] = new stdClass(); $displayData['title'] = 'Volunteer Registration'; if (!$this->verifyHash($strHash, $displayData, $lFormID)) { return; } $rRec =& $displayData['rRec']; $displayData['bCreateAcct'] = $bCreateAcct = $rRec->bPermEditContact || $rRec->bPermPassReset || $rRec->bPermViewGiftHistory || $rRec->bPermEditJobSkills || $rRec->bPermViewHrsHistory || $rRec->bPermAddVolHours || $rRec->bVolShiftSignup; //----------------------------- // validation rules //----------------------------- $this->form_validation->set_error_delimiters('<div class="formError">', '</div>'); $this->setValText($rRec->bShowFName, $rRec->bFNameRequired, 'txtFName', 'First Name'); $this->setValText($rRec->bShowLName, $rRec->bLNameRequired, 'txtLName', 'Last Name'); $this->setValText($rRec->bShowAddr, $rRec->bAddrRequired, 'txtAddr1', 'Address'); $this->setValText($rRec->bShowAddr, false, 'txtAddr2', 'Address 2'); $this->setValText($rRec->bShowAddr, $rRec->bAddrRequired, 'txtCity', 'City'); $this->setValText($rRec->bShowAddr, $rRec->bAddrRequired, 'txtState', 'State'); $this->setValText($rRec->bShowAddr, $rRec->bAddrRequired, 'txtZip', 'Zip'); $this->setValText($rRec->bShowAddr, $rRec->bAddrRequired, 'txtCountry', 'Country'); if ($rRec->bShowEmail) { if ($rRec->bEmailRequired) { $this->form_validation->set_rules('txtEmail', 'Email', 'required|callback_verifyEmail'); } else { $this->form_validation->set_rules('txtEmail', 'Email', 'callback_verifyEmail'); } } $this->setValText($rRec->bShowPhone, $rRec->bPhoneRequired, 'txtPhone', 'Phone'); $this->setValText($rRec->bShowCell, $rRec->bCellRequired, 'txtCell', 'Cell'); cusFormSetValDate($rRec->bShowBDay, $rRec->bBDateRequired, 'txtBDate', 'Birth Date', false); if ($rRec->bDisclaimerAckRqrd) { $this->form_validation->set_rules('chkDisclaimer', 'Disclaimer', 'callback_verifyDisclaimer'); } if ($rRec->bCaptchaRequired) { $this->form_validation->set_rules('txtCaptcha', 'Captcha', 'callback_verifyCaptcha'); } if ($bCreateAcct) { $this->form_validation->set_rules('txtPWord1', 'Password', 'callback_verifyPWords'); $this->form_validation->set_rules('txtPWord2', 'Password', 'trim'); } // basic info $displayData['basicInfo'] = array(); $this->setBasicInfo($displayData['basicInfo'][0], 'First Name', $rRec->bShowFName, $rRec->bFNameRequired, 'txtFName', 40, 80); $this->setBasicInfo($displayData['basicInfo'][1], 'Last Name', $rRec->bShowLName, $rRec->bLNameRequired, 'txtLName', 40, 80); $this->setBasicInfo($displayData['basicInfo'][2], 'Address', $rRec->bShowAddr, $rRec->bAddrRequired, 'txtAddr1', 40, 80); $this->setBasicInfo($displayData['basicInfo'][3], 'Address 2', $rRec->bShowAddr, false, 'txtAddr2', 40, 80); $this->setBasicInfo($displayData['basicInfo'][4], 'City', $rRec->bShowAddr, $rRec->bAddrRequired, 'txtCity', 20, 80); $this->setBasicInfo($displayData['basicInfo'][5], $gclsChapterVoc->vocState, $rRec->bShowAddr, $rRec->bAddrRequired, 'txtState', 20, 80); $this->setBasicInfo($displayData['basicInfo'][6], $gclsChapterVoc->vocZip, $rRec->bShowAddr, $rRec->bAddrRequired, 'txtZip', 20, 40); $this->setBasicInfo($displayData['basicInfo'][7], 'Country', $rRec->bShowAddr, $rRec->bAddrRequired, 'txtCountry', 20, 80); $this->setBasicInfo($displayData['basicInfo'][8], 'Email', $rRec->bShowEmail, $rRec->bEmailRequired, 'txtEmail', 40, 120); $this->setBasicInfo($displayData['basicInfo'][9], 'Phone', $rRec->bShowPhone, $rRec->bPhoneRequired, 'txtPhone', 20, 40); $this->setBasicInfo($displayData['basicInfo'][10], 'Cell', $rRec->bShowCell, $rRec->bCellRequired, 'txtCell', 20, 40); // job skills $this->volReg->loadVolRegFormSkills($lFormID, false); $displayData['lNumSkills'] = $lNumSkills = $this->volReg->lOnFormSkills; $displayData['skills'] = $jobSkills = arrayCopy($this->volReg->skills); $skills =& $displayData['skills']; if ($lNumSkills > 0) { foreach ($skills as $skill) { $skill->bChecked = false; $skill->checkFN = $strChkFN = 'chkJobSkill_' . $skill->lKeyID; $this->form_validation->set_rules($strChkFN, 'Job Skill', 'trim'); $displayData['formData']->txtPWord1 = $displayData['formData']->txtPWord2 = ''; } } // personalized tables and associated fields $this->volReg->loadPTablesForDisplay($lFormID, $this->clsUF); $displayData['utables'] = $utables =& $this->volReg->utables; $displayData['lNumTables'] = $lNumTables = $this->volReg->lNumTables; setValidationUTables($displayData['js'], $lNumTables, $utables); if ($this->form_validation->run() == FALSE) { $this->load->library('generic_form'); $this->load->model('util/mlist_generic', 'clsList'); $this->load->helper('dl_util/web_layout'); $displayData['strHash'] = $strHash; $this->volReg->setLogoImageTag(); // captcha setup if ($rRec->bCaptchaRequired) { $this->initCaptcha($displayData['imgCaptcha']); } if ($rRec->bShowBDay) { $displayData['js'] .= strDatePicker('datepickerBDate', false); } initUTableDates($displayData['js'], $lNumTables, $utables); initUTableDDLs($lNumTables, $utables); if (validation_errors() == '') { // basic info $displayData['basicInfo'][0]->value = $displayData['basicInfo'][1]->value = $displayData['basicInfo'][2]->value = $displayData['basicInfo'][3]->value = $displayData['basicInfo'][4]->value = $displayData['basicInfo'][5]->value = $displayData['basicInfo'][6]->value = $displayData['basicInfo'][7]->value = $displayData['basicInfo'][8]->value = $displayData['basicInfo'][9]->value = $displayData['basicInfo'][10]->value = ''; $displayData['formData']->txtBDate = ''; if ($rRec->bDisclaimerAckRqrd) { $rRec->bDisclaimerChecked = false; } // job skills if ($lNumSkills > 0) { foreach ($skills as $skill) { $skill->bChecked = false; } } // personalized tables setCustomUTableDDLs($lNumTables, $utables); } else { setOnFormError($displayData); $displayData['basicInfo'][0]->value = set_value('txtFName'); $displayData['basicInfo'][1]->value = set_value('txtLName'); $displayData['basicInfo'][2]->value = set_value('txtAddr1'); $displayData['basicInfo'][3]->value = set_value('txtAddr2'); $displayData['basicInfo'][4]->value = set_value('txtCity'); $displayData['basicInfo'][5]->value = set_value('txtState'); $displayData['basicInfo'][6]->value = set_value('txtZip'); $displayData['basicInfo'][7]->value = set_value('txtCountry'); $displayData['basicInfo'][8]->value = set_value('txtEmail'); $displayData['basicInfo'][9]->value = set_value('txtPhone'); $displayData['basicInfo'][10]->value = set_value('txtCell'); $displayData['formData']->txtBDate = set_value('txtBDate'); if (form_error('txtPWord1') == '') { $displayData['formData']->txtPWord1 = $displayData['formData']->txtPWord2 = set_value('txtPWord1'); } else { $displayData['formData']->txtPWord1 = $displayData['formData']->txtPWord2 = ''; } if ($rRec->bDisclaimerAckRqrd) { $rRec->bDisclaimerChecked = set_value('chkDisclaimer') == 'true'; } // job skills if ($lNumSkills > 0) { foreach ($skills as $skill) { $skill->bChecked = set_value($skill->checkFN) == 'true'; } } // personalized tables repopulateCustomTables($lNumTables, $utables); } //-------------------------- // breadcrumbs //-------------------------- $displayData['strOrg'] = $this->clsChapter->chapterRec->strChapterName; $displayData['errMessages'] = arrayCopy($gErrMessages); $this->load->vars($displayData); $this->load->view('vol_reg/register'); } else { $this->saveVolReg($rRec, $lNumTables, $utables, $lNumSkills, $jobSkills, $bCreateAcct); redirect('vol_reg/vol/submitted/' . $strHash); } }