function securepages_form_alter in Secure Pages 6
Same name and namespace in other branches
- 5 securepages.module \securepages_form_alter()
- 6.2 securepages.module \securepages_form_alter()
- 7 securepages.module \securepages_form_alter()
Implementation of hook_form_alter().
File
- ./
securepages.module, line 89 - Provide method of creating allowing certain pages to only viewable from https pages
Code
function securepages_form_alter(&$form, &$form_state, $form_id) {
if (!variable_get('securepages_enable', 0)) {
return;
}
if (isset($form['#action']) && securepages_can_alter_url($form['#action'])) {
@extract(@parse_url($form['#action']));
if (isset($query)) {
parse_str($query, $query);
}
else {
$query = array();
}
if (isset($query['q'])) {
$path = $query['q'];
}
else {
$base_path = base_path();
$path = !strncmp($path, $base_path, drupal_strlen($base_path)) ? drupal_substr($path, drupal_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, array(
'query' => $query,
'secure' => TRUE,
));
}
elseif ($page_match === 0 && securepages_is_secure() && variable_get('securepages_switch', FALSE)) {
$form['#action'] = securepages_url($path, array(
'query' => $query,
'secure' => FALSE,
));
}
}
}