Index: contrib/fckeditor.inc
===================================================================
RCS file: contrib/fckeditor.inc
diff -N contrib/fckeditor.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/fckeditor.inc	28 Apr 2010 08:56:32 -0000
@@ -0,0 +1,73 @@
+<?php
+// $Id$
+/**
+ * @file
+ * CRUD functions for FCKeditor settings.
+ */
+
+/**
+ * Add fields and paths to exclude in the visibility settings
+ *
+ * @param $fields
+ *   array of fields to exclude, use FALSE to keep current settings
+ * @param $paths
+ *   array of paths to exclude, use FALSE to keep current settings
+ * @param $simple_fields
+ *   array of fields to force the simplified toolbar, use FALSE to keep current settings
+ * @param $simple_paths
+ *   array of paths to force the simplified toolbar, use FALSE to keep current settings
+ * @param $profile
+ *   The name of the profile to edit Defaults to the global profile
+ * 
+ */
+function install_fckeditor_visibility($fields=FALSE, $paths=FALSE, $simple_fields=FALSE, $simple_paths=FALSE, $profile='FCKeditor Global Profile'){
+  $result = db_query("SELECT settings FROM {fckeditor_settings} WHERE name='%s'", $profile);
+  $data = db_fetch_object($result);
+  if (!empty($data->settings)) {
+    $settings = unserialize($data->settings);
+  }
+
+  // Check each field and add it to the exclude list if its not already there
+  if($fields !== FALSE){
+    foreach($fields as $key => $value){
+      $exists = strpos($settings['excl_fields'], $value);
+      if ($exists === FALSE){
+        $settings['excl_fields'] .= "\n". $value;
+      }
+    }
+  }
+
+  // Check each path and add it to the exclude list if its not already there
+  if($paths !== FALSE){
+    foreach($paths as $key => $value){
+      $exists = strpos($settings['excl_paths'], $value);
+      if ($exists === FALSE){
+        $settings['excl_paths'] .= "\n". $value;
+      }
+    }
+  }
+
+  // Check each field and add it to the force simple list if its not already there
+  if($simple_fields !== FALSE){
+    foreach($simple_fields as $key => $value){
+      $exists = strpos($settings['simple_incl_fields'], $value);
+      if ($exists === FALSE){
+        $settings['simple_incl_fields'] .= "\n". $value;
+      }
+    }
+  }
+
+  // Check each path and add it to the force simple list if its not already there
+  if($simple_paths !== FALSE){
+    foreach($simple_paths as $key => $value){
+      $exists = strpos($settings['simple_incl_paths'], $value);
+      if ($exists === FALSE){
+        $settings['simple_incl_paths'] .= "\n". $value;
+      }
+    }
+  }
+
+  //save the settings
+  db_query("DELETE FROM {fckeditor_settings} WHERE name = '%s'", 'FCKeditor Global Profile');
+  db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", 'FCKeditor Global Profile', serialize($settings));
+}
