-
Notifications
You must be signed in to change notification settings - Fork 0
/
solr_best_bets.rules.inc
60 lines (57 loc) · 1.76 KB
/
solr_best_bets.rules.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* @file
* Rules hook implementations for Solr Best Bets.
*/
/**
* Implements hook_rules_action_info().
*/
function solr_best_bets_rules_action_info() {
return array(
'solr_best_bets_add' => array(
'label' => t('Add node as a best bet'),
'parameter' => array(
'node' => array(
'type' => 'node',
'label' => t('Content'),
),
'query_text' => array(
'type' => 'text',
'label' => t('Search query text'),
'description' => t('Search queries matching this text will show the content at the top of the search result set.'),
),
'environment' => array(
'type' => 'list<text>',
'label' => t('Search environment'),
'options list' => 'solr_best_bets_get_environment_options',
'description' => t('The search environment the best bet will be applied to.'),
),
'exclude' => array(
'type' => 'boolean',
'label' => t('Exclude from results'),
'description' => t('Exclude this content from searches queries matching the entered text.'),
'default value' => FALSE,
),
),
'group' => t('Search'),
'base' => 'solr_best_bets_add_action',
),
);
}
/**
* Action that flags content as a best bet for a search query.
*
* @see solr_best_bets_save()
*/
function solr_best_bets_add_action($node, $query_text, $environments, $exclude) {
module_load_include('inc', 'solr_best_bets', 'solr_best_bets.crud');
foreach ($environments as $environment_name) {
$values = array(
'content_id' => 'entity:node:' . $node->nid,
'query_text' => $query_text,
'environment' => $environment_name,
'exclude' => $exclude,
);
solr_best_bets_save($values);
}
}