privatemsg.admin.inc

  1. 7-1 privatemsg.admin.inc
  2. 7-2 privatemsg.admin.inc
  3. 6-2 privatemsg.admin.inc

Administration menu callbacks for Privatemsg.

File

privatemsg.admin.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Administration menu callbacks for Privatemsg.
  5. */
  6. function privatemsg_admin_settings() {
  7. $form = array();
  8. $form['settings'] = array(
  9. '#type' => 'vertical_tabs',
  10. );
  11. $form['display_settings'] = array(
  12. '#type' => 'fieldset',
  13. '#collapsible' => TRUE,
  14. '#collapsed' => TRUE,
  15. '#title' => t('Display'),
  16. '#weight' => 5,
  17. '#group' => 'settings',
  18. );
  19. $form['display_settings']['private_message_view_template'] = array(
  20. '#type' => 'radios',
  21. '#title' => t('Private message display template'),
  22. '#default_value' => variable_get('private_message_view_template', 'privatemsg-view'),
  23. '#options' => privatemsg_view_options(),
  24. '#weight' => -10,
  25. );
  26. $form['display_settings']['privatemsg_display_loginmessage'] = array(
  27. '#type' => 'checkbox',
  28. '#title' => t('Inform the user about unread messages on login'),
  29. '#default_value' => variable_get('privatemsg_display_loginmessage', TRUE),
  30. '#description' => t('This option can safely be disabled if the "Unread message indication" block is used instead.'),
  31. '#weight' => -5,
  32. );
  33. $form['display_settings']['privatemsg_display_disabled_message'] = array(
  34. '#type' => 'checkbox',
  35. '#title' => t('Inform the user on /messages pages that he can not write new messages when privatemsg is disabled.'),
  36. '#default_value' => variable_get('privatemsg_display_disabled_message', TRUE),
  37. '#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.'),
  38. '#weight' => -8,
  39. );
  40. $form['display_settings']['privatemsg_default_redirect'] = array(
  41. '#type' => 'textfield',
  42. '#title' => t('Default redirection URL'),
  43. '#default_value' => variable_get('privatemsg_default_redirect', '<new-message>'),
  44. '#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.'),
  45. '#weight' => 0,
  46. );
  47. $form['display_settings']['privatemsg_default_redirect_reply'] = array(
  48. '#type' => 'checkbox',
  49. '#title' => t('Redirect replies too'),
  50. '#default_value' => variable_get('privatemsg_default_redirect_reply', FALSE),
  51. '#description' => t('Also redirect to the defined page when replying.'),
  52. '#weight' => 1,
  53. );
  54. $form['display_settings']['privatemsg_display_preview_button'] = array(
  55. '#type' => 'checkbox',
  56. '#title' => t('Show preview button on compose form'),
  57. '#description' => t('If checked, displays a preview button when sending new messages.'),
  58. '#default_value' => variable_get('privatemsg_display_preview_button', FALSE),
  59. '#weight' => 5,
  60. );
  61. $form['flush_deleted'] = array(
  62. '#type' => 'fieldset',
  63. '#collapsible' => TRUE,
  64. '#collapsed' => TRUE,
  65. '#title' => t('Deleted messages'),
  66. '#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.'),
  67. '#weight' => 20,
  68. '#group' => 'settings',
  69. );
  70. $form['flush_deleted']['privatemsg_flush_enabled'] = array(
  71. '#type' => 'checkbox',
  72. '#title' => t('Flush deleted messages'),
  73. '#default_value' => variable_get('privatemsg_flush_enabled', FALSE),
  74. '#description' => t('Enable the flushing of deleted messages. Requires that cron is enabled'),
  75. );
  76. $form['flush_deleted']['privatemsg_flush_days'] = array(
  77. '#type' => 'select',
  78. '#title' => t('Flush messages after they have been deleted for more days than'),
  79. '#default_value' => variable_get('privatemsg_flush_days', 30),
  80. '#options' => drupal_map_assoc(array(0, 1, 2, 5, 10, 30, 100)),
  81. );
  82. $form['flush_deleted']['privatemsg_flush_max'] = array(
  83. '#type' => 'select',
  84. '#title' => t('Maximum number of messages to flush per cron run'),
  85. '#default_value' => variable_get('privatemsg_flush_max', 200),
  86. '#options' => drupal_map_assoc(array(50, 100, 200, 500, 1000)),
  87. );
  88. $form['privatemsg_listing'] = array(
  89. '#type' => 'fieldset',
  90. '#title' => t('Message lists'),
  91. '#collapsible' => TRUE,
  92. '#collapsed' => FALSE,
  93. '#weight' => -5,
  94. '#group' => 'settings',
  95. );
  96. $form['privatemsg_listing']['privatemsg_per_page'] = array(
  97. '#type' => 'select',
  98. '#title' => t('Threads per page'),
  99. '#default_value' => variable_get('privatemsg_per_page', 25),
  100. '#options' => drupal_map_assoc(array(10, 25, 50, 75, 100)),
  101. '#description' => t('Choose the number of conversations that should be listed per page.'),
  102. );
  103. $form['privatemsg_listing']['privatemsg_fields'] = array(
  104. '#type' => 'fieldset',
  105. '#title' => t('Configure fields'),
  106. '#description' => t('Select which columns/fields should be displayed in the message listings.'),
  107. '#collapsible' => FALSE,
  108. '#theme' => 'privatemsg_admin_settings_display_fields',
  109. 'privatemsg_display_fields' => array(
  110. '#tree' => TRUE,
  111. ),
  112. 'privatemsg_display_fields_weights' => array(
  113. '#tree' => TRUE,
  114. ),
  115. );
  116. foreach (privatemsg_get_headers() as $key => $header) {
  117. $form['privatemsg_listing']['privatemsg_fields']['privatemsg_display_fields'][$key] = array(
  118. '#type' => 'checkbox',
  119. '#title' => $header['#title'],
  120. '#return_value' => $key,
  121. '#default_value' => $header['#enabled'],
  122. '#disabled' => $header['#locked'],
  123. '#weight' => $header['#weight'],
  124. );
  125. $form['privatemsg_listing']['privatemsg_fields']['privatemsg_display_fields_weights'][$key] = array(
  126. '#type' => 'weight',
  127. '#title' => t('!field weight', array('!field' => $header['#title'])),
  128. '#default_value' => $header['#weight'],
  129. '#delta' => 20,
  130. );
  131. }
  132. $amounts = drupal_map_assoc(array(5, 10, 20, 30, 50, 70, 90, 150, 200, 250, 300));
  133. $form['privatemsg_listing']['privatemsg_view_max_amount'] = array(
  134. '#type' => 'select',
  135. '#title' => t('Number of messages on thread pages'),
  136. '#options' => $amounts + array(PRIVATEMSG_UNLIMITED => t('Unlimited')),
  137. '#default_value' => variable_get('privatemsg_view_max_amount', 20),
  138. '#description' => t('Threads will not show more than this number of messages on a single page.'),
  139. '#weight' => 10,
  140. );
  141. $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array(
  142. '#type' => 'checkbox',
  143. '#title' => t('Display different amount of messages on first thread page'),
  144. '#default_value' => variable_get('privatemsg_view_use_max_as_default', FALSE),
  145. '#description' => t('By default, the first thread page shows the maximally allowed amount of messages. Enable this checkbox to set a different value.'),
  146. '#weight' => 15,
  147. );
  148. $form['privatemsg_listing']['privatemsg_view_default_amount'] = array(
  149. '#prefix' => '<div id="privatemsg-view-default-button">',
  150. '#suffix' => '</div>',
  151. '#type' => 'select',
  152. '#title' => t('Number of messages on first thread page'),
  153. '#default_value' => variable_get('privatemsg_view_default_amount', 10),
  154. '#description' => t('The number of messages to be displayed on first thread page. Displays the newest messages.'),
  155. '#options' => $amounts,
  156. '#weight' => 20,
  157. '#states' => array(
  158. 'visible' => array(
  159. "input[name='privatemsg_view_use_max_as_default']" => array('checked' => TRUE),
  160. )
  161. )
  162. );
  163. $form['links'] = array(
  164. '#type' => 'fieldset',
  165. '#title' => t('Links'),
  166. '#collapsible' => TRUE,
  167. '#collapsed' => TRUE,
  168. '#weight' => 10,
  169. '#group' => 'settings',
  170. );
  171. $form['links']['privatemsg_display_link_self'] = array(
  172. '#type' => 'checkbox',
  173. '#title' => t('Display "Send this user a message" links for themself'),
  174. '#description' => t('If enabled, each users sees that link on their own profile, comments and similar places.'),
  175. '#default_value' => variable_get('privatemsg_display_link_self', TRUE),
  176. '#weight' => -10,
  177. );
  178. $form['links']['privatemsg_display_profile_links'] = array(
  179. '#type' => 'checkbox',
  180. '#title' => t('Display link on profile pages.'),
  181. '#description' => t('If this setting is enabled, a link to send a private message will be displayed.'),
  182. '#default_value' => variable_get('privatemsg_display_profile_links', 1),
  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. $form['#submit'][] = 'privatemsg_admin_settings_submit';
  204. return system_settings_form($form);
  205. }
  206. function privatemsg_admin_settings_submit() {
  207. drupal_theme_rebuild();
  208. }
  209. function privatemsg_view_options() {
  210. $options = module_invoke_all('privatemsg_view_template');
  211. return $options;
  212. }

Functions