You are here

function reviews_enabled_load in Reviews 7

Menu callback. Returns FALSE if content type does not allow reviews, otherwise returns the srgument passed from the URL.

File

./reviews.module, line 252
This file defines all the necessary hooks and functions to create a system for enabling and authoring content reviews on a per content type basis.

Code

function reviews_enabled_load($arg) {

  // Check if reviews are enabled, if not return FALSE immediately.
  if (!reviews_reviews_enabled()) {
    return FALSE;
  }

  // Load the node to find it's type.
  $node = node_load($arg);
  $node_type = $node->type;

  // Get the Array containing which content types are allowed reviews.
  $reviewable_ctypes = variable_get('reviews_enabled_content_types', array());

  // Check if reviews are allowed for the node type, if not return FALSE.
  $allow_reviews_for_ctype = FALSE;
  if (isset($reviewable_ctypes[$node_type]) && $reviewable_ctypes[$node_type] === $node_type) {
    $allow_reviews_for_ctype = TRUE;
  }
  if (!$allow_reviews_for_ctype) {
    return FALSE;
  }
  return $arg;
}