You are here

function content_access_save_per_node_settings in Content Access 7

Same name and namespace in other branches
  1. 8 content_access.module \content_access_save_per_node_settings()
  2. 5 content_access.module \content_access_save_per_node_settings()
  3. 6 content_access.module \content_access_save_per_node_settings()

Saves custom per node settings in the own content_access table.

4 calls to content_access_save_per_node_settings()
content_access_action_grant_node_permissions in content_access_rules/content_access_rules.rules.inc
Action implementation: Grant permissions for a node.
content_access_action_revoke_node_permissions in content_access_rules/content_access_rules.rules.inc
Action implementation: Revoke permissions for a node.
content_access_node_export_after_import_alter in ./content_access.module
Implements hook_node_export_after_import_alter().
content_access_page_submit in ./content_access.admin.inc
Submit callback for content_access_page().

File

./content_access.module, line 451
Content access module file.

Code

function content_access_save_per_node_settings($node, $settings) {
  $count = db_select('content_access')
    ->condition('nid', $node->nid)
    ->countQuery()
    ->execute()
    ->fetchField();
  if ($count > 0) {
    db_update('content_access')
      ->condition('nid', $node->nid)
      ->fields(array(
      'settings' => serialize($settings),
    ))
      ->execute();
  }
  else {
    db_insert('content_access')
      ->fields(array(
      'nid' => $node->nid,
      'settings' => serialize($settings),
    ))
      ->execute();
  }

  // Make content_access_per_node_setting() use the new settings
  content_access_per_node_setting(NULL, $node, $settings);
}