規則匯出格式中顯示的自定義規則
以下是規則匯出格式中的規則示例 :
{ "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,則會顯示以“你有足夠的積分……”開頭的訊息,否則訊息將以“你沒有足夠的積分……”開頭。