You are here

function notifications_manage_subscriptions_operations in Notifications 7

Subscription mass operations.

Parameters

$account: User account if we are administering subscriptions for this user

2 calls to notifications_manage_subscriptions_operations()
notifications_manage_subscriptions_form_options in ./notifications.manage.inc
Form options
notifications_manage_subscriptions_form_submit in ./notifications.manage.inc
Handle manage form submissions, run batch operations

File

./notifications.manage.inc, line 238
Common functions for bulk management of subscriptions

Code

function notifications_manage_subscriptions_operations($account = NULL) {
  $operations = array(
    'activate' => array(
      'label' => t('Activate'),
      'callback' => 'notifications_manage_subscriptions_mass_update',
      'callback arguments' => array(
        'updates' => array(
          'status' => Notifications_Subscription::STATUS_ACTIVE,
        ),
      ),
    ),
    'deactivate' => array(
      'label' => t('Deactivate'),
      'callback' => 'notifications_manage_subscriptions_mass_update',
      'callback arguments' => array(
        'updates' => array(
          'status' => Notifications_Subscription::STATUS_INACTIVE,
        ),
      ),
    ),
    'delete' => array(
      'label' => t('Delete'),
      'callback' => NULL,
    ),
  );

  // Block option only for administrators
  if (user_access('administer notifications') || user_access('manage all subscriptions')) {
    $operations['block'] = array(
      'label' => t('Block'),
      'callback' => 'notifications_manage_subscriptions_mass_update',
      'callback arguments' => array(
        'updates' => array(
          'status' => Notifications_Subscription::STATUS_BLOCKED,
        ),
      ),
    );
  }

  // Sending methods, not for destination
  if (!empty($account->mdid)) {
    $parent = t('Change send method to');
    foreach (_notifications_send_methods($account) as $key => $name) {
      $operations['send_method-' . $key] = array(
        'label' => $name,
        'parent' => $parent,
        'callback' => 'notifications_manage_subscriptions_mass_update',
        'callback arguments' => array(
          'updates' => array(
            'send_method' => $key,
          ),
        ),
      );
    }
  }
  $parent = t('Change send interval to');
  foreach (notifications_send_intervals() as $key => $name) {
    $operations['send_interval-' . $key] = array(
      'label' => $name,
      'parent' => $parent,
      'callback' => 'notifications_manage_subscriptions_mass_update',
      'callback arguments' => array(
        'updates' => array(
          'send_interval' => $key,
        ),
      ),
    );
  }

  // Intervals
  return $operations;
}