You are here

function scald_is_registered in Scald: Media Management made easy 6

Same name and namespace in other branches
  1. 7 scald.module \scald_is_registered()

Determine if a Scald Atom is registered with Scald Core or not.

Parameters

$sid: The Scald ID being tested.

Return value

A Scald Atom Object if the Scald ID is valid. The Atom Object is *ONLY* populated with the following members: type, provider, base_id, actions, and fetched *set to FALSE*. FALSE if $sid is not a valid Scald ID (int) or if it does not reference an Atom.

5 calls to scald_is_registered()
scald_fetch in ./scald.module
Load a Scald Atom.
scald_prerender in ./scald.module
Prepare a Scald Atom for rendering
scald_render in ./scald.module
Render a Scald Atom
scald_unregister_atom in ./scald.module
Unregister a Scald Atom
scald_update_atom in ./scald.module
Update a Scald Atom

File

./scald.module, line 1283

Code

function scald_is_registered($sid, $rebuild = FALSE) {

  // Argument validation
  if (!is_numeric($sid)) {
    return FALSE;
  }
  $sid = (int) $sid;
  static $scald_atoms;
  if (!isset($scald_atoms)) {
    $scald_atoms = array();
  }

  // Reference the memory cache when appropriate
  if (!$rebuild && isset($scald_atoms[$sid])) {
    return $scald_atoms[$sid];
  }

  // Build the Atom from the db
  $registration_results = db_query("SELECT * FROM {scald_atoms} WHERE sid = %d", $sid);
  if (!$registration_results) {

    // Ensure that no Atoms linger improperly post-deletion
    unset($scald_atoms[$sid]);
    return FALSE;
  }
  $atom = db_fetch_object($registration_results);
  if (!empty($atom)) {
    $atom->fetched = FALSE;
  }
  else {
    return FALSE;
  }
  $scald_atoms[$sid] = $atom;
  return $scald_atoms[$sid];
}