-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbbb.module
674 lines (629 loc) · 22.7 KB
/
bbb.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
<?php
/**
* @file
* Big Blue Button - Enables universities and colleges to deliver a high-quality
* learning experience.
*
* @author
* Stefan Auditor <[email protected]>
*
* TODO:
* - Add 'start meeting' button
* - Rework waiting page
* - do a seperate page with a big throbber, that tells the status of the
* meeeting, so that it's clear you have to wait here.
* - Incorporate a Flash Player check, explain it and use the waiting time
* to adjust the audio/video settings
*/
// API version
define('BIGBLUEBUTTON_API_VERSION', \Drupal::config('bbb.api')->get('version'));
define('BIGBLUEBUTTON_GET_MEETING_INFO_URL', '/api/getMeetingInfo');
define('BIGBLUEBUTTON_CREATE_URL', '/api/create');
define('BIGBLUEBUTTON_JOIN_URL', '/api/join');
define('BIGBLUEBUTTON_IS_MEETING_RUNNING_URL', '/api/isMeetingRunning');
// Security Salt
// see /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
define('BIGBLUEBUTTON_SECURITY_SALT', \Drupal::config('bbb.settings')->get('security_salt'));
define('BIGBLUEBUTTON_BASE_URL', \Drupal::config('bbb.settings')->get('base_url'));
// Define default settings
define('BIGBLUEBUTTON_DISPLAY_MODE', \Drupal::config('bbb.settings')->get('display_mode'));
define('BIGBLUEBUTTON_DISPLAY_HEIGHT', \Drupal::config('bbb.settings')->get('display_height'));
define('BIGBLUEBUTTON_DISPLAY_WIDTH', \Drupal::config('bbb.settings')->get('display_width'));
include_once(drupal_get_path('modules', 'bbb') . 'includes/api.bbb.inc');
//
///* Drupal Hooks */
//
///**
// * Implements hook_views_api().
// */
//function bbb_views_api() {
// return array(
// 'api' => 2,
// 'path' => drupal_get_path('module', 'bbb') . '/includes',
// );
//}
/**
* Implements HOOK_permission().
*/
function bbb_permission() {
return array(
'administer big blue button' => array(
'title' => t('Administer BigBlueButton'),
'restrict access' => TRUE,
'description' => t('Allow administration of BigBlueButton')
),
//TODO:
// 'start meetings',
// 'start own meetings',
'moderate meetings' => array(
'title' => t('Moderate meetings'),
'description' => t('Allow moderation of meetings')
),
'moderate own meetings' => array(
'title' => t('Moderate own meetings'),
'description' => t('Allow moderation of own meetings')
),
'attend meetings' => array(
'title' => t('Attend meetings'),
'description' => t('Allow following meetings as an attendee')
),
'record meetings' => array(
'title' => t('Record meetings'),
'description' => t('Allow the user to record meetings.')
)
);
}
/**
* Implement HOOK_menu().
*/
function bbb_menu() {
$items = array();
$show_local_tasks = \Drupal::config('bbb.settings')->get('local_tasks');
$items['node/%node/meeting/attend'] = array(
'title' => 'Attend Meeting',
'route_name' => 'bbb.meeting.attend',
'type' => $show_local_tasks ? MENU_LOCAL_TASK : MENU_CALLBACK,
'weight' => 2,
);
$items['node/%node/meeting/moderate'] = array(
'title' => 'Moderate Meeting',
'route_name' => 'bbb.meeting.moderate',
'type' => $show_local_tasks ? MENU_LOCAL_TASK : MENU_CALLBACK,
'weight' => 2,
);
$items['node/%node/meeting/end-confirm'] = array(
'title' => 'Terminate Meeting',
'type' => MENU_CALLBACK,
);
$items['node/%node/redirect/attend'] = array(
'type' => MENU_CALLBACK,
);
$items['node/%node/redirect/moderate'] = array(
'type' => MENU_CALLBACK,
);
$items['node/%node/meeting/status'] = array(
'type' => MENU_CALLBACK,
//'file' => 'includes/api.bbb.inc',
);
$items['admin/config/media/bigbluebutton'] = array(
'title' => 'BigBlueButton meetings',
'description' => 'Default server and meeting settings.',
'route_name' => 'bbb.admin',
'type' => MENU_NORMAL_ITEM,
);
$items['admin/structure/bigbluebutton'] = array(
'title' => 'BigBlueButton content types',
'description' => 'Content Types configured to be used with Big Blue Button',
'route_name' => 'bbb.node_type.list',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Check that the user is allowed to set meetings to record
*/
function bbb_access_record($node) {
if (!bbb_is_meeting_type($node->getType())) {
return FALSE;
}
// No bother to check for node access since this will be on edit/create pages.
if (user_access('record meetings') || user_access('administer big blue button')) {
return TRUE;
}
return FALSE;
}
/**
* Implements HOOK_form_alter().
*/
function bbb_form_alter(&$form, &$form_state, $form_id) {
// Node type settings form
switch ($form_id) {
case 'node_type_edit_form':
case 'node_type_add_form':
$manager = \Drupal::entityManager();
if ($form_id == 'node_type_edit_form') {
$node_type = node_type_load(arg(4));
$id = $node_type->type;
$label = $node_type->name;
$entity = entity_load('bbb_node_type', $id);
if (!$entity) {
$entity = entity_create('bbb_node_type', array('id' => $id, 'label' => $label));
}
}
else {
$entity = entity_create('bbb_node_type', array());
}
$bbb_form = $manager->getForm($entity, 'edit');
$form['bbb'] = $bbb_form['bbb'];
$form['#submit'][] = array_pop($bbb_form['#submit']);
$validate = array_merge($form['actions']['submit']['#validate'], $bbb_form['actions']['submit']['#validate']);
$submit = array_merge($form['actions']['submit']['#submit'], $bbb_form['actions']['submit']['#submit']);
$form['actions']['submit']['#validate'] = $validate;
$form['actions']['submit']['#submit'] = $submit;
break;
default:
break;
}
}
/**
* Implements HOOK_form_BASE_FORM_ID_alter().
*/
function bbb_form_node_form_alter(&$form, &$form_state, $form_id) {
$node_type = $form['type']['#value']->getEntity()->getType();
if (bbb_is_meeting_type($node_type)) {
$nid = $form['nid']['#value']->getEntity()->id();
if (is_numeric($nid)) {
$meeting = bbb_get_meeting($nid);
}
if (user_access('administer big blue button')) {
$form['bbb'] = array(
'#title' => t('Meeting settings'),
'#type' => 'details',
'#description' => t("The following settings may be changed until the meeting first starts."),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
'#group' => 'advanced',
'#weight' => 100,
);
$form['bbb']['welcome'] = array(
'#title' => t('Welcome message'),
'#type' => 'textfield',
'#default_value' => !empty($meeting->welcome) ? $meeting->welcome : \Drupal::config("bbb.node_type.$node_type")->get('welcome'),
'#maxlength' => 255,
'#description' => t('A welcome message that gets displayed on the chat window when the participant joins. You can include keywords (%%CONFNAME%%, %%DIALNUM%%, %%CONFNUM%%) which will be substituted automatically.'),
'#attributes' => !empty($meeting->meetingID) ? array('disabled' => 'disabled') : array(),
);
$form['bbb']['dialNumber'] = array(
'#title' => t('Dial number'),
'#type' => 'textfield',
'#default_value' => !empty($meeting->dialNumber) ? $meeting->dialNumber : \Drupal::config("bbb.node_type.$node_type")->get('dialNumber'),
'#maxlength' => 32,
'#description' => t('The dial access number that participants can call in using regular phone.'),
'#attributes' => !empty($meeting->meetingID) ? array('disabled' => 'disabled') : array(),
);
$form['bbb']['moderatorPW'] = array(
'#title' => t('Moderator password'),
'#type' => 'textfield',
'#default_value' => !empty($meeting->moderatorPW) ? $meeting->moderatorPW : \Drupal::config("bbb.node_type.$node_type")->get('moderatorPW'),
'#maxlength' => 32,
'#description' => t('The password that will be required for moderators to join the meeting or for certain administrative actions (i.e. ending a meeting).'),
'#attributes' => !empty($meeting->meetingID) ? array('disabled' => 'disabled') : array(),
);
$form['bbb']['attendeePW'] = array(
'#title' => t('Attendee password'),
'#type' => 'textfield',
'#default_value' => !empty($meeting->attendeePW) ? $meeting->attendeePW : \Drupal::config("bbb.node_type.$node_type")->get('attendeePW'),
'#maxlength' => 32,
'#description' => t('The password that will be required for attendees to join the meeting.'),
'#attributes' => !empty($meeting->meetingID) ? array('disabled' => 'disabled') : array(),
);
$form['bbb']['logoutURL'] = array(
'#title' => t('Logout URL'),
'#type' => 'textfield',
'#default_value' => !empty($meeting->logoutURL) ? $meeting->logoutURL : \Drupal::config("bbb.node_type.$node_type")->get('logoutURL'),
'#maxlength' => 255,
'#description' => t('The URL that the Big Blue Button client will go to after users click the OK button on the <em>You have been logged out message</em>.'),
'#attributes' => !empty($meeting->meetingID) ? array('disabled' => 'disabled') : array(),
);
$form['bbb']['record'] = array(
'#title' => t('Record meeting'),
'#type' => 'select',
'#default_value' => !empty($meeting->record) ? $meeting->record : \Drupal::config("bbb.node_type.$node_type")->get('record'),
'#options' => array(
0 => t('Do not record'),
1 => t('Record'),
),
'#attributes' => empty($meeting->initialized) ? array() : array('disabled' => 'disabled'),
'#weight' => -1,
);
}
if (user_access('record meetings') && empty($form['bbb']['record'])) {
// this clause is for users who have the record meetings permission but no permissions to "administer BBB"
$form['bbb'] = array(
'#title' => t('Recording settings'),
'#type' => 'details',
'#description' => t("The following settings may be changed until the meeting first starts."),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
'#group' => 'advanced',
'#weight' => 100,
);
$form['bbb']['record'] = array(
'#title' => t('Record meeting'),
'#type' => 'select',
'#default_value' => !empty($meeting->record) ? $meeting->record : \Drupal::config("bbb.node_type.$node_type")->get('record'),
'#options' => array(
0 => t('Do not record'),
1 => t('Record'),
),
'#attributes' => empty($meeting->initialized) ? array() : array('disabled' => 'disabled'),
'#weight' => -1,
);
}
}
}
/**
* Implements HOOK_node_insert().
*/
function bbb_node_insert($node) {
if (!bbb_is_meeting_type($node->getType())) {
return;
}
bbb_store_meeting($node, (array) $meeting);
}
/**
* Implement HOOK_node_update().
*/
function bbb_node_update($node) {
if (!bbb_is_meeting_type($node->getType())) {
return;
}
bbb_update_meeting($node, (array) $node->bbb);
}
/**
* Implement HOOK_node_view().
*/
function bbb_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\entity\Entity\EntityDisplay $display, $view_mode, $langcode) {
$node_type = $node->getType();
if (!bbb_is_meeting_type($node_type)) {
return;
}
$BBBNodeTypeConfig = \Drupal::config("bbb.node_type.$node_type");
// Show meeting status.
if ($BBBNodeTypeConfig->get('showStatus')) {
$meeting = bbb_get_meeting($node->id());
$node->content['bbb_meeting_status'] = array(
'#markup' => theme('bbb_meeting_status', array('meeting' => $meeting)),
'#weight' => 10,
);
$node->content['bbb_meeting_record'] = array(
'#markup' => theme('bbb_meeting_record', array('meeting' => $meeting)),
'#weight' => 11,
);
}
// Add links to content.
global $user;
$links = array();
$show = $BBBNodeTypeConfig->get('showLinks');
if ($view_mode != 'teaser' && $show) {
$meeting = bbb_get_meeting($node->id());
if (user_access('attend meetings') || user_access('administer big blue button')) {
$links['meeting_attend'] = array(
'title' => t('Attend meeting'),
'href' => 'node/' . $node->id() . '/meeting/attend',
);
}
if ((user_access('moderate meetings') || user_access('administer big blue button')) ||
$user->id() == $node->getAuthor()->id() && user_access('moderate own meetings')) {
$links['meeting_moderate'] = array(
'title' => t('Moderate meeting'),
'href' => 'node/' . $node->id() . '/meeting/moderate',
);
}
if ((user_access('moderate meetings') || user_access('administer big blue button')) ||
$user->id() == $node->getAuthor()->id() && user_access('moderate own meetings') &&
$meeting->running) {
$links['meeting_end'] = array(
'title' => t('Terminate meeting'),
'href' => 'node/' . $node->id() . '/meeting/end-confirm',
);
}
if (!empty($links)) {
$node->content['links']['bbb'] = array(
'#links' => $links,
);
}
}
}
/**
* Implement HOOK_node_load().
*/
function bbb_node_load($nodes, $types) {
foreach ($nodes as $node) {
if (bbb_is_meeting_type($node->getType())) {
$node->bbb = bbb_get_meeting($node->id());
}
}
}
/**
* Implement HOOK_node_delete().
*/
function bbb_node_delete($node) {
if (!bbb_is_meeting_type($node->getType())) {
return;
}
bbb_delete_meeting($node->id());
}
/**
* Implement HOOK_theme().
*/
function bbb_theme($existing, $type, $theme, $path) {
return array(
'bbb_meeting' => array(
'variables' => array('meeting' => NULL, 'mode' => NULL, 'params' => array()),
),
'bbb_meeting_status' => array(
'variables' => array('meeting' => NULL),
),
'bbb_meeting_record' => array(
'variables' => array('meeting' => NULL),
),
'bbb_meeting_join_moderator' => array(
'variables' => array('meeting' => NULL),
),
'bbb_meeting_join_attendee' => array(
'variables' => array('meeting' => NULL),
),
'bbb_block_meeting' => array(
'variables' => array('meeting' => NULL),
),
);
}
/* Helper functions */
/**
* Check if user is meeting owner
*/
function bbb_is_meeting_owner($nid, $account = NULL) {
if (!$account) {
global $user;
$account = $user;
}
$sql = "SELECT COUNT(nid) FROM {bbb_meetings} bm
INNER JOIN {node} n ON bm.nid = n.nid
WHERE n.uid = :uid
AND nid = :nid";
$owner = db_query($sql, array(':uid' => $account->uid, ':nid' => $nid));
return $owner ? TRUE : FALSE;
}
/**
* Check if node type is meeting
*/
function bbb_is_meeting_type($type) {
$BBBNodeTypeConfig = \Drupal::config("bbb.node_type.$type");
return $BBBNodeTypeConfig->get('active');
}
/**
* Return a meeting object
*/
function bbb_get_meeting($nid, $account = NULL, $cached = TRUE) {
// Simple static cache
static $meetings = array();
if (!$account) {
global $user;
$account = $user;
}
if (!isset($meetings[$nid]) || !$cached) {
$result = db_query("SELECT * FROM {bbb_meetings} WHERE nid = :nid", array(':nid' => $nid));
$meeting = $result->fetchObject();
if ($meeting) {
$meeting->running = bbb_api_isMeetingRunning(array('meetingID' => $meeting->meetingID));
// insert the recording option
$recording = ($meeting->record == 1) ? array('record' => 'true') : array();
$attend = array(
'fullName' => property_exists($account,'name') ? $account->name : t('Anonymous'),
'meetingID' => $meeting->meetingID,
'password' => $meeting->attendeePW,
);
$moderate = array(
'fullName' => property_exists($account,'name') ? $account->name : t('Anonymous'),
'meetingID' => $meeting->meetingID,
'password' => $meeting->moderatorPW,
);
$attend = array_merge($attend, $recording);
$moderate = array_merge($moderate, $recording);
$meeting->url = array(
'attend' => bbb_api_join($attend),
'moderate' => bbb_api_join($moderate),
);
// Allow alteration for e.g. access control
// Just implement hook_bbb_meeting_alter(&$data) {} in your module
drupal_alter('bbb_meeting', $meeting);
// Static cache
$meetings[$nid] = $meeting;
}
}
return isset($meetings[$nid]) ? $meetings[$nid] : array();
}
/**
* Init meeting
*/
function bbb_init_meeting($node = NULL, $params = array()) {
$node_type = $node->getType();
$BBBNodeTypeConfig = \Drupal::config("bbb.node_type.$node_type");
$welcome = $BBBNodeTypeConfig->get('welcome');
$dialNumber = $BBBNodeTypeConfig->get('dialNumber');
$moderatorPW = $BBBNodeTypeConfig->get('moderatorPW');
$attendeePW = $BBBNodeTypeConfig->get('attendeePW');
$logoutURL = $BBBNodeTypeConfig->get('logoutURL');
$default_rec = $BBBNodeTypeConfig->get('record');
if (isset($node->bbb)) {
$record = (array) $node->bbb;
$record = empty($record['record']) ? $default_rec : 1;
}
$settings = array(
'nid' => $node->id(),
'name' => $node->getTitle(),
'meetingID' => bbb_create_meeting_id($node->id()),
'attendeePW' => !empty($attendeePW) ? $attendeePW : user_password(),
'moderatorPW' => !empty($moderatorPW) ? $moderatorPW : user_password(),
'welcome' => !empty($welcome) ? $welcome : t('Welcome to @title', array('@title' => $node->getTitle())),
'dialNumber' => $dialNumber ? $dialNumber : NULL,
// TODO: This is limited to 90000 voice bridges and may
// collide sooner, as rand() may return x twice in a row
'voiceBridge' => rand(10000, 99999),
'logoutURL' => $logoutURL, //TODO: make absolute, as soon as supported
'record' => $record,
'initialized' => 0,
'created' => time(),
);
$params = array_merge($params, $settings);
return $params;
}
/**
* Update meeting
*/
function bbb_update_meeting($node, $params = array()) {
// This is a new record if params is empty.
$primary_key = empty($params) ? array() : 'nid';
$params += bbb_init_meeting($node, $params);
return drupal_write_record('bbb_meetings', $params, $primary_key);
}
/**
* Create meeting
*/
function bbb_create_meeting($node, $params = array()) {
$params += bbb_init_meeting($node, $params);
// we need to change the "record" param (0 or 1 in the database), to "true" if 1
if ($params['record'] == 1) {
$params['record'] = 'true';
} else {
unset($params['record']);
}
if ($data = bbb_api_create($params)) {
return $data;
}
return FALSE;
}
/**
* Store meeting
*/
function bbb_store_meeting($node, $params = array()) {
$params += bbb_init_meeting($node, $params);
return drupal_write_record('bbb_meetings', $params);
}
/**
* Delete meeting
*/
function bbb_delete_meeting($nid) {
return db_query("DELETE FROM {bbb_meetings} WHERE nid = :nid", array(':nid' => $nid));
}
/* Menu Callbacks */
/**
* Redirect to big blue button instance; Menu callback
*
* @param OBJECT $node
* A Drupal node object
*/
function bbb_meeting_end($node) {
$meeting = bbb_get_meeting($node->id());
$params = array(
'meetingID' => $meeting->meetingID,
'password' => $meeting->moderatorPW,
);
$request = bbb_api_endMeeting($params);
return $request;
}
function bbb_encode_int($string) {
$ords = array();
for ($i = 0; $i < drupal_strlen($string); $i++) {
$ords[] = ord(drupal_substr($string, $i , 1));
}
return implode($ords);
}
/**
* Creating a meeting id.
*
* @param null $salt
* @return string
*/
function bbb_create_meeting_id($salt = NULL) {
$private_key = \Drupal::service('private_key')->get();
return bbb_encode_int($private_key) . $salt;
}
/* Themeables */
/**
* Theme inline meeting
*/
function theme_bbb_meeting($meeting, $variables = array()) {
$url = url('node/' . $meeting['meeting']->nid . '/redirect/' . $meeting['mode'], array('absolute' => TRUE));
$output = '<iframe src="' . $url . '" style="height:' . $meeting['height'] . ';width:' . $meeting['width'] . ';border:0;"></iframe>';
return $output;
}
/**
* Theme meeting status
*/
function theme_bbb_meeting_status($meeting) {
$meeting = $meeting['meeting'];
if (isset($meeting->running) && $meeting->running) {
$output = '<div class="bbb-status-is-running">' . t('Status: Meeting is in progress.') . '</div>';
}
else {
$output = '<div class="bbb-status-is-not-running">' . t('Status: Meeting is not running') . '</div>';
}
return $output;
}
/**
* Theme meeting recording
*/
function theme_bbb_meeting_record($meeting) {
$meeting = $meeting['meeting'];
$output = ''; // Only if the meeting is set to record do we output as such.
if (isset($meeting->record) && $meeting->record) {
$output = '<div class="bbb-meeting-record">' . t('This meeting is set to be recorded.') . '</div>';
}
return $output;
}
/**
* Theme meeting details block
*/
function theme_bbb_block_meeting($meeting) {
$meeting = $meeting['meeting'];
$output = '<div class="bbb-meeting-details">';
if ($meeting->welcome) {
$output .= '<div class="bbb-welcome">' . $meeting->welcome . '</div>';
}
$output .= theme('bbb_meeting_status', array('meeting' => $meeting));
// format links according to settings:
$display_mode = \Drupal::config('bbb.settings')->get('display_mode');
// block links
$attend = 'node/' . $meeting->nid . '/meeting/attend';
$attend_options = array();
$moderate = 'node/' . $meeting->nid . '/meeting/moderate';
$moderate_options = array();
if ($display_mode == 'blank') {
// if it opens in a new window, make absolute paths and add some javascript
global $base_url;
$attend = $base_url . '/' . $attend;
$attend_options = array('attributes' => array('onClick' => 'window.open(\'' . $attend . '\');return false', 'html' => TRUE));
$moderate = $base_url . '/' . $moderate;
$moderate_options = array('attributes' => array('onClick' => 'window.open(\'' . $moderate . '\');return false', 'html' => TRUE));
$nolink = 'node/' . $meeting->nid;
}
if ($meeting->dialNumber) {
$output .= '<div class="bbb-dial-number">' . t('Phone: @number', array('@number' => $meeting->dialNumber)) . '</div>';
}
if (user_access('attend meetings') || user_access('administer big blue button')) {
$output .= '<div class="bbb-meeting-attend">' . l(t('Attend meeting'), ($display_mode == 'blank') ? $nolink : $attend, $attend_options) . '</div>';
}
if (user_access('moderate meetings') || user_access('administer big blue button')) {
$output .= '<div class="bbb-meeting-moderate">' . l(t('Moderate meeting'), ($display_mode == 'blank') ? $nolink : $moderate, $moderate_options) . '</div>';
}
if (user_access('moderate meetings') || user_access('administer big blue button')) {
$output .= '<div class="bbb-meeting-end">' . l(t('Terminate meeting'), 'node/' . $meeting->nid . '/meeting/end-confirm') . '</div>';
}
$output .= theme('bbb_meeting_record', array('meeting' => $meeting));
$output .= '</div>';
return $output;
}