content_access.install 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @file
  4. * Content access install file.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function content_access_uninstall() {
  10. foreach (node_type_get_types() as $type_name => $type) {
  11. variable_del('content_access_' . $type_name);
  12. }
  13. }
  14. /**
  15. * Implements hook_schema().
  16. */
  17. function content_access_schema() {
  18. $schema['content_access'] = array(
  19. 'fields' => array(
  20. 'nid' => array(
  21. 'type' => 'int',
  22. 'unsigned' => TRUE,
  23. 'not null' => TRUE,
  24. 'default' => 0
  25. ),
  26. 'settings' => array(
  27. 'type' => 'text',
  28. 'not null' => FALSE,
  29. 'size' => 'medium'
  30. ),
  31. ),
  32. 'primary key' => array('nid')
  33. );
  34. return $schema;
  35. }
  36. /**
  37. * Convert content type settings to a new features-friendly storage format.
  38. */
  39. function content_access_update_7101() {
  40. $settings = variable_get('content_access_settings', array());
  41. foreach ($settings as $setting => $data) {
  42. foreach ($data as $type_name => $value) {
  43. $settings_new[$type_name][$setting] = $value;
  44. }
  45. }
  46. foreach ($settings_new as $type_name => $data) {
  47. variable_set('content_access_' . $type_name, $data);
  48. }
  49. variable_del('content_access_settings');
  50. }