uid, $event_type, $field, $value)) { $subscription = array( 'uid' => $user->uid, 'type' => $type, 'event_type' => $event_type, 'fields' => array($field => $value), ); notifications_save_subscription($subscription); } } /** * Implementation of hook_form_alter(). * * Adds autosubscribe checkbox to user edit form. */ function notifications_autosubscribe_form_alter($form_id, &$form) { switch ($form_id) { case 'user_edit': if (isset($form['notifications'])) { $form['notifications']['notifications_auto'] = array( '#type' => 'checkbox', '#title' => t('Autosubscribe'), '#default_value' => notifications_user_setting('auto', $form['_account']['#value']), '#description' => t('Checking this box allows you to be automatically subscribe to any thread you create or post a comment to. You will recieve an email with a title and link to the post.'), ); } break; case 'notifications_content_settings_form': $form['content']['notifications_default_auto'] = array( '#type' => 'checkbox', '#title' => t('Set all users to "autosubscribe" by default'), '#default_value' => variable_get('notifications_default_auto', 0), '#description' => t('Sets each users "autosubscribe" profile option.'), ); break; } } /** * Implementation of hook_notifications. */ function notifications_autosubscribe_notifications($op, $arg0, $arg1 = NULL, $arg2 = NULL) { if ($op == 'event trigger') { $event = $arg0; if ($event->type == 'node' && isset($event->node->nid)) { notifications_autosubscribe('thread', 'node', 'nid', $event->node->nid); } } }