openmeetings.class.php 26 KB

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