Example #1
0
 public static function deliverRedirect($result)
 {
     if (is_int($result)) {
         drupal_deliver_html_page($result);
         return;
     }
     if (module_exists('redirect')) {
         // Using the redirect module instead of drupal_goto() may allow this
         // redirect to be stored in the page cache.
         $redirect = new stdClass();
         $redirect->redirect = $result;
         redirect_redirect($redirect);
     } else {
         drupal_goto($result, array(), 301);
     }
 }
Example #2
0
 /**
  * Delivery callback; redirect to the file's location.
  *
  * @param mixed $file
  */
 public static function deliverFileRedirect($file)
 {
     if (is_int($file)) {
         drupal_deliver_html_page($file);
         return;
     } elseif (!is_object($file)) {
         drupal_deliver_html_page(MENU_NOT_FOUND);
         return;
     }
     $file->url = file_create_url($file->uri);
     if (module_exists('redirect')) {
         // Using the redirect module instead of drupal_goto() may allow this
         // redirect to be stored in the page cache.
         $redirect = new stdClass();
         $redirect->redirect = $file->url;
         redirect_redirect($redirect);
     } else {
         drupal_goto($file->url, array(), 301);
     }
 }