I created a calendar 7.x-3.4. Users can add events using a content type. Content type has a mandatory term reference field. I want to check conflict between date field belong the same taxonomy term: may I use resource conflict module?

thanks

Comments

ohthehugemanatee’s picture

Status: Active » Closed (works as designed)

yes you can. This is very easy with the 7.x version of the module.

Install, and edit the rule that comes with the module to check the taxonomy field in the "conditions" section.

Miao1994’s picture

Great, I'll try it as soon as possible.
Thanks for your quick response.

liberatr’s picture

Currently trying to understand how one would really do this - are the conflicted nodes available in the "Conditions" area?

The only node I have in data selector is "unsaved node".

I understand that the node being validated is there, but what about the others? Is this module complete? If so, can you upload an export of a working rule?

Thanks for an awesome module, BTW.

liberatr’s picture

Answering my own question: based on a comment on #1637570: Booking rooms for events for Drupal 7

This assumes you have a taxonomy field called field_places on the node type you're checking for conflicts.

The main Rule is modified from the default to fire a Rules Componenet instead of the Validation error.

Here is the Rule:

{ "rules_display_conflict_message_on_node_save" : {
    "LABEL" : "Double Booking",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "resource_conflict", "rules" ],
    "ON" : [ "resource_conflict_node_validation" ],
    "IF" : [
      { "resource_conflict_contains_conflict" : { "node" : [ "node" ] } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_places" } }
    ],
    "DO" : [
      { "resource_conflict_load_conflict_list" : {
          "USING" : { "node" : [ "node" ] },
          "PROVIDE" : { "conflict_list" : { "conflict_list" : "Conflict List" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "conflict-list" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "component_rules_check_venue" : {
                "venue_unsaved" : [ "node:field-places" ],
                "node_in_conflict" : [ "list-item" ],
                "form" : [ "form" ]
              }
            }
          ]
        }
      }
    ]
  }
}

Here is the Rules Component (type Rule):

{ "rules_check_venue" : {
    "LABEL" : "Check Venue",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules", "resource_conflict" ],
    "USES VARIABLES" : {
      "venue_unsaved" : { "label" : "Venue Unsaved", "type" : "taxonomy_term" },
      "node_in_conflict" : { "label" : "Node in conflict", "type" : "node" },
      "form" : { "label" : "Form", "type" : "form" }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node-in-conflict" ], "field" : "field_places" } },
      { "data_is" : {
          "data" : [ "venue-unsaved" ],
          "value" : [ "node-in-conflict:field-places" ]
        }
      }
    ],
    "DO" : [
      { "resource_conflict_form_error" : { "message" : "This Event conflicts with another event in the same venue: [node-in-conflict:title]" } }
    ]
  }
}

I am hoping to write this up in the handbook later, but this is what worked for me.

gcaudle’s picture

Working on this now - liberatr, did you get this into a handbook somewhere? I'm desperately trying to find a solution to check for conflicts by venue. I tried to import your example, but I get error messages I don't really understand yet. I've got a content type called event, and a taxonomy field called spacerequested. Any advice you could give on this would be greatly appreciated.