-
Notifications
You must be signed in to change notification settings - Fork 0
/
vojo_twentyone_cambridge.module
101 lines (87 loc) · 3.23 KB
/
vojo_twentyone_cambridge.module
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
define('TWENTYONE_CAMBRIDGE_GROUP_ID', 12655);
/**
* @file Provides VoIP Drupal functionality for the 21 Questions Cambridge project
*/
define("VOJO_TWENTYONE_CAMBRIDGE_HELP_NUMBER_VAR", 'vojo_twentyone_cambridge_help_number');
/**
* Load up helpers
*/
function vojo_twentyone_cambridge_init(){
// load costom voip-drupal scripts
module_load_include('inc', 'vojo_twentyone_cambridge', 'vojo_twentyone_cambridge.script');
}
/**
* Return the script to run based on the script name
* Implementation of hook_voipscript_load_script().
*/
function vojo_twentyone_cambridge_voipscript_load_script($script_name, $params = NULL) {
if ($script_name == 'vojo_twentyone_cambridge_group') {
module_load_include('inc', 'vojo_twentyone_cambridge', 'vojo_twentyone_cambridge.script');
$node = node_load($params['nid']);
return _vojo_twentyone_cambridge_group_script($node);
}
if ($script_name == 'vojo_twentyone_cambridge_pick_language') {
module_load_include('inc', 'vojo_twentyone_cambridge', 'vojo_twentyone_cambridge.script');
return _vojo_twentyone_cambridge_pick_language_script();
}
}
/**
* Return the list of script names this module provides
* Implementation of hook_voipscript_get_script_names().
*/
function vojo_twentyone_cambridge_voipscript_get_script_names() {
return array(
'vojo_twentyone_cambridge_group',
'vojo_twentyone_cambridge_pick_language',
);
}
/**
* Add a page to configure the module settings
**/
function vojo_twentyone_cambridge_menu() {
$items['admin/settings/vojo_twentyone_cambridge'] = array(
'title' => 'Vojo 21 Questions Cambridge Settings',
'description' => 'Set up options for the group.',
'page callback' => 'drupal_get_form',
'page arguments' => array('vojo_twentyone_cambridge_admin_settings_form'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Return the form to change settings for this module
*/
function vojo_twentyone_cambridge_admin_settings_form(&$form_state) {
$form = vojo_twentyone_cambridge_settings_fields($form_state);
return system_settings_form($form);
}
/**
* Return the fields for the form to change settings for this module
*/
function vojo_twentyone_cambridge_settings_fields(&$form_state, $field=FALSE) {
$form[VOJO_TWENTYONE_CAMBRIDGE_HELP_NUMBER_VAR] = array(
'#type' => 'textfield',
'#default_value' => variable_get(VOJO_TWENTYONE_CAMBRIDGE_HELP_NUMBER_VAR,''),
'#title' => t('Help Number'),
'#description' => t('Enter the phone number to redirect people to is they need help right away.'),
);
return $form;
}
/**
* Change the RSS title element to be the full post body
* @see http://drupal.org/node/174359#comment-3047564
*/
function vojo_twentyone_cambridge_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ( ($node->type=='blog') && is_array($node->og_groups) && array_key_exists(TWENTYONE_CAMBRIDGE_GROUP_ID,$node->og_groups) ) {
switch ($op) {
case 'alter':
if ($node->build_mode == NODE_BUILD_RSS) {
$node->title = strip_tags($node->content['body']['#value']); // use full content as title
$node->og_groups_both = array(); // get rid of group info
}
break;
}
}
}