? content_lock.843100.patch
Index: content_lock.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_lock/Attic/content_lock.admin.inc,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 content_lock.admin.inc
--- content_lock.admin.inc	18 Apr 2010 12:39:20 -0000	1.1.2.4
+++ content_lock.admin.inc	19 Aug 2010 17:31:33 -0000
@@ -3,8 +3,9 @@
 
 # Copyright (c) 2010 Impressive.media
 # Author: Eugen Mayer
-/*
- * Providing a administration interface for tagging.
+
+/**
+ * Providing a administration interface for content_lock.
  */
 function content_lock_admin_settings() {
   $form['content_lock_admin_verbose'] = array(
@@ -21,5 +22,27 @@ function content_lock_admin_settings() {
       '#default_value' => variable_get('content_lock_admin_cancelbutton', true),
   );
 
+  $form['content_lock_allowed_node_types'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Lockable content types'),
+    '#description' => t('Apply lock to the selected content types. Leave blank for all.'),
+    '#options' => node_get_types('names'),
+    '#default_value' => variable_get('content_lock_allowed_node_types', array()),
+  );
+
+  $formats = filter_formats();
+  $format_options = array();
+  foreach ($formats as $id => $format) {
+    $format_options[$id] = $format->name;
+  }
+
+  $form['content_lock_allowed_formats'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Lockable text formats'),
+    '#description' => t('Apply lock to selected formats only. Leave blank for all.'),
+    '#options' => $format_options,
+    '#default_value' => variable_get('content_lock_allowed_formats', array()),
+  );
+
   return system_settings_form($form);
-}
\ No newline at end of file
+}
Index: content_lock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_lock/content_lock.module,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 content_lock.module
--- content_lock.module	18 Apr 2010 12:39:20 -0000	1.1.2.11
+++ content_lock.module	19 Aug 2010 17:31:34 -0000
@@ -105,7 +105,7 @@ function content_lock_nodeapi(&$node, $o
 
   switch ($op) {
     case 'validate':
-      if (isset($node->nid) && user_access('check out documents')) {
+      if (isset($node->nid) && _content_lock_is_lockable_node($node) && user_access('check out documents')) {
         // Existing node. Check if we still own the lock.
         if ($lock = content_lock_fetch_lock($node->nid)) {
           if ($lock->uid != $user->uid) {
@@ -122,13 +122,22 @@ function content_lock_nodeapi(&$node, $o
       }
       break;
     case 'update':
+      if (_content_lock_is_lockable_node($node)) {
         content_lock_release($node->nid, $user->uid);
+      }
       break;
     case 'delete':
-      content_lock_release($node->nid, NULL);
+      if (_content_lock_is_lockable_node($node)) {
+        content_lock_release($node->nid, NULL);
+      }
       break;
     case 'view':
       global $user;
+
+      if (!_content_lock_is_lockable_node($node)) {
+        break;
+      }
+
       if(!$messages_shown) {
         _content_lock_show_warnings();
         $messages_shown = true;
@@ -158,14 +167,14 @@ function content_lock_form_alter(&$form,
 
   $node = $form['#node'];
   $nid = $form['nid']['#value'];
-
   if( $node_type_blacklist[$node->type] !== true  // If this node is blacklisted, dont lock
       && user_access('check out documents')       // The user must have this permission to be able to lock
       && ($node->type."_node_form" == $form_id)   // Dont lock if we are administrating the node-type
       && ($node != NULL)                          // If we somehow have no node, no need to lock at all
-      && ($user->uid > 0)                           // A valid user is needed for locking
+      && ($user->uid > 0)                         // A valid user is needed for locking
       && ($form_state['submitted'] === false)     // submitted: is true if we save, but false if its a preview. We dont want to try to lock and saves
       && (!empty($nid))                           // nid: If we have no nid, we are adding a node and therefor we need not locking.
+      && _content_lock_is_lockable_node($node)    // Only process nodes configured for locking. Must be after form and null node checks.
       && $form_id != "comment_form")              // form_id: if we just got called because of adding a comment, we dont need to lock the node itself
     {
     _content_lock_add_unload_js($form);
@@ -540,3 +549,26 @@ function content_lock_release_own_item($
     }
   }
 }
+
+/**
+ * Check whether a node is configured to be protected by content_lock.
+ */
+function _content_lock_is_lockable_node($node) {
+  static $lockable;
+
+  if (isset($lockable[$node->format][$node->nid])) {
+    return $lockable[$node->format][$node->nid];
+  }
+
+  $types = array_filter(variable_get('content_lock_allowed_node_types', array()));
+  $formats = array_filter(variable_get('content_lock_allowed_formats', array()));
+
+  $lockable[$node->format][$node->nid] = FALSE;
+  // Determine if the node is of a lockable content type or text format.
+  if ((empty($types) || in_array($node->type, $types))
+      && (empty($formats) || in_array($node->format, $formats))) {
+    $lockable[$node->format][$node->nid] = TRUE;
+  }
+
+  return $lockable[$node->format][$node->nid];
+}
