You are here

function node_limit_user_node_limit_save in Node Limit 8

Same name and namespace in other branches
  1. 6 node_limit_user/node_limit_user.module \node_limit_user_node_limit_save()
  2. 7 node_limit_user/node_limit_user.module \node_limit_user_node_limit_save()

Implements hook_node_limit_save().

File

old/node_limit_user/node_limit_user.module, line 96
Module to restrict the number of nodes by user.

Code

function node_limit_user_node_limit_save($lid, $applies, $element) {
  if ($applies) {

    // In the clone context, $element is an array containing
    // the uid and the user name.
    if (is_array($element)) {
      $uid = $element['uid'];
    }
    else {
      $user = user_load_by_name($element);
      $uid = $user->uid;
    }
    \Drupal::database()
      ->insert('node_limit_user')
      ->fields(array(
      'lid' => $lid,
      'uid' => $uid,
    ))
      ->execute();
  }
}