path.rules.inc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * @file rules integration for the path module
  4. *
  5. * @addtogroup rules
  6. * @{
  7. */
  8. /**
  9. * Implements hook_rules_file_info() on behalf of the path module.
  10. */
  11. function rules_path_file_info() {
  12. return array('modules/path.eval');
  13. }
  14. /**
  15. * Implements hook_rules_action_info() on behalf of the path module.
  16. */
  17. function rules_path_action_info() {
  18. return array(
  19. 'path_alias' => array(
  20. 'label' => t('Create or delete any URL alias'),
  21. 'group' => t('Path'),
  22. 'parameter' => array(
  23. 'source' => array(
  24. 'type' => 'text',
  25. 'label' => t('Existing system path'),
  26. 'description' => t('Specifies the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.') .' '. t('Leave it empty to delete URL aliases pointing to the given path alias.'),
  27. 'optional' => TRUE,
  28. ),
  29. 'alias' => array(
  30. 'type' => 'text',
  31. 'label' => t('URL alias'),
  32. 'description' => t('Specify an alternative path by which this data can be accessed. For example, "about" for an about page. Use a relative path and do not add a trailing slash.') .' '. t('Leave it empty to delete URL aliases pointing to the given system path.'),
  33. 'optional' => TRUE,
  34. 'cleaning callback' => 'rules_path_clean_replacement_values',
  35. ),
  36. 'language' => array(
  37. 'type' => 'token',
  38. 'label' => t('Language'),
  39. 'description' => t('If specified, the language for which the URL alias applies.'),
  40. 'options list' => 'entity_metadata_language_list',
  41. 'optional' => TRUE,
  42. 'default value' => LANGUAGE_NONE,
  43. ),
  44. ),
  45. 'base' => 'rules_action_path_alias',
  46. 'callbacks' => array('dependencies' => 'rules_path_dependencies'),
  47. 'access callback' => 'rules_path_integration_access',
  48. ),
  49. 'node_path_alias' => array(
  50. 'label' => t("Create or delete a content's URL alias"),
  51. 'group' => t('Path'),
  52. 'parameter' => array(
  53. 'node' => array(
  54. 'type' => 'node',
  55. 'label' => t('Content'),
  56. 'save' => TRUE,
  57. ),
  58. 'alias' => array(
  59. 'type' => 'text',
  60. 'label' => t('URL alias'),
  61. 'description' => t('Specify an alternative path by which the content can be accessed. For example, "about" for an about page. Use a relative path and do not add a trailing slash.') .' '. t('Leave it empty to delete the URL alias.'),
  62. 'optional' => TRUE,
  63. 'cleaning callback' => 'rules_path_clean_replacement_values',
  64. ),
  65. ),
  66. 'base' => 'rules_action_node_path_alias',
  67. 'callbacks' => array('dependencies' => 'rules_path_dependencies'),
  68. 'access callback' => 'rules_path_integration_access',
  69. ),
  70. 'taxonomy_term_path_alias' => array(
  71. 'label' => t("Create or delete a taxonomy term's URL alias"),
  72. 'group' => t('Path'),
  73. 'parameter' => array(
  74. 'node' => array(
  75. 'type' => 'taxonomy_term',
  76. 'label' => t('Taxonomy term'),
  77. 'save' => TRUE,
  78. ),
  79. 'alias' => array(
  80. 'type' => 'text',
  81. 'label' => t('URL alias'),
  82. 'description' => t('Specify an alternative path by which the term can be accessed. For example, "content/drupal" for a Drupal term. Use a relative path and do not add a trailing slash.') .' '. t('Leave it empty to delete the URL alias.'),
  83. 'optional' => TRUE,
  84. 'cleaning callback' => 'rules_path_clean_replacement_values',
  85. ),
  86. ),
  87. 'base' => 'rules_action_node_path_alias',
  88. 'callbacks' => array('dependencies' => 'rules_path_dependencies'),
  89. 'access callback' => 'rules_path_integration_access',
  90. ),
  91. );
  92. }
  93. /**
  94. * Callback to specify the path module as dependency.
  95. */
  96. function rules_path_dependencies() {
  97. return array('path');
  98. }
  99. /**
  100. * Path integration access callback.
  101. */
  102. function rules_path_integration_access($type, $name) {
  103. if ($type == 'action' && $name == 'path_alias') {
  104. return user_access('administer url aliases');
  105. }
  106. return user_access('create url aliases');
  107. }
  108. /**
  109. * Implements hook_rules_condition_info() on behalf of the path module.
  110. */
  111. function rules_path_condition_info() {
  112. return array(
  113. 'path_has_alias' => array(
  114. 'label' => t('Path has URL alias'),
  115. 'group' => t('Path'),
  116. 'parameter' => array(
  117. 'source' => array(
  118. 'type' => 'text',
  119. 'label' => t('Existing system path'),
  120. 'description' => t('Specifies the existing path you wish to check for. For example: node/28, forum/1, taxonomy/term/1+2.'),
  121. 'optional' => TRUE,
  122. ),
  123. 'language' => array(
  124. 'type' => 'token',
  125. 'label' => t('Language'),
  126. 'description' => t('If specified, the language for which the URL alias applies.'),
  127. 'options list' => 'entity_metadata_language_list',
  128. 'optional' => TRUE,
  129. 'default value' => LANGUAGE_NONE,
  130. ),
  131. ),
  132. 'base' => 'rules_condition_path_has_alias',
  133. 'callbacks' => array('dependencies' => 'rules_path_dependencies'),
  134. 'access callback' => 'rules_path_integration_access',
  135. ),
  136. 'path_alias_exists' => array(
  137. 'label' => t('URL alias exists'),
  138. 'group' => t('Path'),
  139. 'parameter' => array(
  140. 'alias' => array(
  141. 'type' => 'text',
  142. 'label' => t('URL alias'),
  143. 'description' => t('Specify the URL alias to check for. For example, "about" for an about page.'),
  144. 'optional' => TRUE,
  145. 'cleaning callback' => 'rules_path_clean_replacement_values',
  146. ),
  147. 'language' => array(
  148. 'type' => 'token',
  149. 'label' => t('Language'),
  150. 'description' => t('If specified, the language for which the URL alias applies.'),
  151. 'options list' => 'entity_metadata_language_list',
  152. 'optional' => TRUE,
  153. 'default value' => LANGUAGE_NONE,
  154. ),
  155. ),
  156. 'base' => 'rules_condition_path_alias_exists',
  157. 'callbacks' => array('dependencies' => 'rules_path_dependencies'),
  158. 'access callback' => 'rules_path_integration_access',
  159. ),
  160. );
  161. }
  162. /**
  163. * @}
  164. */