/[drupal]/contributions/modules/birthdays/birthdays.admin.inc
ViewVC logotype

Contents of /contributions/modules/birthdays/birthdays.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.12 - (show annotations) (download) (as text)
Sun Oct 5 09:18:37 2008 UTC (13 months, 3 weeks ago) by maartenvg
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, DRUPAL-6--1-0-RC1, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.11: +6 -8 lines
File MIME type: text/x-php
Use user_mail_tokens() for birthday e-mails.
1 <?php
2 // $Id: birthdays.admin.inc,v 1.11 2008/10/04 10:29:02 maartenvg Exp $
3 /**
4 * @file
5 * All functions related to the birthdays adminstration
6 */
7
8 /**
9 * Generates the Birthdays admininistration form located at
10 * ?q=admin/settings/birthdays.
11 */
12 function birthdays_admin_settings() {
13 // Get fields from the profile.module of the type 'date'.
14 $options = _birthdays_get_date_fields();
15
16 // If there aren't any 'date' fields, throw an error and return an empty form
17 if (empty($options)) {
18 drupal_set_message(t('No profile fields of type \'date\' were found, please <a href="@profile-settings-page">create one here</a>.', array('@profile-settings-page' => url('admin/user/profile/add/date'))), 'error');
19 return;
20 }
21
22 $options = array('') + $options;
23 // Fieldset for general settings
24 $form['birthdays_general_settings'] = array(
25 '#type' => 'fieldset',
26 '#title' => t('General settings'),
27 '#collapsible' => TRUE,
28 '#collapsed' => FALSE,
29 );
30
31 $form['birthdays_general_settings']['birthdays_field_id'] = array(
32 '#type' => 'select',
33 '#title' => t('Profile field'),
34 '#default_value' => variable_get('birthdays_field_id', NULL),
35 '#description' => t("Select which profile field of type 'date' you want to use as date of birth."),
36 '#options' => $options,
37 '#required' => TRUE,
38 );
39
40 $form['birthdays_general_settings']['birthdays_show_starsign'] = array(
41 '#type' => 'select',
42 '#title' => t('Show star signs'),
43 '#default_value' => variable_get('birthdays_show_starsign', BIRTHDAYS_STARSIGN_OFF),
44 '#options' => array(
45 BIRTHDAYS_STARSIGN_OFF => t('No'),
46 BIRTHDAYS_STARSIGN_LINK => t('Yes, with link to Yahoo Astrology'),
47 BIRTHDAYS_STARSIGN_NOLINK => t('Yes, without link to Yahoo Astrology')
48 ),
49 '#description' => t('Select whether the star signs should be enabled.'),
50 );
51
52 $form['birthdays_general_settings']['birthdays_hide_year'] = array(
53 '#type' => 'select',
54 '#title' => t('Hide year and age'),
55 '#default_value' => variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO),
56 '#description' => t('Select whether the birth year and age should be shown.'),
57 '#options' => array(
58 BIRTHDAYS_HIDE_YEAR_NO => t('No'),
59 BIRTHDAYS_HIDE_YEAR_YES => t('Yes'),
60 BIRTHDAYS_HIDE_YEAR_USER => t("User optional, 'No' by default"),
61 ),
62 );
63
64 // Fieldset for the birthdays page.
65 $form['birthdays_page'] = array(
66 '#type' => 'fieldset',
67 '#title' => t('Birthdays page settings'),
68 '#collapsible' => TRUE,
69 '#collapsed' => FALSE,
70 );
71
72 $form['birthdays_page']['birthdays_page_settings'] = array(
73 '#type' => 'select',
74 '#title' => t('Set birthdays page settings'),
75 '#default_value' => variable_get('birthdays_page_settings', BIRTHDAYS_PAGE_FILTER_SORT_DATE),
76 '#description' => t("Select whether users that haven't entered their date of birth should be shown on the birthdays page, and whether the list should be ordered by birthday or by username."),
77 '#options' => array(
78 BIRTHDAYS_PAGE_FILTER_SORT_DATE => t('Filter users, sort by date'),
79 BIRTHDAYS_PAGE_FILTER_SORT_USER => t('Filter users, sort by username'),
80 BIRTHDAYS_PAGE_NOFILTER_SORT_USER => t('Do not filter users, sort by username'),
81 ),
82 );
83
84 $form['birthdays_page']['birthdays_page_list_number'] = array(
85 '#type' => 'textfield',
86 '#title' => t('Birthdays page size'),
87 '#default_value' => variable_get('birthdays_page_list_number', 25),
88 '#description' => t('How many users should be listed on each page on the Birthdays listing?'),
89 '#required' => TRUE,
90 '#size' => 10,
91 );
92
93 $form['birthdays_page']['birthdays_page_show_filters'] = array(
94 '#type' => 'select',
95 '#title' => t('Show filter options'),
96 '#default_value' => variable_get('birthdays_page_show_filters', 1),
97 '#description' => t("Show the 'Filter by month and year' selections on the birthdays page. When 'Hide year' has been set to 'Yes', the year filter isn't shown."),
98 '#options' => array(
99 0 => t('No'),
100 1 => t('Yes'),
101 ),
102 );
103
104 // Fieldset for e-mails.
105 $form['birthdays_email'] = array(
106 '#type' => 'fieldset',
107 '#title' => t('E-mail settings'),
108 '#description' => t('Adjust the e-mail settings for both e-mails to users and e-mails to the administrator. This requires cron jobs to be active. Please see the <a href="@cron_url">online handbook</a> for more information on how to accomplish that.', array('@cron_url' => 'http://drupal.org/cron')),
109 '#collapsible' => TRUE,
110 '#collapsed' => FALSE,
111 );
112
113 // Fieldset for Admin E-mails
114 $form['birthdays_email']['admin'] = array(
115 '#type' => 'fieldset',
116 '#title' => t('Admin'),
117 '#collapsible' => TRUE,
118 '#collapsed' => variable_get('birthdays_remind', BIRTHDAYS_ADMIN_MAIL_DISABLED) == BIRTHDAYS_ADMIN_MAIL_DISABLED,
119 );
120
121 $days = array(0 => t('sunday'), 1 => t('monday'), 2 => t('tuesday'), 3 => t('wednesday'), 4 => t('thursday'), 5 => t('friday'), 6 => t('saturday'));
122
123 $form['birthdays_email']['admin']['birthdays_remind'] = array(
124 '#type' => 'select',
125 '#title' => t('Send upcoming birthdays to admin'),
126 '#default_value' => variable_get('birthdays_remind', BIRTHDAYS_ADMIN_MAIL_DISABLED),
127 '#options' => array(
128 BIRTHDAYS_ADMIN_MAIL_DISABLED => t('Disabled'),
129 BIRTHDAYS_ADMIN_MAIL_DAILY => t('Daily'),
130 BIRTHDAYS_ADMIN_MAIL_WEEKLY => t('Weekly, on @first_weekday', array('@first_weekday' => $days[variable_get('date_first_day', 0)])),
131 BIRTHDAYS_ADMIN_MAIL_MONTHLY => t('Monthly'),
132 ),
133 '#description' => t('Do you want to receive periodic e-mails containing all upcoming birthdays?')
134 );
135
136 // Fieldset for User E-mails
137 $form['birthdays_email']['users'] = array(
138 '#type' => 'fieldset',
139 '#title' => t('User'),
140 '#collapsible' => TRUE,
141 '#collapsed' => variable_get('birthdays_send_user', BIRTHDAYS_USER_MAIL_NO) == BIRTHDAYS_USER_MAIL_NO,
142 );
143
144 $form['birthdays_email']['users']['birthdays_send_user'] = array(
145 '#type' => 'select',
146 '#title' => t('Send user e-mail on day of birth'),
147 '#default_value' => variable_get('birthdays_send_user', BIRTHDAYS_USER_MAIL_NO),
148 '#options' => array(
149 BIRTHDAYS_USER_MAIL_NO => t('No'),
150 BIRTHDAYS_USER_MAIL_YES => t('Yes'),
151 BIRTHDAYS_USER_MAIL_USER => t("User optional, 'Yes' by default"),
152 ),
153 '#description' => t('Should users that have their birthday today receive an e-mail?'),
154 );
155 $email_token_help = t('Available variables are:') .' !username, !site, !password, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url.';
156 $form['birthdays_email']['users']['birthdays_send_user_subject'] = array(
157 '#type' => 'textfield',
158 '#title' => t('Subject'),
159 '#default_value' => _birthdays_mail_text('subject'),
160 '#description' => $email_token_help,
161 );
162
163 $form['birthdays_email']['users']['birthdays_send_user_message'] = array(
164 '#type' => 'textarea',
165 '#title' => t('Message'),
166 '#default_value' => _birthdays_mail_text('message'),
167 '#description' => $email_token_help,
168 );
169
170
171 return system_settings_form($form);
172 }
173
174 /**
175 * Implementation of hook_form().
176 */
177 function birthdays_sync_form() {
178 global $_birthdays_field;
179
180 if (!isset($_birthdays_field)) {
181 drupal_set_message(t('No date field has been selected as birthdays field. Please visit the <a href="@birthdays-settings">birthdays settings page</a>.', array('@birthdays-settings' => url('admin/settings/birthdays'))), 'warning');
182 return array();
183 }
184 $form['profile_fieldset'] = array('#type' => 'fieldset');
185
186 $form['profile_fieldset']['description'] = array(
187 '#type' => 'item',
188 '#title' => 'Profile to Birthdays',
189 '#value' => t("Fill the Birthdays module's table with data from the Profile module's table. This is needed when you install the Birthdays module, but already collected birthdays with the Profile module (e.g. for age verification, to show in the profile or after uninstalling the Birthdays module)."),
190 );
191
192 $form['profile_fieldset']['submit'] = array(
193 '#type' => 'submit',
194 '#value' => t('Copy Profile data to Birthdays module'),
195 '#submit' => array('birthdays_sync_profiles_to_birthdays'),
196 );
197
198 $form['birthdays_fieldset'] = array('#type' => 'fieldset');
199
200 $form['birthdays_fieldset']['description'] = array(
201 '#type' => 'item',
202 '#title' => 'Birthdays to Profile',
203 '#value' => t("Fill the Profile module's table with data from the Birthdays module's table. You can use this if you completely reinstalled the Profile module while leaving the Birthdays module alone, or to copy the old data collected by a version of the Birthdays module which didn't use the Profile module (pre-5.x)."),
204 );
205
206 $form['birthdays_fieldset']['submit'] = array(
207 '#type' => 'submit',
208 '#value' => t('Copy Birthdays data to Profile module'),
209 '#submit' => array('birthdays_sync_birthdays_to_profiles'),
210 );
211
212 return $form;
213 }

  ViewVC Help
Powered by ViewVC 1.1.2