&$link) { if ($link['href'] && securepages_can_alter_url($link['href'])) { //drupal_set_message(print_r($link, 1)); $url = multilink_securepages_url($link['href']); //drupal_set_message('multilink securepages_link_alter:' . $link['href'] . '->' . $url, 'warning'); $links[$module]['href'] = $url; } } } } // Utility function for MultiLink Redirect to fix interference with Secure Pages redirects. function multilink_securepages_redirect_fix($rpath) { if (multilink_securepages_enable()) { // If destination is set but the same as current requested path, remove destination. // This fixes a loop condition with Secure Pages due to having a secure page in destination: // Drupal redirects to http://[destination] and we then redirect to https://[destination], repeatedly. // Example: http[s]://example.org/en/node/1?destination=node/1 where node/1 is set for https would loop. if (isset($_REQUEST['destination'])) { $destination = multilink_securepages_url($_REQUEST['destination']); if ($rpath == $destination) { unset($_REQUEST['destination']); //drupal_set_message('Removed destination: ' . $destination, 'error'); } } } } // Utility function to check if Secure Pages is enabled and disable it prevent conflicts. // This with the form_alter hook below allow us to take over from Secure Pages for redirects and link processing. function multilink_securepages_enable() { if (variable_get('securepages_enable', 0)) { variable_del('securepages_enable'); variable_set('multilink_securepages_enable', TRUE); return TRUE; } else { return variable_get('multilink_securepages_enable', FALSE); } } /* * Hook form_FORM_ID_modify */ function multilink_securepages_form_securepages_settings_alter(&$form, $form_state) { $old_element = $form['securepages_enable']; $element = array( '#title' => t($old_element['#title']) . ' ' . t('(via %module)', array('%module' => 'MultiLink')), '#default_value' => multilink_securepages_enable(), '#disabled' => $old_element['#disabled'] && !multilink_securepages_enable(), ); $new_form['multilink_securepages_enable'] = array_merge($old_element, $element); unset($form['securepages_enable']); $form = array_merge($new_form, $form); } // --- Drupal docs advise NOT closing PHP tags ---