Projet

Général

Profil

Paste
Télécharger (9,23 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / privatemsg / privatemsg.admin.inc @ ba09eb79

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Administration menu callbacks for Privatemsg.
6
 */
7
8
function privatemsg_admin_settings() {
9
  $form = array();
10
11
  $form['settings'] = array(
12
    '#type' => 'vertical_tabs',
13
  );
14
15
  $form['display_settings'] = array(
16
    '#type'        => 'fieldset',
17
    '#collapsible' => TRUE,
18
    '#collapsed'   => TRUE,
19
    '#title'       => t('Display'),
20
    '#weight'      => 5,
21
    '#group'       => 'settings',
22
  );
23
  $form['display_settings']['private_message_view_template'] = array(
24
    '#type'          => 'radios',
25
    '#title'         => t('Private message display template'),
26
    '#default_value' => variable_get('private_message_view_template', 'privatemsg-view'),
27
    '#options'       => privatemsg_view_options(),
28
    '#weight'        => -10,
29
  );
30
  $form['display_settings']['privatemsg_display_loginmessage'] = array(
31
    '#type' => 'checkbox',
32
    '#title' => t('Inform the user about new messages on login'),
33
    '#default_value' => variable_get('privatemsg_display_loginmessage', TRUE),
34
    '#description' => t('This option can safely be disabled if the "New message indication" block is used instead.'),
35
    '#weight'      => -5,
36
  );
37
  $form['display_settings']['privatemsg_display_disabled_message'] = array(
38
    '#type' => 'checkbox',
39
    '#title' => t('Inform the user on /messages pages that he can not write new messages when privatemsg is disabled.'),
40
    '#default_value' => variable_get('privatemsg_display_disabled_message', TRUE),
41
    '#description' => t('Users can (if given the permission) disable Privatemsg which disallows writing messages to them and they can not write messages themself. If enabled, those users are informed on the relevant pages why they are not allowed to write messages.'),
42
    '#weight'      => -8,
43
  );
44
  $form['display_settings']['privatemsg_default_redirect'] = array(
45
    '#type' => 'textfield',
46
    '#title' => t('Default redirection URL'),
47
    '#default_value' => variable_get('privatemsg_default_redirect', '<new-message>'),
48
    '#description' => t('Defines to which page users are sent after sending a new message. &lt;front&gt; can be used for the defined front page and &lt;new-message&gt; to redirect to the new message. Leave empty to disable the redirect.'),
49
    '#weight'      => 0,
50
  );
51
  $form['display_settings']['privatemsg_default_redirect_reply'] = array(
52
    '#type' => 'checkbox',
53
    '#title' => t('Redirect replies too'),
54
    '#default_value' => variable_get('privatemsg_default_redirect_reply', FALSE),
55
    '#description' => t('Also redirect to the defined page when replying.'),
56
    '#weight'      => 1,
57
  );
58
  $form['display_settings']['privatemsg_display_preview_button'] = array(
59
    '#type' => 'checkbox',
60
    '#title' => t('Show preview button on compose form'),
61
    '#description' => t('If checked, displays a preview button when sending new messages.'),
62
    '#default_value' => variable_get('privatemsg_display_preview_button', FALSE),
63
    '#weight' => 5,
64
  );
65
66
  $form['flush_deleted'] = array(
67
    '#type'        => 'fieldset',
68
    '#collapsible' => TRUE,
69
    '#collapsed'   => TRUE,
70
    '#title'       => t('Deleted messages'),
71
    '#description' => t('By default, deleted messages are only hidden from the user but still stored in the database. These settings control if and when messages should be removed.'),
72
    '#weight'    => 20,
73
    '#group'       => 'settings',
74
  );
75
76
  $form['flush_deleted']['privatemsg_flush_enabled'] = array(
77
    '#type'          => 'checkbox',
78
    '#title'         => t('Flush deleted messages'),
79
    '#default_value' => variable_get('privatemsg_flush_enabled', FALSE),
80
    '#description'   => t('Enable the flushing of deleted messages. Requires that cron is enabled'),
81
  );
82
83
  $form['flush_deleted']['privatemsg_flush_days'] = array(
84
    '#type' => 'select',
85
    '#title' => t('Flush messages after they have been deleted for more days than'),
86
    '#default_value' => variable_get('privatemsg_flush_days', 30),
87
    '#options' => drupal_map_assoc(array(0, 1, 2, 5, 10, 30, 100)),
88
  );
89
90
  $form['flush_deleted']['privatemsg_flush_max'] = array(
91
    '#type' => 'select',
92
    '#title' => t('Maximum number of messages to flush per cron run'),
93
    '#default_value' => variable_get('privatemsg_flush_max', 200),
94
    '#options' => drupal_map_assoc(array(50, 100, 200, 500, 1000)),
95
  );
96
97
  $form['privatemsg_listing'] = array(
98
    '#type' => 'fieldset',
99
    '#title' => t('Message lists'),
100
    '#collapsible' => TRUE,
101
    '#collapsed' => FALSE,
102
    '#weight' => -5,
103
    '#group'       => 'settings',
104
  );
105
106
  $form['privatemsg_listing']['privatemsg_per_page'] = array(
107
    '#type' => 'select',
108
    '#title' => t('Threads per page'),
109
    '#default_value' => variable_get('privatemsg_per_page', 25),
110
    '#options' => drupal_map_assoc(array(10, 25, 50, 75, 100)),
111
    '#description' => t('Choose the number of conversations that should be listed per page.'),
112
  );
113
114
  $form['privatemsg_listing']['privatemsg_display_fields'] = array(
115
    '#type' => 'checkboxes',
116
    '#title' => t('Configure fields'),
117
    '#description' => t('Select which columns/fields should be displayed in the message listings. Subject and Last updated cannot be disabled.'),
118
    '#options' => array(
119
      'participants'    => t('Participants'),
120
      'thread_started'  => t('Started'),
121
      'count'           => t('Messages'),
122
    ),
123
    '#default_value' => variable_get('privatemsg_display_fields', array('participants')),
124
  );
125
126
  $amounts = drupal_map_assoc(array(5, 10, 20, 30, 50, 70, 90, 150, 200, 250, 300));
127
  $form['privatemsg_listing']['privatemsg_view_max_amount'] = array(
128
    '#type'          => 'select',
129
    '#title'         => t('Number of messages on thread pages'),
130
    '#options'       => $amounts + array(PRIVATEMSG_UNLIMITED => t('Unlimited')),
131
    '#default_value' => variable_get('privatemsg_view_max_amount', 20),
132
    '#description'   => t('Threads will not show more than this number of messages on a single page.'),
133
    '#weight'        => 10,
134
  );
135
136
  $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array(
137
    '#type'          => 'checkbox',
138
    '#title'         => t('Display different amount of messages on first thread page'),
139
    '#default_value' => variable_get('privatemsg_view_use_max_as_default', FALSE),
140
    '#description'   => t('By default, the first thread page shows the maximally allowed amount of messages. Enable this checkbox to set a different value.'),
141
    '#weight'        => 15,
142
  );
143
144
  $form['privatemsg_listing']['privatemsg_view_default_amount'] = array(
145
    '#prefix'        => '<div id="privatemsg-view-default-button">',
146
    '#suffix'        => '</div>',
147
    '#type'          => 'select',
148
    '#title'         => t('Number of messages on first thread page'),
149
    '#default_value' => variable_get('privatemsg_view_default_amount', 10),
150
    '#description'   => t('The number of messages to be displayed on first thread page. Displays the newest messages.'),
151
    '#options'       => $amounts,
152
    '#weight'        => 20,
153
    '#states'        => array(
154
      'visible' => array(
155
        "input[name='privatemsg_view_use_max_as_default']" => array('checked' => TRUE),
156
      )
157
    )
158
  );
159
160
  $form['links'] = array(
161
    '#type' => 'fieldset',
162
    '#title' => t('Links'),
163
    '#collapsible' => TRUE,
164
    '#collapsed' => TRUE,
165
    '#weight' => 10,
166
    '#group'       => 'settings',
167
  );
168
169
  $form['links']['privatemsg_display_link_self'] = array(
170
    '#type' => 'checkbox',
171
    '#title' => t('Display "Send this user a message" links for themself'),
172
    '#description' => t('If enabled, each users sees that link on their own profile, comments and similiar places.'),
173
    '#default_value' => variable_get('privatemsg_display_link_self', TRUE),
174
    '#weight'        => -10,
175
  );
176
177
  $form['links']['privatemsg_display_profile_links'] = array(
178
    '#type' => 'checkbox',
179
    '#title' => t('Display link on profile pages.'),
180
    '#description' => t('If this setting is enabled, a link to send a private message will be displayed.'),
181
    '#default_value' => variable_get('privatemsg_display_profile_links', 1),
182
  );
183
184
  $node_types = node_type_get_names();
185
  $form['links']['privatemsg_link_node_types'] = array(
186
    '#type' => 'checkboxes',
187
    '#title' => t('Display link on the selected content types'),
188
    '#description' => t('Select which content types should display a link to send a private message to the author. By default, the link is not displayed below teasers.'),
189
    '#default_value' => variable_get('privatemsg_link_node_types', array()),
190
    '#options' => $node_types,
191
  );
192
  $form['links']['privatemsg_display_on_teaser'] = array(
193
    '#type' => 'checkbox',
194
    '#title' => t('Display link on teasers of the selected content types.'),
195
    '#default_value' => variable_get('privatemsg_display_on_teaser', 1),
196
  );
197
  $form['links']['privatemsg_display_on_comments'] = array(
198
    '#type' => 'checkbox',
199
    '#title' => t('Display links on comments of selected content types.'),
200
    '#description' => t('Also display a link to send a private message to the authors of the comments of the selected content types.'),
201
    '#default_value' => variable_get('privatemsg_display_on_comments', 0),
202
  );
203
204
  $form['#submit'][] = 'privatemsg_admin_settings_submit';
205
  return system_settings_form($form);
206
}
207
208
function privatemsg_admin_settings_submit() {
209
  drupal_theme_rebuild();
210
}
211
212
function privatemsg_view_options() {
213
  $options = module_invoke_all('privatemsg_view_template');
214
  return $options;
215
}