规则导出格式中显示的自定义规则
以下是规则导出格式中的规则示例 :
{ "rules_display_userpoints_after_updating_content" : {
"LABEL" : "Display userpoints after updating content",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "userpoints_rules", "rules", "rules_conditional" ],
"ON" : { "node_update" : [] },
"DO" : [
{ "userpoints_rules_get_current_points" : {
"USING" : { "user" : [ "site:current-user" ], "tid" : "all" },
"PROVIDE" : { "loaded_points" : { "total_points" : "Number of points in all categories together" } }
}
},
{ "drupal_message" : { "message" : "You now have [total-points:value] points" } },
{ "CONDITIONAL" : [
{
"IF" : { "NOT data_is" : { "data" : [ "total-points" ], "op" : "\u003C", "value" : "20" } },
"DO" : [
{ "drupal_message" : { "message" : "You have sufficient points (you still have [total-points:value] ...)." } }
]
},
{ "ELSE" : [
{ "drupal_message" : { "message" : "You DO NOT have sufficient points (you only have [total-points:value] ...)." } }
]
}
]
}
]
}
}
它确实检索用户当前的用户点数量,作为第一个规则操作(不是规则条件!)。如果金额至少为 20,则会显示以“你有足够的积分……”开头的消息,否则消息将以“你没有足够的积分……”开头。