room.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Definition for the room class
  4. * @package chamilo.plugin.videoconference
  5. */
  6. namespace Chamilo\Plugin\OpenMeetings;
  7. /**
  8. * Class room
  9. */
  10. class Room
  11. {
  12. public $SID;
  13. /**
  14. * Defining plural and non-plural because of inconsistency in OpenMeetings
  15. */
  16. public $rooms_id;
  17. public $room_id;
  18. /**
  19. * Status is false for closed, true for open
  20. */
  21. public $status = false;
  22. public $name;
  23. /**
  24. * Room types are described here http://openmeetings.apache.org/RoomService.html#addRoomWithModerationAndExternalType
  25. * 1 = Conference, 2 = Audience, 3 = Restricted, 4 = Interview
  26. * $roomTypeId = ( $this->isTeacher() ) ? 1 : 2 ;
  27. */
  28. public $roomtypes_id = 1;
  29. public $comment;
  30. public $numberOfPartizipants = 40;
  31. public $ispublic = false;
  32. public $appointment = false;
  33. public $isDemoRoom = false;
  34. public $demoTime = 0;
  35. public $isModeratedRoom = true;
  36. public $externalRoomType = 'chamilolms';
  37. public $allowUserQuestions = false;
  38. public $isAudioOnly = false;
  39. public $waitForRecording = true;
  40. public $allowRecording = true;
  41. public $chamiloCourseId;
  42. public $chamiloSessionId;
  43. private $table;
  44. public function __construct()
  45. {
  46. $this->table = \Database::get_main_table('plugin_openmeetings');
  47. global $_configuration;
  48. $this->name = 'C'.api_get_course_int_id().'-'.api_get_session_id();
  49. $accessUrl = api_get_access_url($_configuration['access_url']);
  50. $this->externalRoomType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1);
  51. if (strcmp($this->externalRoomType, 'localhost') == 0) {
  52. $this->externalRoomType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1);
  53. }
  54. $this->externalRoomType = 'chamilolms.'.$this->externalRoomType;
  55. }
  56. /**
  57. * Get Room by id
  58. * @param int $id
  59. */
  60. public function getRoom($id)
  61. {
  62. if (!empty($id)) {
  63. $roomData = \Database::select('*', $this->table, array('where' => array('id = ?' => $id)), 'first');
  64. if (!empty($roomData)) {
  65. $this->rooms_id = $this->room_id = $roomData['room_id'];
  66. $this->status = $roomData['status'];
  67. $this->name = $roomData['meeting_name'];
  68. $this->comment = $roomData['welcome_msg'];
  69. $this->allowRecording = $roomData['record'];
  70. $this->chamiloCourseId = $roomData['c_id'];
  71. $this->chamiloSessionId = $roomData['session_id'];
  72. }
  73. }
  74. }
  75. /**
  76. * Sets the room ID and loads as much info as possible from the local table
  77. * @param int $id The room ID (from table.room_id)
  78. */
  79. public function loadRoomId($id)
  80. {
  81. if (!empty($id)) {
  82. $roomData = \Database::select('*', $this->table, array('where' => array('room_id = ?' => $id)), 'last');
  83. if (!empty($roomData)) {
  84. $this->rooms_id = $this->room_id = $roomData['room_id'];
  85. $this->status = $roomData['status'];
  86. $this->name = $roomData['meeting_name'];
  87. $this->comment = $roomData['welcome_msg'];
  88. $this->allowRecording = $roomData['record'];
  89. $this->chamiloCourseId = $roomData['c_id'];
  90. $this->chamiloSessionId = $roomData['session_id'];
  91. }
  92. }
  93. }
  94. /**
  95. * Gets a string from a boolean attribute
  96. * @param string $attribute Name of the attribute
  97. * @param mixed $voidReturn What to return if the value is not defined
  98. * @return string The boolean value expressed as string ('true' or 'false')
  99. */
  100. public function getString($attribute, $voidReturn = false)
  101. {
  102. if (empty($attribute)) {
  103. return false;
  104. }
  105. if (!isset($this->$attribute)) {
  106. return $voidReturn;
  107. }
  108. return $this->$attribute ? 'true' : 'false';
  109. }
  110. }