You are here

class flag_rules_data_type in Flag 6

Same name and namespace in other branches
  1. 6.2 includes/flag.rules.inc \flag_rules_data_type

Defines the flag rule data type.

Hierarchy

Expanded class hierarchy of flag_rules_data_type

1 string reference to 'flag_rules_data_type'
flag_rules_data_type_info in includes/flag.rules.inc
Implementation of hook_rules_data_type_info().

File

includes/flag.rules.inc, line 29
flag.rules.inc Rules integration for the Flag module.

View source
class flag_rules_data_type extends rules_data_type {
  function save() {
    $flag =& $this
      ->get();
    $flag->save;
    return TRUE;
  }
  function load($name) {
    return flag_get_flag($name);
  }
  function get_identifier() {
    $flag =& $this
      ->get();
    return $flag->name;
  }

  /**
   * Returns radios for selecting a flag of the type given in
   * $info['flag_type'].
   */
  function get_default_input_form($info, $value, &$form_state) {
    $options = _flag_rules_flags_options(isset($info['flag_type']) ? $info['flag_type'] : NULL);
    $form = array(
      '#type' => 'radios',
      '#title' => $info['label'],
      '#options' => $options,
      '#required' => TRUE,
      '#disabled' => !$options,
      '#default_value' => isset($value) ? $value : NULL,
      '#theme' => 'flag_rules_radios',
      '#printed' => TRUE,
    );
    if (!$options) {
      $form['#description'] = t('Error: There is no suiting flag available.');
    }
    return $form;
  }
  function check_value($info, $value) {
    if ($flag = flag_get_flag($value)) {
      return $flag;
    }
    rules_log(t('The flag %name does not exist any more.', array(
      '%name' => $value,
    )));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
flag_rules_data_type::check_value function Checks the value of your data type. E.g. the number data type uses this to make sure the value is a number. Overrides rules_data_type::check_value
flag_rules_data_type::get_default_input_form function Returns radios for selecting a flag of the type given in $info['flag_type']. Overrides rules_data_type::get_default_input_form
flag_rules_data_type::get_identifier function Gets the identifier of this data, which can be of every php data type - even an array. Implement it, if your data type is identifiable. Overrides rules_data_type::get_identifier
flag_rules_data_type::load function Loads the data identified with an identifier as returned by get_identifier(). Just return the data or FALSE if loading the data failed. Overrides rules_data_type::load
flag_rules_data_type::save function Makes changes to the data permanent. Implement it, if your data type is savable. Overrides rules_data_type::save
rules_data_type::$type property
rules_data_type::$_data property
rules_data_type::$_info property
rules_data_type::construct function Constructor
rules_data_type::eval_input function Returns whether the input evaluator should be used for this data
rules_data_type::get function Gets the data
rules_data_type::get_info function Gets the information about this data type.
rules_data_type::init function Inititate the data
rules_data_type::is_identifiable function Returns whether this data is identifiable
rules_data_type::is_savable function Returns whether this data is savable
rules_data_type::update function Replaces the data with the new one
rules_data_type::uses_input_form function Returns whether this data makes use of an input form for creating an instance on the fly.