rayogram / SimplyCivi

A Drupal admin theme for CiviCRM, sponsored by rayogram.com
21 stars 7 forks source link

empty $headers results in error #12

Open shaneonabike opened 12 years ago

shaneonabike commented 12 years ago

This is a really great addition to CiviCRM btw.. fantastic theme.

On one of my clients is getting the following error and at first I was puzzled until I realized why!

This should never happen.. well unless there are no headers in drupal_set_header() which means it will return an array of nothing unfortunately.

So my suggestion would be just to change this to ....


  //Play nicely with the page_title module if it is there.
  if (!module_exists('page_title')) {
    // Fixup the $head_title and $title vars to display better.
    $title = drupal_get_title();
    $headers = drupal_set_header();

    // if this is a 403 and they aren't logged in, tell them they need to log in
// [shaneonabike]: Added check for empty headers to skip this bizo
    if (!empty($headers) && strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
      $title = t('Please login to continue');
    }
    $vars['title'] = $title;

    if (!drupal_is_front_page()) {
      $vars['head_title'] = $title .' | '. $vars['site_name'];
      if ($vars['site_slogan'] != '') {
        $vars['head_title'] .= ' – '. $vars['site_slogan'];
      }
    }
    $vars['head_title'] = strip_tags($vars['head_title']);
  }