openmeetings.class.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <?php
  2. /**
  3. * Chamilo-OpenMeetings integration plugin library, defining methods to connect
  4. * to OpenMeetings from Chamilo by calling its web services
  5. * @package chamilo.plugin.openmeetings
  6. */
  7. /**
  8. * Initialization
  9. */
  10. namespace Chamilo\Plugin\OpenMeetings;
  11. include_once __DIR__.'/session.class.php';
  12. include_once __DIR__.'/room.class.php';
  13. include_once __DIR__.'/user.class.php';
  14. /**
  15. * Open Meetings-Chamilo connector class
  16. */
  17. class OpenMeetings
  18. {
  19. public $url;
  20. public $user;
  21. public $pass;
  22. public $api;
  23. public $user_complete_name = null;
  24. public $protocol = 'http://';
  25. public $debug = false;
  26. public $logout_url = null;
  27. public $plugin_enabled = false;
  28. public $sessionId = "";
  29. public $roomName = '';
  30. public $chamiloCourseId;
  31. public $chamiloSessionId;
  32. public $externalType;
  33. /**
  34. * Constructor (generates a connection to the API and the Chamilo settings
  35. * required for the connection to the video conference server)
  36. */
  37. public function __construct()
  38. {
  39. // initialize video server settings from global settings
  40. $plugin = \OpenMeetingsPlugin::create();
  41. $om_plugin = $plugin->get('tool_enable');
  42. $om_host = $plugin->get('host');
  43. $om_user = $plugin->get('user');
  44. $om_pass = $plugin->get('pass');
  45. $accessUrl = api_get_access_url(api_get_current_access_url_id());
  46. $this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://')+3, -1);
  47. if (strcmp($this->externalType, 'localhost') == 0) {
  48. $this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://')+3, -1);
  49. }
  50. $this->externalType = 'chamilolms.'.$this->externalType;
  51. $this->table = \Database::get_main_table('plugin_openmeetings');
  52. if ($om_plugin) {
  53. $user_info = api_get_user_info();
  54. $this->user_complete_name = $user_info['complete_name'];
  55. $this->user = $om_user;
  56. $this->pass = $om_pass;
  57. $this->url = $om_host;
  58. // Setting OM api
  59. define('CONFIG_OPENMEETINGS_USER', $this->user);
  60. define('CONFIG_OPENMEETINGS_PASS', $this->pass);
  61. define('CONFIG_OPENMEETINGS_SERVER_URL', $this->url);
  62. $this->gateway = new \OpenMeetingsGateway($this->url, $this->user, $this->pass);
  63. $this->plugin_enabled = $om_plugin;
  64. // The room has a name composed of C + course ID + '-' + session ID
  65. $this->chamiloCourseId = api_get_course_int_id();
  66. $this->chamiloSessionId = api_get_session_id();
  67. $this->roomName = 'C'.$this->chamiloCourseId.'-'.$this->chamiloSessionId;
  68. $return = $this->gateway->loginUser();
  69. if ($return == 0) {
  70. $msg = 'Could not initiate session with server through OpenMeetingsGateway::loginUser()';
  71. error_log(__FILE__.'+'.__LINE__.': '.$msg);
  72. die($msg);
  73. }
  74. $this->sessionId = $this->gateway->sessionId;
  75. }
  76. }
  77. /**
  78. * Checks whether a user is teacher in the current course
  79. * @return bool True if the user can be considered a teacher in this course, false otherwise
  80. */
  81. public function isTeacher()
  82. {
  83. return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
  84. }
  85. /**
  86. * Login the user with OM Server. This generates a session ID that is
  87. * specific to the current user, but that does not require specific user data
  88. *
  89. * It is similar to opening a PHP session. In fact, the session ID is kept
  90. * inside the $_SESSION['openmeetings_session'] session variable
  91. * @return bool True if the user is correct and false when is incorrect
  92. * @deprecated loginUser now called at object instanciation
  93. */
  94. /**
  95. function loginUser()
  96. {
  97. try {
  98. //Verifying if there is already an active session
  99. if (empty($_SESSION['openmeetings_session'])) {
  100. // Login user returns either 0 or >0, depending on the results
  101. // Technically, as long as the SOAP user has been configured in OpenMeetings and OpenMeetings is on, this should always succeed.
  102. if ($this->gateway->loginUser()) {
  103. $this->sessionId = $_SESSION['openmeetings_session'] = $this->gateway->session_id;
  104. return true;
  105. } else {
  106. error_log('loginUser did not succeed');
  107. return false;
  108. }
  109. } else {
  110. $this->sessionId = $_SESSION['openmeetings_session'];
  111. return true;
  112. }
  113. } catch (SoapFault $e) {
  114. error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems. Fault: '.$e->faultstring);
  115. return false;
  116. }
  117. }
  118. */
  119. /*
  120. * Creating a Room for the meeting
  121. * @return bool True if the user is correct and false when is incorrect
  122. */
  123. public function createMeeting($params)
  124. {
  125. // First, try to see if there is an active room for this course and session.
  126. $roomId = null;
  127. $meetingData = \Database::select(
  128. '*',
  129. $this->table,
  130. array(
  131. 'where' =>
  132. array(
  133. 'c_id = ?' => $this->chamiloCourseId,
  134. ' AND session_id = ? ' => $this->chamiloSessionId,
  135. ' AND status <> ? ' => 2,
  136. )
  137. ),
  138. 'first'
  139. );
  140. if ($meetingData != false && count($meetingData) > 0) {
  141. //error_log(print_r($meetingData,1));
  142. //error_log('Found previous room reference - reusing');
  143. // There has been a room in the past for this course. It should
  144. // still be on the server, so update (instead of creating a new one)
  145. // This fills the following attributes: status, name, comment, chamiloCourseId, chamiloSessionId
  146. $room = new Room();
  147. $room->loadRoomId($meetingData['room_id']);
  148. $roomArray = (array)$room;
  149. $roomArray['SID'] = $this->sessionId;
  150. $roomId = $this->gateway->updateRoomWithModeration($room);
  151. if ($roomId != $meetingData['room_id']) {
  152. $msg = 'Something went wrong: the updated room ID ('.$roomId.') is not the same as the one we had ('.$meetingData['room_id'].')';
  153. error_log($msg);
  154. die($msg);
  155. }
  156. } else {
  157. //error_log('Found no previous room - creating');
  158. $room = new Room();
  159. $room->SID = $this->sessionId;
  160. $room->name = $this->roomName;
  161. //$room->roomtypes_id = $room->roomtypes_id;
  162. $room->comment = urlencode(get_lang('Course').': ' . $params['meeting_name'] . ' - '.api_get_configuration_value('software_name'));
  163. //$room->numberOfPartizipants = $room->numberOfPartizipants;
  164. $room->ispublic = $room->getString('isPublic', 'false');
  165. //$room->appointment = $room->getString('appointment');
  166. //$room->isDemoRoom = $room->getString('isDemoRoom');
  167. //$room->demoTime = $room->demoTime;
  168. //$room->isModeratedRoom = $room->getString('isModeratedRoom');
  169. $roomId = $this->gateway->createRoomWithModAndType($room);
  170. }
  171. if (!empty($roomId)) {
  172. /*
  173. // Find the biggest room_id so far, and create a new one
  174. if (empty($roomId)) {
  175. $roomData = \Database::select('MAX(room_id) as room_id', $this->table, array(), 'first');
  176. $roomId = $roomData['room_id'] + 1;
  177. }*/
  178. $params['status'] = '1';
  179. $params['meeting_name'] = $room->name;
  180. $params['created_at'] = api_get_utc_datetime();
  181. $params['room_id'] = $roomId;
  182. $params['c_id'] = api_get_course_int_id();
  183. $params['session_id'] = api_get_session_id();
  184. $params['record'] = ($room->allowRecording?1:0);
  185. $id = \Database::insert($this->table, $params);
  186. $this->joinMeeting($id);
  187. } else {
  188. return -1;
  189. }
  190. }
  191. /**
  192. * Returns a meeting "join" URL
  193. * @param string The name of the meeting (usually the course code)
  194. * @return mixed The URL to join the meeting, or false on error
  195. * @todo implement moderator pass
  196. * @assert ('') === false
  197. * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
  198. */
  199. public function joinMeeting($meetingId)
  200. {
  201. if (empty($meetingId)) {
  202. return false;
  203. }
  204. $meetingData = \Database::select(
  205. '*',
  206. $this->table,
  207. array('where' => array('id = ? AND status = 1 ' => $meetingId)),
  208. 'first'
  209. );
  210. if (empty($meetingData)) {
  211. if ($this->debug) {
  212. error_log("meeting does not exist: $meetingId ");
  213. }
  214. return false;
  215. }
  216. $params = array('room_id' => $meetingData['room_id']);
  217. $returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag($params);
  218. $iframe = $this->url . "/?" ."secureHash=" . $returnVal;
  219. printf("<iframe src='%s' width='%s' height = '%s' />", $iframe, "100%", 640);
  220. }
  221. /**
  222. * Checks if the videoconference server is running.
  223. * Function currently disabled (always returns 1)
  224. * @return bool True if server is running, false otherwise
  225. * @assert () === false
  226. */
  227. public function isServerRunning()
  228. {
  229. // Always return true for now as this requires the openmeetings object
  230. // to have been instanciated and this includes a loginUser() which
  231. // connects to the server
  232. return true;
  233. }
  234. /**
  235. * Gets the password for a specific meeting for the current user
  236. * @return string A moderator password if user is teacher, or the course code otherwise
  237. */
  238. public function getMeetingUserPassword()
  239. {
  240. if ($this->isTeacher()) {
  241. return $this->getMeetingModerationPassword();
  242. } else {
  243. return api_get_course_id();
  244. }
  245. }
  246. /**
  247. * Generated a moderator password for the meeting
  248. * @return string A password for the moderation of the video conference
  249. */
  250. public function getMeetingModerationPassword()
  251. {
  252. return api_get_course_id().'mod';
  253. }
  254. /**
  255. * Get information about the given meeting
  256. * @param array ...?
  257. * @return mixed Array of information on success, false on error
  258. * @assert (array()) === false
  259. */
  260. public function getMeetingInfo($params)
  261. {
  262. try {
  263. $result = $this->api->getMeetingInfoArray($params);
  264. if ($result == null) {
  265. if ($this->debug) {
  266. error_log(__FILE__.'+'.__LINE__." Failed to get any response. Maybe we can't contact the OpenMeetings server.");
  267. }
  268. } else {
  269. return $result;
  270. }
  271. } catch (Exception $e) {
  272. if ($this->debug) {
  273. error_log(__FILE__.'+'.__LINE__.' Caught exception: ', $e->getMessage(), "\n");
  274. }
  275. }
  276. return false;
  277. }
  278. /**
  279. * @param array $params Array of parameters
  280. * @return mixed
  281. */
  282. public function setUserObjectAndGenerateRecordingHashByURL($params)
  283. {
  284. $username = $_SESSION['_user']['username'];
  285. $firstname = $_SESSION['_user']['firstname'];
  286. $lastname = $_SESSION['_user']['lastname'];
  287. $userId = $_SESSION['_user']['user_id'];
  288. $systemType = 'chamilo';
  289. $room_id = $params['room_id'];
  290. $urlWsdl = $this->url."/services/UserService?wsdl";
  291. $omServices = new \SoapClient($urlWsdl);
  292. $objRec = new User();
  293. $objRec->SID = $this->sessionId;
  294. $objRec->username = $username;
  295. $objRec->firstname = $firstname;
  296. $objRec->lastname = $lastname;
  297. $objRec->externalUserId = $userId;
  298. $objRec->externalUserType = $systemType;
  299. $objRec->recording_id = $recording_id;
  300. $orFn = $omServices->setUserObjectAndGenerateRecordingHashByURL($objRec);
  301. return $orFn->return;
  302. }
  303. /**
  304. * @param Array $params Array of parameters
  305. * @return mixed
  306. */
  307. public function setUserObjectAndGenerateRoomHashByURLAndRecFlag($params)
  308. {
  309. $username = $_SESSION['_user']['username'];
  310. $firstname = $_SESSION['_user']['firstname'];
  311. $lastname = $_SESSION['_user']['lastname'];
  312. $profilePictureUrl = $_SESSION['_user']['avatar'];
  313. $email = $_SESSION['_user']['mail'];
  314. $userId = $_SESSION['_user']['user_id'];
  315. $systemType = 'Chamilo';
  316. $room_id = $params['room_id'];
  317. $becomeModerator = ( $this->isTeacher() ? 1 : 0 );
  318. $allowRecording = 1; //Provisional
  319. $urlWsdl = $this->url."/services/UserService?wsdl";
  320. $omServices = new \SoapClient($urlWsdl);
  321. $objRec = new User();
  322. $objRec->SID = $this->sessionId;
  323. $objRec->username = $username;
  324. $objRec->firstname = $firstname;
  325. $objRec->lastname = $lastname;
  326. $objRec->profilePictureUrl = $profilePictureUrl;
  327. $objRec->email = $email;
  328. $objRec->externalUserId = $userId;
  329. $objRec->externalUserType = $systemType;
  330. $objRec->room_id = $room_id;
  331. $objRec->becomeModeratorAsInt = $becomeModerator;
  332. $objRec->showAudioVideoTestAsInt = 1;
  333. $objRec->allowRecording = $allowRecording;
  334. $rcFn = $omServices->setUserObjectAndGenerateRoomHashByURLAndRecFlag($objRec);
  335. return $rcFn->return;
  336. }
  337. /**
  338. * Gets all the course meetings saved in the plugin_openmeetings table
  339. * @return array Array of current open meeting rooms
  340. */
  341. public function getCourseMeetings()
  342. {
  343. $newMeetingsList = array();
  344. $item = array();
  345. $meetingsList = \Database::select(
  346. '*',
  347. $this->table,
  348. array('where' =>
  349. array(
  350. 'c_id = ? ' => api_get_course_int_id(),
  351. ' AND session_id = ? ' => api_get_session_id(),
  352. ' AND status <> ? ' => 2 // status deleted
  353. )
  354. )
  355. );
  356. /*$urlWsdl = $this->url."/services/RoomService?wsdl";
  357. $omServices = new \SoapClient($urlWsdl);*/
  358. $room = new Room();
  359. /*
  360. try {
  361. $rooms = $this->gateway->getRoomsWithCurrentUsersByType();
  362. //$rooms = $omServices->getRoomsPublic(array(
  363. //'SID' => $this->sessionId,
  364. //'start' => 0,
  365. //'max' => 10,
  366. //'orderby' => 'name',
  367. //'asc' => 'true',
  368. //'externalRoomType' => 'chamilo',
  369. //'roomtypes_id' => 'chamilo',
  370. //)
  371. //);
  372. } catch (SoapFault $e) {
  373. error_log(__FILE__.'+'.__LINE__.' '.$e->faultstring);
  374. //error_log($rooms->getDebug());
  375. return false;
  376. }
  377. */
  378. $room->SID = $this->sessionId;
  379. //error_log(__FILE__.'+'.__LINE__.' Meetings found: '.print_r($room->SID,1));
  380. if (!empty($meetingsList)) {
  381. foreach ($meetingsList as $meetingDb) {
  382. //$room->rooms_id = $meetingDb['room_id'];
  383. error_log(__FILE__.'+'.__LINE__.' Meetings found: '.print_r($meetingDb, 1));
  384. $remoteMeeting = array();
  385. $meetingDb['created_at'] = api_get_local_time($meetingDb['created_at']);
  386. $meetingDb['closed_at'] = (!empty($meetingDb['closed_at']) ? api_get_local_time($meetingDb['closed_at']):'');
  387. // Fixed value for now
  388. $meetingDb['participantCount'] = 40;
  389. $rec = $this->gateway->getFlvRecordingByRoomId($meetingDb['room_id']);
  390. $links = array();
  391. // Links to videos look like these:
  392. // http://video2.openmeetings.com:5080/openmeetings/DownloadHandler?fileName=flvRecording_4.avi&moduleName=lzRecorderApp&parentPath=&room_id=&sid=dfc0cac396d384f59242aa66e5a9bbdd
  393. $link = $this->url.'/DownloadHandler?fileName=%s&moduleName=lzRecorderApp&parentPath=&room_id=%s&sid=%s';
  394. if (!empty($rec)) {
  395. $link1 = sprintf($link, $rec['fileHash'], $meetingDb['room_id'], $this->sessionId);
  396. $link2 = sprintf($link, $rec['alternateDownload'], $meetingDb['room_id'], $this->sessionId);
  397. $links[] = $rec['fileName'].' '.
  398. \Display::url('[.flv]', $link1, array('target' => '_blank')).' '.
  399. \Display::url('[.avi]', $link2, array('target' => '_blank'));
  400. }
  401. $item['show_links'] = implode('<br />', $links);
  402. // The following code is currently commented because the web service
  403. // says this is not allowed by the SOAP user.
  404. /*
  405. try {
  406. // Get the conference room object from OpenMeetings server - requires SID and rooms_id to be defined
  407. $objRoomId = $this->gateway->getRoomById($meetingDb['room_id']);
  408. if (empty($objRoomId->return)) {
  409. error_log(__FILE__.'+'.__LINE__.' Emptyyyyy ');
  410. //\Database::delete($this->table, "id = {$meetingDb['id']}");
  411. // Don't delete expired rooms, just mark as closed
  412. \Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $meetingDb['id']));
  413. continue;
  414. }
  415. //$objCurUs = $omServices->getRoomWithCurrentUsersById($objCurrentUsers);
  416. } catch (SoapFault $e) {
  417. error_log(__FILE__.'+'.__LINE__.' '.$e->faultstring);
  418. exit;
  419. }
  420. //if( empty($objCurUs->returnMeetingID) ) continue;
  421. $current_room = array(
  422. 'roomtype' => $objRoomId->return->roomtype->roomtypes_id,
  423. 'meetingName' => $objRoomId->return->name,
  424. 'meetingId' => $objRoomId->return->meetingID,
  425. 'createTime' => $objRoomId->return->rooms_id,
  426. 'showMicrophoneStatus' => $objRoomId->return->showMicrophoneStatus,
  427. 'attendeePw' => $objRoomId->return->attendeePW,
  428. 'moderatorPw' => $objRoomId->return->moderators,
  429. 'isClosed' => $objRoomId->return->isClosed,
  430. 'allowRecording' => $objRoomId->return->allowRecording,
  431. 'startTime' => $objRoomId->return->startTime,
  432. 'endTime' => $objRoomId->return->updatetime,
  433. 'participantCount' => count($objRoomId->return->currentusers),
  434. 'maxUsers' => $objRoomId->return->numberOfPartizipants,
  435. 'moderatorCount' => count($objRoomId->return->moderators)
  436. );
  437. // Then interate through attendee results and return them as part of the array:
  438. if (!empty($objRoomId->return->currentusers)) {
  439. foreach ($objRoomId->return->currentusers as $a)
  440. $current_room[] = array(
  441. 'userId' => $a->username,
  442. 'fullName' => $a->firstname . " " . $a->lastname,
  443. 'isMod' => $a->isMod
  444. );
  445. }
  446. $remoteMeeting = $current_room;
  447. */
  448. if (empty( $remoteMeeting )) {
  449. /*
  450. error_log(__FILE__.'+'.__LINE__.' Empty remote Meeting for now');
  451. if ($meetingDb['status'] == 1 && $this->isTeacher()) {
  452. $this->endMeeting($meetingDb['id']);
  453. }
  454. */
  455. } else {
  456. $remoteMeeting['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meetingDb['id'].'&start='.api_strtotime($meetingDb['startTime']);
  457. }
  458. $remoteMeeting['end_url'] = api_get_self().'?action=end&id='.$meetingDb['id'];
  459. $remoteMeeting['delete_url'] = api_get_self().'?action=delete&id='.$meetingDb['id'];
  460. //$record_array = array();
  461. // if ($meetingDb['record'] == 1) {
  462. // $recordingParams = array(
  463. // 'meetingId' => $meetingDb['id'], //-- OPTIONAL - comma separate if multiple ids
  464. // );
  465. //
  466. // $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams);
  467. // if (!empty($records)) {
  468. // $count = 1;
  469. // if (isset($records['message']) && !empty($records['message'])) {
  470. // if ($records['messageKey'] == 'noRecordings') {
  471. // $record_array[] = get_lang('NoRecording');
  472. // } else {
  473. // //$record_array[] = $records['message'];
  474. // }
  475. // } else {
  476. // foreach ($records as $record) {
  477. // if (is_array($record) && isset($record['recordId'])) {
  478. // $url = Display::url(get_lang('ViewRecord'), $record['playbackFormatUrl'], array('target' => '_blank'));
  479. // if ($this->is_teacher()) {
  480. // $url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meetingDb['id'].'&record_id='.$record['recordId']);
  481. // $url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meetingDb['id'].'&start='.api_strtotime($meetingDb['created_at']).'&url='.$record['playbackFormatUrl']);
  482. // $url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordId']);
  483. // }
  484. // //$url .= api_get_self().'?action=publish&id='.$record['recordID'];
  485. // $count++;
  486. // $record_array[] = $url;
  487. // } else {
  488. //
  489. // }
  490. // }
  491. // }
  492. // }
  493. // //var_dump($record_array);
  494. // $item['show_links'] = implode('<br />', $record_array);
  495. //
  496. // }
  497. //
  498. //$item['created_at'] = api_convert_and_format_date($meetingDb['created_at']);
  499. // //created_at
  500. //
  501. // $item['publish_url'] = api_get_self().'?action=publish&id='.$meetingDb['id'];
  502. // $item['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meetingDb['id'];
  503. //
  504. //if ($meetingDb['status'] == 1) {
  505. // $joinParams = array(
  506. // 'meetingId' => $meetingDb['id'], //-- REQUIRED - A unique id for the meeting
  507. // 'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting
  508. // 'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
  509. // 'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
  510. // 'userID' => '', // -- OPTIONAL - string
  511. // 'webVoiceConf' => '' // -- OPTIONAL - string
  512. // );
  513. // $returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag( array('room_id' => $meetingDb['id']) );
  514. // $joinUrl = CONFIG_OPENMEETINGS_SERVER_URL . "?" .
  515. // "secureHash=" . $returnVal;
  516. //
  517. // $item['go_url'] = $joinUrl;
  518. //}
  519. $item = array_merge($item, $meetingDb, $remoteMeeting);
  520. //error_log(__FILE__.'+'.__LINE__.' Item: '.print_r($item,1));
  521. $newMeetingsList[] = $item;
  522. } //end foreach $meetingsList
  523. }
  524. return $newMeetingsList;
  525. }
  526. /**
  527. * Send a command to the OpenMeetings server to close the meeting
  528. * @param int $meetingId
  529. * @return int
  530. */
  531. public function endMeeting($meetingId)
  532. {
  533. try {
  534. $room = new Room($meetingId);
  535. $room->SID = $this->sessionId;
  536. $room->room_id = intval($meetingId);
  537. $room->status = false;
  538. $urlWsdl = $this->url."/services/RoomService?wsdl";
  539. $ws = new \SoapClient($urlWsdl);
  540. $roomClosed = $ws->closeRoom($room);
  541. if ($roomClosed > 0) {
  542. \Database::update(
  543. $this->table,
  544. array(
  545. 'status' => 0,
  546. 'closed_at' => api_get_utc_datetime()
  547. ),
  548. array('id = ? ' => $meetingId)
  549. );
  550. }
  551. //error_log(__FILE__.'+'.__LINE__.' Finished closing');
  552. } catch (SoapFault $e) {
  553. error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems: Fault: '.$e->faultstring);
  554. exit;
  555. return -1;
  556. }
  557. }
  558. /**
  559. * @param int $id
  560. * @return int
  561. */
  562. public function deleteMeeting($id)
  563. {
  564. try {
  565. $room = new Room();
  566. $room->loadRoomId($id);
  567. $this->gateway->deleteRoom($room);
  568. \Database::update(
  569. $this->table,
  570. array(
  571. 'status' => 2
  572. ),
  573. array('id = ? ' => $id)
  574. );
  575. return $id;
  576. //error_log(__FILE__.'+'.__LINE__.' Finished closing');
  577. } catch (SoapFault $e) {
  578. error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems: Fault: '.$e->faultstring);
  579. exit;
  580. return -1;
  581. }
  582. }
  583. }