/[drupal]/contributions/modules/anti_existing_field/anti_existing_field.module
ViewVC logotype

Contents of /contributions/modules/anti_existing_field/anti_existing_field.module

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


Revision 1.3 - (show annotations) (download) (as text)
Mon Jan 5 17:13:56 2009 UTC (10 months, 3 weeks ago) by deekayen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +18 -12 lines
File MIME type: text/x-php
sync head with 6--2
1 <?php
2 // $Id: anti_existing_field.module,v 1.2.4.1 2008/11/03 17:31:38 deekayen Exp $
3
4 /**
5 * @file
6 * Disable the ability to re-use CCK fields. Prevents fields
7 * from being split out of their original content type tables
8 * into separate field-specific tables.
9 */
10
11 /**
12 * Implementation of hook_menu().
13 */
14 function anti_existing_field_menu() {
15 $items = array();
16 $items['admin/settings/anti_existing_field'] = array(
17 'page callback' => 'drupal_get_form',
18 'page arguments' => array('anti_existing_field_admin_settings'),
19 'title' => 'Anti Existing Field',
20 'description' => 'Turn off the ability to re-use fields in CCK.',
21 'access callback' => 'user_access',
22 'access arguments' => array('administer site configuration')
23 );
24
25 return $items;
26 }
27
28 /**
29 * Settings form
30 *
31 * @return array
32 */
33 function anti_existing_field_admin_settings() {
34 $form = array();
35
36 $form['anti_existing_field'] = array(
37 '#type' => 'radios',
38 '#options' => array(
39 'off' => t('Turn off re-use interference'),
40 'disable' => t('Disable submit button'),
41 'remove' => t('Remove add existing field form completely'),
42 'prank' => t('Move the submit button on mouseover')
43 ),
44 '#default_value' => variable_get('anti_existing_field', 'disable')
45 );
46
47 return system_settings_form($form);
48 }
49
50 /**
51 * Implementation of hook_form_alter().
52 *
53 * @param string $form_id
54 * @param array $form
55 */
56 function anti_existing_field_form_alter(&$form, $form_state, $form_id) {
57 if ($form_id == 'content_field_overview_form') {
58
59 switch (variable_get('anti_existing_field', 'disable')) {
60 case 'disable':
61 $form['_add_existing_field']['label']['#disabled'] = TRUE;
62 $form['_add_existing_field']['field_name']['#disabled'] = TRUE;
63 $form['_add_existing_field']['type']['#disabled'] = TRUE;
64 break;
65 case 'remove':
66 // don't unset everything because cck/theme/theme.inc will throw notices when it expects existing options to be there
67 unset($form['_add_existing_field']['label']);
68 unset($form['_add_existing_field']['field_name']);
69 unset($form['_add_existing_field']['type']);
70 unset($form['_add_existing_field']['widget_type']);
71 $form['_add_existing_field']['label'] = array(
72 '#value' => l(t('Re-enable this option'), 'admin/settings/anti_existing_field')
73 );
74 break;
75 case 'prank':
76 $form['_add_existing_field']['label']['#prefix'] = '<div id="anti-existing-field">';
77 $form['_add_existing_field']['label']['#suffix'] = '</div>';
78 $form['_add_existing_field']['label']['#attributes'] = array('onMouseover' => 'aef_prank()');
79 drupal_add_js(drupal_get_path('module', 'anti_existing_field') .'/anti_existing_field.js');
80 break;
81 }
82 }
83 }

  ViewVC Help
Powered by ViewVC 1.1.2