Index: crud.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/install_profile_api/crud.inc,v
retrieving revision 1.15
diff -u -p -r1.15 crud.inc
--- crud.inc	25 Sep 2007 19:52:18 -0000	1.15
+++ crud.inc	24 Nov 2007 02:35:13 -0000
@@ -1,5 +1,4 @@
 <?php
-
 /* $Id: crud.inc,v 1.15 2007/09/25 19:52:18 tatien Exp $ */
 
 /* --- NODE / CONTENT --- */
@@ -21,13 +20,13 @@ function install_add_user($username, $pa
   user_save(
     new stdClass(),
     array(
-      'name' => $username, 
+      'name' => $username,
       'pass' => $password,
       'mail' => $email,
       'roles' => $roles,
       'status' => $status
     )
-  );	
+  );
 }
 
 /* --- CONTACT --- */
@@ -46,30 +45,30 @@ function install_contact_add_category($c
  * Given a funky array of profile fields, create them.
  */
 function install_profile_field_add($data) {
-	if (!is_array($data) || !isset($data['title']) || !isset($data['name'])) {
-	  return false;
-	}
-	$data['fid'] = db_next_id("{profile_fields}_fid");
-	$data['category'] = ($data['category']) ? $data['category'] : '';
-	$data['type'] = ($data['type']) ? $data['type'] : 'textfield';
-	$data['required'] = ($data['required']) ? $data['required'] : '0';
-	$data['register'] = ($data['register']) ? $data['register'] : '0';
-	$data['visibility'] = ($data['visibility']) ? $data['visibility'] : '0';
-	$data['explanation'] = ($data['explanation']) ? $data['explanation'] : '';
-	
-	$fields = array_keys($data);
-	
-	// Prepare the query:
-	foreach ($data as $key => $value) {
-	  if (in_array((string) $key, $fields)) {
-	    $k[] = db_escape_string($key);
-	    $v[] = $value;
-	    $s[] = "'%s'";
-	  }
-	}
-	db_query("INSERT INTO {profile_fields} (". implode(", ", $k) .") VALUES (". implode(", ", $s) .")", $v);
-	
-	return $data['fid'];
+  if (!is_array($data) || !isset($data['title']) || !isset($data['name'])) {
+    return false;
+  }
+  $data['fid']         = db_next_id("{profile_fields}_fid");
+  $data['category']    = ($data['category']) ? $data['category'] : '';
+  $data['type']        = ($data['type']) ? $data['type'] : 'textfield';
+  $data['required']    = ($data['required']) ? $data['required'] : '0';
+  $data['register']    = ($data['register']) ? $data['register'] : '0';
+  $data['visibility']  = ($data['visibility']) ? $data['visibility'] : '0';
+  $data['explanation'] = ($data['explanation']) ? $data['explanation'] : '';
+  
+  $fields              = array_keys($data);
+  
+  // Prepare the query:
+  foreach ($data as $key => $value) {
+    if (in_array((string) $key, $fields)) {
+      $k[] = db_escape_string($key);
+      $v[] = $value;
+      $s[] = "'%s'";
+    }
+  }
+  db_query("INSERT INTO {profile_fields} (". implode(", ", $k) .") VALUES (". implode(", ", $s) .")", $v);
+  
+  return $data['fid'];
 }
 
 /* --- ROLE --- */
@@ -101,6 +100,7 @@ function install_set_permissions($rid, $
 
 /**
  * Create a new top-level menu
+ *
  * @return	integer		The database ID of the newly created menu
  */
 function install_menu_create_menu($title, $weight = 0) {
@@ -112,25 +112,30 @@ function install_menu_create_menu($title
     $mid = db_next_id('{menu}_mid');
   }
   db_query("INSERT INTO {menu} (mid, pid, title, weight, type) VALUES (%d, 0, '%s', %d, 115)", $mid, $title, $weight);
-  menu_rebuild(); // not sure if this is needed, but we've seen problems without it
-  return $mid; // this is important to add new items to this menu.
+  // not sure if this is needed, but we've seen problems without it
+  menu_rebuild();
+  // this is important to add new items to this menu.
+  return $mid;
 }
 
 /**
  * Get the menu ID, searching on path
+ *
  * @return	integer		The database ID of a menu item based on its path
  */
 function install_menu_get_mid($path) {
-  menu_rebuild(); // not sure if this is needed, but we've seen problems without it
-  return db_result(db_query("SELECT mid FROM {menu} WHERE path = '%s' LIMIT 1", $path));	
+  // not sure if this is needed, but we've seen problems without it
+  menu_rebuild();
+  return db_result(db_query("SELECT mid FROM {menu} WHERE path = '%s' LIMIT 1", $path));
 }
 
 /**
  * Get the menu ID of a root menu, based on title, e.g. Secondary links
+ *
  * @return	integer		The database ID of the root menu that matches the $title
  */
 function install_menu_get_root_menu($title) {
-  return db_result(db_query("SELECT mid FROM {menu} WHERE title = '%s' LIMIT 1", $title));	
+  return db_result(db_query("SELECT mid FROM {menu} WHERE title = '%s' LIMIT 1", $title));
 }
 
 /**
@@ -138,17 +143,20 @@ function install_menu_get_root_menu($tit
  */
 function install_menu_set_menu($mid, $pid, $weight = 0, $type = 54) {
   db_query("UPDATE {menu} SET pid = %d, type = %d, weight = %d WHERE mid = %d", $pid, $type, $weight, $mid);
-  menu_rebuild(); // not sure if this is needed, but we've seen problems without it
+  // not sure if this is needed, but we've seen problems without it
+  menu_rebuild();
 }
 
 /**
  * Create a new menu item
+ *
  * @param	$path			Path of the new menu item
  * @param	$title			Title of the menu item (visible label for menu)
  * @param	$pid			Parent ID -- which menu the item is being added to
  * @param	$description	Description of the menu item (tooltip)
  * @param	$weight			Weight for positioning
  * @param	$type			Menu item type; new items are 118 by default
+ *
  * @return	integer			The database ID of the menu item
  */
 function install_menu_create_menu_item($path, $title, $pid, $description = '', $weight = 0, $type = 118) {
@@ -158,17 +166,20 @@ function install_menu_create_menu_item($
     'pid' => $pid,
     'description' => st($description),
     'weight' => $weight,
-    'type' => $type
+    'type' => $type,
   );
   menu_save_item($menu);
   
-  menu_rebuild(); // not sure if this is needed, but we've seen problems without it
+  // not sure if this is needed, but we've seen problems without it
+  menu_rebuild();
   
-  return install_menu_get_mid($path); // this is important to add new items to this menu.
+  // this is important to add new items to this menu.
+  return install_menu_get_mid($path);
 }
 
 /**
  * Creates a batch of menu items
+ *
  * @param $items     An array containing menu items (as arrays)
  * @param $pid       Parent ID -- which menu the items are being added to
  */
@@ -184,12 +195,13 @@ function install_menu_create_menu_items(
 }
 
 /**
- * Remove the specified filter from the specified format 
+ * Remove the specified filter from the specified format
+ *
  * @param	$mid	The ID of the menu item to disable
  *
  * NOTE: the module name + the delta is what uniquely identifies a filter
  */
-function install_menu_disable_item($mid) { 
+function install_menu_disable_item($mid) {
   $item = menu_get_item($mid);
   $type = $item['type'];
   $type &= ~MENU_VISIBLE_IN_TREE;
@@ -234,6 +246,7 @@ function install_tinymce_add_roles($name
 
 /**
  * Create a new TinyMCE profile and set the settings
+ *
  * @param	$name		A text string identifying the profile
  * @param	$settings	An associative array containing key value pairs
  */
@@ -245,6 +258,7 @@ function install_tinymce_create_profile(
 
 /**
  * Given the name of a vocabulary, return its Vocab ID
+ *
  * @param	$name		A text string identifying the vocabulary
  */
 function install_get_vid($name) {
@@ -255,17 +269,19 @@ function install_get_vid($name) {
 /* --- FILTER --- */
 
 /**
- * Set the roles that can be used with the filter 
+ * Set the roles that can be used with the filter
+ *
  * @param	$roles		An array of role IDs
  * @param	$format_id	An integer of the format ID
  */
 function install_format_set_roles($roles, $format_id) {
-  $roles = implode(',',$roles);	
+  $roles = implode(',', $roles);
   db_query("UPDATE {filter_formats} SET roles = '%s' WHERE format = %d", $roles, $format_id);
 }
 
 /**
- * Add a new input format 
+ * Add a new input format
+ *
  * @param	$name	The human-readable name of the new format
  * @param	$cache	If this format is cacheable
  */
@@ -282,19 +298,21 @@ function install_add_format($name, $cach
 }
 
 /**
- * Remove the specified filter from the specified format 
+ * Remove the specified filter from the specified format
+ *
  * @param	$format_id	The ID of the format to remove the filter from
  * @param	$module		The module this filter belongs to
  * @param	$delta		The delta of this filter
  *
  * NOTE: the module name + the delta is what uniquely identifies a filter
  */
-function install_remove_filter($format_id, $module, $delta) {	
+function install_remove_filter($format_id, $module, $delta) {
   db_query("DELETE FROM {filters} WHERE format = %d AND module = '%s' AND delta = %d", $format_id, $module, $delta);
 }
 
 /**
  * Add a filter to an input format
+ *
  * @param	$format_id	The ID of the format to add the filter to
  * @param	$module		The module this filter belongs to
  * @param	$delta		The delta of this filter
@@ -314,9 +332,10 @@ function install_add_filter($format_id, 
  */
 
 /**
-* Enable theme
-* @param	$theme	Unique string that is the name of theme
-*/
+ * Enable theme
+ *
+ * @param	$theme	Unique string that is the name of theme
+ */
 function install_enable_theme($theme) {
   system_theme_data();
   db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $theme);
@@ -324,27 +343,31 @@ function install_enable_theme($theme) {
 }
 
 /**
-* Disable theme
-* @param	$theme	Unique string that is the name of theme
-*/
+ * Disable theme
+ *
+ * @param	$theme	Unique string that is the name of theme
+ */
 function install_disable_theme($theme) {
   system_theme_data();
   db_query("UPDATE {system} SET status = 0 WHERE type = 'theme' and name ='%s'", $theme);
 }
 
 /**
-* Set default theme
-* @param	$theme	Unique string that is the name of theme
-*/
+ * Set default theme
+ *
+ * @param	$theme	Unique string that is the name of theme
+ */
 function install_default_theme($theme) {
   install_enable_theme($theme);
   variable_set('theme_default', $theme);
 }
 
 /**
-* Set admin theme
-* @param	$theme	Unique string that is the name of theme
-*/
+ * Set admin theme
+ *
+ * @param	$theme	Unique string that is the name of theme
+ */
 function install_admin_theme($theme) {
   variable_set('admin_theme', $theme);
 }
+
