Change blacklist to 2-dimensional array

관리 편의를 위해 블랙리스트를 자료 종류별로 구분합니다.
단, 기존과 같이 Context::isBlacklistedPlugin()을 호출하면
자료 종류 구분 없이 블랙리스트 여부를 알려줍니다.
This commit is contained in:
Kijin Sung 2021-01-24 11:39:42 +09:00
parent 6b32bc6789
commit 1ec6e1ec7a
9 changed files with 54 additions and 26 deletions

View file

@ -2529,9 +2529,10 @@ class Context
* Check whether an addon, module, or widget is blacklisted
*
* @param string $plugin_name
* @param string $type
* @return bool
*/
public static function isBlacklistedPlugin($plugin_name)
public static function isBlacklistedPlugin($plugin_name, $type = '')
{
if (self::$_blacklist === null)
{
@ -2542,7 +2543,21 @@ class Context
}
}
return isset(self::$_blacklist[$plugin_name]);
if ($type)
{
return isset(self::$_blacklist[$type][$plugin_name]);
}
else
{
foreach (self::$_blacklist as $type => $blacklist)
{
if (isset(self::$_blacklist[$type][$plugin_name]))
{
return true;
}
}
return false;
}
}
/**

View file

@ -6,20 +6,33 @@
* Copyright (c) Rhymix Developers and Contributors
*/
return array(
'autolang' => true,
'auto_login' => true,
'errorlogger' => true,
'fix_mysql_utf8' => true,
'homepage' => true,
'jquerycdn' => true,
'member_communication' => true,
'multidomain' => true,
'seo' => true,
'session_shield' => true,
'smartphone' => true,
'trackback' => true,
'zipperupper' => true,
'elkha_www' => true,
'autowww' => true,
'fix_domain' => true,
// Addons
'addon' => array(
'autolang' => true,
'autowww' => true,
'elkha_www' => true,
'fix_domain' => true,
'fix_mysql_utf8' => true,
'jquerycdn' => true,
'member_communication' => true,
'session_shield' => true,
'smartphone' => true,
'zipperupper' => true,
),
// Modules
'module' => array(
'auto_login' => true,
'errorlogger' => true,
'homepage' => true,
'multidomain' => true,
'seo' => true,
'trackback' => true,
),
// Widgets
'widget' => array(
),
);

View file

@ -47,7 +47,7 @@ class addonAdminModel extends addon
foreach($addonList as $key => $addon)
{
// check blacklist
$addonList[$key]->isBlacklisted = Context::isBlacklistedPlugin($addon->addon);
$addonList[$key]->isBlacklisted = Context::isBlacklistedPlugin($addon->addon, 'addon');
// get easyinstall remove url
$packageSrl = $oAutoinstallModel->getPackageSrlByPath($addon->path);

View file

@ -77,7 +77,7 @@ class addonController extends addon
$addon_list = $oAddonModel->getInsertedAddons($site_srl, $gtype);
foreach($addon_list as $addon => $val)
{
if(Context::isBlacklistedPlugin($addon)
if(Context::isBlacklistedPlugin($addon, 'addon')
|| ($type == "pc" && $val->is_used != 'Y')
|| ($type == "mobile" && $val->is_used_m != 'Y')
|| ($gtype == 'global' && $val->is_fixed != 'Y')

View file

@ -35,7 +35,7 @@
<tr loop="$addon_list => $addon">
<td class="title">
<p><strong style="color:#aaa"|cond="$addon->isBlacklisted">{$addon->title}</strong></p>
<p>{$addon->description}</p>
<p style="color:#aaa"|cond="$addon->isBlacklisted">{$addon->description}</p>
<p cond="$addon->need_update == 'Y'" class="update">
{$lang->msg_avail_easy_update} <a href="{$addon->update_url}&amp;return_url={urlencode(getRequestUriByServerEnviroment())}">{$lang->msg_do_you_like_update}</a>
</p>

View file

@ -34,7 +34,7 @@
</tr>
</tbody>
</table>
<div cond="Context::isBlacklistedPlugin($addon_info->addon_name)" class="message error">
<div cond="Context::isBlacklistedPlugin($addon_info->addon_name, 'addon')" class="message error">
<p><em class="x_label x_label-important">{$lang->msg_warning}</em> {$lang->msg_blacklisted_module}<br />{$lang->get('admin.msg_blacklisted_reason.'.$addon_info->addon_name)}</p>
</div>
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/addon/tpl/setup_addon/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">

View file

@ -2,7 +2,7 @@
<include target="./_header.html" />
<div class="content" id="content">
<div cond="Context::isBlacklistedPlugin($blacklisted_plugin_name = strtolower(preg_replace('/^disp([A-Z][a-z0-9_]+)[A-Z].+$/', '$1', $act)))" class="message error" style="margin-top:15px">
<div cond="Context::isBlacklistedPlugin($blacklisted_plugin_name = strtolower(preg_replace('/^disp([A-Z][a-z0-9_]+)[A-Z].+$/', '$1', $act)), 'module')" class="message error" style="margin-top:15px">
<p>
<em class="x_label x_label-important">{$lang->msg_warning}</em> {$lang->msg_blacklisted_module}<br />
{$lang->get('admin.msg_blacklisted_reason.'.$blacklisted_plugin_name)}

View file

@ -1481,7 +1481,7 @@ class moduleModel extends module
$info->path = $path;
$info->admin_index_act = $info->admin_index_act ?? null;
if(!Context::isBlacklistedPlugin($module_name))
if(!Context::isBlacklistedPlugin($module_name, 'module'))
{
// Check if DB is installed
if($table_count > $created_table_count)

View file

@ -32,7 +32,7 @@
<strong cond="!$val->admin_index_act">{$val->title}</strong>
</p>
<p cond="$val->description">{$val->description}</p>
<p cond="Context::isBlacklistedPlugin($val->module)" class="x_alert x_alert-error">
<p cond="Context::isBlacklistedPlugin($val->module, 'module')" class="x_alert x_alert-error">
{$lang->msg_blacklisted_module}<br />
{$lang->get('admin.msg_blacklisted_reason.'.$val->module)}
</p>
@ -43,7 +43,7 @@
<!--@if($val->version === 'RX_VERSION')-->
<img src="{\RX_BASEURL}common/img/icon.png" class="core_symbol" alt="Rhymix Core" title="Rhymix Core" />
<!--@else-->
<span style="color:#aaa"|cond="Context::isBlacklistedPlugin($val->module)">{$val->version}</span>
<span style="color:#aaa"|cond="Context::isBlacklistedPlugin($val->module, 'module')">{$val->version}</span>
<!--@endif-->
</td>
<td class="nowr rx_detail_marks">