You are here

function _filebrowser_prepare_record in Filebrowser 6.2

Same name and namespace in other branches
  1. 8 filebrowser.common.inc \_filebrowser_prepare_record()
  2. 7.4 filebrowser.common.inc \_filebrowser_prepare_record()
  3. 7.2 filebrowser.common.inc \_filebrowser_prepare_record()
  4. 7.3 filebrowser.common.inc \_filebrowser_prepare_record()

Prepare node record to be used. This is mainly about default stuff.

Parameters

$node node to prepage:

$load is this for loading (TRUE) or inserting/updating (FALSE):

3 calls to _filebrowser_prepare_record()
filebrowser_insert in ./filebrowser.module
Implementation of hook_insert().
filebrowser_load in ./filebrowser.module
Implementation of hook_load().
filebrowser_update in ./filebrowser.module
Implementation of hook_update().

File

includes/node.inc, line 65

Code

function _filebrowser_prepare_record(&$node, $load = TRUE) {

  // Fix trailing slashes
  $node->folder_path = rtrim($node->folder_path, '/');

  // Process uploads
  $node->folder_uploads = (object) $node->folder_uploads;

  // Process handlers
  $node->file_handlers = (object) $node->file_handlers;
  foreach (module_implements("filebrowser_handler_info") as $module) {
    if (isset($node->{$module})) {
      $node->file_handlers->{$module} = $node->{$module};
      unset($node->{$module});
    }
    $node->file_handlers = (object) $node->file_handlers;
    $node->file_handlers->{$module} = (object) $node->file_handlers->{$module};
  }

  // Fix rights
  $node->folder_rights = (object) $node->folder_rights;

  // Fix presentation
  $node->folder_presentation = (object) $node->folder_presentation;
  $columns = _filebrowser_externals('metadata_info');
  $node->folder_presentation->visible_columns = _filebrowser_filter_checkboxes_result($node->folder_presentation->visible_columns);
  foreach ($node->folder_presentation->visible_columns as $name => $value) {
    if (!isset($columns[$name])) {
      unset($node->folder_presentation->visible_columns[$name]);
    }
  }
  if (count($node->folder_presentation->visible_columns) == 0) {
    $node->folder_presentation->visible_columns = array(
      FILEBROWSER_DATA_NAME_ICON => 1,
      FILEBROWSER_DATA_NAME_DISPLAY_NAME => 1,
    );
  }
  if (!isset($node->folder_presentation->default_sort)) {
    foreach ($node->folder_presentation->visible_columns as $name => $foo) {
      if (isset($columns[$name]['sortable']) && $columns[$name]['sortable']) {
        $node->folder_presentation->default_sort = $name;
        break;
      }
    }
  }

  // Create serialized properties
  $data = new stdClass();
  $data->folder_rights = $node->folder_rights;
  $data->folder_presentation = $node->folder_presentation;
  $data->folder_uploads = $node->folder_uploads;
  $data->file_handlers = isset($node->file_handlers) ? $node->file_handlers : (object) array();
  $node->properties = serialize($data);
}