function _webform_localization_mollom_form_alter in Webform Localization 7.4
Interaction with mollom_form_alter() for 'single_webform' localization.
If the translation source node's webform is protected by mollom, and uses our 'single_webform' setting, then we must also protect the other nodes in the translation set.
This is because each node in the translation set will still have a unique client form_id (based on the nid, not the tnid), but mollom will only know about one of those form_ids.
See also
webform_localization_module_implements_alter()
1 call to _webform_localization_mollom_form_alter()
- webform_localization_form_alter in ./
webform_localization.module - Implements hook_form_alter().
File
- ./
webform_localization.module, line 895 - Webform localization module.
Code
function _webform_localization_mollom_form_alter(&$form, &$form_state, $form_id) {
// Establish that the current node has a (different) translation source.
// (If this is the translation source, mollom will already know about it).
$node = $form['#node'];
if (empty($node->tnid) || $node->tnid == $node->nid) {
return;
}
// Prime the static mollom form cache (for manipulation).
mollom_form_cache();
$mollom_cache =& drupal_static('mollom_form_cache');
$protected =& $mollom_cache['protected'];
// If the source node's webform is not protected by mollom, we can bail
// out immediately.
$source_form_id = 'webform_client_form_' . $node->tnid;
if (!array_key_exists($source_form_id, $protected)) {
return;
}
// Check that the 'single_webform' option is configured for the source.
$source_wl_options = webform_localization_get_config($node->tnid);
if (empty($source_wl_options['single_webform'])) {
return;
}
// Protect this form using the settings for the single webform.
// Firstly we take care of the mollom_form_cache() static cache.
$protected[$form_id] = $protected[$source_form_id];
// Then, if necessary, we update the mollom_form_load() cache.
$mollom_form = mollom_form_load($form_id);
if (!$mollom_form) {
$source_mollom_form = mollom_form_load($source_form_id);
$mollom_form = $source_mollom_form;
$mollom_form['form_id'] = $form_id;
$cid = 'mollom:form:' . $form_id;
cache_set($cid, $mollom_form);
}
}