'lists', 'title' => t('Mailing lists'), 'access' => user_access('access content'), 'callback' => 'drupal_get_form', 'callback arguments' => array('lists_subscribe_form'), 'type' => MENU_SUGGESTED_ITEM ); } return $items; } /** * Internal helper function to return a list of mailing lists. */ function _lists_get_lists() { $lists = array( 'support' => array( 'name' => 'Support', 'description' => 'A list for support questions.', 'mailto' => 'support-request@drupal.org', ), 'development' => array( 'name' => 'Development', 'description' => 'A list for Drupal developers.', 'mailto' => 'development-request@drupal.org', ), 'themes' => array( 'name' => 'Themes', 'description' => 'A list for Drupal theme developers/designers.', 'mailto' => 'themes-request@drupal.org', ), 'documentation' => array( 'name' => 'Documentation', 'description' => 'A list for documentation contributors.', 'mailto' => 'documentation-request@drupal.org', ), 'translations' => array( 'name' => 'Translations', 'description' => 'A list for Drupal UI translators.', 'mailto' => 'translations-request@drupal.org', ), 'consulting' => array( 'name' => 'Consulting', 'description' => 'A mailing list for Drupal consultants and Drupal service/hosting providers.', 'mailto' => 'consulting-request@drupal.org', ), 'drupal-cvs' => array( 'name' => 'CVS commits', 'description' => 'A list with all CVS commit messages.', 'mailto' => 'drupal-cvs-request@drupal.org', ), 'cvs-applications' => array( 'name' => 'CVS applications', 'description' => 'A list of all applications for an account in the Drupal contributions CVS repository.', 'mailto' => 'cvs-applications-request@drupal.org', 'private' => TRUE, ), 'webmasters' => array( 'name' => 'Webmasters', 'description' => 'A list for drupal.org webmasters (e.g. settings and content on the drupal.org website, user management, removing spam, etc.).', 'mailto' => 'webmasters-request@drupal.org', 'private' => TRUE, ), 'infrastructure' => array( 'name' => 'Infrastructure', 'description' => 'A list for drupal.org infrastructure maintainers (e.g. drupal.org hardware and server configuration, the CVS repository, mailing lists, etc).', 'mailto' => 'infrastructure-request@drupal.org', 'private' => TRUE, ), 'drupal-con' => array( 'name' => 'DrupalCON', 'description' => 'A list for the organization of Drupal conferences and events.', 'mailto' => 'drupal-con-request@drupal.org', 'private' => TRUE, ), ); return $lists; } /** * Mailing list form builder function. * * @see lists_subscribe_form_validate() * @see lists_subscribe_form_submit() */ function lists_subscribe_form() { global $user; $lists = _lists_get_lists(); foreach ($lists as $list => $info) { $links = array(); if (isset($info['private']) && $info['private']) { $links[] = "view archive (members only)"; } else { $links[] = "view archive"; $links[] = "search archive"; } $output .= "

$info[name]

\n"; if (!$info['disabled']) { $links[] = "mailman page"; } else { $output .= "This list has been disabled.\n"; } $output .= "

$info[description]

\n"; $output .= "

"; $output .= implode(' . ', $links); $output .= "

\n"; } $output .= '

Subscribe

'; $form['intro'] = array( '#type' => 'markup', '#value' => $output, ); $form['mail'] = array( '#type' => 'textfield', '#title' => t('E-mail address'), '#default_value' => ($user->uid ? $user->mail : ''), '#size' => 50, '#maxlength' => 255, '#required' => TRUE, ); $form['item'] = array( '#type' => 'item', '#title' => t('Mailing lists'), '#default_value' => '', ); foreach ($lists as $list => $info) { if (!$info['disabled']) { $form[$list] = array( '#type' => 'checkbox', '#title' => $list, ); } } $form['subscribe'] = array( '#type' => 'submit', '#value' => t('Subscribe'), ); return $form; } /** * Validate form submission. * * @see lists_subscribe_form() */ function lists_subscribe_form_validate($form_id,$form) { if (!valid_email_address($form['mail'])) { form_set_error('mail', t("Please enter a valid e-mail address.")); } } /** * Submission handler for the subscription form. * * @see lists_subscribe_form() */ function lists_subscribe_form_submit($form_id, $form = NULL) { $sent = FALSE; $mail = $form['mail']; if ($mail) { foreach (_lists_get_lists() as $list => $info) { if ($form[$list]) { $sent = TRUE; $headers = "From: $mail\nReturn-path: $mail\nError-to: $mail"; $result[] = mail($info['mailto'], "subscribe address=$mail", 'subscribe to mailing list', $headers); } } } if (!$sent) { drupal_set_message('You did not fill in the form properly.', 'error'); } else { drupal_set_message('You will receive confirmation emails for your subscriptions. Please read them carefully and follow the directions.'); } }