'citizenspeak_thank_you', 'title' => t('Customize Thank You Page'), 'weight' => 0)); } } /** * The user account is being deleted. The module should remove its custom * additions to the user object from the database. * * @param &$edit * The array of form values submitted by the user. * @param &$user * The user object on which the operation is being performed. * @param $category * The active category of user information being edited. */ function citizenspeak_user_delete(&$edit, &$user, $category = false) { db_query("DELETE FROM {citizenspeak_thankyou_options} WHERE uid = %d", $user->uid); } /** * The user account edit form is about to be displayed. The module should * present the form elements it wishes to inject into the form. * * @param &$edit * The array of form values submitted by the user. * @param &$user * The user object on which the operation is being performed. * @param $category * The active category of user information being edited. * @return * A linear array of form groups for the specified category. Each group * is represented as an associative array with keys: * - "title": The human-readable, localized name of the group. * - "data": A string containing the form elements to display. * - "weight": An integer specifying the group's sort ordering. */ function citizenspeak_user_form(&$edit, &$user, $category = false) { if ($category == "citizenspeak_thank_you" && user_access('customize thank you page', $user)) { $thank_group = $customize_desc = ''; $option_desc = form_textfield('Email To', 'volunteer_email', $user->volunteer_email, 25, 255); $customize_desc .= form_checkbox(t('Volunteer Signup'), 'request_volunteers', 1, $user->request_volunteers, $option_desc); $option_desc = form_textfield('PayPal ID', 'donation_paypal_id', $user->donation_paypal_id, 25, 255); $customize_desc .= form_checkbox(t('Donation Link'), 'request_donations', 1, $user->request_donations, $option_desc); $option_desc = form_textfield('PayPal ID', 'membership_paypal_id', $user->membership_paypal_id, 25, 255); $option_desc .= form_textfield('Dues: $', 'membership_paypal_amount', $user->membership_paypal_amount, 6, 10, t('(yearly)')); $customize_desc .= form_checkbox(t('Membership Link'), 'request_memberships', 1, $user->request_memberships, $option_desc); $option_desc = form_select('', 'additional_text_language', $user->additional_text_language, drupal_map_assoc(array('English', 'Spanish'))); $option_desc .= form_textarea('', 'additional_text', $user->additional_text, 60, 6); $customize_desc .= form_checkbox(t('Additional Text'), 'include_additional_text', 1, $user->include_additional_text, $option_desc); $option_desc = form_textfield('Email To', 'feedback_email', $user->feedback_email, 25, 255); $customize_desc .= form_checkbox(t('Feedback'), 'request_feedback', 1, $user->request_feedback, $option_desc); $thank_group .= form_radio(t('Customize Standard Page:'), 'use_redirect', 0, !$user->use_redirect, $customize_desc, NULL, true); $redirect_desc = form_textfield('', 'redirect_url', $user->redirect_url, 25, 255, t('Your full web address')); $thank_group .= form_radio(t('Use Your Page:'), 'use_redirect', 1, $user->use_redirect, $redirect_desc, NULL, true); return array(array('title' => t('Thank You Page'), 'data' => $thank_group, 'weight' => 0)); } } /** * The user account is being added. The module should save its custom * additions to the user object into the database and set the saved fields * to NULL in $edit. * * @param &$edit * The array of form values submitted by the user. * @param &$user * The user object on which the operation is being performed. * @param $category * The active category of user information being edited. */ function citizenspeak_user_insert(&$edit, &$user, $category = false) { db_query("INSERT INTO {citizenspeak_thankyou_options} (uid) VALUES (%d)", $user->uid); } /** * The user account is being changed. The module should save its custom * additions to the user object into the database and set the saved fields * to NULL in $edit. * * @param &$edit * The array of form values submitted by the user. * @param &$user * The user object on which the operation is being performed. * @param $category * The active category of user information being edited. */ function citizenspeak_user_update(&$edit, &$user, $category = false) { if ($category == "citizenspeak_thank_you" && user_access('customize thank you page', $user)) { db_query("UPDATE {citizenspeak_thankyou_options} SET use_redirect = %d, redirect_url = '%s', request_volunteers = %d, volunteer_email = '%s', request_donations = %d, donation_paypal_id = '%s', request_memberships = %d, membership_paypal_id = '%s', membership_paypal_amount = %.2f, include_additional_text = %d, additional_text_language = '%s', additional_text = '%s', request_feedback = %d, feedback_email = '%s' WHERE uid = %d", $edit['use_redirect'], $edit['redirect_url'], $edit['request_volunteers'], $edit['volunteer_email'], $edit['request_donations'], $edit['donation_paypal_id'], $edit['request_memberships'], $edit['membership_paypal_id'], $edit['membership_paypal_amount'], $edit['include_additional_text'], $edit['additional_text_language'], $edit['additional_text'], $edit['request_feedback'], $edit['feedback_email'], $user->uid); } } /** * The user account is about to be modified. The module should validate its * custom additions to the user object, registering errors as necessary. * * @param &$edit * The array of form values submitted by the user. * @param &$user * The user object on which the operation is being performed. * @param $category * The active category of user information being edited. */ function citizenspeak_user_validate(&$edit, &$user, $category = false) { if ($category == "citizenspeak_thank_you" && user_access('customize thank you page', $user)) { if ($edit['volunteer_email'] && !valid_email_address($edit['volunteer_email'])) { form_set_error('volunteer_email', 'You must provide a valid email address'); } if ($edit['feedback_email'] && !valid_email_address($edit['feedback_email'])) { form_set_error('feedback_email', 'You must provide a valid email address'); } if ($edit['donation_paypal_id'] && !valid_email_address($edit['donation_paypal_id'])) { form_set_error('donation_paypal_id', 'You must provide a valid email address'); } if ($edit['membership_paypal_id'] && !valid_email_address($edit['membership_paypal_id'])) { form_set_error('membership_paypal_id', 'You must provide a valid email address'); } if ($edit['redirect_url'] && !valid_url($edit['redirect_url'])) { form_set_error('redirect_url', 'You must provide a valid web address'); } } }