-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.module
More file actions
130 lines (118 loc) · 2.85 KB
/
Copy pathchat.module
File metadata and controls
130 lines (118 loc) · 2.85 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* Implementation of hook_menu().
*/
function chat_menu() {
// Admin settings.
$items['admin/config/user-interface/chat'] = array(
'title' => 'Chat',
'description' => 'Custom chat',
'page callback' => 'drupal_get_form',
'page arguments' => array('chat_admin_form'),
'access arguments' => array('administer site configuration'),
);
return $items;
}
/**
* Callback function for admin setting.
*/
function chat_admin_form($form, &$form_state) {
$settings = variable_get('chat_settings');
$options['helper'] = array(
'#markup' => t('<h3>Chat Options</h3>
<p>Custom chat, set chat URL and load on an IFRAME</p>'),
);
$options['url'] = array(
'#type' => 'textfield',
'#title' => t('Service URL'),
'#default_value' => $settings['url'],
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
);
$options['button_text'] = array(
'#type' => 'textfield',
'#title' => t('Button Text'),
'#default_value' => $settings['button_text'],
'#size' => 60,
'#maxlength' => 64,
'#required' => TRUE,
);
$options['delay'] = array(
'#type' => 'textfield',
'#title' => t('Delay in seconds'),
'#default_value' => $settings['delay'],
'#size' => 60,
'#maxlength' => 2,
'#required' => TRUE,
);
$options['#tree'] = TRUE;
$form['chat_settings'] = $options;
// Disable automatic defaults, which don't work with nested values.
return system_settings_form($form, FALSE);
}
/**
* Implementation of hook_block_info();
*/
function chat_block_info(){
$blocks['block_chat'] = array(
'info' => t('Chat TLS/UCAL'),
'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
/**
* Implementation of hook_block_view();
*/
function chat_block_view($delta = '') {
$settings = variable_get('chat_settings');
$block = array();
switch ($delta) {
case 'block_chat':
$block['content'] = theme('chat', array(
'url' => $settings['url'],
'button_text' => $settings['button_text'],
));
break;
}
return $block;
}
function chat_theme() {
return array(
'chat' => array(
'template' => 'chat',
'variables' => array(
'url' => '#',
'button_text' => 'Conectarse con un operador',
),
),
);
}
/**
* Implements hook_preprocess_THEME(&$variables).
*/
function chat_preprocess_chat(&$variables) {
$module_path = drupal_get_path('module', 'chat');
$settings = variable_get('chat_settings');
$delay = 0;
//If exist the session the delay = 0
if (!isset($_SESSION['ucal_chat_session'])) {
$_SESSION['ucal_chat_session'] = 1;
$delay = $settings['delay'];
}
drupal_add_js(
array(
'chat' => array(
'delay' => $delay,
),
),
array('type' =>'setting')
);
drupal_add_js($module_path . '/js/chat.js');
}
/**
* Implements hook_init().
*/
function chat_init() {
//global $user;
}