From 43e9597fda5bdf91313fa04304540907f8aab548 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 13 Jun 2023 08:59:50 +0800 Subject: [PATCH] + Add permission judgments to the link on the fields. --- lib/zin/wg/dtable/v1.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/zin/wg/dtable/v1.php b/lib/zin/wg/dtable/v1.php index a4ea54cc91..adb0442ac0 100644 --- a/lib/zin/wg/dtable/v1.php +++ b/lib/zin/wg/dtable/v1.php @@ -37,6 +37,8 @@ class dtable extends wg if(!isset($config['name'])) $config['name'] = $field; if(!isset($config['title'])) $config['title'] = zget($app->lang->{$module}, $config['name'], zget($app->lang, $config['name'])); + if(isset($config['link']) && is_array($config['link'])) $config['link'] = $this->getLink($config['link']); + if(isset($config['assignLink']) && is_array($config['assignLink'])) $config['assignLink'] = $this->getLink($config['assignLink']); } $this->setProp('cols', array_values($colConfigs)); @@ -49,6 +51,22 @@ class dtable extends wg return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css'); } + /** + * 获取字段链接。 + * Get link to the field. + * + * @param array $setting + * @access protected + * @return array|string + */ + protected function getLink(array $setting): array|string + { + if(empty($setting['module']) || empty($setting['method'])) return $setting; + if(!hasPriv($setting['module'], $setting['method'])) return ''; + + return createLink($setting['module'], $setting['method'], zget($setting, 'params', '')); + } + protected function build() { return zui::dtable(inherit($this));