uid; $module_type = variable_get('subscriptions_registration_module', 'node'); $node_type = variable_get('subscriptions_registration_type', 'story'); if (isset($edit['subscriptions_decision']) && $edit['subscriptions_decision'] == 1){ db_query('INSERT INTO {subscriptions} (module, field, value, recipient_uid, send_interval, author_uid, send_updates, send_comments) VALUES (\'%s\', \'%s\', \'%s\', %d, %d, %d, %d, %d)', $module_type, 'type', $node_type, $account->uid, 1, -1, 1, 1); } break; } // switch ($type} } /** * Adds field to user registration field to allow users to subscribe to content */ function _subscriptions_registration_user_fields() { // Add a fieldset containing a checkbox for users to accept // getting updates on the registration form. $fields['subscriptions_agree'] = array( '#type' => 'fieldset', '#title' => t('News Subscriptions'), ); // Add the checkbox to the fieldset $fields['subscriptions_agree']['subscriptions_decision'] = array( '#type' => 'checkbox', '#title' => t('Subscribe to news posted on this site. Emails are sent every whenever a new article is posted.'), '#return_value' => 1, '#default_value' => 1, '#description' => t('By subscribing to email updates, you will be kept informed of news associated with ' . variable_get('site_name', 'Drupal') . '.'), ); return $fields; } /** * Display help and module information* @param path which path of the site we're displaying help * @param arg array that holds the current path as would be returned from the arg() function* @return help text for the path */ function subscriptions_registration_help($path, $arg) { $output = ''; switch ($path) { case "admin/help#subscriptions_registration": $output = '

'. t("Adds a field to the user registration page to allow users to opt-in for Subscriptions") .'

'; break; } return $output; } // function subscriptions_registration_help /* * Implementation of hook_admin() */ function subscriptions_registration_admin() { $form['subscriptions_registration_enable'] = array( '#type' => 'checkbox', '#title' => t('Show Subscriptions block on the user registration form.'), '#default_value' => variable_get('subscriptions_registration_enable', 0), ); $registration_modules = drupal_map_assoc(array('node')); $form['subscriptions_registration_module'] = array( '#type' => 'select', '#title' => t('Default Module Type'), '#default' => 'node', '#options' => $registration_modules, '#description' => t('The Subscription module to be used for default subscriptions.'), ); $registration_types = drupal_map_assoc(array('story','page')); $form['subscriptions_registration_type'] = array( '#type' => 'select', '#title' => t('Default Node Type'), '#default' => 'node', '#options' => $registration_types, '#description' => t('The node type to be used for default subscriptions.'), ); $registration_send_interval = drupal_map_assoc(array('1','900','3600','10800','86400')); $form['subscriptions_registration_send_interval'] = array( '#type' => 'select', '#title' => t('Minumum Send Interval'), '#default_value' => variable_get('subscriptions_registration_send_interval', 900), '#options' => $registration_send_interval, '#description' => t('The minimum frequency to send notifications in seconds.'), ); $form['subscriptions_registration_send_updates'] = array( '#type' => 'checkbox', '#title' => t('Send email notifications when a node is updated.'), '#default_value' => variable_get('subscriptions_registration_send_updates', 0), '#descriptions' => t('Send email nofications when a node is updated?'), ); $form['subscriptions_registration_send_comments'] = array( '#type' => 'checkbox', '#title' => t('Send email nofications when comments are added.'), '#default_value' => variable_get('subscriptions_registration_send_comments', 0), '#descriptions' => t('Send email nofications when comments are added?'), ); return system_settings_form($form); } function subscriptions_registration_menu() { $items = array(); $items['admin/settings/subscriptions_registration'] = array( 'title' => 'Subscriptions Registration', 'description' => 'Controls options for Subscriptions on the user registration form', 'page callback' => 'drupal_get_form', 'page arguments' => array('subscriptions_registration_admin'), 'access arguments' => array('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * hook_validate() implementation */ function subscriptions_registration_admin_validate($form, &$form_state) { $show_subscriptions = $form_state['values']['subscriptions_registration_enable']; if ( ($show_subscriptions != 0) && ($show_subscriptions != 1) ) { form_set_error('show_subscriptions', t('Invalid value for show subscriptions. (must be 0 or 1)')); } } /** * Valid permissions for this module * @return array An array of valid permissions for this module */ function subscriptions_registration_perm() { return array('administer Subscriptions Registration block'); } // function subscriptions_registration_perm()