You are here

function print_ui_node_update in Printer, email and PDF versions 7.2

Implements hook_node_update().

1 call to print_ui_node_update()
print_ui_node_insert in print_ui/print_ui.module
Implements hook_node_insert().

File

print_ui/print_ui.module, line 334
Printer-friendly pages User Interface module.

Code

function print_ui_node_update($node) {

  // If no global user object, the user_access call will fail.
  if (!isset($GLOBALS['user']) || !is_object($GLOBALS['user'])) {
    return;
  }
  if (user_access('administer print') || user_access('node-specific print configuration')) {
    foreach (module_implements('print_link') as $module) {
      $function = $module . '_print_link';
      if (function_exists($function)) {
        $link = call_user_func_array($function, array());
        $display = 'print_' . $link['format'] . '_display';
        $display_comment = 'print_' . $link['format'] . '_display_comment';
        $display_urllist = 'print_' . $link['format'] . '_display_urllist';
        if (!isset($node->{$display}) || $node->{$display} === NULL) {
          $node->{$display} = variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT);
        }
        if (!isset($node->{$display_comment}) || $node->{$display_comment} === NULL) {
          $node->{$display_comment} = variable_get($display_comment . '_' . $node->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
        }
        if (!isset($node->{$display_urllist}) || $node->{$display_urllist} === NULL) {
          $node->{$display_urllist} = variable_get($display_urllist . '_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
        }
        db_merge($module . '_node_conf')
          ->key(array(
          'nid' => $node->nid,
        ))
          ->fields(array(
          'link' => $node->{$display},
          'comments' => $node->{$display_comment},
          'url_list' => $node->{$display_urllist},
        ))
          ->execute();
      }
    }
  }
}