openmeetings.class.php 26 KB

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