common.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. global $app;
  3. helper::import($app->getModulePath('', 'common') . 'model.php');
  4. class extcommonModel extends commonModel
  5. {
  6. public static function getLicensePropertyValue($propertyName)
  7. {
  8. return (new self)->loadExtension('xuanxuan')->getLicensePropertyValue($propertyName);
  9. }
  10. public static function ilMethod($module, $method, $extra = '')
  11. {
  12. return (new self)->loadExtension('xuanxuan')->ilMethod($module, $method, $extra);
  13. }
  14. public function isOpenMethod($module, $method)
  15. {
  16. if(defined('RUN_MODE') && RUN_MODE == 'xuanxuan' && !empty($this->config->xuanxuan->enabledMethods[$module][$method])) return true;
  17. if($module == 'entry' and $method == 'visit') return true;
  18. if($module == 'integration' and $method == 'wopi') return true;
  19. if($module == 'im' and $method == 'authorize') return true;
  20. if(in_array("$module.$method", $this->config->openMethods)) return true;
  21. if($this->loadModel('user')->isLogon() or ($this->app->company->guest and $this->app->user->account == 'guest'))
  22. {
  23. if(in_array("$module.$method", $this->config->logonMethods)) return true;
  24. if(stripos($method, 'ajax') !== false) return true;
  25. if($module == 'block' && stripos(',dashboard,printblock,create,edit,delete,close,reset,layout,', ",{$method},") !== false) return true;
  26. if($module == 'index' and $method == 'app') return true;
  27. if($module == 'my' and $method == 'guidechangetheme') return true;
  28. if($module == 'product' and $method == 'showerrornone') return true;
  29. if($module == 'misc' and in_array($method, array('downloadclient', 'changelog'))) return true;
  30. if($module == 'tutorial' and in_array($method, array('start', 'index', 'quit', 'wizard'))) return true;
  31. }
  32. return false;
  33. }
  34. public function loadConfigFromDB()
  35. {
  36. if($this->app->isServing() || (defined('RUN_MODE') && RUN_MODE == 'api'))
  37. {
  38. $this->loadModel('setting');
  39. $xxItems = $this->setting->getItems('owner=system&module=common&section=xuanxuan');
  40. $xxConfig = array();
  41. foreach($xxItems as $xxItem) $xxConfig[$xxItem->key] = $xxItem->value;
  42. if(empty($xxConfig['key']))
  43. {
  44. $this->setting->setItem('system.common.xuanxuan.turnon', '0');
  45. $this->setting->setItem('system.common.xuanxuan.key', $this->setting->computeSN());
  46. }
  47. if(!isset($xxConfig['chatPort'])) $this->setting->setItem('system.common.xuanxuan.chatPort', '11444');
  48. if(!isset($xxConfig['commonPort'])) $this->setting->setItem('system.common.xuanxuan.commonPort', '11443');
  49. if(!isset($xxConfig['ip'])) $this->setting->setItem('system.common.xuanxuan.ip', '0.0.0.0');
  50. if(!isset($xxConfig['uploadFileSize'])) $this->setting->setItem('system.common.xuanxuan.uploadFileSize', '20');
  51. if(!isset($xxConfig['https']) and !isset($xxConfig['isHttps'])) $this->setting->setItem('system.common.xuanxuan.https', 'off');
  52. }
  53. /* Get configs of system and current user. */
  54. $account = isset($this->app->user->account) ? $this->app->user->account : '';
  55. if($this->config->db->name) $config = $this->loadModel('setting')->getSysAndPersonalConfig($account);
  56. $this->config->systemDB = isset($config['system']) ? $config['system'] : array();
  57. $this->config->personalDB = isset($config[$account]) ? $config[$account] : array();
  58. /* Web root cannot be changed by api request. */
  59. if(!$this->app->apiVersion)
  60. {
  61. $this->commonTao->updateDBWebRoot($this->config->systemDB);
  62. }
  63. /* Override the items defined in config/config.php and config/my.php. */
  64. if(isset($this->config->systemDB->common)) $this->app->mergeConfig($this->config->systemDB->common, 'common');
  65. if(isset($this->config->personalDB->common)) $this->app->mergeConfig($this->config->personalDB->common, 'common');
  66. $this->config->disabledFeatures = $this->config->disabledFeatures . ',' . $this->config->closedFeatures;
  67. /* Sanplex hide features. */
  68. $this->app->loadConfig('common');
  69. if(!empty($this->config->hiddenFeature)) $this->config->disabledFeatures .= ',' . implode(',', $this->config->hiddenFeature);
  70. }
  71. //**//
  72. }