? content_lock.type_and_format.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	1 Jul 2010 22:09:11 -0000
@@ -21,5 +21,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	1 Jul 2010 22:09:11 -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;
@@ -166,6 +175,7 @@ function content_lock_form_alter(&$form,
       && ($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 +550,27 @@ function content_lock_release_own_item($
     }
   }
 }
+
+/**
+ * Check whether a node is configured to be covered 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 = variable_get('content_lock_allowed_node_types', array());
+  $formats = variable_get('content_lock_allowed_formats', array());
+
+  // The node is not of a lockable content type or text format.
+  if ((!in_array($node->type, $types) && !empty($types))
+    || (!in_array($node->format, $formats) && !empty($formats))) {
+
+    $lockable[$node->format][$node->nid] = FALSE;
+  }
+  $lockable[$node->format][$node->nid] = TRUE;
+
+  return $lockable[$node->format][$node->nid];
+}
