You are here

function edit_limit_node_prepare in Edit Limit 7

Implements hook_node_prepare().

File

./edit_limit.module, line 255
edit_limit.module Primary module file for Edit Limit. This contains all the hooks needed to run the module.

Code

function edit_limit_node_prepare($node) {
  if (!empty($node->nid)) {
    if (variable_get('edit_limit_node_count_enabled', FALSE)) {
      $limit = variable_get('edit_limit_node_count_default', EDIT_LIMIT_NODE_COUNT_DEFAULT);
      $count = edit_limit_node_count($node->nid);

      // If the edit count is getting close to the limit, make this a warning instead of a simple status
      $type = $count + 2 > $limit ? 'warning' : 'status';
      $message = t("This node has been edit !count out of !limit times, after which it will be locked.", array(
        '!count' => $count,
        '!limit' => $limit,
      ));
      drupal_set_message(filter_xss($message), $type);
    }
  }
}