function securepages_form_alter in Secure Pages 5
Same name and namespace in other branches
- 6.2 securepages.module \securepages_form_alter()
- 6 securepages.module \securepages_form_alter()
- 7 securepages.module \securepages_form_alter()
Implementation of hook_form_alter()
File
- ./
securepages.module, line 121
Code
function securepages_form_alter($form_id, &$form) {
if (!variable_get('securepages_enable', 0)) {
return;
}
if (isset($form['#action']) && securepages_can_alter_url($form['#action'])) {
extract(parse_url($form['#action']));
parse_str($query, $query);
if (isset($query['q'])) {
$path = $query['q'];
}
else {
$base_path = base_path();
$path = !strncmp($path, $base_path, strlen($base_path)) ? substr($path, strlen($base_path)) : $path;
}
$path = drupal_get_normal_path($path);
$query = drupal_query_string_encode($query);
$page_match = securepages_match($path);
if ($page_match && !securepages_is_secure()) {
$form['#action'] = securepages_url($path, $query, NULL, TRUE);
}
elseif ($page_match === 0 && securepages_is_secure() && variable_get('securepages_switch', FALSE)) {
$form['#action'] = securepages_url($path, $query, NULL, FALSE);
}
}
}