Adding custom code on flagging a node
If you enable the Trigger and the Flag actions modules, you can assign a group of actions that is executed when a user or a node is flagged by a user.
Flag integrates also with Rules, and it allows to execute rules when a flag is used for users or nodes.