Add module.getModuleAdminScopes (after) event

This commit is contained in:
Kijin Sung 2024-10-17 21:45:17 +09:00
parent a2e5434aec
commit 64b0d97fbb
2 changed files with 17 additions and 2 deletions

View file

@ -197,6 +197,8 @@ class ModuleAdminModel extends Module
// Extract admin ID set in the current module
$admin_member = ModuleModel::getAdminId($module_srl) ?: [];
Context::set('admin_member', $admin_member);
// Get defined scopes
Context::set('manager_scopes', $this->getModuleAdminScopes());
// Get a list of groups
$group_list = MemberModel::getGroups();
Context::set('group_list', $group_list);
@ -286,6 +288,19 @@ class ModuleAdminModel extends Module
$this->add('grantList', $grantList);
}
/**
* Get defined scopes of module admin.
*
* @return array
*/
public function getModuleAdminScopes(): array
{
$obj = new \stdClass;
$obj->scopes = lang('module.admin_scopes')->getArrayCopy();
ModuleHandler::triggerCall('module.getModuleAdminScopes', 'after', $obj);
return $obj->scopes;
}
/**
* @brief Common:: skin setting page for the module
*/

View file

@ -39,9 +39,9 @@
{$lang->admin_scope}
</label>
<div class="x_controls">
{@ $default_scopes = array_keys($lang->admin_scopes->getArrayCopy())}
{@ $default_scopes = array_keys($manager_scopes)}
{@ $admin_scopes = $admin_member ? (array_first($admin_member)->scopes ?? $default_scopes) : $default_scopes}
<!--@foreach($lang->admin_scopes as $key => $val)-->
<!--@foreach($manager_scopes as $key => $val)-->
<label class="x_inline">
<input type="checkbox" name="admin_scopes[]" value="{$key}" checked="checked"|cond="in_array($key, $admin_scopes)" />
{$val}