path.rules.inc 6.1 KB

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