Permalink
Browse files

[recaptcha] Removing the captcha functionality entirely from sympal. …

…The new, standalone, sfSympalReCaptchaPlugin can be used if this functionality is needed. This is another step towards decoupling all of sympal.
  • Loading branch information...
1 parent fceb976 commit 0d56deda654838aa2a597dfb2738af8cbcd3e527 @weaverryan weaverryan committed Jun 10, 2010
View
@@ -68,10 +68,6 @@ all:
fields: [label]
indexName: content_type_sluggable
- # Configure forms that should have recaptcha enabled
- recaptcha_forms:
- sfGuardRegisterForm: true
-
# The displayed name. You can change this to the project name you build on top of Sympal for example.
sympal_name: Sympal
@@ -160,14 +160,6 @@ neue Plugins einfach herunterladen und installieren.</target>
<source>Default rendering action</source>
<target>Action für die Standarddarstellung</target>
</trans-unit>
- <trans-unit id="390">
- <source>Recaptcha public key</source>
- <target>Öffentlicher Schlüssel für ReCaptcha</target>
- </trans-unit>
- <trans-unit id="400">
- <source>Recaptcha private key</source>
- <target>Privater Schlüssel für ReCaptcha</target>
- </trans-unit>
<trans-unit id="410">
<source>Breadcrumbs separator</source>
<target>Trennungszeichen für das Brotkrumenmenü (Breadcrumbs)</target>
@@ -199,14 +199,6 @@ theme name below to see what it looks like!</source>
<target>Action de rendu par défaut</target>
</trans-unit>
<trans-unit>
- <source>Recaptcha public key</source>
- <target>Clé publique pour le ReCaptcha</target>
- </trans-unit>
- <trans-unit>
- <source>Recaptcha private key</source>
- <target>Clé privée pour le ReCaptcha</target>
- </trans-unit>
- <trans-unit>
<source>Breadcrumbs separator</source>
<target>Séparateur de menus (breadcrumbs)</target>
</trans-unit>
@@ -11,8 +11,4 @@ all:
remove_timestampable_from_forms: true
form_formatters:
- table: sfSympalWidgetFormSchemaFormatterTable
-
- # Configure recaptcha from sfFormExtraPlugin
- recaptcha_public_key: 6Ld2DgQAAAAAAApXLteupHPcbSxbSHkhNTuYLChX
- recaptcha_private_key: 6Ld2DgQAAAAAANIbaXJsFEBOyg56CL_ljy3APlPb
+ table: sfSympalWidgetFormSchemaFormatterTable
@@ -19,9 +19,6 @@ class sfSympalFormPluginConfiguration extends sfPluginConfiguration
public function initialize()
{
$this->dispatcher->connect('sympal.load', array($this, 'bootstrap'));
-
- // Connect to the sympal.load_config_form evnet
- $this->dispatcher->connect('sympal.load_config_form', array($this, 'loadConfigForm'));
}
/**
@@ -37,25 +34,11 @@ public function bootstrap(sfEvent $event)
$form = $this->_sympalContext->getServiceContainer()->getService('form_extended');
$this->dispatcher->connect('form.method_not_found', array($form, 'extend'));
- // Register a listener on the form.filter_values event
- new sfSympalFormFilterValuesListener($this->dispatcher, $this);
-
// Register a listener on the form.post_configure event
new sfSympalFormPostConfigureListener($this->dispatcher, $this);
}
/**
- * Listens to the sympal.load_config_form and allows for customization
- * of the config form
- */
- public function loadConfigForm(sfEvent $event)
- {
- $form = $event->getSubject();
- $form->addSetting('form', 'recaptcha_public_key', 'Recaptcha Public Key');
- $form->addSetting('form', 'recaptcha_private_key', 'Recaptcha Private Key');
- }
-
- /**
* @return sfSympalContext
*/
public function getSympalContext()
@@ -1,39 +0,0 @@
-<?php
-
-/**
- * Listener for the form.filter_values event
- *
- * Ensures that the recaptcha values are set correctly
- *
- * @package sfSympalPlugin
- * @subpackage events
- * @author Jonathan H. Wage <jonwage@gmail.com>
- * @since 2010-03-27
- * @version svn:$Id$ $Author$
- */
-class sfSympalFormFilterValuesListener extends sfSympalListener
-{
- public function getEventName()
- {
- return 'form.filter_values';
- }
-
- public function run(sfEvent $event, $values)
- {
- $form = $event->getSubject();
- if ($form->hasRecaptcha())
- {
- $request = $this->_invoker
- ->getSympalContext()
- ->getSymfonyContext()
- ->getRequest();
- $captcha = array(
- 'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'),
- 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'),
- );
- $values = array_merge($values, array('captcha' => $captcha));
- }
-
- return $values;
- }
-}
@@ -28,11 +28,6 @@ public function run(sfEvent $event)
}
}
- if ($form->hasRecaptcha())
- {
- sfSympalFormToolkit::embedRecaptcha($form);
- }
-
$this->configureWidgetSchema($form);
// Converts date fields to rich date fields
@@ -52,27 +52,4 @@ public function getRequiredFields(sfValidatorSchema $validatorSchema = null, $fo
return $fields;
}
-
- /**
- * Whether or not this form should have a recaptcha field added to it
- *
- * This is called by the following events so that the addition and processing
- * of this field occurs automatically:
- * - form.post_configure Adds the recaptcha field
- * - form.filter_values: Processes the submitted value
- *
- * @return boolean
- */
- public function hasRecaptcha()
- {
- // No recaptcha in test environment
- if (sfConfig::get('sf_environment') === 'test')
- {
- return false;
- }
- $forms = sfSympalConfig::get('recaptcha_forms', null, array());
- $class = get_class($this->getSubject());
-
- return (array_key_exists($class, $forms) && $forms[$class]) ? true : false;
- }
}
@@ -143,33 +143,6 @@ public static function changeDateWidget($name, sfForm $form)
}
/**
- * Embed recaptcha to a form
- *
- * @param sfForm $form
- * @return void
- */
- public static function embedRecaptcha(sfForm $form)
- {
- $publicKey = sfSympalConfig::get('form', 'recaptcha_public_key');
- $privateKey = sfSympalConfig::get('form', 'recaptcha_private_key');
-
- if (!$publicKey || !$privateKey) {
- throw new sfException('You must specify the recaptcha public and private key in your sympal configuration');
- }
-
- $widgetSchema = $form->getWidgetSchema();
- $validatorSchema = $form->getValidatorSchema();
-
- $widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array(
- 'public_key' => $publicKey
- ));
-
- $validatorSchema['captcha'] = new sfValidatorReCaptcha(array(
- 'private_key' => $privateKey
- ));
- }
-
- /**
* Change the content slot form value widget
*
* @param string $type The type of the widget
@@ -3,4 +3,9 @@ all:
admin_modules:
sympal_users: ~
sympal_groups: ~
- sympal_permissions: ~
+ sympal_permissions: ~
+
+ # if sfReCaptchaFormPlugin is present, recaptcha will be added to it
+ recaptcha:
+ forms:
+ sfGuardRegisterForm: true
@@ -23,7 +23,7 @@
->info(' 1.1 - Change a few settings and save')
->click('Save', array('settings' => array(
'default_rendering_action' => 'test',
- 'form' => array('recaptcha_private_key' => '1234test'),
+ 'content_list' => array('rows_per_page' => 65),
)))
->with('request')->begin()
@@ -41,4 +41,4 @@
$browser->info(' 1.2 - Check that the application app.yml was updated with the changed config');
$appYaml = sfYaml::load(sfConfig::get('sf_apps_dir').'/sympal/config/app.yml');
$browser->test()->is($appYaml['all']['sympal_config']['default_rendering_action'], 'test');
-$browser->test()->is($appYaml['all']['sympal_config']['form']['recaptcha_private_key'], '1234test');
+$browser->test()->is($appYaml['all']['sympal_config']['content_list']['rows_per_page'], 65);

0 comments on commit 0d56ded

Please sign in to comment.