function message_subscribe_email_flag in Message Subscribe 7
When flagging subscription flags, check if user wants email notifications and flag the user for emails accordingly.
Parameters
$op: The operation being performed: one of 'flag' or 'unflag'.
$flag: The flag object.
$entity_id: The id of the entity the flag is on.
$account: The user account performing the action.
$flagging_id: The flagging entity.
2 calls to message_subscribe_email_flag()
- message_subscribe_email_flag_flag in message_subscribe_email/
message_subscribe_email.module - Implements hook_flag_flag().
- message_subscribe_email_flag_unflag in message_subscribe_email/
message_subscribe_email.module - Implements hook_flag_unflag().
File
- message_subscribe_email/
message_subscribe_email.module, line 55 - Code for the message subscribe email feature.
Code
function message_subscribe_email_flag($action, $flag, $content_id, $account) {
$prefix = variable_get('message_subscribe_flag_prefix', 'subscribe') . '_';
if (strpos($flag->name, $prefix) === 0) {
// The flag is a subscription flag.
$wrapper = entity_metadata_wrapper('user', $account);
if ($wrapper->message_subscribe_email
->value() || $action == 'unflag') {
// User wants to use email for the subscription.
// Flag or unflag user for emailing according to action taken.
$name = str_replace($prefix, '', $flag->name);
flag($action, 'email_' . $name, $content_id, $account);
}
}
}