You are here

function notifications_custom_user_operations in Notifications 6

Same name and namespace in other branches
  1. 6.4 notifications_custom/notifications_custom.module \notifications_custom_user_operations()

Implementation of hook_user_operations()

File

notifications_custom/notifications_custom.module, line 355
Custom notifications module

Code

function notifications_custom_user_operations($form_state = array()) {
  $operations = array();
  if (user_access('administer notifications') && ($custom_list = notifications_custom_list())) {
    foreach ($custom_list as $subs) {
      $subs_options['custom_subscribe-' . $subs->type] = $subs->name;
    }
    $operations = array(
      t('Add subscription for selected users') => array(
        'label' => $subs_options,
      ),
    );

    // If the form has been posted, we need to insert the proper data for adding subscriptions
    if (!empty($form_state['submitted'])) {
      $operation_subs = explode('-', $form_state['values']['operation']);
      $operation = $operation_subs[0];
      if ($operation == 'custom_subscribe') {
        $type = $operation_subs[1];
        $operations[$form_state['values']['operation']] = array(
          'callback' => 'notifications_custom_user_multiple_subscribe',
          'callback arguments' => array(
            $type,
          ),
        );
      }
    }
  }
  return $operations;
}