You are here

function uc_store_footer in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.module \uc_store_footer()

Implementation of hook_footer().

File

uc_store/uc_store.module, line 455
Contains global Ubercart functions and store administration functionality.

Code

function uc_store_footer() {

  // Exit if the store footer is turned off.
  if (variable_get('uc_footer_message', 0) === 'none') {
    return;
  }

  // Figure out what page is being viewed.
  $path = drupal_get_normal_path($_GET['q']);
  $parts = explode('/', $path);
  switch ($parts[0]) {
    case 'admin':
      if ($parts[1] != 'store') {
        break;
      }
    case 'node':
      if (intval($parts[1]) > 0) {
        if ($node = node_load($parts[1])) {
          if (function_exists('uc_product_node_info') && !in_array($node->type, module_invoke_all('product_types'))) {
            break;
          }
        }
      }
    case 'catalog':
    case 'cart':
    case 'manufacturer':
      $messages = _store_footer_options();
      if (($message = variable_get('uc_footer_message', 0)) > 0) {
        $message = $messages[$message];
      }
      else {
        $message = db_result(db_query("SELECT message FROM {uc_store_footers} WHERE path_hash = '%s'", md5($path)));
        if (!$message) {
          unset($messages['none']);
          $message = $messages[array_rand($messages)];
          db_query("INSERT INTO {uc_store_footers} (path_hash, message) VALUES ('%s', '%s')", md5($path), $message);
        }
      }
      return theme('uc_store_footer', $message);
  }
}