contentsadminrelink.module 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * @file
  4. * This is the file description for Contentsadminrelink module.
  5. *
  6. * In this more verbose, multi-line description, you can specify what this
  7. * file does exactly. Make sure to wrap your documentation in column 78 so
  8. * that the file can be displayed nicely in default-sized consoles.
  9. */
  10. /**
  11. * Implements hook_menu().
  12. */
  13. function contentsadminrelink_menu() {
  14. $items = array();
  15. return $items;
  16. }
  17. /**
  18. * Implements hook_url_outbound_alter().
  19. */
  20. # useless, just play with perms and menu_alter
  21. // function contentsadminrelink_url_outbound_alter(&$path, &$options, $original_path) {
  22. // if ($path == 'admin/content' || $path == 'admin/content/node') {
  23. // $path = 'admin/content/nodes';
  24. // }
  25. //}
  26. /**
  27. * Implements hook_permission().
  28. */
  29. function contentsadminrelink_permission() {
  30. return array(
  31. 'access core content overview' => array(
  32. 'title' => t('Access core content overview'),
  33. // 'description' => t('Perform administration tasks for my module.'),
  34. ),
  35. 'access core media overview' => array(
  36. 'title' => t('Access classic media overview'),
  37. // 'description' => t('Perform administration tasks for my module.'),
  38. ),
  39. );
  40. }
  41. /**
  42. * Implements hook_menu_alter().
  43. */
  44. function contentsadminrelink_menu_alter(&$items) {
  45. // dsm($items, '$items');
  46. if(isset($items['admin/content']))
  47. $items['admin/content']['access arguments'] = array('access core content overview');
  48. if(isset($items['admin/content/node']))
  49. $items['admin/content/node']['access arguments'] = array('access core content overview');
  50. if(isset($items['admin/content/media']))
  51. $items['admin/content/media']['access arguments'] = array('access classic media overview');
  52. // dsm($items, '$items');
  53. }
  54. /**
  55. * Implements hook_menu_local_tasks_alter().
  56. */
  57. function contentsadminrelink_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  58. switch($root_path){
  59. case 'admin/content/nodes' : // for example 'page/view/news'
  60. $item = menu_get_item('node/add');
  61. if ($item['access']) {
  62. $data['actions']['output'][] = array(
  63. '#theme' => 'menu_local_action',
  64. '#link' => $item,
  65. );
  66. }
  67. break;
  68. case 'admin/content/materiaux' :
  69. $item = menu_get_item('node/add/materiau');
  70. if ($item['access']) {
  71. $data['actions']['output'][] = array(
  72. '#theme' => 'menu_local_action',
  73. '#link' => $item,
  74. );
  75. }
  76. $item = menu_get_item('node/add/breve');
  77. if ($item['access']) {
  78. $data['actions']['output'][] = array(
  79. '#theme' => 'menu_local_action',
  80. '#link' => $item,
  81. );
  82. }
  83. break;
  84. case 'admin/content/companies' :
  85. $item = menu_get_item('node/add/company');
  86. if ($item['access']) {
  87. $data['actions']['output'][] = array(
  88. '#theme' => 'menu_local_action',
  89. '#link' => $item,
  90. );
  91. }
  92. $item = menu_get_item('admin/people/create');
  93. if ($item['access']) {
  94. $data['actions']['output'][] = array(
  95. '#theme' => 'menu_local_action',
  96. '#link' => $item,
  97. );
  98. }
  99. break;
  100. case 'admin/users' :
  101. $item = menu_get_item('admin/people/create');
  102. if ($item['access']) {
  103. $data['actions']['output'][] = array(
  104. '#theme' => 'menu_local_action',
  105. '#link' => $item,
  106. );
  107. }
  108. break;
  109. // case 'admin/content/medias' : // for example 'page/view/news'
  110. // $item = menu_get_item('admin/content/media/import');
  111. // if ($item['access']) {
  112. // $data['actions']['output'][] = array(
  113. // '#theme' => 'menu_local_action',
  114. // '#link' => $item,
  115. // );
  116. // }
  117. // break;
  118. }
  119. }