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