You are here

function node_limit_user_node_limit_element_validate in Node Limit 6

Same name and namespace in other branches
  1. 8 old/node_limit_user/node_limit_user.module \node_limit_user_node_limit_element_validate()
  2. 7 node_limit_user/node_limit_user.module \node_limit_user_node_limit_element_validate()

Implementation of hook_node_limit_element_validate().

File

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

Code

function node_limit_user_node_limit_element_validate($element) {

  /**
   * Validation:
   * User cannot be user:1
   * User must be in the {user} table
   */
  $potential_user = user_load(array(
    'name' => $element,
  ));
  if ($potential_user->uid == 1) {

    //we cannot apply a limit to user:1
    return array(
      'error' => t('Node Limits cannot be applied to User #1'),
    );
  }
  else {
    if ($potential_user === FALSE) {

      //unknown user
      return array(
        'error' => t('Unknown user "!user"', array(
          '!user' => $element,
        )),
      );
    }
  }
  return TRUE;
}