You are here

public static function ShareaholicContentSettings::load in Share Buttons, Related Posts, Content Analytics - Shareaholic 7.3

Same name and namespace in other branches
  1. 8 content_settings.php \ShareaholicContentSettings::load()

Load the content settings from the database and attach to each node object

Parameters

Array $node The list of node objects:

Array $types The list of content types from the available nodes:

1 call to ShareaholicContentSettings::load()
shareaholic_node_load in includes/node.php
Implements hook_node_load().

File

./content_settings.php, line 103

Class

ShareaholicContentSettings
An interface to the Shareaholic Content Settings database table

Code

public static function load($nodes, $types) {
  if (!db_table_exists('shareaholic_content_settings')) {
    return;
  }
  $result = db_query('SELECT * FROM {shareaholic_content_settings} WHERE nid IN(:nids)', array(
    ':nids' => array_keys($nodes),
  ))
    ->fetchAllAssoc('nid');
  foreach ($nodes as &$node) {
    if (isset($result[$node->nid]->settings)) {
      $settings = self::unserialize_settings($result[$node->nid]);
      $node->shareaholic_options['shareaholic_exclude_from_recommendations'] = isset($settings['exclude_from_recommendations']) && $settings['exclude_from_recommendations'];
      $node->shareaholic_options['shareaholic_hide_recommendations'] = isset($settings['hide_recommendations']) && $settings['hide_recommendations'];
      $node->shareaholic_options['shareaholic_hide_share_buttons'] = isset($settings['hide_share_buttons']) && $settings['hide_share_buttons'];
      $node->shareaholic_options['shareaholic_exclude_og_tags'] = isset($settings['exclude_og_tags']) && $settings['exclude_og_tags'];
    }
  }
}