diff --git casetracker.rules.inc casetracker.rules.inc
new file mode 100644
index 0000000..1417616
--- /dev/null
+++ casetracker.rules.inc
@@ -0,0 +1,227 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Provides basic rules module support.
+ */
+
+function casetracker_available_options() {
+  return array(
+    'pid' => t('Project'),
+    'assign_to' => t('Assign to'),
+    'status' => t('Status'),
+    'priority' => t('Priority'),
+    'department' => t('Department'),
+  );
+}
+
+/**
+ * Implementation of hook_rules_action_info().
+ */
+function casetracker_rules_action_info() {
+  $info = array();
+  $info['casetracker_rules_action_change_realm'] = array(
+    'label' => t('Change case values'),
+    'arguments' => array(
+      'node' => array(
+        'type' => 'node',
+        'label' => t('Content'),
+      ),
+    ),
+    'eval input' => array('code'),
+    'help' => t('You should make sure that the node type was defined to work as cases by casetracker.'),
+    'module' => 'Case Tracker',
+  );
+  return $info;
+}
+
+/**
+ * Action: change value for a case.
+ */
+function casetracker_rules_action_change_realm($node, $settings, $element, &$state) {
+  // Get information about the field.
+  $realm = $settings['casetracker_realm'];
+  $value = $settings['casetracker_realm_value'];
+
+  if (!empty($realm) && is_numeric($value)) {
+    if ($realm != 'assign_to' || $realm != 'pid') {
+      dsm($node);
+      $node->casetracker->{'case_' . $realm . '_id'} = $value;
+      return array('node' => $node);
+    }
+    else {
+      $node->casetracker->$realm = $value;
+      return array('node' => $node);
+    }
+  }
+}
+
+/**
+ * Action "change case value" configuration form.
+ *
+ * This is a multistep form.
+ */
+function casetracker_rules_action_change_realm_form($settings, &$form, &$form_state) {
+  if (empty($settings['casetracker_realm'])) {
+    $form['settings']['casetracker_realm'] = array(
+      '#type' => 'select',
+      '#title' => t('Case Tracker value'),
+      '#options' => casetracker_available_options(),
+      '#default_value' => $settings['casetracker_realm'],
+      '#description' => t('Select the casetracker value to change.'),
+      '#required' => TRUE,
+    );
+    // Hide some form elements in the first step.
+    $form['negate']['#access'] = FALSE;
+    $form['input_help']['#access'] = FALSE;
+    $form['weight']['#access'] = FALSE;
+
+    // Replace the usual submit handlers with a own handler.
+    $form['submit']['#submit'] = array('casetracker_rules_action_change_realm_form_step_submit');
+    $form['submit']['#value'] = t('Continue');
+  }
+  else {
+    $realms = casetracker_available_options();
+
+    $realm = $settings['casetracker_realm'];
+
+    if ($realm == 'pid') {
+    $options = casetracker_project_options();
+    }
+    elseif ($realm == 'assign_to') {
+      $options = drupal_map_assoc(casetracker_user_options());
+    }
+    else {
+      $options = casetracker_realm_load($realm);
+    }
+
+    $form['settings']['casetracker_realm_value'] = array(
+      '#type' => 'select',
+      '#title' => t('Change @realm', array('@realm' => $realms[$realm])),
+      '#options' => $options,
+      '#default_value' => $settings['casetracker_realm_value'],
+    );
+  }
+}
+
+function casetracker_rules_action_change_realm_form_step_submit($form, &$form_state) {
+  $form_state['element']['#settings']['casetracker_realm'] = $form_state['values']['settings']['casetracker_realm'];
+}
+
+/**
+ * Implementation of hook_rules_condition_info().
+ */
+function casetracker_rules_condition_info() {
+  $info = array();
+  $info['casetracker_rules_condition_realm_has_value'] = array(
+    'label' => t('Realm has value'),
+    'arguments' => array(
+      'node' => array('type' => 'node', 'label' => t('Content')),
+    ),
+    'eval input' => array('code'),
+    'help' => t('The condition returns TRUE, if the selected realm has the given value.'),
+    'module' => 'Case Tracker',
+  );
+  $info['casetracker_rules_condition_realm_has_changed'] = array(
+    'label' => t('Realm has changed'),
+    'arguments' => array(
+      'node' => array('type' => 'node', 'label' => t('Content containing changes')),
+      'node_unchanged' => array('type' => 'node', 'label' => t('Content not containing changes')),
+    ),
+    'help' => t('You should make sure that the used field exists in the given content type.'),
+    'module' => 'Case Tracker',
+  );
+  $info['casetracker_rules_condition_is_case'] = array(
+    'label' => t('Is case'),
+    'arguments' => array(
+      'node' => array('type' => 'node', 'label' => t('Content containing changes')),
+    ),
+    'help' => t('You should make sure that the used field exists in the given content type.'),
+    'module' => 'Case Tracker',
+  );
+  $info['casetracker_rules_condition_is_project'] = array(
+    'label' => t('Is project'),
+    'arguments' => array(
+      'node' => array('type' => 'node', 'label' => t('Content containing changes')),
+    ),
+    'help' => t('You should make sure that the used field exists in the given content type.'),
+    'module' => 'Case Tracker',
+  );
+
+  return $info;
+}
+
+function casetracker_rules_condition_realm_has_value($node, $settings) {
+  if (!empty($node->casetracker)) {
+    $realm = $settings['casetracker_realm'];
+    if ($realm != 'pid' && $realm != 'assign_to') {
+      return $node->casetracker->{'case_' . $realm . '_id'} == $settings['casetracker_realm_value'];
+    }
+    else {
+      return $node->casetracker->$realm == $settings['casetracker_realm_value'];
+    }
+  }
+}
+
+function casetracker_rules_condition_realm_has_value_form($settings, &$form, &$form_state) {
+  // Re-use form
+  casetracker_rules_action_change_realm_form($settings, &$form, &$form_state);
+}
+
+function casetracker_rules_condition_is_case($node, $settings) {
+  return casetracker_is_case($node);
+}
+
+function casetracker_rules_condition_is_project($node, $settings) {
+  return casetracker_is_project($node);
+}
+
+function casetracker_rules_condition_realm_has_changed($node1, $node2, $settings) {
+  if (!empty($node1->casetracker) && !empty($node2->casetracker)) {
+    $realm = $settings['casetracker_realm'];
+    if ($realm != 'pid' && $realm != 'assign_to') {
+      return $node1->casetracker->{'case_' . $realm . '_id'} != $node2->casetracker->{'case_' . $realm . '_id'};
+    }
+    else {
+      return $node1->casetracker->$realm != $node2->casetracker[$realm];
+    }
+  }
+}
+
+function casetracker_rules_condition_realm_has_changed_form($settings, &$form, &$form_state) {
+  $form['settings']['casetracker_realm'] = array(
+    '#type' => 'select',
+    '#title' => t('Case Tracker value'),
+    '#options' => casetracker_available_options(),
+    '#default_value' => $settings['casetracker_realm'],
+    '#description' => t('Select the casetracker value to change.'),
+    '#required' => TRUE,
+  );
+}
+
+/**
+ * Labels
+ */
+function casetracker_rules_action_change_realm_label($settings, $argument_labels) {
+  $realms = casetracker_available_options();
+  return t("Change @node's @realm", array('@realm' => $realms[$settings['casetracker_realm']]) + $argument_labels);
+}
+
+function casetracker_rules_condition_is_case_label($settings, $argument_labels) {
+  return t("@node's is case", $argument_labels);
+}
+
+function casetracker_rules_condition_is_project_label($settings, $argument_labels) {
+  return t("@node's is case", $argument_labels);
+}
+
+function casetracker_rules_condition_realm_has_changed_label($settings, $argument_labels) {
+  $realms = casetracker_available_options();
+  return t("@node's @realm has changed", array('@realm' => $realms[$settings['casetracker_realm']]) + $argument_labels);  
+}
+
+function casetracker_rules_condition_realm_has_value_label($node, $settings) {
+  $realms = casetracker_available_options();
+  return t("@node's @realm has value", array('@realm' => $realms[$settings['casetracker_realm']]) + $argument_labels);  
+}
