node.admin.inc 22 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
<?php
// $Id$

/**
 * @file
 * Content administration and module settings UI.
 */

/**
 * Menu callback; presents general node configuration options.
 */
function node_configure() {
13
14
  $status = '<p>' . t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Possible causes for permission problems are disabling modules or configuration changes to permissions. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings.') . '</p>';
  $status .= '<p>' . t('Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.') . '</p>';
15

16
17
18
19
20
21
22
23
24
25
  $form['access'] = array(
    '#type' => 'fieldset',
    '#title' => t('Node access status'),
  );
  $form['access']['status'] = array('#markup' => $status);
  $form['access']['rebuild'] = array(
    '#type' => 'submit',
    '#value' => t('Rebuild permissions'),
    '#submit' => array('node_configure_access_submit'),
  );
26
  $form['default_nodes_main'] = array(
27
28
    '#type' => 'select', '#title' => t('Number of posts on main page'),
    '#default_value' => 10,
29
    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
30
31
32
    '#description' => t('The default maximum number of posts to display per page on overview pages such as the main page.')
  );
  $form['teaser_length'] = array(
33
    '#type' => 'select', '#title' => t('Length of trimmed posts'),
34
    '#default_value' => variable_get('teaser_length', 600),
35
    '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'),
36
    '#description' => t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited'.")
37
38
39
  );

  $form['node_preview'] = array(
40
41
    '#type' => 'radios',
    '#title' => t('Preview post'),
42
    '#default_value' => 0,
43
44
    '#options' => array(t('Optional'), t('Required')),
    '#description' => t('Must users preview posts before submitting?'),
45
46
  );

47
  return system_settings_form($form, TRUE);
48
49
50
}

/**
51
 * Form button submit callback.
52
 */
53
54
function node_configure_access_submit($form, &$form_state) {
  $form_state['redirect'] = 'admin/content/node-settings/rebuild';
55
56
57
58
59
60
}

/**
 * Menu callback: confirm rebuilding of permissions.
 */
function node_configure_rebuild_confirm() {
61
62
  return confirm_form(array(), t('Are you sure you want to rebuild the permissions on site content?'),
                  'admin/content/node-settings', t('This action rebuilds all permissions on site content, and may be a lengthy process. This action cannot be undone.'), t('Rebuild permissions'), t('Cancel'));
63
64
65
66
67
}

/**
 * Handler for wipe confirmation
 */
68
function node_configure_rebuild_confirm_submit($form, &$form_state) {
69
  node_access_rebuild(TRUE);
70
  $form_state['redirect'] = 'admin/reports/status';
71
72
73
}

/**
74
 * Implement hook_node_operations().
75
76
77
78
79
 */
function node_node_operations() {
  $operations = array(
    'publish' => array(
      'label' => t('Publish'),
80
81
      'callback' => 'node_mass_update',
      'callback arguments' => array('updates' => array('status' => 1)),
82
83
84
    ),
    'unpublish' => array(
      'label' => t('Unpublish'),
85
86
      'callback' => 'node_mass_update',
      'callback arguments' => array('updates' => array('status' => 0)),
87
88
89
    ),
    'promote' => array(
      'label' => t('Promote to front page'),
90
91
      'callback' => 'node_mass_update',
      'callback arguments' => array('updates' => array('status' => 1, 'promote' => 1)),
92
93
94
    ),
    'demote' => array(
      'label' => t('Demote from front page'),
95
96
      'callback' => 'node_mass_update',
      'callback arguments' => array('updates' => array('promote' => 0)),
97
98
99
    ),
    'sticky' => array(
      'label' => t('Make sticky'),
100
101
      'callback' => 'node_mass_update',
      'callback arguments' => array('updates' => array('status' => 1, 'sticky' => 1)),
102
103
104
    ),
    'unsticky' => array(
      'label' => t('Remove stickiness'),
105
106
      'callback' => 'node_mass_update',
      'callback arguments' => array('updates' => array('sticky' => 0)),
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    ),
    'delete' => array(
      'label' => t('Delete'),
      'callback' => NULL,
    ),
  );
  return $operations;
}

/**
 * List node administration filters that can be applied.
 */
function node_filters() {
  // Regular filters
121
122
123
124
125
126
127
128
129
130
  $filters['status'] = array(
    'title' => t('status'),
    'options' => array(
      'status-1' => t('published'),
      'status-0' => t('not published'),
      'promote-1' => t('promoted'),
      'promote-0' => t('not promoted'),
      'sticky-1' => t('sticky'),
      'sticky-0' => t('not sticky'),
    ),
131
132
133
  );
  // Include translation states if we have this module enabled
  if (module_exists('translation')) {
134
135
136
137
    $filters['status']['options'] += array(
      'translate-0' => t('Up to date translation'),
      'translate-1' => t('Outdated translation'),
    );
138
139
  }

140
  $filters['type'] = array('title' => t('type'), 'options' => node_type_get_names());
141
142
143

  // The taxonomy filter
  if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) {
144
    $filters['term'] = array('title' => t('term'), 'options' => $taxonomy);
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  }
  // Language filter if there is a list of languages
  if ($languages = module_invoke('locale', 'language_list')) {
    $languages = array('' => t('Language neutral')) + $languages;
    $filters['language'] = array('title' => t('language'), 'options' => $languages);
  }
  return $filters;
}

/**
 * Build query for node administration filters based on session.
 */
function node_build_filter_query() {
  // Build query
  $where = $args = array();
  $join = '';
161
162
  $filter_data = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array();
  foreach ($filter_data as $index => $filter) {
163
164
165
166
167
    list($key, $value) = $filter;
    switch ($key) {
      case 'status':
        // Note: no exploitable hole as $key/$value have already been checked when submitted
        list($key, $value) = explode('-', $value, 2);
168
        $where[] = 'n.' . $key . ' = %d';
169
        break;
170
      case 'term':
171
172
        $table = "tn$index";
        $where[] = "$table.tid = %d";
173
        $join .= "INNER JOIN {taxonomy_term_node} $table ON n.nid = $table.nid ";
174
175
176
        break;
      case 'type':
        $where[] = "n.type = '%s'";
177
        break;
178
179
      case 'language':
        $where[] = "n.language = '%s'";
180
        break;
181
182
183
    }
    $args[] = $value;
  }
184
  $where = count($where) ? 'WHERE ' . implode(' AND ', $where) : '';
185
186
187
188
189
190
191
192

  return array('where' => $where, 'join' => $join, 'args' => $args);
}

/**
 * Return form for node administration filters.
 */
function node_filter_form() {
193
  $session = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array();
194
195
196
  $filters = node_filters();

  $i = 0;
197
198
  $form['filters'] = array(
    '#type' => 'fieldset',
199
200
201
202
203
204
    '#title' => t('Show only items where'),
    '#theme' => 'node_filters',
  );
  $form['#submit'][] = 'node_filter_form_submit';
  foreach ($session as $filter) {
    list($type, $value) = $filter;
205
    if ($type == 'term') {
206
      // Load term name from DB rather than search and parse options array.
207
      $value = module_invoke('taxonomy', 'term_load', $value);
208
209
      $value = $value->name;
    }
210
    elseif ($type == 'language') {
211
212
213
214
215
216
      $value = empty($value) ? t('Language neutral') : module_invoke('locale', 'language_name', $value);
    }
    else {
      $value = $filters[$type]['options'][$value];
    }
    if ($i++) {
217
      $form['filters']['current'][] = array('#markup' => t('<em>and</em> where <strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
218
219
    }
    else {
220
      $form['filters']['current'][] = array('#markup' => t('<strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    }
    if (in_array($type, array('type', 'language'))) {
      // Remove the option if it is already being filtered on.
      unset($filters[$type]);
    }
  }

  foreach ($filters as $key => $filter) {
    $names[$key] = $filter['title'];
    $form['filters']['status'][$key] = array('#type' => 'select', '#options' => $filter['options']);
  }

  $form['filters']['filter'] = array('#type' => 'radios', '#options' => $names, '#default_value' => 'status');
  $form['filters']['buttons']['submit'] = array('#type' => 'submit', '#value' => (count($session) ? t('Refine') : t('Filter')));
  if (count($session)) {
    $form['filters']['buttons']['undo'] = array('#type' => 'submit', '#value' => t('Undo'));
    $form['filters']['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
  }

240
  drupal_add_js('misc/form.js');
241
242
243
244
245
246

  return $form;
}

/**
 * Theme node administration filter form.
247
248
 *
 * @ingroup themeable
249
250
251
252
253
254
 */
function theme_node_filter_form($form) {
  $output = '';
  $output .= '<div id="node-admin-filter">';
  $output .= drupal_render($form['filters']);
  $output .= '</div>';
255
  $output .= drupal_render_children($form);
256
257
258
259
260
  return $output;
}

/**
 * Theme node administration filter selector.
261
262
 *
 * @ingroup themeable
263
264
265
 */
function theme_node_filters($form) {
  $output = '';
266
  $output .= '<ul class="clearfix">';
267
268
  if (!empty($form['current'])) {
    foreach (element_children($form['current']) as $key) {
269
      $output .= '<li>' . drupal_render($form['current'][$key]) . '</li>';
270
271
272
    }
  }

273
  $output .= '<li><dl class="multiselect">' . (!empty($form['current']) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '') . '<dd class="a">';
274
275
276
277
278
  foreach (element_children($form['filter']) as $key) {
    $output .= drupal_render($form['filter'][$key]);
  }
  $output .= '</dd>';

279
  $output .= '<dt>' . t('is') . '</dt><dd class="b">';
280
281
282
283
284
285
286

  foreach (element_children($form['status']) as $key) {
    $output .= drupal_render($form['status'][$key]);
  }
  $output .= '</dd>';

  $output .= '</dl>';
287
  $output .= '<div class="container-inline" id="node-admin-buttons">' . drupal_render($form['buttons']) . '</div>';
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
  $output .= '</li></ul>';

  return $output;
}

/**
 * Process result from node administration filter form.
 */
function node_filter_form_submit($form, &$form_state) {
  $filters = node_filters();
  switch ($form_state['values']['op']) {
    case t('Filter'):
    case t('Refine'):
      if (isset($form_state['values']['filter'])) {
        $filter = $form_state['values']['filter'];

        // Flatten the options array to accommodate hierarchical/nested options.
        $flat_options = form_options_flatten($filters[$filter]['options']);

        if (isset($flat_options[$form_state['values'][$filter]])) {
          $_SESSION['node_overview_filter'][] = array($filter, $form_state['values'][$filter]);
        }
      }
      break;
    case t('Undo'):
      array_pop($_SESSION['node_overview_filter']);
      break;
    case t('Reset'):
316
      $_SESSION['node_overview_filter'] = array();
317
318
319
320
      break;
  }
}

321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/**
 * Make mass update of nodes, changing all nodes in the $nodes array
 * to update them with the field values in $updates.
 *
 * IMPORTANT NOTE: This function is intended to work when called
 * from a form submit handler. Calling it outside of the form submission
 * process may not work correctly.
 *
 * @param array $nodes
 *   Array of node nids to update.
 * @param array $updates
 *   Array of key/value pairs with node field names and the
 *   value to update that field to.
 */
function node_mass_update($nodes, $updates) {
  // We use batch processing to prevent timeout when updating a large number
  // of nodes.
  if (count($nodes) > 10) {
    $batch = array(
      'operations' => array(
        array('_node_mass_update_batch_process', array($nodes, $updates))
      ),
      'finished' => '_node_mass_update_batch_finished',
      'title' => t('Processing'),
      // We use a single multi-pass operation, so the default
      // 'Remaining x of y operations' message will be confusing here.
      'progress_message' => '',
      'error_message' => t('The update has encountered an error.'),
      // The operations do not live in the .module file, so we need to
      // tell the batch engine which file to load before calling them.
351
      'file' => drupal_get_path('module', 'node') . '/node.admin.inc',
352
353
354
355
    );
    batch_set($batch);
  }
  else {
356
    foreach ($nodes as $nid) {
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
      _node_mass_update_helper($nid, $updates);
    }
    drupal_set_message(t('The update has been performed.'));
  }
}

/**
 * Node Mass Update - helper function.
 */
function _node_mass_update_helper($nid, $updates) {
  $node = node_load($nid, NULL, TRUE);
  foreach ($updates as $name => $value) {
    $node->$name = $value;
  }
  node_save($node);
  return $node;
}

/**
 * Node Mass Update Batch operation
 */
function _node_mass_update_batch_process($nodes, $updates, &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($nodes);
    $context['sandbox']['nodes'] = $nodes;
  }

  // Process nodes by groups of 5.
  $count = min(5, count($context['sandbox']['nodes']));
  for ($i = 1; $i <= $count; $i++) {
    // For each nid, load the node, reset the values, and save it.
    $nid = array_shift($context['sandbox']['nodes']);
    $node = _node_mass_update_helper($nid, $updates);

    // Store result for post-processing in the finished callback.
393
    $context['results'][] = l($node->title, 'node/' . $node->nid);
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420

    // Update our progress information.
    $context['sandbox']['progress']++;
  }

  // Inform the batch engine that we are not finished,
  // and provide an estimation of the completion level we reached.
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}

/**
 * Node Mass Update Batch 'finished' callback.
 */
function _node_mass_update_batch_finished($success, $results, $operations) {
  if ($success) {
    drupal_set_message(t('The update has been performed.'));
  }
  else {
    drupal_set_message(t('An error occurred and processing did not complete.'), 'error');
    $message = format_plural(count($results), '1 item successfully processed:', '@count items successfully processed:');
    $message .= theme('item_list', $results);
    drupal_set_message($message);
  }
}

421
422
423
424
425
426
427
428
429
/**
 * Menu callback: content administration.
 */
function node_admin_content($form_state) {
  if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') {
    return node_multiple_delete_confirm($form_state, array_filter($form_state['values']['nodes']));
  }
  $form = node_filter_form();

430
  $form['#theme'] = 'node_filter_form';
431
  $form['admin'] = node_admin_nodes();
432
433
434
435

  return $form;
}

436
437
438
/**
 * Form builder: Builds the node administration overview.
 */
439
function node_admin_nodes() {
440
441
  // Enable language column if translation module is enabled
  // or if we have any node with language.
442
  $multilanguage = (module_exists('translation') || db_query("SELECT COUNT(*) FROM {node} WHERE language <> ''")->fetchField());
443
444
445
446
447
448
449
450
451
452
453
454
455

  // Build the sortable table header.
  $header = array();
  $header[] = theme('table_select_header_cell');
  $header[] = array('data' => t('Title'), 'field' => 'n.title');
  $header[] = array('data' => t('Type'), 'field' => 'n.type');
  $header[] = array('data' => t('Author'), 'field' => 'u.name');
  $header[] = array('data' => t('Status'), 'field' => 'n.status');
  $header[] = array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc');
  if ($multilanguage) {
    $header[] = array('data' => t('Language'), 'field' => 'n.language');
  }
  $header[] = array('data' => t('Operations'));
456

457
458
459
460
  $form['header'] = array(
   '#type' => 'value',
   '#value' => $header,
  );
461

462
463
  // Build the query and load the nodes we want to display.
  $filter = node_build_filter_query();
464

465
  $sort = tablesort_sql($header, '', 'n.changed DESC');
466
  $result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n ' . $filter['join'] . ' INNER JOIN {users} u ON n.uid = u.uid ' . $filter['where'] . $sort), 50, 0, NULL, $filter['args']);
467

468
  // Build the 'Update options' form.
469
470
  $form['options'] = array(
    '#type' => 'fieldset',
471
472
473
474
475
476
477
478
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $options = array();
  foreach (module_invoke_all('node_operations') as $operation => $array) {
    $options[$operation] = $array['label'];
  }
479
480
481
482
483
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 'approve',
  );
484
485
486
487
488
489
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
    '#submit' => array('node_admin_nodes_submit'),
  );

490
  $languages = language_list();
491
492
493
494
  $destination = drupal_get_destination();
  $nodes = array();
  while ($node = db_fetch_object($result)) {
    $nodes[$node->nid] = '';
495
    $options = empty($node->language) ? array() : array('language' => $languages[$node->language]);
496
    $form['title'][$node->nid] = array('#markup' => l($node->title, 'node/' . $node->nid, $options) . ' ' . theme('mark', node_mark($node->nid, $node->changed)));
497
    $form['name'][$node->nid] =  array('#markup' => check_plain(node_type_get_name($node)));
498
499
    $form['username'][$node->nid] = array('#markup' => theme('username', $node));
    $form['status'][$node->nid] =  array('#markup' => ($node->status ? t('published') : t('not published')));
500
    $form['changed'][$node->nid] = array('#markup' => format_date($node->changed, 'small'));
501
    if ($multilanguage) {
502
      $form['language'][$node->nid] = array('#markup' => empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name));
503
    }
504
    $form['operations'][$node->nid] = array('#markup' => l(t('edit'), 'node/' . $node->nid . '/edit', array('query' => $destination)));
505
  }
506
507
508
509
  $form['nodes'] = array(
    '#type' => 'checkboxes',
    '#options' => $nodes,
  );
510
  $form['pager'] = array('#markup' => theme('pager', NULL));
511
512
513
514
  $form['#theme'] = 'node_admin_nodes';
  return $form;
}

515
516
/**
 * Validate node_admin_nodes form submissions.
517
 *
518
519
520
521
522
523
524
525
526
527
528
529
 * Check if any nodes have been selected to perform the chosen
 * 'Update option' on.
 */
function node_admin_nodes_validate($form, &$form_state) {
  $nodes = array_filter($form_state['values']['nodes']);
  if (count($nodes) == 0) {
    form_set_error('', t('No items selected.'));
  }
}

/**
 * Process node_admin_nodes form submissions.
530
 *
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
 * Execute the chosen 'Update option' on the selected nodes.
 */
function node_admin_nodes_submit($form, &$form_state) {
  $operations = module_invoke_all('node_operations');
  $operation = $operations[$form_state['values']['operation']];
  // Filter out unchecked nodes
  $nodes = array_filter($form_state['values']['nodes']);
  if ($function = $operation['callback']) {
    // Add in callback arguments if present.
    if (isset($operation['callback arguments'])) {
      $args = array_merge(array($nodes), $operation['callback arguments']);
    }
    else {
      $args = array($nodes);
    }
    call_user_func_array($function, $args);

    cache_clear_all();
  }
  else {
551
    // We need to rebuild the form to go to a second step. For example, to
552
553
554
555
556
557
    // show the confirmation form for the deletion of nodes.
    $form_state['rebuild'] = TRUE;
  }
}


558
559
/**
 * Theme node administration overview.
560
561
 *
 * @ingroup themeable
562
563
564
565
 */
function theme_node_admin_nodes($form) {
  $output = '';
  $output .= drupal_render($form['options']);
566
567
568
569

  $header = $form['header']['#value'];

  $has_posts = isset($form['title']) && is_array($form['title']);
570
  if ($has_posts) {
571
    $rows = array();
572
573
574
575
576
577
578
    foreach (element_children($form['title']) as $key) {
      $row = array();
      $row[] = drupal_render($form['nodes'][$key]);
      $row[] = drupal_render($form['title'][$key]);
      $row[] = drupal_render($form['name'][$key]);
      $row[] = drupal_render($form['username'][$key]);
      $row[] = drupal_render($form['status'][$key]);
579
      $row[] = drupal_render($form['changed'][$key]);
580
581
582
583
584
585
586
      if (isset($form['language'])) {
        $row[] = drupal_render($form['language'][$key]);
      }
      $row[] = drupal_render($form['operations'][$key]);
      $rows[] = $row;
    }
  }
587
  else {
588
    $rows[] = array(
589
      array('data' => t('No content available.'), 'colspan' => count($header)),
590
    );
591
592
593
  }

  $output .= theme('table', $header, $rows);
594

595
  if ($form['pager']['#markup']) {
596
597
598
    $output .= drupal_render($form['pager']);
  }

599
  $output .= drupal_render_children($form);
600
601
602
603
604
605
606
607

  return $output;
}

function node_multiple_delete_confirm(&$form_state, $nodes) {
  $form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
  // array_filter returns only elements with TRUE values
  foreach ($nodes as $nid => $value) {
608
    $title = db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
609
610
611
612
    $form['nodes'][$nid] = array(
      '#type' => 'hidden',
      '#value' => $nid,
      '#prefix' => '<li>',
613
      '#suffix' => check_plain($title) . "</li>\n",
614
    );
615
616
617
  }
  $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
  $form['#submit'][] = 'node_multiple_delete_confirm_submit';
618
619
  $confirm_question = format_plural(count($nodes),
                                  'Are you sure you want to delete this item?',
620
                                  'Are you sure you want to delete these items?');
621
  return confirm_form($form,
622
623
624
                    $confirm_question,
                    'admin/content/node', t('This action cannot be undone.'),
                    t('Delete'), t('Cancel'));
625
626
627
628
}

function node_multiple_delete_confirm_submit($form, &$form_state) {
  if ($form_state['values']['confirm']) {
629
630
631
632
    node_delete_multiple(array_keys($form_state['values']['nodes']));
    $count = count($form_state['values']['nodes']);
    watchdog('content', 'Deleted @count posts.', array('@count' => $count));
    drupal_set_message(t('Deleted @count posts.', array('@count' => $count)));
633
634
635
636
  }
  $form_state['redirect'] = 'admin/content/node';
  return;
}
637
638
639
640
641
642
643
644

/**
 * Implement hook_modules_installed()
 */
function node_modules_installed($modules) {
  // Clear node type cache for node permissions.
  node_type_clear();
}