1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Admin menu callbacks for privatemsg_limits module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Menu callback for the admin configuration.
|
10 |
|
|
*/
|
11 |
|
|
function privatemsg_limits_admin($form, &$form_state) {
|
12 |
|
|
$default = array(
|
13 |
|
|
'#type' => 'textfield',
|
14 |
|
|
'#size' => '10',
|
15 |
|
|
);
|
16 |
|
|
|
17 |
|
|
$form['conversation'] = array(
|
18 |
|
|
'#type' => 'fieldset',
|
19 |
|
|
'#title' => t('Conversation settings'),
|
20 |
|
|
);
|
21 |
|
|
$form['conversation']['privatemsg_limits_messages_per_thread'] = array(
|
22 |
|
|
'#type' => 'textfield',
|
23 |
|
|
'#title' => t('Maximum number of messages in a conversation'),
|
24 |
|
|
'#description' => t('The maximum number of messages that can be included in a conversation. If this maximum has already been reached and a user attempts to add an additional message, then the action specified below shall be taken. Leave this set to 0 if you want unlimited messages per conversation.'),
|
25 |
|
|
'#default_value' => variable_get('privatemsg_limits_messages_per_thread', 0),
|
26 |
|
|
'#size' => '3',
|
27 |
|
|
);
|
28 |
|
|
$form['conversation']['privatemsg_limits_messages_per_thread_action'] = array(
|
29 |
|
|
'#type' => 'radios',
|
30 |
|
|
'#title' => t('Maximum messages action'),
|
31 |
|
|
'#description' => t('This action shall be taken once a thread has already reached its maximum number of messages.'),
|
32 |
|
|
'#default_value' => variable_get('privatemsg_limits_messages_per_thread_action', 'create-new'),
|
33 |
|
|
'#options' => array(
|
34 |
|
|
'create-new' => t('Create new conversation'),
|
35 |
|
|
'block-message' => t('Block message from being sent')
|
36 |
|
|
),
|
37 |
|
|
);
|
38 |
|
|
|
39 |
|
|
$form['receive'] = array(
|
40 |
|
|
'#type' => 'fieldset',
|
41 |
|
|
'#title' => t('Receive settings'),
|
42 |
|
|
);
|
43 |
|
|
$form['receive']['privatemsg_limits_receive_enabled'] = array(
|
44 |
|
|
'#type' => 'checkbox',
|
45 |
|
|
'#title' => t('Limit the total number of messages/conversations that a user may have.'),
|
46 |
|
|
'#default_value' => variable_get('privatemsg_limits_receive_enabled', FALSE),
|
47 |
|
|
);
|
48 |
|
|
$form['receive']['privatemsg_limits_receive_object'] = array(
|
49 |
|
|
'#type' => 'select',
|
50 |
|
|
'#title' => t('What should be limited'),
|
51 |
|
|
'#description' => t('Do you want to limit the number of individual messages a user can send, or limit the number of message conversations a user can initiate? An exceeded conversation limit will allow users to still write individual messages in existing conversations, but not start new ones.'),
|
52 |
|
|
'#default_value' => variable_get('privatemsg_limits_receive_object', 'message'),
|
53 |
|
|
'#options' => array('message' => t('Messages'), 'thread' => t('Conversations')),
|
54 |
|
|
);
|
55 |
|
|
$form['receive']['privatemsg_limits_receive_amount'] = array(
|
56 |
|
|
'#type' => 'textfield',
|
57 |
|
|
'#title' => t('Maximum number of messages/conversations per user'),
|
58 |
|
|
'#description' => t('The total number of messages/conversations that a user may have before he has to delete old messages/conversations. When this limit is reached, users are not allowed to receive or send new messages.'),
|
59 |
|
|
'#default_value' => variable_get('privatemsg_limits_receive_amount', 0),
|
60 |
|
|
'#size' => '10',
|
61 |
|
|
);
|
62 |
|
|
$form['receive'] += _privatemsg_limits_role_override_form('receive_amount', $default);
|
63 |
|
|
|
64 |
|
|
$form['send'] = array(
|
65 |
|
|
'#type' => 'fieldset',
|
66 |
|
|
'#title' => t('Send settings'),
|
67 |
|
|
);
|
68 |
|
|
$form['send']['privatemsg_limits_send_enabled'] = array(
|
69 |
|
|
'#type' => 'checkbox',
|
70 |
|
|
'#title' => t('Limit the total number of messages/conversations that a user can send in a given time period'),
|
71 |
|
|
'#default_value' => variable_get('privatemsg_limits_send_enabled', FALSE),
|
72 |
|
|
);
|
73 |
|
|
$form['send']['privatemsg_limits_send_object'] = array(
|
74 |
|
|
'#type' => 'select',
|
75 |
|
|
'#title' => t('What should be limited'),
|
76 |
|
|
'#description' => t('Do you want to limit the number of individual messages a user can send, or limit the number of message conversations a user can initiate? An exceeded conversation limit will allow users to still write individual messages in existing conversations, but not start new ones.'),
|
77 |
|
|
'#default_value' => variable_get('privatemsg_limits_send_object', 'message'),
|
78 |
|
|
'#options' => array('message' => t('Messages'), 'thread' => t('Conversations')),
|
79 |
|
|
);
|
80 |
|
|
$form['send']['privatemsg_limits_send_amount'] = array(
|
81 |
|
|
'#type' => 'textfield',
|
82 |
|
|
'#title' => t('Maximum number of messages/conversations per time period'),
|
83 |
|
|
'#description' => t('The total number of messages/conversations that a user may send in a given time period.'),
|
84 |
|
|
'#default_value' => variable_get('privatemsg_limits_send_amount', 0),
|
85 |
|
|
'#size' => '10',
|
86 |
|
|
);
|
87 |
|
|
$form['send']['privatemsg_limits_send_timeframe'] = array(
|
88 |
|
|
'#type' => 'select',
|
89 |
|
|
'#title' => t('Set the time period to be used'),
|
90 |
|
|
'#description' => t("Specify the time period to be used when limiting a user's sent messages/threads."),
|
91 |
|
|
'#default_value' => variable_get('privatemsg_limits_send_timeframe', 3600),
|
92 |
|
|
'#options' => drupal_map_assoc(array(60, 300, 1800, 3600, 86400, 604800, 604800 * 4), 'format_interval'),
|
93 |
|
|
);
|
94 |
|
|
$form['send'] += _privatemsg_limits_role_override_form('send_amount', $default);
|
95 |
|
|
|
96 |
|
|
$form['recipients'] = array(
|
97 |
|
|
'#type' => 'fieldset',
|
98 |
|
|
'#title' => t('Recipient settings'),
|
99 |
|
|
);
|
100 |
|
|
$form['recipients']['privatemsg_limits_recipients_enabled'] = array(
|
101 |
|
|
'#type' => 'checkbox',
|
102 |
|
|
'#title' => t('Limit the total number of recipients that a user can include in a single message'),
|
103 |
|
|
'#default_value' => variable_get('privatemsg_limits_recipients_enabled', FALSE),
|
104 |
|
|
);
|
105 |
|
|
$form['recipients']['privatemsg_limits_recipients_amount'] = array(
|
106 |
|
|
'#type' => 'textfield',
|
107 |
|
|
'#title' => t('Maximum number of recipients per message'),
|
108 |
|
|
'#description' => t('Defines the total number of recipients a user may include in a single message. This setting only affects new messages (and not replies on existing message threads). A role (just like any other recipient type) is considered to be a single recipient regardless of the number of users with that role.'),
|
109 |
|
|
'#default_value' => variable_get('privatemsg_limits_recipients_amount', 0),
|
110 |
|
|
'#size' => '10',
|
111 |
|
|
);
|
112 |
|
|
$form['recipients'] += _privatemsg_limits_role_override_form('recipients_amount', $default);
|
113 |
|
|
|
114 |
|
|
return system_settings_form($form);
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
/**
|
118 |
|
|
* Provides a generic rules form to override the default values.
|
119 |
|
|
*
|
120 |
|
|
* @param string $name Unique name for the value
|
121 |
|
|
* @param array $default default form configuration
|
122 |
|
|
*
|
123 |
|
|
* @return array Form fieldset
|
124 |
|
|
*/
|
125 |
|
|
function _privatemsg_limits_role_override_form($name, $default) {
|
126 |
|
|
$form['roles'] = array(
|
127 |
|
|
'#type' => 'fieldset',
|
128 |
|
|
'#description' => t('You may override the maximum limit specified above on a per-role basis. If a user has multiple roles, then the highest maximum value shall be used. Enter "unlimited" if a role may have unlimited messages/conversations. Enter "0" if you do not want to override the maximum limit setting.'),
|
129 |
|
|
'#title' => t('Override maximum limit by role'),
|
130 |
|
|
'#collapsible' => TRUE,
|
131 |
|
|
'#collapsed' => TRUE,
|
132 |
|
|
);
|
133 |
|
|
|
134 |
|
|
foreach (user_roles(TRUE) as $id => $role) {
|
135 |
|
|
$form['roles']["privatemsg_limits_{$name}_role_{$id}"] = $default + array(
|
136 |
|
|
'#title' => $role,
|
137 |
|
|
'#default_value' => variable_get("privatemsg_limits_{$name}_role_" . $id, 0),
|
138 |
|
|
);
|
139 |
|
|
}
|
140 |
|
|
return $form;
|
141 |
|
|
} |