content_type_extras.admin.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <?php
  2. function content_type_extras_settings() {
  3. $defaults = content_type_extras_get_default();
  4. // Get all available user roles
  5. $roles = user_roles();
  6. $admin_role = variable_get('user_admin_role', 0);
  7. if ($admin_role != 0) {
  8. $roles[$admin_role] .= t(' <em>(administrator role)</em>');
  9. }
  10. if(!isset($defaults['user_permissions']['edit_own_roles'])) {
  11. $defaults['user_permissions']['edit_own_roles'] = array();
  12. }
  13. if(!isset($defaults['user_permissions']['delete_own_roles'])) {
  14. $defaults['user_permissions']['delete_own_roles'] = array();
  15. }
  16. $form = array(
  17. 'intro' => array(
  18. '#markup' => t('Set the default settings for all new content types below. These settings can be overridden on the content type page.'),
  19. ),
  20. 'content_type_extras' => array(
  21. '#type' => 'vertical_tabs',
  22. 'submission' => array(
  23. '#type' => 'fieldset',
  24. '#title' => t('Submission form settings'),
  25. '#attached' => array(
  26. 'js' => array(
  27. 'vertical-tabs' => drupal_get_path('module', 'content_type_extras') . '/js/content_type_extras.vertical_tabs.js',
  28. ),
  29. ),
  30. '#weight' => 0,
  31. 'title_label' => array(
  32. '#type' => 'textfield',
  33. '#title' => t('Title field label'),
  34. '#default_value' => $defaults['title_label'],
  35. '#required' => 1,
  36. ),
  37. 'node_preview' => array(
  38. '#type' => 'radios',
  39. '#title' => t('Preview before submitting'),
  40. '#options' => array(
  41. t('Disabled'),
  42. t('Optional'),
  43. t('Required'),
  44. ),
  45. '#default_value' => $defaults['node_preview'],
  46. ),
  47. 'content_type_extras_preview_button' => array(
  48. '#type' => 'textfield',
  49. '#title' => t('Preview button value'),
  50. '#description' => t('The name of the Preview button that will display on the content edit form if enabled'),
  51. '#default_value' => $defaults['content_type_extras_preview_button'],
  52. '#required' => 1,
  53. ),
  54. 'content_type_extras_save_and_new' => array(
  55. '#type' => 'radios',
  56. '#title' => t('Save and New button'),
  57. '#options' => array(
  58. t('Disabled'),
  59. t('Enabled'),
  60. ),
  61. '#default_value' => $defaults['content_type_extras_save_and_new'],
  62. ),
  63. 'content_type_extras_save_and_new_button' => array(
  64. '#type' => 'textfield',
  65. '#title' => t('Save and New button value'),
  66. '#description' => t('The name of the Save and New button that will display on the content edit form if enabled'),
  67. '#default_value' => $defaults['content_type_extras_save_and_new_button'],
  68. '#required' => 1,
  69. ),
  70. 'content_type_extras_save_and_edit' => array(
  71. '#type' => 'radios',
  72. '#title' => t('Save and Edit button'),
  73. '#options' => array(
  74. t('Disabled'),
  75. t('Enabled'),
  76. ),
  77. '#default_value' => $defaults['content_type_extras_save_and_edit'],
  78. ),
  79. 'content_type_extras_save_and_edit_button' => array(
  80. '#type' => 'textfield',
  81. '#title' => t('Save and Edit button value'),
  82. '#description' => t('The name of the Save and Edit button that will display on the content edit form if enabled'),
  83. '#default_value' => $defaults['content_type_extras_save_and_edit_button'],
  84. '#required' => 1,
  85. ),
  86. 'content_type_extras_cancel' => array(
  87. '#type' => 'radios',
  88. '#title' => t('Cancel button'),
  89. '#options' => array(
  90. t('Disabled'),
  91. t('Enabled'),
  92. ),
  93. '#default_value' => $defaults['content_type_extras_cancel'],
  94. )
  95. ),
  96. 'workflow' => array(
  97. '#type' => 'fieldset',
  98. '#title' => t('Publishing options'),
  99. '#weight' => 10,
  100. 'node_options' => array(
  101. '#type' => 'checkboxes',
  102. '#title' => t('Default options'),
  103. '#options' => array(
  104. 'status' => t('Published'),
  105. 'promote' => t('Promoted to front page'),
  106. 'sticky' => t('Sticky at top of lists'),
  107. 'revision' => t('Create new revision'),
  108. ),
  109. '#default_value' => $defaults['node_options'],
  110. ),
  111. ),
  112. 'display' => array(
  113. '#type' => 'fieldset',
  114. '#title' => t('Display settings'),
  115. '#weight' => 20,
  116. 'node_submitted' => array(
  117. '#type' => 'checkbox',
  118. '#title' => t('Display author and date information.'),
  119. '#description' => t('Author username and publish date will be displayed.'),
  120. '#default_value' => $defaults['node_submitted'],
  121. ),
  122. ),
  123. 'user_permissions' => array(
  124. '#type' => 'fieldset',
  125. '#title' => t('User permissions'),
  126. '#tree' => TRUE,
  127. '#weight' => 30,
  128. 'intro' => array(
  129. '#markup' => '<p>' . t('These permissions set the defaults for <em>new</em> content types. They do not change global permissions for all content types.'),
  130. ),
  131. 'create_roles' => array(
  132. '#type' => 'checkboxes',
  133. '#title' => t('Roles that can CREATE content'),
  134. '#options' => $roles,
  135. '#default_value' => $defaults['user_permissions']['create_roles'],
  136. ),
  137. 'edit_roles' => array(
  138. '#type' => 'checkboxes',
  139. '#title' => t('Roles that can EDIT any content'),
  140. '#options' => $roles,
  141. '#default_value' => $defaults['user_permissions']['edit_roles'],
  142. ),
  143. 'edit_own_roles' => array(
  144. '#type' => 'checkboxes',
  145. '#title' => t('Roles that can EDIT own content'),
  146. '#options' => $roles,
  147. '#default_value' => $defaults['user_permissions']['edit_own_roles'],
  148. ),
  149. 'delete_roles' => array(
  150. '#type' => 'checkboxes',
  151. '#title' => t('Roles that can DELETE any content'),
  152. '#options' => $roles,
  153. '#default_value' => $defaults['user_permissions']['delete_roles'],
  154. ),
  155. 'delete_own_roles' => array(
  156. '#type' => 'checkboxes',
  157. '#title' => t('Roles that can DELETE own content'),
  158. '#options' => $roles,
  159. '#default_value' => $defaults['user_permissions']['delete_own_roles'],
  160. ),
  161. ),
  162. 'extras' => array(
  163. '#type' => 'fieldset',
  164. '#title' => t('Extra settings'),
  165. '#weight' => 40,
  166. 'content_type_forms' => array(
  167. '#type' => 'fieldset',
  168. '#title' => t('Content type forms'),
  169. '#weight' => 0,
  170. 'content_type_extras_descriptions_required' => array(
  171. '#type' => 'checkbox',
  172. '#title' => t('Make description field on all content types required'),
  173. '#description' => t('Drupal by default does not require that the description field be filled in. Enabling this option will make the description field required.'),
  174. '#default_value' => $defaults['content_type_extras_descriptions_required'],
  175. ),
  176. 'content_type_extras_remove_body' => array(
  177. '#type' => 'checkbox',
  178. '#description' => t("Drupal by default automatically creates a body field for each content type. Enabling this option will remove the body field from a newly created content type. This option can be overridden on a per content type basis."),
  179. '#title' => t('Remove body field from content types'),
  180. '#default_value' => $defaults['content_type_extras_remove_body'],
  181. ),
  182. 'content_type_extras_disable_token_display' => array(
  183. '#type' => 'checkbox',
  184. '#description' => t('Using modules such as pathauto uses tokens and, by default, we show the replacement patterns to use available tokens. However, this can slow some page loads down considerably. To disable token replacement patterns from being displayed on pages altered by Content Type: Extras (i.e. the content type edit page) check this box. This feature only hides the token replacement patterns. Tokens may still be used, they just must be entered manually.'),
  185. '#title' => t('Disable token replacement patterns'),
  186. '#default_value' => $defaults['content_type_extras_disable_token_display'],
  187. ),
  188. 'content_type_extras_cancel_button_location' => array(
  189. '#type' => 'radios',
  190. '#description' => t('Choose whether the user will be taken to the previous page or a specific page when the Cancel button is pressed.'),
  191. '#title' => t('Cancel button destination'),
  192. '#options' => array(
  193. 'previous' => t('Previous page'),
  194. 'static_path' => t('Static path'),
  195. ),
  196. '#default_value' => $defaults['content_type_extras_cancel_button_location'],
  197. ),
  198. 'content_type_extras_cancel_button_location_path' => array(
  199. '#type' => 'textfield',
  200. '#description' => t('Set the path where the user should be redirected when the cancel button is pressed. <strong>Note:</strong> In most cases you will probably want to prepend the path with a /.'),
  201. '#title' => t('Path'),
  202. '#default_value' => $defaults['content_type_extras_cancel_button_location_path'],
  203. '#states' => array(
  204. 'visible' => array(
  205. ':input[name="content_type_extras_cancel_button_location"]' => array('value' => 'static_path'),
  206. ),
  207. ),
  208. ),
  209. ),
  210. 'node_titles' => array(
  211. '#type' => 'fieldset',
  212. '#title' => t('Node titles'),
  213. '#weight' => 1,
  214. 'content_type_extras_title_hide' => array(
  215. '#type' => 'checkbox',
  216. '#title' => t('Hide title on node view'),
  217. '#description' => t('If checked, node titles will be hidden by default. Users with the <a href="/admin/people/permissions#module-content_type_extras">appropriate permission</a> can override this on a per-node basis.'),
  218. '#default_value' => $defaults['content_type_extras_title_hide'],
  219. ),
  220. 'content_type_extras_title_hide_css' => array(
  221. '#type' => 'checkbox',
  222. '#title' => t('Hide titles with CSS'),
  223. '#description' => t('If checked, any node titles that are selected to be hidden will be hidden with CSS so that they render in HTML for devices like screenreaders.'),
  224. '#default_value' => $defaults['content_type_extras_title_hide_css'],
  225. ),
  226. 'content_type_extras_title_hide_front' => array(
  227. '#type' => 'checkbox',
  228. '#title' => t('Hide node title on front page'),
  229. '#description' => t('If checked, the node title on the front page will be hidden, regardless of what content type it is associated with'),
  230. '#default_value' => $defaults['content_type_extras_title_hide_front'],
  231. ),
  232. ),
  233. 'form_buttons' => array(
  234. '#type' => 'fieldset',
  235. '#title' => t('Form buttons'),
  236. '#weight' => 2,
  237. 'content_type_extras_top_buttons' => array(
  238. '#type' => 'checkboxes',
  239. '#title' => t('Show form buttons at top of:'),
  240. '#description' => t('Select the areas to duplicate form submission buttons on the top of the page.'),
  241. '#options' => array(
  242. 'manage_fields' => t('Manage fields form'),
  243. 'node_edit' => t('Node edit form'),
  244. ),
  245. '#default_value' => $defaults['content_type_extras_top_buttons'],
  246. ),
  247. ),
  248. ),
  249. 'configuration' => array(
  250. '#type' => 'fieldset',
  251. '#title' => t('Configuration settings'),
  252. '#weight' => 50,
  253. 'content_type_extras_excluded_node_forms' => array(
  254. '#type' => 'textarea',
  255. '#title' => t('Excluded node forms'),
  256. '#description' => t('Enter the node form ids that you would like to exclude from being processed by Content Type: Extras, one per line.<br><strong>Note:</strong> \'subscriptions_ui_node_form\' and \'field_collection_item_form\' will always be added to prevent errors.'),
  257. '#default_value' => implode("\n", $defaults['content_type_extras_excluded_node_forms']),
  258. ),
  259. ),
  260. ),
  261. );
  262. if (module_exists('comment')) {
  263. $form['content_type_extras']['comment'] = array(
  264. '#type' => 'fieldset',
  265. '#title' => t('Comment settings'),
  266. '#tree' => TRUE,
  267. '#weight' => 25,
  268. 'comment' => array(
  269. '#type' => 'select',
  270. '#title' => t('Default comment setting for new content types'),
  271. '#default_value' => $defaults['comment']['comment'],
  272. '#options' => array(
  273. COMMENT_NODE_OPEN => t('Open'),
  274. COMMENT_NODE_CLOSED => t('Closed'),
  275. COMMENT_NODE_HIDDEN => t('Hidden'),
  276. ),
  277. ),
  278. 'default_mode' => array(
  279. '#type' => 'checkbox',
  280. '#title' => t('Threading'),
  281. '#default_value' => $defaults['comment']['default_mode'],
  282. '#description' => t('Show comment replies in a threaded list.'),
  283. ),
  284. 'default_per_page' => array(
  285. '#type' => 'select',
  286. '#title' => t('Comments per page'),
  287. '#default_value' => $defaults['comment']['default_per_page'],
  288. '#options' => _comment_per_page(),
  289. ),
  290. 'anonymous' => array(
  291. '#type' => 'select',
  292. '#title' => t('Anonymous commenting'),
  293. '#default_value' => $defaults['comment']['anonymous'],
  294. '#options' => array(
  295. COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
  296. COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
  297. COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
  298. ),
  299. '#access' => user_access('post comments', drupal_anonymous_user()),
  300. ),
  301. 'subject_field' => array(
  302. '#type' => 'checkbox',
  303. '#title' => t('Allow comment title'),
  304. '#default_value' => $defaults['comment']['subject_field'],
  305. ),
  306. 'form_location' => array(
  307. '#type' => 'checkbox',
  308. '#title' => t('Show reply form on the same page as comments'),
  309. '#default_value' => $defaults['comment']['form_location'],
  310. ),
  311. 'preview' => array(
  312. '#type' => 'radios',
  313. '#title' => t('Preview comment'),
  314. '#default_value' => $defaults['comment']['preview'],
  315. '#options' => array(
  316. DRUPAL_DISABLED => t('Disabled'),
  317. DRUPAL_OPTIONAL => t('Optional'),
  318. DRUPAL_REQUIRED => t('Required'),
  319. ),
  320. ),
  321. );
  322. }
  323. if (module_exists('xmlsitemap')) {
  324. $form['content_type_extras']['xmlsitemap_settings'] = array(
  325. '#type' => 'fieldset',
  326. '#title' => t('XML Sitemap'),
  327. '#tree' => TRUE, // Set to TRUE to match node_type_form for saving settings
  328. '#weight' => 35,
  329. 'status' => array(
  330. '#type' => 'select',
  331. '#title' => t('Inclusion'),
  332. '#options' => array(
  333. 1 => t('Included'),
  334. 0 => t('Excluded'),
  335. ),
  336. '#default_value' => $defaults['xmlsitemap_settings']['status'],
  337. ),
  338. 'priority' => array(
  339. '#type' => 'select',
  340. '#title' => t('Default priority'),
  341. '#options' => array(
  342. '1.0' => t('1.0 (highest)'),
  343. '0.9' => '0.9',
  344. '0.8' => '0.8',
  345. '0.7' => '0.7',
  346. '0.6' => '0.6',
  347. '0.5' => t('0.5 (normal)'),
  348. '0.4' => '0.4',
  349. '0.3' => '0.3',
  350. '0.2' => '0.2',
  351. '0.1' => '0.1',
  352. '0.0' => t('0.0 (lowest)'),
  353. ),
  354. '#default_value' => $defaults['xmlsitemap_settings']['priority'],
  355. '#states' => array(
  356. 'invisible' => array(
  357. 'select[name="xmlsitemap_settings[status]"]' => array('value' => '0'),
  358. ),
  359. ),
  360. ),
  361. );
  362. }
  363. if (module_exists('scheduler')) {
  364. $form['content_type_extras']['scheduler_settings'] = array(
  365. '#type' => 'fieldset',
  366. '#title' => t('Scheduler'),
  367. '#tree' => TRUE, // Set to TRUE to match node_type_form for saving settings
  368. '#weight' => 35,
  369. 'publish_enable' => array(
  370. '#type' => 'checkbox',
  371. '#title' => t('Enable Scheduled publishing for new content types'),
  372. '#default_value' => $defaults['scheduler_settings']['publish_enable'],
  373. ),
  374. 'publish_touch' => array(
  375. '#type' => 'checkbox',
  376. '#title' => t('Change content creation time to match the scheduled publish time for new content types'),
  377. '#default_value' => $defaults['scheduler_settings']['publish_touch'],
  378. ),
  379. 'publish_require' => array(
  380. '#type' => 'checkbox',
  381. '#title' => t('Require scheduled publishing for new content types'),
  382. '#default_value' => $defaults['scheduler_settings']['publish_require'],
  383. ),
  384. 'publish_revision' => array(
  385. '#type' => 'checkbox',
  386. '#title' => t('Create a new revision on publishing for new content types'),
  387. '#default_value' => $defaults['scheduler_settings']['publish_revision'],
  388. ),
  389. 'unpublish_enable' => array(
  390. '#type' => 'checkbox',
  391. '#title' => t('Enable scheduled unpublishing for new content types'),
  392. '#default_value' => $defaults['scheduler_settings']['unpublish_enable'],
  393. ),
  394. 'unpublish_require' => array(
  395. '#type' => 'checkbox',
  396. '#title' => t('Require scheduled unpublishing for new content types'),
  397. '#default_value' => $defaults['scheduler_settings']['unpublish_require'],
  398. ),
  399. 'unpublish_revision' => array(
  400. '#type' => 'checkbox',
  401. '#title' => t('Create a new revision on unpublishing for new content types'),
  402. '#default_value' => $defaults['scheduler_settings']['unpublish_revision'],
  403. ),
  404. );
  405. }
  406. if (module_exists('fpa')) {
  407. $form['content_type_extras']['extras']['content_type_forms']['content_type_extras_user_permissions_select'] = array(
  408. '#type' => 'radios',
  409. '#title' => t('Select which user interface to use to manage permissions on node type forms'),
  410. '#options' => array(
  411. 'cte' => t('Content Type: Extras'),
  412. 'fpa' => t('Fast Permissions Administration (FPA)'),
  413. ),
  414. '#default_value' => $defaults['content_type_extras_user_permissions_select'],
  415. );
  416. }
  417. $form['actions'] = array(
  418. 'submit' => array(
  419. '#type' => 'submit',
  420. '#value' => t('Save configuration'),
  421. ),
  422. );
  423. return $form;
  424. }
  425. function content_type_extras_settings_submit(&$form, &$form_state) {
  426. $values = $form_state['values'];
  427. // Place the values of content_type_extras_excluded_node_forms into an array
  428. $values['content_type_extras_excluded_node_forms'] = explode("\n", $values['content_type_extras_excluded_node_forms']);
  429. unset($values['submit'], $values['form_build_id'], $values['form_token'], $values['form_id'], $values['op']);
  430. variable_set('content_type_extras_default_settings', $values);
  431. drupal_set_message(t('Default content type settings saved.'));
  432. $form_state['redirect'] = 'admin/structure/types';
  433. }