# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
--- ckeditor_link.module
+++ ckeditor_link.module
@@ -33,6 +33,13 @@
     'access arguments' => array('access ckeditor link'),
     'type' => MENU_CALLBACK,
   );
+  $items['admin/settings/ckeditor_link'] = array(
+    'title' => 'CKEditor link',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('ckeditor_link_settings_form'),
+    'access arguments' => array('administer ckeditor link'),
+    'type' => MENU_NORMAL_ITEM,
+  );
   return $items;
 }
 
@@ -40,8 +47,11 @@
   $matches = array();
 
   if ($string !== '') {
-    $sql = db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.title LIKE '%%%s%%' ORDER BY n.title, n.type");
-    $result = db_query_range($sql, array($string), 0, 10);
+    $args = array($string);
+    $node_types = array_keys(array_filter(variable_get('ckeditor_link_include_ct', array('page' => TRUE))));
+    $args = array_merge($args, $node_types);
+    $sql = db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.title LIKE '%%%s%%' AND n.type IN(" . db_placeholders($node_types, 'text') . ") ORDER BY n.title, n.type");
+    $result = db_query_range($sql, $args, 0, 10);
     while ($node = db_fetch_object($result)) {
       $matches[$node->title .' (node/'. $node->nid. ')'] = '<div class="reference-autocomplete">'. check_plain($node->title) .'</div>';
     }
@@ -50,6 +60,19 @@
   drupal_json($matches);
 }
 
+function ckeditor_link_settings_form(&$form_state) {
+  $form = array();
+
+  $form['ckeditor_link_include_ct'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Include this node types'),
+      '#options' => node_get_types('names'),
+      '#default_value' => variable_get('ckeditor_link_include_ct', array('page' => TRUE))
+  );
+
+  return system_settings_form($form);
+}
+
 /**
  * Implementation of hook_form_alter().
  */
