room.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. /**
  45. * Room constructor.
  46. */
  47. public function __construct()
  48. {
  49. $this->table = \Database::get_main_table('plugin_openmeetings');
  50. $this->name = 'C'.api_get_real_course_id().'-'.api_get_session_id();
  51. $accessUrl = api_get_access_url(api_get_current_access_url_id());
  52. $this->externalRoomType = substr($accessUrl['url'], strpos($accessUrl['url'],'://')+3,-1);
  53. if (strcmp($this->externalRoomType, 'localhost') == 0) {
  54. $this->externalRoomType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH),'://')+3, -1);
  55. }
  56. $this->externalRoomType = 'chamilolms.'.$this->externalRoomType;
  57. }
  58. /**
  59. * Get Room by id
  60. * @param int $id
  61. */
  62. public function getRoom($id)
  63. {
  64. if (!empty($id)) {
  65. $roomData = \Database::select('*', $this->table, array('where' => array('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. * @param int $id The room ID (from table.room_id)
  80. */
  81. public function loadRoomId($id)
  82. {
  83. if (!empty($id)) {
  84. $roomData = \Database::select('*', $this->table, array('where' => array('room_id = ?' => $id)), 'last');
  85. if (!empty($roomData)) {
  86. $this->rooms_id = $this->room_id = $roomData['room_id'];
  87. $this->status = $roomData['status'];
  88. $this->name = $roomData['meeting_name'];
  89. $this->comment = $roomData['welcome_msg'];
  90. $this->allowRecording = $roomData['record'];
  91. $this->chamiloCourseId = $roomData['c_id'];
  92. $this->chamiloSessionId = $roomData['session_id'];
  93. }
  94. }
  95. }
  96. /**
  97. * Gets a string from a boolean attribute
  98. * @param string $attribute Name of the attribute
  99. * @param mixed $voidReturn What to return if the value is not defined
  100. * @return string The boolean value expressed as string ('true' or 'false')
  101. */
  102. public function getString($attribute, $voidReturn = false)
  103. {
  104. if (empty($attribute)) {
  105. return false;
  106. }
  107. if (!isset($this->$attribute)) {
  108. return $voidReturn;
  109. }
  110. return $this->$attribute?'true':'false';
  111. }
  112. }