1. lakshminp
  2. metrics

Commits

vinothini  committed d3e91d4

unwanted modules removed

  • Participants
  • Parent commits 5e8c550
  • Branches default

Comments (0)

Files changed (70)

File sites/all/modules/conditional_fields/CHANGELOG.txt

-$Id:$
-
-Conditional Fields 1.0, 2009-28-11
-- First official release. Enjoy!
-
-Conditional Fields 0.1.alpha1, 2008-06-27
-----------------------
-- First point release. Still very experimental.
-  To see the list of changes: http://drupal.org/project/cvs/206178
-
-Conditional Fields 0.1-dev, 2008-01-04
-----------------------
-- Initial commit of module

File sites/all/modules/conditional_fields/LICENSE.txt

-GNU GENERAL PUBLIC LICENSE
-
-              Version 2, June 1991
-
-Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
-Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
-verbatim copies of this license document, but changing it is not allowed.
-
-                  Preamble
-
-The licenses for most software are designed to take away your freedom to
-share and change it. By contrast, the GNU General Public License is
-intended to guarantee your freedom to share and change free software--to
-make sure the software is free for all its users. This General Public License
-applies to most of the Free Software Foundation's software and to any other
-program whose authors commit to using it. (Some other Free Software
-Foundation software is covered by the GNU Library General Public License
-instead.) You can apply it to your programs, too.
-
-When we speak of free software, we are referring to freedom, not price. Our
-General Public Licenses are designed to make sure that you have the
-freedom to distribute copies of free software (and charge for this service if
-you wish), that you receive source code or can get it if you want it, that you
-can change the software or use pieces of it in new free programs; and that
-you know you can do these things.
-
-To protect your rights, we need to make restrictions that forbid anyone to
-deny you these rights or to ask you to surrender the rights. These restrictions
-translate to certain responsibilities for you if you distribute copies of the
-software, or if you modify it.
-
-For example, if you distribute copies of such a program, whether gratis or for
-a fee, you must give the recipients all the rights that you have. You must make
-sure that they, too, receive or can get the source code. And you must show
-them these terms so they know their rights.
-
-We protect your rights with two steps: (1) copyright the software, and (2)
-offer you this license which gives you legal permission to copy, distribute
-and/or modify the software.
-
-Also, for each author's protection and ours, we want to make certain that
-everyone understands that there is no warranty for this free software. If the
-software is modified by someone else and passed on, we want its recipients
-to know that what they have is not the original, so that any problems
-introduced by others will not reflect on the original authors' reputations.
-
-Finally, any free program is threatened constantly by software patents. We
-wish to avoid the danger that redistributors of a free program will individually
-obtain patent licenses, in effect making the program proprietary. To prevent
-this, we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
-The precise terms and conditions for copying, distribution and modification
-follow.
-
-           GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
-               MODIFICATION
-
-0. This License applies to any program or other work which contains a notice
-placed by the copyright holder saying it may be distributed under the terms
-of this General Public License. The "Program", below, refers to any such
-program or work, and a "work based on the Program" means either the
-Program or any derivative work under copyright law: that is to say, a work
-containing the Program or a portion of it, either verbatim or with
-modifications and/or translated into another language. (Hereinafter, translation
-is included without limitation in the term "modification".) Each licensee is
-addressed as "you".
-
-Activities other than copying, distribution and modification are not covered
-by this License; they are outside its scope. The act of running the Program is
-not restricted, and the output from the Program is covered only if its contents
-constitute a work based on the Program (independent of having been made
-by running the Program). Whether that is true depends on what the Program
-does.
-
-1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this License
-and to the absence of any warranty; and give any other recipients of the
-Program a copy of this License along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and you
-may at your option offer warranty protection in exchange for a fee.
-
-2. You may modify your copy or copies of the Program or any portion of it,
-thus forming a work based on the Program, and copy and distribute such
-modifications or work under the terms of Section 1 above, provided that you
-also meet all of these conditions:
-
-a) You must cause the modified files to carry prominent notices stating that
-you changed the files and the date of any change.
-
-b) You must cause any work that you distribute or publish, that in whole or in
-part contains or is derived from the Program or any part thereof, to be
-licensed as a whole at no charge to all third parties under the terms of this
-License.
-
-c) If the modified program normally reads commands interactively when run,
-you must cause it, when started running for such interactive use in the most
-ordinary way, to print or display an announcement including an appropriate
-copyright notice and a notice that there is no warranty (or else, saying that
-you provide a warranty) and that users may redistribute the program under
-these conditions, and telling the user how to view a copy of this License.
-(Exception: if the Program itself is interactive but does not normally print such
-an announcement, your work based on the Program is not required to print
-an announcement.)
-
-These requirements apply to the modified work as a whole. If identifiable
-sections of that work are not derived from the Program, and can be
-reasonably considered independent and separate works in themselves, then
-this License, and its terms, do not apply to those sections when you distribute
-them as separate works. But when you distribute the same sections as part
-of a whole which is a work based on the Program, the distribution of the
-whole must be on the terms of this License, whose permissions for other
-licensees extend to the entire whole, and thus to each and every part
-regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest your rights to
-work written entirely by you; rather, the intent is to exercise the right to
-control the distribution of derivative or collective works based on the
-Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of a
-storage or distribution medium does not bring the other work under the scope
-of this License.
-
-3. You may copy and distribute the Program (or a work based on it, under
-Section 2) in object code or executable form under the terms of Sections 1
-and 2 above provided that you also do one of the following:
-
-a) Accompany it with the complete corresponding machine-readable source
-code, which must be distributed under the terms of Sections 1 and 2 above
-on a medium customarily used for software interchange; or,
-
-b) Accompany it with a written offer, valid for at least three years, to give
-any third party, for a charge no more than your cost of physically performing
-source distribution, a complete machine-readable copy of the corresponding
-source code, to be distributed under the terms of Sections 1 and 2 above on
-a medium customarily used for software interchange; or,
-
-c) Accompany it with the information you received as to the offer to distribute
-corresponding source code. (This alternative is allowed only for
-noncommercial distribution and only if you received the program in object
-code or executable form with such an offer, in accord with Subsection b
-above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source code
-means all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation and
-installation of the executable. However, as a special exception, the source
-code distributed need not include anything that is normally distributed (in
-either source or binary form) with the major components (compiler, kernel,
-and so on) of the operating system on which the executable runs, unless that
-component itself accompanies the executable.
-
-If distribution of executable or object code is made by offering access to
-copy from a designated place, then offering equivalent access to copy the
-source code from the same place counts as distribution of the source code,
-even though third parties are not compelled to copy the source along with the
-object code.
-
-4. You may not copy, modify, sublicense, or distribute the Program except as
-expressly provided under this License. Any attempt otherwise to copy,
-modify, sublicense or distribute the Program is void, and will automatically
-terminate your rights under this License. However, parties who have received
-copies, or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-5. You are not required to accept this License, since you have not signed it.
-However, nothing else grants you permission to modify or distribute the
-Program or its derivative works. These actions are prohibited by law if you
-do not accept this License. Therefore, by modifying or distributing the
-Program (or any work based on the Program), you indicate your acceptance
-of this License to do so, and all its terms and conditions for copying,
-distributing or modifying the Program or works based on it.
-
-6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these terms and
-conditions. You may not impose any further restrictions on the recipients'
-exercise of the rights granted herein. You are not responsible for enforcing
-compliance by third parties to this License.
-
-7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues), conditions
-are imposed on you (whether by court order, agreement or otherwise) that
-contradict the conditions of this License, they do not excuse you from the
-conditions of this License. If you cannot distribute so as to satisfy
-simultaneously your obligations under this License and any other pertinent
-obligations, then as a consequence you may not distribute the Program at all.
-For example, if a patent license would not permit royalty-free redistribution
-of the Program by all those who receive copies directly or indirectly through
-you, then the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply and
-the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any patents or
-other property right claims or to contest validity of any such claims; this
-section has the sole purpose of protecting the integrity of the free software
-distribution system, which is implemented by public license practices. Many
-people have made generous contributions to the wide range of software
-distributed through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing to
-distribute software through any other system and a licensee cannot impose
-that choice.
-
-This section is intended to make thoroughly clear what is believed to be a
-consequence of the rest of this License.
-
-8. If the distribution and/or use of the Program is restricted in certain
-countries either by patents or by copyrighted interfaces, the original copyright
-holder who places the Program under this License may add an explicit
-geographical distribution limitation excluding those countries, so that
-distribution is permitted only in or among countries not thus excluded. In such
-case, this License incorporates the limitation as if written in the body of this
-License.
-
-9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will be
-similar in spirit to the present version, but may differ in detail to address new
-problems or concerns.
-
-Each version is given a distinguishing version number. If the Program specifies
-a version number of this License which applies to it and "any later version",
-you have the option of following the terms and conditions either of that
-version or of any later version published by the Free Software Foundation. If
-the Program does not specify a version number of this License, you may
-choose any version ever published by the Free Software Foundation.
-
-10. If you wish to incorporate parts of the Program into other free programs
-whose distribution conditions are different, write to the author to ask for
-permission. For software which is copyrighted by the Free Software
-Foundation, write to the Free Software Foundation; we sometimes make
-exceptions for this. Our decision will be guided by the two goals of
-preserving the free status of all derivatives of our free software and of
-promoting the sharing and reuse of software generally.
-
-               NO WARRANTY
-
-11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
-THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
-PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
-STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
-WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
-PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
-NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
-AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
-ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
-LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
-SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF THE USE OR INABILITY TO USE THE
-PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
-OR DATA BEING RENDERED INACCURATE OR LOSSES
-SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
-PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
-IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.
-
-          END OF TERMS AND CONDITIONS

File sites/all/modules/conditional_fields/README.txt

-$Id$
-
-Conditional Fields:
---------------------
-A Drupal module
-
-
-Author:
---------------------
-Gregorio Magini (peterpoe) <gmagini@gmail.com> - http://www.wikirandom.org
-Initially inspired by the Explainfield module -> http://drupal.org/project/explainfield
-
-
-Short Description:
---------------------
-Content fields and groups visibility based on the values of user defined "controlling" fields.
-
-
-Description:
---------------------
-Conditional Fields allows you to assign fields with allowed values as "controlling fields" for other fields and groups. When a field or group is "controlled", it will only be available for editing and displayed if the selected values of the controlling field match the "trigger values" assigned to it.
-When editing a node, the controlled fields are dynamically shown and hidden with javascript.
-You can, for example, make a custom "article teaser" field that is shown only if a "Has teaser" checkbox is checked.
-
-
-Dependencies:
---------------------
-- Drupal core: 6.x or 5.x (note that the 5.x branch of Conditional Fields is very outdated, while the 6.x branch is actively maintained).
-- CCK / content.module > http://drupal.org/project/cck
-- OPTIONAL: Fieldgroups (included in CCK) > If enabled you can also set groups as controlled fields
-
-
-Installation:
---------------------
-- Copy the unpacked folder "conditional_fields" in your modules folder (usually [base_path]/sites/all/module).
-- Go to the modules administration page (admin/build/modules) and activate the module (you will find it in the "CCK" package)
-- Assign the "Administer conditional fields" permission to the desired user roles.
-
-
-Usage:
---------------------
-Read the Conditional Fields handbook:
-http://drupal.org/node/475488
-
-
-Limitations:
---------------------
-- Each field or group can be controlled from only one field (though a field can control any number of fields and groups). This will be corrected in later development.
-- If the controlling field is in a group, it can only control or be controlled only by fields that are in the same group.
-- Conditional Fields, for now, supports only core CCK fields and widgets (checkbox, select, and radio) as controlling fields. Fields from other modules might work, but probably won't. There are confirmed incompatibilities with many non-core CCK modules (Date, Multigroup, Content Taxonomy, etc). 
-
-
-To Do:
---------------------
-Any help is welcome!
---------------------
-Check the issue queue of this module for more information:
-http://drupal.org/project/issues/conditional_fields
-
-These are the top priority future features:
-- Extend compatibility with non-core CCK modules
-- Negate conditions (so that a field can be triggered when some allowed values are *not* selected)
-- Allow multiple controlling fields on the same field
-- Views integration
-- Allow nested conditional fields

File sites/all/modules/conditional_fields/conditional_fields.info

-; $Id:$
-name = Conditional Fields
-description = Content fields and groups visibility based on the values of user defined 'trigger' fields.
-dependencies[] = content
-package = CCK
-core = 6.x
-
-; Information added by drupal.org packaging script on 2010-10-29
-version = "6.x-2.0-beta2"
-core = "6.x"
-project = "conditional_fields"
-datestamp = "1288377343"
-

File sites/all/modules/conditional_fields/conditional_fields.install

-<?php
-// $Id$
-/**
- * @file
- * Install, update and uninstall functions for the Conditional Fields module.
- */
-
-/**
- * Implementation of hook_install().
- */
-function conditional_fields_install() {
-  drupal_install_schema('conditional_fields');
-
-  // Increase module weight to 10, over fieldgroup.module which has 9.
-  db_query("UPDATE {system} SET weight = 10 WHERE name = 'conditional_fields'");
-
-  $t = get_t();
-  drupal_set_message($t('Conditional Fields installed. You should now <a href="!url">give the permission</a> to administer conditional fields to the desired roles.', array('!url' => url('admin/user/permissions', array('fragment' => 'module-conditional_fields')))));
-}
-
-function conditional_fields_schema() {
-  $schema['conditional_fields'] = array(
-    'fields' => array(
-      'control_field_name' => array(
-        'type' => 'varchar',
-        'length' => '32',
-        'not null' => TRUE,
-        'default' => ''),
-      'field_name' => array(
-        'type' => 'varchar',
-        'length' => '32',
-        'not null' => TRUE,
-        'default' => ''),
-      'type' => array(
-        'type' => 'varchar',
-        'length' => '127',
-        'not null' => TRUE,
-        'default' => ''),
-      'trigger_values' => array(
-        'type' => 'text',
-        'size' => 'medium',
-        'not null' => TRUE)
-        ),
-      'primary key' => array('control_field_name', 'field_name', 'type'),
-    );
-
-  return $schema;
-}
-
-
-/**
- * Implementation of hook_uninstall().
- */
-function conditional_fields_uninstall() {
-  drupal_uninstall_schema('conditional_fields');
-
-  // Delete all the conditional fields variables and then clear the variable cache
-  db_query("DELETE FROM {variable} WHERE name LIKE 'c_fields_%'");
-  cache_clear_all('variables', 'cache');
-
-}
-
-/**
- * Add primary key to table
- */
-function conditional_fields_update_6002() {
-  $ret = array();
-  db_add_primary_key($ret, 'conditional_fields', array('control_field_name', 'field_name', 'type'));
-  
-  return $ret;
-}

File sites/all/modules/conditional_fields/conditional_fields.js

-/* $Id$ */
-
-if (!Drupal.ConditionalFields) {
-  Drupal.ConditionalFields = {};
-}
-
-Drupal.ConditionalFields.switchField = function(id, values, onPageReady) {
-  // Check each controlled field
-  if (Drupal.settings.ConditionalFields.controlling_fields == undefined || Drupal.settings.ConditionalFields.controlling_fields[id] == undefined) {
-    return;
-  }
-  $.each(Drupal.settings.ConditionalFields.controlling_fields[id], function(i, controlledField) {
-    var triggers = Drupal.ConditionalFields.checkTriggered(controlledField, values);
-    // If the field was not triggered, hide it
-    if (!triggers) {
-      Drupal.ConditionalFields.doAnimation(controlledField, 'hide', onPageReady);
-    }
-    // Else check other controlling fields: if any one doesn't trigger, hide the field and stop checking
-    else {
-      var otherTriggers = true;
-      $.each(Drupal.settings.ConditionalFields.controlling_fields, function(ii, maybeControllingField) {
-        if (ii != id) {
-          $.each(maybeControllingField, function(iii, maybeControlledField) {
-            if (maybeControlledField.field_id == controlledField.field_id) {
-              otherTriggers = Drupal.ConditionalFields.checkTriggered(maybeControlledField, Drupal.ConditionalFields.findValues($(ii)));
-              if (!otherTriggers) {
-                return false;
-              }
-            }
-          });
-        }
-        if (!otherTriggers) {
-          Drupal.ConditionalFields.doAnimation(controlledField, 'hide', onPageReady);
-          return false;
-        }
-      });
-      if (otherTriggers) {
-        Drupal.ConditionalFields.doAnimation(controlledField, 'show', onPageReady);
-      }
-    }
-  });
-}
-
-Drupal.ConditionalFields.checkTriggered = function(controlledField, selectedValues) {
-  var triggers = false;
-  $.each(controlledField.trigger_values, function(ii, val) {
-    if (jQuery.inArray(val, selectedValues) !== -1) {
-      triggers = true;
-      return false;
-    }
-  });
-  return triggers;
-}
-
-Drupal.ConditionalFields.doAnimation = function(fieldSettings, showOrHide, onPageReady) {
-  /* Multiple fields are enclosed in a wrapper */
-  if ($(fieldSettings.field_id).parents('#' + fieldSettings.field_id.substring(13) + '-add-more-wrapper').length == 1) {
-    var toSwitch = $('#' + fieldSettings.field_id.substring(13) + '-add-more-wrapper');
-  } else {
-    var toSwitch = $(fieldSettings.field_id);
-  }
-
-  if (Drupal.settings.ConditionalFields.ui_settings == 'disable') {
-    var disabled = '';
-    if (showOrHide == 'hide') {
-      disabled = 'disabled';
-    }
-    toSwitch.find('textarea, input, select').attr('disabled', disabled);
-  }
-  /* Avoid flickering */
-  else if (onPageReady == true) {
-    /* Setting css instead of simply hiding to avoid interference from collapse.js */
-    showOrHide == 'show' ? toSwitch.show() : toSwitch.css('display', 'none');
-  }
-  else {
-    switch (Drupal.settings.ConditionalFields.ui_settings.animation) {
-      case 0:
-        showOrHide == 'show' ? toSwitch.show() : toSwitch.hide();
-        break;
-      case 1:
-        /* Don't double top and bottom margins while sliding. */
-        var firstChild = toSwitch.children(':first-child');
-        var marginTop = firstChild.css('margin-top');
-        var marginBottom = firstChild.css('margin-bottom');
-        firstChild.css('margin-top', '0').css('margin-bottom', '0');
-        if (showOrHide == 'show') {
-          toSwitch.slideDown(Drupal.settings.ConditionalFields.ui_settings.anim_speed, function() {
-            firstChild.css('margin-top', marginTop).css('margin-bottom', marginBottom);
-          });
-        }
-        else {
-          toSwitch.slideUp(Drupal.settings.ConditionalFields.ui_settings.anim_speed, function() {
-            firstChild.css('margin-top', marginTop).css('margin-bottom', marginBottom);
-          });
-        }
-        break;
-      case 2:
-        showOrHide == 'show' ? toSwitch.fadeIn(Drupal.settings.ConditionalFields.ui_settings.anim_speed) :
-                               toSwitch.fadeOut(Drupal.settings.ConditionalFields.ui_settings.anim_speed);
-    }
-  }
-}
-
-Drupal.ConditionalFields.findValues = function(field) {
-  var values = [];
-  field.find('option:selected, input:checked, input:text, textarea').each( function() {
-    values[values.length] = this.value;
-  });
-  return values;
-}       
-
-Drupal.ConditionalFields.fieldChange = function() {
-  var values = Drupal.ConditionalFields.findValues($(this));
-  var id = '#' + $(this).attr('id');
-  Drupal.ConditionalFields.switchField(id, values, false);
-}
-
-Drupal.behaviors.ConditionalFields = function (context) {
-  $('.conditional-field.controlling-field:not(.conditional-field-processed)').addClass('conditional-field-processed').each(function () {
-    /* Set default state */
-    Drupal.ConditionalFields.switchField('#' + $(this).attr('id'), Drupal.ConditionalFields.findValues($(this)), true);
-    if ($(this).find('option, input:not(:text)').length > 0) {
-      /* Apparently, Explorer doesn't catch the change event? */
-      $.browser.msie == true ? $(this).click(Drupal.ConditionalFields.fieldChange) : $(this).change(Drupal.ConditionalFields.fieldChange);
-    }
-    else if ($(this).find('textarea, input:text').length > 0) {
-      $(this).keyup(Drupal.ConditionalFields.fieldChange);
-    }
-  });
-};

File sites/all/modules/conditional_fields/conditional_fields.module

-<?php
-// $Id$
-
-/**
- * @file
- * Content fields and groups visibility based on the values of user defined 'trigger' fields.
- */
-
-// Fields settings
-define ('C_FIELDS_JS_NO', 0);
-define ('C_FIELDS_JS_HIDE', 1);
-define ('C_FIELDS_JS_DISABLE', 2);
-
-define ('C_FIELDS_ANIMATION_NO', 0);
-define ('C_FIELDS_ANIMATION_FADE', 1);
-define ('C_FIELDS_ANIMATION_SLIDE', 2);
-
-define ('C_FIELDS_ORPHANED_HIDE', 0);
-define ('C_FIELDS_ORPHANED_SHOW_TRIGGERED', 1);
-define ('C_FIELDS_ORPHANED_SHOW_ALL', 2);
-
-function conditional_fields_help($path, $arg) {
-switch ($path) {
-  case "admin/content/node-type/$arg[3]/conditional":
-    return t('These settings only apply to the conditional fields of this content type.');
-    break;
-  case 'admin/help#conditional_fields':
-    $output = '<p>' . t('The Conditional Fields module allows to set fields with allowed values as "controlling fields" for other fields and groups. When a field or group is "controlled", it will only be available for editing and displayed if the selected values of the controlling field match the "trigger values" assigned to it. You can, for example, make a custom "article teaser" field that is shown only if a "Has teaser" checkbox is checked.') . '</p>';
-    $output .= '<p>' . t('When editing a node, the controlled fields are dynamically shown and hidden with javascript.') . '</p>';
-    $output .= '<p>' . t('On node view, the controlled fields which were left untriggered are hidden.') . '</p>';
-    $output .= '<p>' . t('Once the module is activated, a new set of options will appear in the editing form of cck fields, from where you can select which of the allowed values available of candidate "controlling" fields will make the field "controlled". If <em>- Not controlling -</em> or no value is selected, the field will be shown as usual.') . '</p>';
-    $output .= '<p>' . t('These are the requisites to make a field controllable:') . '</p>';
-    $output .= '<ul>';
-    $output .= '<li>' . t('The controlling field widget must be single or multiple select list, radio buttons or checkboxes.') . '</li>';
-    $output .= '<li>' . t('The controlling field must have allowed values.') . '</li>';
-    $output .= '<li>' . t('If the controlled field is in a group, the controlling field must be in the same group.') . '</li>';
-    $output .= '<li>' . t('If you want to make a group controllable, the controlling field should not be inside a group.') . '</li>';
-    $output .= '</ul>';
-    $output .= '<p>' . t('There is also a "Conditional fields" settings tab in every content type admin page.') . '</p>';
-    $output .= '<p>' . t('The <a href="@handbook">Conditional Fields Handbook</a> contains further explanations and examples.', array('@handbook' => url('http://drupal.org/node/475488'))) . '</p>';
-    return $output;
-    break;
-  }
-}
-
-/**
- * Implementation of hook_menu().
- */
-function conditional_fields_menu() {
-  $items = array();
-
-  foreach (node_get_types() as $type) {
-    $content_type = content_types($type->type);
-
-    $items['admin/content/node-type/' . $content_type['url_str'] . '/conditional'] = array(
-      'title' => 'Conditional fields',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('_conditional_fields_admin', $content_type['type']),
-      'access arguments' => array('administer conditional fields'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 5
-      );
-  }
-
-  return $items;
-}
-
-/**
- * Implementation of hook_perm().
- */
-function conditional_fields_perm() {
-  return array('administer conditional fields');
-}
-
-/**
- *  Administration form for conditional fields
- */
-function _conditional_fields_admin($form, $type) {
-  $form = array();
-
-  $form['js_set'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('User Interface options'),
-    '#collapsible' => TRUE
-  );
-  $form['js_set']['js'] = array(
-    '#type' => 'radios',
-    '#options' => array(
-      C_FIELDS_JS_NO => t("Don't use javascript. Fields are only hidden on node view."),
-      C_FIELDS_JS_HIDE => t('Hide untriggered fields.'),
-      C_FIELDS_JS_DISABLE => t('Disable untriggered fields.')
-    ),
-    '#title' => 'Javascript',
-    '#description' => t('Choose the desired javascript behaviour in node editing forms.'),
-    '#default_value' => variable_get('c_fields_js_' . $type, C_FIELDS_JS_HIDE)
-  );
-  $form['js_set']['anim'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Animation'),
-    '#description' => t('These settings have effect only if you select the "Hide untriggered fields" option above.'),
-  );
-  $form['js_set']['anim']['animation'] = array(
-    '#type' => 'radios',
-    '#title' => t('Type'),
-    '#default_value' => variable_get('c_fields_animation_' . $type, C_FIELDS_ANIMATION_NO),
-    '#options' => array(
-      C_FIELDS_ANIMATION_NO => t('No animation'),
-      C_FIELDS_ANIMATION_FADE => t('Slide down'),
-      C_FIELDS_ANIMATION_SLIDE => t('Fade'),
-    ),
-  );
-  $form['js_set']['anim']['anim_speed'] = array(
-    '#type' => 'radios',
-    '#title' => t('Speed'),
-    '#description' => t('The speed at which the animation is performed. Slow = 600ms; Normal = 400ms; Fast = 200ms.'),
-    '#default_value' => variable_get('c_fields_anim_speed_' . $type, 'normal'),
-    '#options' => array(
-      'slow' => t('Slow'),
-      'normal' => t('Normal'),
-      'fast' => t('Fast'),
-    ),
-  );
-  $form['orphaned'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Orphaned controlled fields settings'),
-    '#description' => t('Configure the visibility/editability of controlled fields whose controlling fields are not visible/editable.'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE
-  );
-  $options = array(C_FIELDS_ORPHANED_HIDE => t('Hide'), C_FIELDS_ORPHANED_SHOW_TRIGGERED => t('Show only if triggered'), C_FIELDS_ORPHANED_SHOW_ALL => t('Show'));
-  $form['orphaned']['orphaned_view'] = array(
-    '#type' => 'radios',
-    '#title' => t('On node view'),
-    '#options' => $options,
-    '#default_value' => variable_get('c_fields_view_' . $type, C_FIELDS_ORPHANED_SHOW_TRIGGERED)
-  );
-  $form['orphaned']['orphaned_edit'] = array(
-    '#type' => 'radios',
-    '#title' => t('On node edit'),
-    '#options' => $options,
-    '#default_value' => variable_get('c_fields_edit_' . $type, C_FIELDS_ORPHANED_SHOW_TRIGGERED)
-  );
-  $form['reset_default'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Reset untriggered fields to default values'),
-    '#description' => t('Select this box to reset untriggered controlled fields to their default values when saving a node.'),
-    '#default_value' => variable_get('c_fields_reset_default_' . $type, 1)
-  );
-  $form['show_all'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Administrators see all fields'),
-    '#description' => t('Select this box to let users with the <a href="@access-control-page">administer conditional fields</a> permission to view all controlled fields of a node.', array('@access-control-page' => url('admin/user/permissions', array('fragment' => 'module-conditional_fields')))),
-    '#default_value' => variable_get('c_fields_show_all_' . $type, 0)
-  );
-  $form['delete'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Delete'),
-    '#description' => t('Delete all conditional fields configured for this content type. This will delete the conditional fields settings, not the fields themselves.'),
-    '#default_value' => 0
-  );
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save'),
-  );
-
-  return $form;
-}
-
-function _conditional_fields_admin_submit($form, &$form_state) {
-  $type = $form['#parameters'][2];
-
-  variable_set('c_fields_js_' . $type, $form_state['values']['js']);
-  variable_set('c_fields_animation_' . $type, $form_state['values']['animation']);
-  variable_set('c_fields_anim_speed_' . $type, $form_state['values']['anim_speed']);
-  variable_set('c_fields_view_' . $type, $form_state['values']['orphaned_view']);
-  variable_set('c_fields_edit_' . $type, $form_state['values']['orphaned_edit']);
-  variable_set('c_fields_reset_default_' . $type, $form_state['values']['reset_default']);
-  variable_set('c_fields_show_all_' . $type, $form_state['values']['show_all']);
-
-  drupal_set_message(t('Conditional fields options for this content type saved.') . $message);
-
-  if ($form_state['values']['delete'] == 1) {
-    conditional_fields_node_type_delete($type);
-    drupal_set_message(t('All configured conditional fields for this content type have been deleted.'));
-  }
-}
-
-/**
- * Implementation of hook_nodeapi().
- */
-function conditional_fields_nodeapi(&$node, $op, $teaser, $page) {
-  if ($op == 'view') {
-    // First we check if there any conditional fields in this node type
-    $type = content_types($node->type);
-    if (!$data = conditional_fields_load_data($type['type'])) {
-      return;
-    }
-
-    // Then we check if user is an administrator and this content type
-    // and has the show hidden fields pref enabled
-    if (user_access('administer conditional fields') && variable_get('c_fields_show_all_' . $type['type'], 0)) {
-      return;
-    }
-
-    foreach ($data as $field) {
-
-      // We might have to look for the field in a group
-      $controlled_group = conditional_fields_get_group($node->type, $field['field_name']);
-      $controlling_group = conditional_fields_get_group($node->type, $field['control_field_name']);
-
-      // The controlled field is not in a group and is not in the form for other reasons. Skip.
-      if (!$controlled_group && !$node->content[$field['field_name']]) {
-        continue;
-      }
-
-      // The controlled field is in a group and is not the form for other reasons. Skip.
-      if ($controlled_group && !$node->content[$controlled_group]['group'][$field['field_name']]) {
-        continue;
-      }
-
-      $viewed = FALSE;
-      $current_values[$field['control_field_name']] = array();
-
-      // Create an array with the selected controlling field's values
-      // Check if the controlling field is viewed as well
-      $field_key = array_keys($type['fields'][$field['control_field_name']]['columns']);
-      foreach ((array)$node->$field['control_field_name'] as $value) {
-        $current_values[$field['control_field_name']][] = $value[$field_key[0]];
-        if (!empty($value[$field_key[0]])) {
-          if ($node->content[$field['control_field_name']]['field']['#access'] == TRUE ||
-              ($controlling_group && $node->content[$controlling_group]['group'][$field['control_field_name']]['field']['#access'] == TRUE)) {
-            $viewed = TRUE;
-          }
-        }
-      }
-
-      if ($viewed) {
-        // Hide the controlled field if it is not triggered
-        if (!conditional_fields_is_triggered($current_values[$field['control_field_name']], $field['trigger_values'])) {
-          if ($controlled_group) {
-            $node->content[$controlled_group]['group'][$field['field_name']]['#access'] = FALSE;
-          }
-          else {
-            $node->content[$field['field_name']]['#access'] = FALSE;
-          }
-        }
-      }
-      else {
-        // Apply orphaned fields settings
-        $orphaned_settings = variable_get('c_fields_view_' . $node->type, C_FIELDS_ORPHANED_SHOW_TRIGGERED);
-
-        switch ($orphaned_settings) {
-          case C_FIELDS_ORPHANED_SHOW_TRIGGERED:
-            // If the field was triggered, don't hide it
-            if (conditional_fields_is_triggered($current_values[$field['control_field_name']], $field['trigger_values'])) {
-              break;
-            }
-          case C_FIELDS_ORPHANED_HIDE:
-            // We hide the field
-            if ($controlled_group) {
-              $node->content[$controlled_group]['group'][$field['field_name']]['#access'] = FALSE;
-            }
-            else {
-              $node->content[$field['field_name']]['#access'] = FALSE;
-            }
-          case C_FIELDS_ORPHANED_SHOW_ALL:
-            // Nothing to do...
-            break;
-        }
-      }
-    }
-  }
-}
-
-/**
- * Implementation of hook_form_alter().
- */
-function conditional_fields_form_alter(&$form, $form_state, $form_id) {
-  switch ($form_id) {
-    case 'content_field_edit_form':
-      if (!isset($form_state['clicked_button']) || $form_state['clicked_button']['#parents'][0] != 'change') {
-        conditional_fields_content_admin_field($form);
-      }
-      break;
-    case 'fieldgroup_group_edit_form':
-      conditional_fields_fieldgroup_group_edit_form($form);
-      break;
-    case 'content_field_overview_form':
-      // Find conditional fields, mark them, and disable group select for them
-      $conditional_fields = conditional_fields_field_overview_form($form);
-      break;
-    case '_content_admin_field_remove':
-      $form['#submit'] = $form['#submit'] + array('_conditional_fields_content_admin_field_remove_submit' => array());
-      break;
-    case 'fieldgroup_remove_group':
-      $form['#submit'][] = 'conditional_fields_fieldgroup_remove_group_submit';
-      break;
-    case 'content_add_more_js':
-      // Handle ahah multiple fields
-      foreach ($form as $item_name => $item) {
-        if (db_result(db_query("SELECT COUNT(*) FROM {conditional_fields} WHERE field_name = '%s'", $item_name))) {
-          $form[$item_name]['#post_render'] = array_merge(array('conditional_fields_add_more_post_render'), (array)$form[$item_name]['#post_render']);
-          foreach (element_children($form[$item_name]) as $element) {
-            conditional_fields_custom_required_field($form[$item_name][$element]);
-          }
-        }
-      }
-      break;
-    case 'content_copy_import_form':
-      $form['#submit'][] = 'conditional_fields_import';
-      break;
-  }
-
-  if (isset($form['type']['#value']) && $form_id == $form['type']['#value'] . '_node_form') {
-    conditional_fields_node_editing_form($form, $form_state);
-  }
-}
-
-/**
- * Alteration of the field editing form
- */
-function conditional_fields_content_admin_field(&$form) {
-  if (!user_access('administer conditional fields')) {
-    return;
-  }
-
-  $type = (array)content_types($form['type_name']['#value']);
-
-  // Load conditional fields data.
-  $data = conditional_fields_load_data($type['type']);
-  // Get all fields controlled by this one.
-  $controlled_fields = array();
-  foreach ($data as $row) {
-    if ($row['control_field_name'] == $form['field_name']['#value']) {
-      $controlled_fields[$row['field_name']] = $row['trigger_values'];
-    }
-  }
-
-  // Build controlling field form.
-  if (!empty($controlled_fields)) {
-    // Needed to handle nested fields.
-    $form['#controlled_fields'] = $controlled_fields;
-
-    // Add validation function
-    $form['#validate'] = array_merge(array('conditional_fields_content_admin_field_validate'), $form['#validate']);
-    $form['controlled_fields'] = array(
-      '#type' => 'value',
-      '#value' => $controlled_fields,
-    );
-
-    $controlled_fieldset = conditional_fields_content_admin_field_controlling($type, $controlled_fields);
-  }
-
-  // Check if field is in a group
-  if (isset($form['widget']['group'])) {
-    $group_of_controlled_field = $form['widget']['group']['#value'];
-  }
-
-  // Get candidate controlling fields
-  foreach ($type['fields'] as $field) {
-    // - Exclude this one :)
-    if ($field['field_name'] == $form['field_name']['#value']) {
-      continue;
-    }
-    // - Exlude fields already controlled by this one
-    if ($controlled_fields[$field['field_name']]) {
-      continue;
-    }
-    // - Exclude fields without Allowed values
-    if (!$allowed_values[$field['field_name']] = conditional_fields_allowed_values($field)) {
-      continue;
-    }
-    // If a field is inside a controlled group, it can control or be controlled only by fields in the same group.
-    // This is needed to avoid uncontrollable loops.
-    // First we gather data about groups
-    $group_of_candidate_field = conditional_fields_get_group($field['type_name'], $field['field_name']);
-    if ($group_of_controlled_field || $group_of_candidate_field) {
-      $group_of_controlled_field_is_controlled = FALSE;
-      $group_of_candidate_field_is_controlled = FALSE;
-      foreach ($data as $row) {
-        if ($row['field_name'] == $group_of_controlled_field) {
-          $group_of_controlled_field_is_controlled = TRUE;
-        }
-        elseif ($row['field_name'] == $group_of_candidate_field) {
-          $group_of_candidate_field_is_controlled = TRUE;
-        }
-      }
-    }
-    // If the controlled field is in a group...
-    if ($group_of_controlled_field) {
-      // - Exclude candidates outside the controlled field's group if the group is controlled
-      if (!$group_of_candidate_field && $group_of_controlled_field_is_controlled) {
-        continue;
-      }
-      // - Exclude candidates in different groups if either group is controlled
-      elseif ($group_of_candidate_field &&
-              $group_of_candidate_field != $group_of_controlled_field &&
-              ($group_of_candidate_field_is_controlled || $group_of_controlled_field_is_controlled)) {
-        continue;
-      }
-    }
-    // Else if the controlled field is not in a group...
-    else {
-      // - Exclude fields in controlled groups
-      if ($group_of_candidate_field && $group_of_candidate_field_is_controlled) {
-        continue;
-      }
-    }
-    $available_fields[$field['field_name']] = $field;
-  }
-
-  if (isset($available_fields)) {
-    $default_values = conditional_fields_available_fields_default_values($form['field_name']['#value'], $available_fields);
-    $available_fieldset = conditional_fields_content_admin_field_controllable($type, $default_values, $available_fields, $allowed_values, 'field');
-
-    // Add validation function
-    $form['#validate'] = array_merge(array('conditional_fields_content_admin_field_validate'), $form['#validate']);
-
-    // Add submission function
-    $form['#submit'] = array_merge(array('conditional_fields_forms_submit'), $form['#submit']);
-  }
-
-  // Add the fieldsets to the form
-  if ($controlled_fieldset || $available_fieldset) {
-    $form['widget']['conditional_fields'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Conditional fields settings'),
-      '#tree' => TRUE,
-      '#collapsible' => TRUE,
-      '#collapsed' => is_null($default_values),
-      '#weight' => 8,
-      '#attributes' => array('id' => 'conditional-fields-settings'),
-    );
-    if ($controlled_fieldset) {
-      $form['widget']['conditional_fields']['controlling_fields'] = $controlled_fieldset;
-    }
-    if ($available_fieldset) {
-      if ($controlled_fieldset) {
-        $available_fieldset['#description'] .= '<p><strong>' . t('Note: this field is already controlling other fields. If you make it controlled, its own controlled fields will be assigned the same settings.') . '</strong></p>';
-      }
-      $form['widget']['conditional_fields']['available_fields'] = $available_fieldset;
-    }
-  }
-  return;
-}
-
-/**
- * Controlling field settings form
- * (just a table containing information about controlled fields)
- */
-function conditional_fields_content_admin_field_controlling($type, $controlled_fields) {
-  foreach ($controlled_fields as $field => $trigger_values) {
-    if (strpos($field , 'group_') === 0) { // It's a group
-      $rows[] = array($field,
-        implode($trigger_values, ', ') . ' (' . t('<a href="@edit-group">edit</a>', array('@edit-group' => url('admin/content/node-type/' . $type['url_str'] . '/groups/' . $field, array('fragment' => 'conditional-fields-settings')))) . ')',
-        t('group')
-      );
-    }
-    else { // It's a field
-      $rows[] = array($field,
-        implode($trigger_values, ', ') . ' ('. t('<a href="@edit-field">edit</a>', array('@edit-field' => url('admin/content/node-type/' . $type['url_str'] . '/fields/' . $field, array('fragment' => 'conditional-fields-settings')))) . ')',
-        t('field'),
-      );
-    }
-  }
-
-  $output = array(
-    '#type' => 'fieldset',
-    '#title' => t('Controlled fields') . ' (' . count($rows) . ')',
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#description' => '<p>' . t('Below are listed all fields and groups controlled by this field.') . '</p>',
-    'controlled_fields_table' => array('#value' => theme('table', array(t('Name'), t('Trigger values'), t('Type')), $rows)),
-  );
-
-  return $output;
-}
-
-/**
- * Controllable field settings form
- */
-function conditional_fields_content_admin_field_controllable($type, $default_values, $available_fields, $allowed_values, $context) {
-  $output = array(
-    '#type' => 'fieldset',
-    '#title' => t('Controlling fields'),
-    '#collapsible' => TRUE,
-    '#collapsed' => FALSE,
-    '#description' => '<p>' . t('Choose which allowed values of available controlling fields will trigger this @context, making it visible both in node editing and view. If no value is set, the @context will be always visible. Only fields with <em>Allowed values</em> set are available for control. If a field is inside a controlled group, it can control or be controlled only by fields in the same group.', array('@context' => $context)) . '</p>',
-  );
-
-  // Create selection lists
-  foreach ($available_fields as $field) {
-    $allowed_values[$field['field_name']] = array('conditional_field_no_value' => t('- Not controlling -')) + $allowed_values[$field['field_name']];
-
-    if (isset($default_values[$field['field_name']]) && $default_values[$field['field_name']] != FALSE) {
-      $default_value = $default_values[$field['field_name']];
-    }
-    else {
-      $default_value = 'conditional_field_no_value';
-    }
-
-    $output[$field['field_name']] = array(
-      '#type' => 'select',
-      '#multiple' => TRUE,
-      '#title' => $field['widget']['label'] . ' (' . $field['field_name'] . ')',
-      // To do: set right url for groups
-      '#description' => t('<a href="@edit-field">Edit the allowed values</a> of %field-name.', array('@edit-field' => url('admin/content/node-type/' . $type['url_str'] . '/fields/' . $field['field_name'], array('query' => 'destination=admin/content/node-type/' . arg(3) . '/' . arg(4) . '/' . arg(5))), '%field-name' => $field['field_name']) ),
-      '#options' => $allowed_values[$field['field_name']],
-      '#default_value' => $default_value,
-    );
-  }
-
-  return $output;
-}
-
-/**
- * Alteration of the fieldgroup editing form
- */
-function conditional_fields_fieldgroup_group_edit_form(&$form) {
-  if (!user_access('administer conditional fields')) {
-    return;
-  }
-
-  // A group that contains fields controlling or controlled by fields in other groups or no groups at all,
-  // cannot be a controlled group.
-  if ($data = conditional_fields_load_data($form['#content_type']['type'])) {
-    $groups = fieldgroup_groups($form['#content_type']['type']);
-    $group = $groups[$form['group_name']['#default_value']];
-    foreach ($data as $row) {
-      if (isset($group['fields'][$row['field_name']]) XOR isset($group['fields'][$row['control_field_name']])) {
-        return;
-      }
-    }
-  }
-
-  // Find fields with allowed values which are not inside a group
-  foreach ($form['#content_type']['fields'] as $field) {
-    $in_group = fieldgroup_get_group($form['#content_type']['type'], $field['field_name']);
-    if (!$in_group) {
-      if ($allowed_values[$field['field_name']] = conditional_fields_allowed_values($field)) {
-        $available_fields[$field['field_name']] = $field;
-      }
-    }
-  }
-
-  if (isset($available_fields)) {
-    $default_values = conditional_fields_available_fields_default_values($form['group_name']['#default_value'], $available_fields);
-    // Add the fieldset to the form
-    $form['widget']['conditional_fields'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Conditional fields settings'),
-      '#tree' => TRUE,
-      '#collapsible' => TRUE,
-      '#collapsed' => is_null($default_values),
-      '#weight' => 8,
-      '#attributes' => array('id' => 'conditional-fields-settings'),
-    );
-    $form['widget']['conditional_fields']['available_fields'] = conditional_fields_content_admin_field_controllable($form['#content_type'], $default_values, $available_fields, $allowed_values, 'group');
-
-    // Add validation function
-    $form['#validate'][] = 'conditional_fields_content_admin_field_validate';
-    // Add submission function
-    $form['#submit'] = array_merge(array('conditional_fields_forms_submit'), $form['#submit']);
-  }
-  return;
-}
-
-/**
- * Check selection of values
- */
-function conditional_fields_content_admin_field_validate($form, &$form_state) {
-  if ($form_state['values']['conditional_fields']['available_fields']) {
-    $count_selected = 0;
-    foreach ($form_state['values']['conditional_fields']['available_fields'] as $available_field => $trigger_values) {
-      // Disallow selecting "Not controlling" and values at the same time
-      if ($trigger_values['conditional_field_no_value'] && count($trigger_values) > 1) {
-        form_set_error('conditional_fields][' . $available_field, t('You cannot select "Not controlling" and other values at the same time.'));
-      }
-    }
-  }
-  else {
-    // Warn user on allowed values change
-    if (!$GLOBALS['content_copy'] && !empty($form['#controlled_fields']) && $form_state['values']['allowed_values'] != $form_state['#field_info'][$form['values']['field_name']]['allowed_values']) {
-      drupal_set_message(t('If you changed or removed any allowed value from the field, you might have to review its controlled fields and fieldgroups settings.'), 'warning');
-    }
-  }
-}
-
-/**
- * Handle saving of conditional field settings.
- * The controlled field can be either a field or a group
- */
-function conditional_fields_forms_submit($form, &$form_state) {
-  $controlled_field = (isset($form_state['values']['field_name']) ? $form_state['values']['field_name'] : $form_state['values']['group_name']);
-  $type = (isset($form['#field']['type_name']) ? $form['#field']['type_name'] : $form['#content_type']['type']);
-  conditional_fields_save_field($type, $controlled_field, $form_state['values']['conditional_fields']['available_fields']);
-
-  // Fields already controlled should share the same settings of their controlling fields
-  if ($form_state['values']['controlled_fields']) {
-    foreach ($form_state['values']['controlled_fields'] as $field_name => $trigger_values) {
-      conditional_fields_save_field($type, $field_name, $form_state['values']['conditional_fields']['available_fields']);
-    }
-  }
-}
-
-/**
- * Find the allowed values for a field
- */
-function conditional_fields_allowed_values($field) {
-  static $options;
-  if ($options[$field['field_name']]) {
-    return $options[$field['field_name']];
-  }
-
-  $function = $field['module'] .'_allowed_values';
-  $options[$field['field_name']] = function_exists($function) ? $function($field) : content_allowed_values($field);
-
-  // Strip tags, since we use a select, not the real widget.
-  foreach ($options[$field['field_name']] as $key => $label) {
-    $options[$field['field_name']][$key] = strip_tags($label);
-  }
-
-  return $options[$field['field_name']];
-}
-
-/**
- * Alter node form. We do it in after_build for compatibility
- * with non-core CCK widgets
- */
-function conditional_fields_node_editing_form(&$form, $form_state) {
-  $form['#after_build'][] = 'conditional_fields_node_after_build';
-}
-
-/**
- * Main tasks:
- * - Create javascript settings
- * - Prepare custom validation for required controlled fields
- * - Assign a theme function to conditional fields
- * - Apply orphaned fields settings if applicable
- */
-function conditional_fields_node_after_build($form, &$form_state) {
-  // Avoid running twice when the form is rebuilt with AHAH
-  if ($form_state['clicked_button']['#ahah']) {
-    return $form;
-  }
-
-  $type_name = $form['type']['#value'];
-
-  // Do nothing if there are no conditional fields
-  if (!$data = conditional_fields_load_data($type_name)) {
-    return $form;
-  }
-
-  $controlling_fields = array();
-  $missing_controlling_fields = array();
-  $controlled_fields = array();
-  $required_fields = array();
-  $js_settings = array();
-
-  foreach ($data as $row) {
-    $controlling_fields[$row['control_field_name']][$row['field_name']] = $row['trigger_values'];
-    $controlled_fields[$row['field_name']][$row['control_field_name']] = $row['trigger_values'];
-  }
-
-  /* Handle controlling fields */
-  foreach ($controlling_fields as $controlling_field_name => $controlling_field_descendants) {
-    // Check if the controlling field is in the form, user has access to it, and is editable.
-    $group_of_controlling_field = conditional_fields_get_group($type_name, $controlling_field_name);
-    $controlling_field = conditional_fields_item_in_form($form, $controlling_field_name, $group_of_controlling_field);
-    if (!$controlling_field || $controlling_field['#access'] === FALSE || $controlling_field['#type'] == 'markup') {
-      $missing_controlling_fields[] = $controlling_field_name;
-      continue;
-    }
-
-    // Set values on form for themeing.
-    if ($group_of_controlling_field) {
-      $form[$group_of_controlling_field][$controlling_field_name]['#controlling_fields'] = TRUE;
-      conditional_fields_item_apply_theme($form[$group_of_controlling_field][$controlling_field_name]);
-    }
-    else {
-      $form[$controlling_field_name]['#controlling_fields'] = TRUE;
-      conditional_fields_item_apply_theme($form[$controlling_field_name]);
-    }
-  }
-
-  /* Handle controlled fields */
-  foreach ($controlled_fields as $controlled_field_name => $controlled_field_parents) {
-    // Check if the controlled field is in the form and user has access to it.
-    $group_of_controlled_field = conditional_fields_get_group($type_name, $controlled_field_name);
-    $controlled_field = conditional_fields_item_in_form($form, $controlled_field_name, $group_of_controlled_field);
-    if (!$controlled_field || $controlled_field['#access'] === FALSE) {
-      continue;
-    }
-
-    // Handle orphaned fields.
-    foreach ($missing_controlling_fields as $missing_controlling_field) {
-      unset($controlled_field_parents[$missing_controlling_field]);
-    }
-    if (count($controlled_field_parents) == 0) {
-      $orphaned_settings = variable_get('c_fields_edit_' . $type_name, C_FIELDS_ORPHANED_SHOW_TRIGGERED);
-      switch ($orphaned_settings) {
-        case C_FIELDS_ORPHANED_SHOW_TRIGGERED:
-          // Show only triggered fields. E.g.: fields whose controlling
-          // fields have triggering values set by default, or set by
-          // another user with permissions.
-          $triggered = TRUE;
-          foreach ($controlling_fields as $controlling_field_name => $controlling_field_descendants) {
-            if ($controlling_field_descendants[$controlled_field_name]) {
-              if (!conditional_fields_is_triggered($form_state['values'][$controlling_field_name], $controlling_field_descendants[$controlled_field_name])) {
-                $triggered = FALSE;
-                break;
-              }
-            }
-          }
-          if ($triggered) {
-            break;
-          }
-        case C_FIELDS_ORPHANED_HIDE:
-          // Unset controlled field.
-          if ($group_of_controlled_field) {
-            unset($form[$group_of_controlled_field][$controlled_field_name]);
-          }
-          else {
-            unset($form[$controlled_field_name]);
-          }
-          break;
-        case C_FIELDS_ORPHANED_SHOW_ALL:
-          // Do nothing: the default behavior is ok.
-      }
-      continue;
-    }
-    if ($controlled_field['#required']) {
-      $required_fields[$controlled_field_name] = array('field' => $controlled_field_name, 'in_group' => $group_of_controlled_field);
-    }
-
-    $is_group = (strpos($controlled_field_name , 'group_') === 0 ? TRUE : FALSE);
-
-    // Required fields inside a controlled fieldgroup
-    // must be handled by conditional fields.
-    if ($is_group) {
-      foreach (element_children($controlled_field) as $group_element) {
-        if ($controlled_field[$group_element]['#required'] && !$controlled_fields[$group_element]) {
-          $required_fields[$group_element] = array('field' => $group_element, 'in_group' => $controlled_field_name);
-        }
-      }
-    }
-
-    // Set values on form for themeing.
-    if ($group_of_controlled_field) {
-      $form[$group_of_controlled_field][$controlled_field_name]['#controlled_fields'] = TRUE;
-      conditional_fields_item_apply_theme($form[$group_of_controlled_field][$controlled_field_name]);
-    }
-    else {
-      $form[$controlled_field_name]['#controlled_fields'] = TRUE;
-      $is_group ? conditional_fields_item_apply_theme($form[$controlled_field_name], $controlled_field_name) : conditional_fields_item_apply_theme($form[$controlled_field_name]);
-    }
-
-    // Add fields to javascript settings
-    // TODO: Use unique ids (requires per-widget settings)
-    $js_controlled_field_id = '#conditional-' . conditional_fields_form_clean_id($controlled_field_name);
-    foreach ($controlled_field_parents as $controlling_field_name => $trigger_values) {
-      $js_controlling_field_id = '#conditional-' . conditional_fields_form_clean_id($controlling_field_name);
-      $js_settings['controlling_fields'][$js_controlling_field_id][$js_controlled_field_id] = array('field_id' => $js_controlled_field_id, 'trigger_values' => $trigger_values);
-    }
-  }
-
-  // Controlled fields should only be required when triggered.
-  // Since required fields validation is hardcoded in _form_validate,
-  // we need to unset the #required property and perform a custom validation.
-  foreach ($required_fields as $field) {
-    if ($field['in_group']) {
-      conditional_fields_custom_required_field($form[$field['in_group']][$field['field']]);
-      conditional_fields_item_apply_theme($form[$field['in_group']][$field['field']]);
-    }
-    else {
-      conditional_fields_custom_required_field($form[$field['field']]);
-      conditional_fields_item_apply_theme($form[$field['field']]);
-    }
-  }
-
-  // Apply user interface settings
-  $ui_settings = variable_get('c_fields_js_' . $type_name, C_FIELDS_JS_HIDE);
-  switch ($ui_settings) {
-    case C_FIELDS_JS_DISABLE:
-      $js_settings['ui_settings'] = 'disable';
-      break;
-    case C_FIELDS_JS_HIDE:
-      $js_settings['ui_settings']['animation'] = (int)variable_get('c_fields_animation_' . $type_name, C_FIELDS_ANIMATION_NO);
-      $js_settings['ui_settings']['anim_speed'] = variable_get('c_fields_anim_speed_' . $type_name, "normal");
-      break;
-  }
-
-  if ($ui_settings != C_FIELDS_JS_NO) {
-    conditional_fields_add_js($js_settings);
-  }
-
-  // Pass variables for validation
-  $form['#conditional_fields']['data'] = $data;
-  $form['#conditional_fields']['required_fields'] = $required_fields;
-  $form['#conditional_fields']['settings'] = $js_settings;
-
-  // Add validation function
-  $form['#validate'] = array_merge(array('conditional_fields_node_editing_form_validate'), (array)$form['#validate']);
-
-  return $form;
-}
-
-/**
- * Insert appropriate themeing functions in a conditional field form element.
- */
-function conditional_fields_item_apply_theme(&$element, $group_name = '') {
-  if (!empty($group_name)) {
-    $element['#group_id'] = 'conditional-' . conditional_fields_form_clean_id($group_name);
-    // We add themeing in post_render so the wrapping is outside the fieldset.
-    $element['#post_render'] = array_merge(array('conditional_fields_fieldgroup_post_render'), (array)$element['#post_render']);
-  }
-  else {
-    // Save a previously set function so it can be called before rendering the field
-    if ($element['#theme'] && $element['#theme'] != 'conditional_fields_form_item') {
-      $element['#conditional_fields_theme'] = $element['#theme'];
-    }
-    $element['#theme'] = 'conditional_fields_form_item';
-  }
-}
-
-/**
- * Find an item in a form by key. If it's a CCK field, the function
- * will find it using field_info.
- */
-function conditional_fields_item_in_form($form, $item_name, $group = FALSE) {
-  static $items;
-  if ($items[$item_name]) {
-    return $items[$item_name];
-  }
-
-  if ($group) {
-    if ($form[$group][$item_name]) {
-      $items[$item_name] = $form[$group][$item_name];
-    }
-    elseif ($form[$group][$form['#field_info'][$item_name]['display_settings']['parent']][$item_name]) {
-      $items[$item_name] = $form[$group][$form['#field_info'][$item_name]['display_settings']['parent']][$item_name];
-    }
-  }
-  else {
-    if ($form[$item_name]) {
-      $items[$item_name] = $form[$item_name];
-    }
-    elseif ($form[$form['#field_info'][$item_name]['display_settings']['parent']][$item_name]) {
-      $items[$item_name] = $form[$form['#field_info'][$item_name]['display_settings']['parent']][$item_name];
-    }
-  }
-
-  if ($items[$item_name]) {
-    return $items[$item_name];
-  }
-
-  return FALSE;
-}
-
-/**
- * Get the fieldgroup of a field
- */
-function conditional_fields_get_group($type_name, $field_name) {
-  if (!module_exists('fieldgroup')) {
-    return FALSE;
-  }
-  return fieldgroup_get_group($type_name, $field_name);
-}
-
-/**
- * Validation for node editing form.
- */
-function conditional_fields_node_editing_form_validate($form, &$form_state) {
-  // When form fails validation, hook_form_alter is not called, so we add js here too
-  if ($form['#conditional_fields']['settings']['ui_settings']) {
-    conditional_fields_add_js($form['#conditional_fields']['settings']);
-  }
-
-  // Rebuild the array grouping the data by controlled fields
-  // Needed to handle multiple controlling field per controlled field
-  $controlled_fields = array();
-  foreach ($form['#conditional_fields']['data'] as $row) {
-    $controlled_fields[$row['field_name']][$row['control_field_name']] = $row['trigger_values'];
-  }
-
-  foreach ($controlled_fields as $controlled_field_name => $controlling_fields) {
-    // Check if all controlling field were triggered
-    $triggered = FALSE;
-    foreach ($controlling_fields as $controlling_field_name => $trigger_values) {
-      $triggered = conditional_fields_is_triggered($form_state['values'][$controlling_field_name], $trigger_values);
-      if ($triggered == FALSE) {
-        break;
-      }
-    }
-
-    $required_fields = $form['#conditional_fields']['required_fields'];
-
-    if ($required_fields[$controlled_field_name]['in_group']) {
-      $controlled_field = &$form[$required_fields[$controlled_field_name]['in_group']][$controlled_field_name];
-    }
-    else {
-      $controlled_field = &$form[$controlled_field_name];
-    }
-
-    // Controlled field
-    if (strpos($controlled_field_name , 'field_') === 0) {
-      if ($triggered) {
-        // Check required
-        if (!empty($required_fields) && $required_fields[$controlled_field_name]) {
-          $in_group = $required_fields[$controlled_field_name]['in_group'];
-          // Check if the controlled field is empty
-          if (conditional_fields_check_empty($form_state['values'][$controlled_field_name])) {
-            // Check whether the controlled field is in a group or not and set error accordingly
-            if (!$in_group) {
-              form_error($controlled_field, t('!name field is required.', array('!name' => $controlled_field['#title'])));
-            }
-            else {
-              // Set error only if the containing group is not controlled or is controlled and triggered
-              $set_error = TRUE;
-              foreach ($form['#conditional_fields']['data'] as $row_check_containing_group) {
-                if ($row_check_containing_group['field_name'] == $in_group) {
-                  if (!conditional_fields_is_triggered($form_state['values'][$row_check_containing_group['control_field_name']], $row_check_containing_group['trigger_values'])) {
-                  $set_error = FALSE;
-                  }
-                  break;
-                }
-              }
-              if ($set_error) {
-                form_error($controlled_field, t('!name field is required.', array('!name' => $controlled_field['#title'])));
-              }
-            }
-          }
-        }
-      }
-      else {
-        // Do not submit values of controlled fields which were not triggered (except on preview)
-        if (variable_get('c_fields_reset_default_' . $form['type']['#value'], 1)
-          && !in_array('node_form_build_preview', (array)$form_state['submit_handlers'])) {
-            // Load default values like in content_field_form() in content.node_form.inc
-            $controlled_field_info = $form['#field_info'][$controlled_field_name];
-            if (content_callback('widget', 'default value', $controlled_field_info) != CONTENT_CALLBACK_NONE) {
-              $callback = content_callback('widget', 'default value', $controlled_field_info) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
-              if (function_exists($callback)) {
-                $items = $callback($form, $form_state, $controlled_field_info, 0);
-              }
-            }
-            $form_state['values'][$controlled_field_name] = $items;
-        }
-      }
-    }
-    // Controlled group
-    elseif (strpos($controlled_field_name , 'group_') === 0) {
-      foreach (element_children($controlled_field) as $field_in_group) {
-        // Check if the controlling field was triggered
-        if ($triggered) {
-          // Check required
-          if (!empty($required_fields)
-            && $required_fields[$field_in_group]
-            && !$controlled_field[$field_in_group]['#controlled_fields']
-            && conditional_fields_check_empty($form_state['values'][$field_in_group])) {
-              form_error($controlled_field[$field_in_group],
-              t('!name field is required.',
-              array('!name' => $controlled_field[$field_in_group]['#title'])));
-          }
-        }
-        else {
-          // Do not submit values of controlled fields which were not triggered (except on preview)
-          if (variable_get('c_fields_reset_default_' . $form['type']['#value'], 1) &&
-            !in_array('node_form_build_preview', $form_state['submit_handlers'])) {
-              // Load default values like in content_field_form() in content.node_form.inc
-              $field_in_group_info = $form['#field_info'][$field_in_group];
-              if (content_callback('widget', 'default value', $field_in_group_info) != CONTENT_CALLBACK_NONE) {
-                $callback = content_callback('widget', 'default value', $field_in_group_info) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
-                if (function_exists($callback)) {
-                  $items = $callback($form, $form_state, $field_in_group_info, 0);
-                }
-              }
-              $form_state['values'][$field_in_group] = $items;
-          }
-        }
-      }
-    }
-  }
-}
-
-/**
- * Checks if a submitted field value is empty
- */
-function conditional_fields_check_empty($field) {
-  // Normal fields
-  if (isset($field[0]['value'])) {
-    $value = $field[0]['value'];
-  }
-  // Node reference
-  elseif (isset($field[0]['nid'])) {
-    $value = $field[0]['nid'];
-  }
-
-  if (!count($value) || (is_string($value) && drupal_strlen(trim($value)) == 0)) {
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
-/**
- * Returns true if the field was triggered
- * $selected_values The values of the controlling field selected by the user when creating the node
- * $trigger_values An array containing the information we need to select the trigger values
- */
-function conditional_fields_is_triggered($selected_values, $trigger_values) {
-  foreach ((array)$selected_values as $values) {
-    foreach ((array)$values as $value) {
-      if (isset($value) && in_array($value, $trigger_values)) {
-        return TRUE;
-      }
-    }
-  }
-  return FALSE;
-}
-
-/**
- * Returns an array of conditional fields settings for a given node type.
- * $structure can be either 'flat' or 'row' . 'row' data is data per row,
- * while 'flat' data is a list of both controlling and controlled fields.
- */
-function conditional_fields_load_data($type, $structure = 'row', $reset = FALSE) {
-  static $data;
-  if ($reset) {
-    unset($data);
-  }
-  if (!isset($data[$structure][$type])) {
-    $data[$structure][$type] = array();
-    if ($structure == 'row') {
-      $query = db_query("SELECT control_field_name, field_name, trigger_values FROM {conditional_fields} WHERE type = '%s'", $type);
-      while ($result = db_fetch_array($query)) {
-        $result['trigger_values'] = unserialize($result['trigger_values']);
-        $data['row'][$type][] = $result;
-      }
-    }
-    elseif ($structure == 'flat') {
-      $query = db_query("SELECT control_field_name, field_name FROM {conditional_fields} WHERE type = '%s'", $type);
-      while ($result = db_fetch_array($query)) {
-        $data['flat'][$type][$result['control_field_name']] = $result['control_field_name'];
-        $data['flat'][$type][$result['field_name']] = $result['field_name'];
-      }
-      $data['flat'][$type] = array_unique($data['flat'][$type]);
-    }
-
-  }
-  return $data[$structure][$type];
-}
-
-/**
- * Find conditional fields and mark them.
- */
-function conditional_fields_field_overview_form(&$form) {
-  // Check if we have conditional data
-  if (!$data = conditional_fields_load_data($form['#type_name'])) {
-    return;
-  }
-
-  foreach ($data as $field) {
-    if (in_array($field['control_field_name'], $form['#fields'])) {
-      $form[$field['control_field_name']]['field_name']['#value'] .= theme('conditional_fields_manage_marker', NULL, $field['field_name']);
-    }
-    if (in_array($field['field_name'], $form['#fields'])) {
-      $form[$field['field_name']]['field_name']['#value'] .= theme('conditional_fields_manage_marker', $field['control_field_name'], NULL);
-    }
-    // Mark groups
-    if (in_array($field['field_name'], $form['#groups'])) {
-      $form[$field['field_name']]['group_name']['#value'] .= theme('conditional_fields_manage_marker', $field['control_field_name'], NULL);
-    }
-  }
-
-  // Add validation function
-  $form['#validate'] = array_merge(array('conditional_fields_field_overview_form_validate'), $form['#validate']);
-}
-
-/**
- * Conditional fields can't change group.
- */
-function conditional_fields_field_overview_form_validate($form, $form_state) {
-  $data = conditional_fields_load_data($form['#type_name'], 'flat');
-
-  foreach ($form['#fields'] as $field_name) {
-    if ($data[$field_name] && $form_state['values'][$field_name]['parent'] != $form_state['values'][$field_name]['prev_parent']) {
-      form_set_error('', t("You can't change the parent group of a conditional field."));
-    }
-  }
-}
-
-/**
- * Load default values from conditional_fields table.
- */
-function conditional_fields_available_fields_default_values($control_field, $conditional_fields) {
-  foreach ($conditional_fields as $field) {
-    $query = db_query("SELECT trigger_values FROM {conditional_fields} WHERE control_field_name = '%s' AND field_name = '%s' AND type = '%s'", $field['field_name'], $control_field, $field['type_name']);
-    $result = unserialize(db_result($query));
-    if ($result) {
-      $default_values[$field['field_name']] = $result;
-    }
-  }
-  return $default_values;
-}
-
-/**
- * Adds javascript to the node editing form
- */
-function conditional_fields_add_js($settings) {
-  // Avoid adding js twice when the node form has failed validation
-  static $js;
-  if (!$js) {
-    drupal_add_js(array('ConditionalFields' => $settings), 'setting');
-    drupal_add_js(drupal_get_path('module', 'conditional_fields') . '/conditional_fields.js');
-    $js = TRUE;
-  }
-}
-
-/**
- * post_render function to handle controlled fields after "add more" ahah request
- */
-function conditional_fields_add_more_post_render($content, $item) {
-  return theme('conditional_fields_wrapper', $content, 'conditional-' . conditional_fields_form_clean_id($item['#field_name']), array('conditional-field', ' controlled-field'));
-}
-
-/**
- * post_render function to make fieldgroup wrapping themeable
- */
-function conditional_fields_fieldgroup_post_render($content, $item) {
-  return theme('conditional_fields_wrapper', $content, $item['#group_id'], array('conditional-field', ' controlled-field'));
-}
-
-/*
- * Clean conditional fields settings pertaining to this removed field
- */
-function _conditional_fields_content_admin_field_remove_submit($form, $form_state) {
-  conditional_fields_remove_field_settings($form_state['field_name']);
-}
-
-/*
- * Clean conditional fields settings pertaining to this removed group
- */
-function conditional_fields_fieldgroup_remove_group_submit($form, $form_state) {
-  conditional_fields_remove_field_settings($form['#group_name']);
-}
-
-/*
- * Remove all settings for a field.
- * Since our field names are really the field instance name, it should be safe to remove without checking.
- */
-function conditional_fields_remove_field_settings($field_name) {
-  db_query("DELETE FROM {conditional_fields} WHERE control_field_name = '%s' OR field_name = '%s'", $field_name, $field_name);
-}