/** * Add element to form. * * @param CRM_Core_Form $form */ public static function add(&$form) { $error = NULL; $config = CRM_Core_Config::singleton(); $useSSL = FALSE; if (!function_exists('recaptcha_get_html')) { require_once 'packages/recaptcha/recaptchalib.php'; } // See if we are using SSL if (CRM_Utils_System::isSSL()) { $useSSL = TRUE; } $html = recaptcha_get_html($config->recaptchaPublicKey, $error, $useSSL); $form->assign('recaptchaHTML', $html); $form->assign('recaptchaOptions', $config->recaptchaOptions); $form->add('text', 'g-recaptcha-response', 'reCaptcha', NULL, TRUE); $form->registerRule('recaptcha', 'callback', 'validate', 'CRM_Utils_ReCAPTCHA'); if ($form->isSubmitted() && empty($form->_submitValues['g-recaptcha-response'])) { $form->setElementError('g-recaptcha-response', ts('Input text must match the phrase in the image. Please review the image and re-enter matching text.')); } }
/** * Build Email Block. * * @param CRM_Core_Form $form * */ public function buildMailBlock(&$form) { $form->registerRule('emailList', 'callback', 'emailList', 'CRM_Utils_Rule'); $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); $form->addYesNo('is_email_confirm', ts('Send Confirmation Email?'), NULL, NULL, array('onclick' => "return showHideByValue('is_email_confirm','','confirmEmail','block','radio',false);")); $form->add('textarea', 'confirm_email_text', ts('Text'), $attributes['confirm_email_text']); $form->add('text', 'cc_confirm', ts('CC Confirmation To'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'cc_confirm')); $form->addRule('cc_confirm', ts('Please enter a valid list of comma delimited email addresses'), 'emailList'); $form->add('text', 'bcc_confirm', ts('BCC Confirmation To'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'bcc_confirm')); $form->addRule('bcc_confirm', ts('Please enter a valid list of comma delimited email addresses'), 'emailList'); $form->add('text', 'confirm_from_name', ts('Confirm From Name')); $form->add('text', 'confirm_from_email', ts('Confirm From Email')); $form->addRule('confirm_from_email', ts('Email is not valid.'), 'email'); }