model.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * The model file of conference module of XXB.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd., www.zentao.net)
  6. * @license ZOSL (https://zpl.pub/page/zoslv1.html)
  7. * @author Wenrui LI <liwenrui@easycorp.ltd>
  8. * @package conference
  9. * @version $Id$
  10. * @link https://xuanim.com
  11. */
  12. ?>
  13. <?php
  14. class conferenceModel extends model
  15. {
  16. /**
  17. * @var settingModel
  18. */
  19. public $setting;
  20. /**
  21. * Get current jitsi configuration.
  22. *
  23. * @access public
  24. * @return object
  25. */
  26. public function getConfiguration()
  27. {
  28. $this->loadModel('setting');
  29. $items = $this->setting->getItems("owner=system&module=jitsi&section=common&key=enabled,domain,detachedConference");
  30. $conferenceConfig = new stdClass();
  31. foreach($items as $item)
  32. {
  33. $conferenceConfig->{$item->key} = $item->value;
  34. }
  35. return $conferenceConfig;
  36. }
  37. /**
  38. * Check and set incoming jitsi configuration.
  39. *
  40. * @param array $config
  41. * @access public
  42. * @return void
  43. */
  44. public function setConfiguration()
  45. {
  46. $post = fixer::input('post')
  47. ->setIF($this->post->domain != '', 'domain', trim($this->post->domain))
  48. ->get();
  49. $errors = array();
  50. if(isset($post->enabled) && $post->enabled === 'true')
  51. {
  52. foreach($this->config->conference->require->fields as $field)
  53. {
  54. if(empty($post->$field)) $errors[$field][] = $this->lang->conference->inputError->{$field};
  55. }
  56. }
  57. if(!empty($errors)) return array('result' => 'fail', 'message' => $errors);
  58. $this->loadModel('setting');
  59. $enabled = !isset($post->enabled) || empty($post->enabled)
  60. ? 'false'
  61. : 'true';
  62. $this->setting->setItem('system.jitsi.common.enabled', $enabled);
  63. $this->setting->setItem('system.jitsi.common.domain', $post->domain);
  64. if(dao::isError()) return array('result' => 'fail', 'message' => dao::getError());
  65. return array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('admin'));
  66. }
  67. /**
  68. * Check if jitsi functionality is enabled.
  69. *
  70. * @access public
  71. * @return boolean
  72. */
  73. public function isEnabled()
  74. {
  75. return filter_var($this->loadModel('setting')->getItem("owner=system&module=jitsi&section=common&key=enabled"), FILTER_VALIDATE_BOOLEAN)
  76. && extCommonModel::ilMethod('conference', 'detachedConference');
  77. }
  78. /**
  79. * Get conference permissions, set max number of participants.
  80. *
  81. * @access public
  82. * @return void
  83. */
  84. public function getConferencePermissions()
  85. {
  86. $conferenceLimitData = $this->loadModel('common')->getLicensePropertyValue('unlimitedParticipants');
  87. /* Fallback for older value. for older user, default give 10 participants limit. */
  88. if($conferenceLimitData === '1') $conferenceLimit = 10;
  89. /* '0' as unlimited participants in the new version */
  90. if($conferenceLimitData === '0') $conferenceLimit = null;
  91. /* not set value as 0 participants */
  92. if($conferenceLimitData === false) $conferenceLimit = 0;
  93. if(!array_key_exists('conferenceLimit', get_defined_vars())) $conferenceLimit = intval($conferenceLimitData);
  94. die(json_encode(array('status' => 'success', 'data' => array('limit' => $conferenceLimit))));
  95. }
  96. }