tiki-log_bigbluebutton_leave.php 1.42 KB
Newer Older
1
<?php
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
6 7 8 9
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
rjsmelo's avatar
rjsmelo committed
10
require_once('tiki-setup.php');
11

12 13
$access->check_feature('bigbluebutton_feature');

14 15
$bigbluebuttonlib = TikiLib::lib('bigbluebutton');
$loglib = TikiLib::lib('logs');
rjsmelo's avatar
rjsmelo committed
16
$user_count = $users = $rooms = $join_log = $total_log = $log_out = $log_in = [];
17 18
$total_log = $loglib->get_log_count("bigbluebutton", "Joined Room");
foreach ($total_log as $row) {
19
	$join_log[$row['action']][$row['object']][] = $row;
20 21
}
if ($join_log['Joined Room']) {
changi67's avatar
changi67 committed
22
	foreach ($join_log['Joined Room'] as $room => $member) {
changi67's avatar
changi67 committed
23 24 25 26 27 28
		$users[$room] = array_map(
			function ($i) {
				return $i['user'];
			},
			$member
		);
changi67's avatar
changi67 committed
29
		$user_count[$room] = $bigbluebuttonlib->getAttendees($room, true);
30
		if (isset($user_count[$room])) {
changi67's avatar
changi67 committed
31
			foreach ($user_count[$room] as $user_room) {
32 33 34 35 36 37 38 39 40 41 42 43 44
				$login_user[$room][] = $user_room['fullName'];
			}
		}
		if (empty($login_user[$room])) {
			foreach ($users[$room] as $user) {
				TikiLib::lib('logs')->add_action('Left Room', $room, 'bigbluebutton', "room is empty", $user);
			}
		} else {
			foreach (array_diff($users[$room], $login_user[$room]) as $user) {
				TikiLib::lib('logs')->add_action('Left Room', $room, 'bigbluebutton', "", $user);
			}
		}
	}
45
}