You are here

function rules_link_component_form in Rules Link 7

Same name and namespace in other branches
  1. 7.2 rules_link.admin.inc \rules_link_component_form()

Form function for the rules link components.

1 string reference to 'rules_link_component_form'
RulesLinkUIController::hook_menu in ./rules_link.admin.inc
Overrides EntityDefaultUIController::hook_menu() defaults.

File

./rules_link.admin.inc, line 444
Generate a admin UI.

Code

function rules_link_component_form($form, &$form_state, $entity_type, $rules_link) {
  $form = array();
  $form_state['rules_link'] = $rules_link;
  $condition = rules_link_load_condition_set($rules_link);
  $condition
    ->form($form['condition_set'], $form_state);
  $form['condition_set']['elements']['#caption'] = '';
  $form['condition_set']['help']['#title'] = t('Access conditions');
  $form['condition_set']['help']['#type'] = 'item';
  $form['condition_set']['help']['#markup'] = t('The access conditions can additionally to <a href="!url">%link</a> specify, when to show the rules links.', array(
    '%link' => t('the permissions'),
    '!url' => url('admin/people/permissions', array(
      'fragment' => 'module-rules_link',
    )),
  ));

  // Since we never want to negate the result, we can hide the form.
  unset($form['condition_set']['negate']);
  $form['condition_set']['#tree'] = TRUE;
  $rule_set = rules_link_load_rules_set($rules_link);
  $rule_set
    ->form($form['rule_set'], $form_state, array(
    'show settings' => TRUE,
  ));

  // Correct the state setup - default ruleset form doesn't expect this structure
  $form['rule_set']['settings']['access']['permissions']['#states'] = array(
    'visible' => array(
      ':input[name="rule_set[settings][access][access_exposed]"]' => array(
        'checked' => TRUE,
      ),
    ),
  );
  $form['rule_set']['elements']['#caption'] = '';
  $form['rule_set']['#tree'] = TRUE;
  $form['rule_set']['help']['#title'] = t('Reactions');
  $form['rule_set']['help']['#type'] = 'item';
  $form['rule_set']['help']['#markup'] = t('To output a system message, simply use the "Show a message on the site" action in one of your rules. Javascript links will replace the link with the text from the system message.');
  $form['rule_set']['settings']['vars']['#description'] .= '<br/>' . t('Please also note that Rules Link only checks if there are enough variables available, but not if the entities could be loaded. You will have to check that your self in your components.');
  $form['rule_set']['settings']['label']['#access'] = FALSE;
  $form['rule_set']['settings']['name']['#type'] = 'value';
  $form['rule_set']['settings']['tags']['#access'] = FALSE;
  $form['rule_set']['settings']['vars']['items'][$rules_link->entity_type]['#disabled'] = TRUE;
  $form_state['rules_link_condition_set'] = $condition;
  $form_state['rules_link_rules_set'] = $rule_set;
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save Rules Link'),
    '#weight' => 40,
  );
  return $form;
}