diff --git a/lib/base/cache/cache.class.php b/lib/base/cache/cache.class.php index 97e7208f62..876ecfef00 100644 --- a/lib/base/cache/cache.class.php +++ b/lib/base/cache/cache.class.php @@ -104,13 +104,12 @@ class baseCache * 构造方法。 * The construct method. * - * @param object $app * @access public * @return void */ - public function __construct($app) + public function __construct() { - global $config; + global $config, $app; $this->app = $app; $this->config = $config; diff --git a/module/cache/handler/bug.php b/module/cache/handler/bug.php new file mode 100644 index 0000000000..e69de29bb2 diff --git a/module/cache/handler/setting.php b/module/cache/handler/setting.php new file mode 100644 index 0000000000..3423c99cf2 --- /dev/null +++ b/module/cache/handler/setting.php @@ -0,0 +1,34 @@ + + * @package action + * @version $Id$ + * @link https://www.zentao.net + */ +class settingHandler +{ + /** + * 获取系统及用户的配置信息。 + * Get system and personal config. + * + * @param string $account + * @access public + * @return array + */ + public function getSysAndPersonalConfig(string $account) + { + $owner = 'system,' . ($account ? $account : ''); + $records = $this->cache->select('*')->from(TABLE_CONFIG) + ->where('owner')->in($owner) + ->beginIF(!$this->app->upgrading)->andWhere('vision')->in(array('', $this->config->vision))->fi() + ->orderBy('id') + ->fetchAll('id'); + + return $records; + } +} diff --git a/module/cache/model.php b/module/cache/model.php index ac3d46c2e2..bb61958561 100644 --- a/module/cache/model.php +++ b/module/cache/model.php @@ -10,8 +10,40 @@ declare(strict_types=1); * @version $Id: model.php 5114 2013-07-12 06:02:59Z chencongzhi520@gmail.com $ * @link https://www.zentao.net */ -?> -cache = $this->app->loadClass('cache'); + } + + /** + * 魔术方法,加载子类。 + * Magic get method. + * + * @param string $handlerName + * @access public + * @return object + */ + public function __get(string $handlerName) + { + include dirname(__FILE__) . DS . 'handler' . DS . strtolower($handlerName) . '.php'; + $handlerName = $handlerName . 'Handler'; + + $handler = new $handlerName(); + $handler->cache = $this->cache; + $handler->app = $this->app; + $handler->config = $this->config; + + return $handler; + } } diff --git a/module/setting/model.php b/module/setting/model.php index c2f1281ee8..a32c992d9b 100644 --- a/module/setting/model.php +++ b/module/setting/model.php @@ -244,12 +244,7 @@ class settingModel extends model */ public function getSysAndPersonalConfig(string $account = ''): array { - $owner = 'system,' . ($account ? $account : ''); - $records = $this->dao->select('*')->from(TABLE_CONFIG) - ->where('owner')->in($owner) - ->beginIF(!$this->app->upgrading)->andWhere('vision')->in(array('', $this->config->vision))->fi() - ->orderBy('id') - ->fetchAll('id'); + $records = $this->cache->setting->getSysAndPersonalConfig($account); if(!$records) return array(); $vision = $this->config->vision;