From c7cb5a3e63ea945a3428a2eca99403a8511c2d15 Mon Sep 17 00:00:00 2001 From: Lufei Date: Mon, 9 Oct 2023 14:49:27 +0800 Subject: [PATCH] * Fix bug #39262, sync helper methods. --- framework/api/helper.class.php | 93 ++++++++++++++++++++++++++++------ framework/helper.class.php | 1 - 2 files changed, 77 insertions(+), 17 deletions(-) diff --git a/framework/api/helper.class.php b/framework/api/helper.class.php index f24358735e..598b84ec3f 100644 --- a/framework/api/helper.class.php +++ b/framework/api/helper.class.php @@ -70,27 +70,29 @@ class helper extends baseHelper } else { - if($feature == 'product' or $feature == 'scrum' or $feature == 'waterfall') return strpos(",$config->disabledFeatures,", ",{$feature},") === false; + if(in_array($feature, array('scrum', 'waterfall', 'agileplus', 'waterfallplus'))) return strpos(",$config->disabledFeatures,", ",{$feature},") === false; - $hasFeature = false; + $hasFeature = false; + $canConfigFeature = false; foreach($config->featureGroup as $group => $modules) { - if($feature == $group) + foreach($modules as $module) { - foreach($modules as $module) + if($feature == $group or $feature == $module) { - if(helper::hasFeature("{$group}_{$module}")) $hasFeature = true; - } - } - else - { - foreach($modules as $module) - { - if($feature == $module and helper::hasFeature("{$group}_{$module}")) $hasFeature = true; + $canConfigFeature = true; + if(in_array($group, array('scrum', 'waterfall', 'agileplus', 'waterfallplus'))) + { + if(helper::hasFeature("{$group}") and helper::hasFeature("{$group}_{$module}")) $hasFeature = true; + } + else + { + if(helper::hasFeature("{$group}_{$module}")) $hasFeature = true; + } } } } - return $hasFeature && strpos(",$config->disabledFeatures,", ",{$feature},") === false; + return !$canConfigFeature or ($hasFeature && strpos(",$config->disabledFeatures,", ",{$feature},") === false); } } @@ -190,9 +192,11 @@ class helper extends baseHelper /** * Create url of issue. * - * @param string $module - * @param string $method + * @param string $moduleName + * @param string $methodName * @param string $vars + * @param string $viewType + * @param bool $onlyBody * @static * @access public * @return string @@ -214,6 +218,50 @@ class helper extends baseHelper } return common::getSysURL() . $link; } + + /** + * 是否是内网。 + * Check is intranet. + * + * @return bool + */ + public static function isIntranet() + { + return !defined('USE_INTRANET') ? false : USE_INTRANET; + } + + /** + * 转换类型。 + * Convert the type. + * + * @param mixed $value + * @param string $type + * @static + * @access public + * @return array|bool|float|int|object|string + */ + public static function convertType($value, $type) + { + switch($type) + { + case 'int': + return (int)$value; + case 'float': + return (float)$value; + case 'bool': + return (bool)$value; + case 'array': + return (array)$value; + case 'object': + return (object)$value; + case 'datetime': + case 'date': + return $value ? (string)$value : null; + case 'string': + default: + return (string)$value; + } + } } /** @@ -228,6 +276,18 @@ function isonlybody() return helper::inOnlyBodyMode(); } +/** + * 检查页面是否是弹窗中。 + * Check page is modal. + * + * @access public + * @return bool + */ +function isInModal(): bool +{ + return helper::isAjaxRequest('modal'); +} + /** * Format time. * @@ -238,9 +298,10 @@ function isonlybody() */ function formatTime($time, $format = '') { + if(empty($time)) return ''; $time = str_replace('0000-00-00', '', $time); $time = str_replace('00:00:00', '', $time); - if(trim($time) == '') return ; + if(trim($time) == '') return ''; if($format) return date($format, strtotime($time)); return trim($time); } diff --git a/framework/helper.class.php b/framework/helper.class.php index 2c95b57131..b95c246487 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -470,7 +470,6 @@ function autoloader($class) spl_autoload_register('autoloader'); - /** * Init page title based on the module name and the method name. *