You are here

function rb_cck_field_is_empty in Rules Bonus Pack 6

Helper function to determine if a field is empty in a given node.

It seems really awkward that there isn't a publically available API function that wraps all the TYPE_content_is_empty functions. But I couldn't find one. I'd be happy if I'm wrong and you tell me about it. //Itangalo 2011-05-10

And here's note! I can find no documentation whatsoever telling me if hook_content_is_empty($element, $field) expects $field to be the field array of information, or just the field name. And I haven't found any example of a module actually using the parameter. I gamble and set it to the info array. //Itangalo 2011-07-05.

@parameter $field_name The (machine) name of the field to check. @parameter $node The node where to check the field emptyness.

Return value

TRUE if the field is empty, otherwise FALSE.

2 calls to rb_cck_field_is_empty()
rb_cck_action_copy_multiple in ./rb_cck.module
Action for 'rb_cck_action_copy_multiple'.
rb_cck_condition_has_content in ./rb_cck.module
The 'rb_cck_condition_has_content' condition.

File

./rb_cck.module, line 310
Functions for extending CCK field management with Rules.

Code

function rb_cck_field_is_empty($field_name, $node) {

  // Get the field type name.
  $field_information = content_fields($field_name);
  $module =& $field_information['module'];

  // Build the name of the empty callback function, on the form
  // TYPE_content_is_empty.
  $empty_callback = $module . '_content_is_empty';

  // Check the first field entry for emptiness, return the result.
  return $empty_callback($node->{$field_name}[0], $field_information);
}