You are here

function notifications_custom_user_multiple_subscribe in Notifications 6.4

Same name and namespace in other branches
  1. 6 notifications_custom/notifications_custom.module \notifications_custom_user_multiple_subscribe()

User operations callback. Bulk subscribe multiple accounts

1 string reference to 'notifications_custom_user_multiple_subscribe'
notifications_custom_user_operations in notifications_custom/notifications_custom.module
Implementation of hook_user_operations().

File

notifications_custom/notifications_custom.module, line 415
Custom notifications module

Code

function notifications_custom_user_multiple_subscribe($accounts, $type) {
  $custom = notifications_custom_build_subscription($type);
  $count = 0;
  foreach ($accounts as $uid) {

    // Skip subscribing the user if they already are subscribed.
    if (!notifications_custom_get_subscription($type, $uid)) {
      $subscription = clone $custom;
      $subscription->uid = $uid;
      notifications_save_subscription($subscription);
      $count++;
    }
  }
  drupal_set_message(format_plural($count, 'A user has been subscribed.', '@count users have been subscribed.'));
}