public function renderImage($attributes, $parameters) { // Get CAPTCHA parameters from the module form's preferences. $pref = ModuleService::getInstance()->getPreferencesDocument('form'); if (!is_null($pref)) { foreach ($pref->getCaptchaParameters() as $name => $value) { // Parameters defined in the template overload the preferences' parameters. if (!isset($parameters[$name])) { $parameters[$name] = $value; } } } self::generateCaptchaCode($parameters); $url = htmlentities(LinkHelper::getUrl('form', 'Captcha', $parameters), ENT_COMPAT, "utf-8"); $code = "<script type=\"text/javascript\">\n//<![CDATA[\nCAPTCHA.imageURL = \"" . $url . "\";\n//]]>\n</script>\n"; $code .= '<span class="captcha"><input type="image" src="' . $url . '"'; if (!isset($attributes['title'])) { $attributes['title'] = f_Locale::translate("&modules.form.bo.general.Captcha-click-to-have-another-one;"); } if (!isset($attributes['onclick'])) { $attributes['onclick'] = 'CAPTCHA.reload(this); return false;'; } foreach ($attributes as $name => $value) { $code .= ' ' . $name . '="' . str_replace('"', '\\"', $value) . '"'; } return $code . '/></span>'; }
/** * @return form_persistentdocument_preferences */ protected function initPersistentDocument() { $document = ModuleService::getInstance()->getPreferencesDocument('form'); return $document !== null ? $document : form_PreferencesService::getInstance()->getNewDocumentInstance(); }
/** * @param form_persistentdocument_baseform $form */ protected function getOverrideNotificationSender($form) { $defaultSender = ModuleService::getInstance()->getPreferenceValue('form', 'sender'); if ($defaultSender !== null) { return f_util_ArrayUtils::firstElement($defaultSender->getEmailAddresses()); } return null; }
/** * @return form_persistentdocument_preferences */ private function getPreferences() { return ModuleService::getInstance()->getPreferencesDocument('form'); }
/** * Creates the notification that is bound to the form. * @param form_persistentdocument_form $form */ protected function createNotification($form) { $notification = notification_NotificationService::getInstance()->getNewDocumentInstance(); $notification->setLabel($form->getLabel()); $notification->setCodename($form->getFormid() . '_notification'); $notification->setTemplate('default'); $notification->setSubject($form->getLabel()); $notification->setBody('{' . self::CONTENT_REPLACEMENT_NAME . '}'); $notification->save(ModuleService::getInstance()->getSystemFolderId('notification', 'form')); $form->setNotification($notification); }