room.class.php 3.9 KB

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