forked from phase2/oa_core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oa_core.api.php
59 lines (55 loc) · 1.68 KB
/
oa_core.api.php
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
<?php
/**
* @file
* Contains documentation about the Open Atrium Core module's hooks.
*/
/**
* @defgroup oa_access Open Atrium Core
* @{
* Hooks from the Open Atrium Core module.
*/
/**
* Gets space_type or section_type options from a Taxonomy term.
*
* This hook is used to take a Taxonomy term and covert it's data into options
* about a Space Blueprint, to be used in Javascript on the node edit page.
*
* @param object $term
* A Taxonomy term object.
* @param string $vocab_name
* The name of the vocabulary that this Taxonomy term comes from.
*
* @return array
* An associative array representing information about this Taxonomy term to
* add to the Javascript options.
*/
function hook_oa_core_space_type_options($term, $vocab_name) {
// Add a new field to the option data, but only for 'space_type' terms (as
// opposed to 'section_type' which also uses this hook).
if ($vocab_name == 'space_type') {
return array(
'my_field_value' => $term->field_my_field[LANGUAGE_NONE][0]['value'],
);
}
}
/**
* Alter the space_type or section_type options from other modules.
*
* @param array &$optionts
* An associative array keyed by the Taxonomy term id containing the option
* data returned by all module via hook_oa_core_space_type_options().
* @param string $vocab_name
* The name of the vocabulary that this Taxonomy term comes from.
*/
function hook_oa_core_space_type_options_alter(&$options, $vocab_name) {
if ($vocab_name == 'space_type') {
foreach ($options as $tid => &$option) {
$term = taxonomy_term_load($tid);
// Modify some data on the option data.
$option['blah'] = 'arbitrary string';
}
}
}
/**
* @}
*/