/[drupal]/contributions/modules/blocks404/blocks404.active.inc
ViewVC logotype

Diff of /contributions/modules/blocks404/blocks404.active.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Tue Jan 6 06:22:17 2009 UTC revision 1.3, Tue Jan 6 06:42:50 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: blocks404.active.inc,v 1.1 2008/12/31 20:54:40 johnalbin Exp $  // $Id: blocks404.active.inc,v 1.2 2009/01/06 06:22:17 johnalbin Exp $
3    
4  /**  /**
5   * Helper function that performs the actual inclusion of the left and right regions.   * Helper function that performs the actual inclusion of the left and right regions.
# Line 80  function blocks404_reset_body_classes(&$ Line 80  function blocks404_reset_body_classes(&$
80      $vars['body_classes'] = implode(' ', $classes);      $vars['body_classes'] = implode(' ', $classes);
81    }    }
82  }  }
83    
84    /**
85     * Implements hook_form_alter().
86     *
87     * We need this to be able to submit any forms from the error pages, otherwise
88     * the form POSTs to the error page and the form is not processed.
89     */
90    function _blocks404_form_alter(&$form, $form_state, $form_id) {
91      if ($_GET['q'] == BLOCKS404_PAGE) {
92        // Form actions that POST to the 404 page won't work properly.
93        if ($form['#action'] == url(BLOCKS404_PAGE) || $form['#action'] == url(BLOCKS404_ORIGINAL_QUERY) || $form_id == 'user_login_block' || $form['#action'] == url(BLOCKS404_PAGE, array('query' => 'destination=' . BLOCKS404_ORIGINAL_QUERY))) {
94          $form['#action'] = url('<front>');
95        }
96        // Form actions that redirect back to the 404 page aren't good either.
97        elseif (strpos($form['#action'], 'destination=' . urlencode(BLOCKS404_ORIGINAL_QUERY)) !== FALSE) {
98          // Deconstruct the URL.
99          list(, $path) = explode($GLOBALS['base_path'], $form['#action']);
100          list($path, $query) = explode('?', $path);
101          $query = explode('&', $query);
102          if (($pos = array_search('destination=' . urlencode(BLOCKS404_ORIGINAL_QUERY), $query)) !== FALSE) {
103            // Remove the broken redirection.
104            unset($query[$pos]);
105            // Reconstruct the URL.
106            $form['#action'] = url($path, array('query' => $query));
107          }
108        }
109      }
110    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2