@@ -170,11 +170,26 @@ function os2web_cs_service_create_case(array $data) {
170
170
}
171
171
}
172
172
else {
173
- $node = node_load(array_pop($nids));
173
+ $node = node_load($nids);
174
+ }
175
+
176
+ // See if the triggered rules on the published node, is approved
177
+ // in the vocabulary. Otherwise the node will be unpublished.
178
+ $vocabulary = taxonomy_vocabulary_machine_name_load('os2web_cp_service_tax_approved_rules');
179
+ $approved_rules = taxonomy_get_tree($vocabulary->vid);
180
+ $approved = FALSE;
181
+ foreach ($data['rules'] as $trigger_rule) {
182
+ foreach ($approved_rules as $approved_rule) {
183
+ if ($approved_rule->name === $trigger_rule) {
184
+ $approved = TRUE;
185
+ break;
186
+ }
187
+ }
174
188
}
189
+
175
190
$node->type = 'os2web_cp_service_cp_case';
176
191
$node->uid = 0;
177
- $node->status = 1 ;
192
+ $node->status = $approved ;
178
193
$node->comment = 0;
179
194
$node->promote = 0;
180
195
$node->moderate = 0;
@@ -211,6 +226,13 @@ function os2web_cs_service_create_case(array $data) {
211
226
}
212
227
}
213
228
}
229
+
230
+ unset($node->field_os2web_cp_service_rules[LANGUAGE_NONE]);
231
+ foreach ($data['rules'] as $name) {
232
+ $term = array_pop(taxonomy_get_term_by_name($name, 'os2web_cp_service_tax_approved_rules'));
233
+ $node->field_os2web_cp_service_rules[LANGUAGE_NONE][]['tid'] = $term->tid;
234
+ }
235
+
214
236
try {
215
237
node_submit($node);
216
238
node_save($node);
@@ -354,9 +376,24 @@ function os2web_cs_service_create_document(array $data) {
354
376
else {
355
377
$node = node_load(array_pop($nids));
356
378
}
379
+
380
+ // See if the triggered rules on the published node, is approved
381
+ // in the vocabulary. Otherwise the node will be unpublished.
382
+ $vocabulary = taxonomy_vocabulary_machine_name_load('os2web_cp_service_tax_approved_rules');
383
+ $approved_rules = taxonomy_get_tree($vocabulary->vid);
384
+ $approved = FALSE;
385
+ foreach ($data['rules'] as $trigger_rule) {
386
+ foreach ($approved_rules as $approved_rule) {
387
+ if ($approved_rule->name === $trigger_rule) {
388
+ $approved = TRUE;
389
+ break;
390
+ }
391
+ }
392
+ }
393
+
357
394
$node->type = 'os2web_cp_service_cp_document';
358
395
$node->uid = 0;
359
- $node->status = 1 ;
396
+ $node->status = $approved ;
360
397
$node->comment = 0;
361
398
$node->promote = 0;
362
399
$node->moderate = 0;
@@ -384,6 +421,13 @@ function os2web_cs_service_create_document(array $data) {
384
421
}
385
422
}
386
423
}
424
+
425
+ unset($node->field_os2web_cp_service_rules[LANGUAGE_NONE]);
426
+ foreach ($data['rules'] as $name) {
427
+ $term = array_pop(taxonomy_get_term_by_name($name, 'os2web_cp_service_tax_approved_rules'));
428
+ $node->field_os2web_cp_service_rules[LANGUAGE_NONE][]['tid'] = $term->tid;
429
+ }
430
+
387
431
try {
388
432
node_submit($node);
389
433
node_save($node);
0 commit comments