You are here

function flashnode_load in Flash Node 6.2

Same name and namespace in other branches
  1. 5.6 flashnode.module \flashnode_load()
  2. 5.2 flashnode.module \flashnode_load()
  3. 5.3 flashnode.module \flashnode_load()
  4. 6.3 flashnode.module \flashnode_load()

Implementation of hook_load

File

./flashnode.module, line 349

Code

function flashnode_load(&$node) {
  if ($node->vid) {

    // Retrieve data for this node from combination of {flash} and {files}
    $result = db_query("SELECT filepath, filename, {flashnode}.* FROM {files} INNER JOIN {flashnode} ON {files}.fid = {flashnode}.fid WHERE {flashnode}.vid = %d", $node->vid);
    $data = db_fetch_object($result);

    // If no object was retrieved then make $data array empty and output a message
    if ($data === FALSE) {
      $data = array();
      drupal_set_message(t('Unable to load flash node data for node @node.', array(
        '@node' => $node->nid,
      )), 'error');
    }

    // Store all the settings in to the $node->flashnode object
    foreach ($data as $parameter => $value) {
      $node->flashnode[$parameter] = $value;
    }

    // Generate default base path if not set
    if (!$flashnode['base']) {
      $flashnode['base'] = file_create_url('');
    }
  }
}