Advertisement
myLoveOnlyForYou

Untitled

Jul 16th, 2019
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <?php
  2. /**
  3. * @file
  4. * This module provides a node type called job post
  5. */
  6. /**
  7. * Implements hook_node_info() to provide our job_post type.
  8. */
  9. // function job_post_node_info() {
  10. // return array(
  11. // 'job_post' => array(
  12. // 'name' => t('Job Post'),
  13. // 'base' => 'job_post',
  14. // 'description' => t('Use this content type to post a job.'),
  15. // 'has_title' => TRUE,
  16. // 'title_label' => t('Job Title'),
  17. // 'help' => t('Enter the job title, job description, and the name of the company that posted the job'),
  18. // ),
  19. // );
  20. // }
  21.  
  22. function node_type_save($info) {
  23. $existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
  24. $is_existing = (bool) db_query_range('SELECT 1 FROM {node_type} WHERE type = :type', 0, 1, array(':type' => $existing_type))->fetchField();
  25. $type = node_type_set_defaults($info);
  26.  
  27. $fields = array(
  28. 'name' => t('Job Post'),
  29. 'base' => 'job_post',
  30. 'description' => t('Use this content type to post a job.'),
  31. 'has_title' => TRUE,
  32. 'title_label' => t('Job Title'),
  33. 'help' => t('Enter the job title, job description, and the name of the company that posted the job'),
  34. );
  35.  
  36. if ($is_existing) {
  37. db_update('node_type')->fields($fields)->condition('type', $existing_type)->execute();
  38.  
  39. if (!empty($type->old_type) && $type->old_type != $type->type) {
  40. entity_invoke_bundle_hook('rename', 'node', $type->old_type, $type->type);
  41. }
  42. module_invoke_all('node_type_update', $type);
  43. $status = SAVED_UPDATED;
  44. }
  45. else {
  46. $fields['orig_type'] = (string) $type->orig_type;
  47. db_insert('node_type')->fields($fields)->execute();
  48.  
  49. entity_invoke_bundle_hook('create', 'node', $type->type);
  50.  
  51. module_invoke_all('node_type_insert', $type);
  52. $status = SAVED_NEW;
  53. }
  54.  
  55. // Clear the node type cache.
  56. node_type_cache_reset();
  57.  
  58. return $status;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement