changes of giftCard page
This commit is contained in:
@@ -56,6 +56,31 @@ class AdminPageAccess
|
||||
'usersMain',
|
||||
];
|
||||
|
||||
/** کلید عملیات ستون هر صفحه؛ با PAGE_TABLE_ACTIONS ادمین یکی بماند. */
|
||||
public const ACTIONS = [
|
||||
'customerMain_limitedOrder' => ['charge', 'tahesab', 'zarin', 'pargar', 'accountingCode', 'info', 'edit', 'referral', 'sms', 'approve', 'archive', 'active', 'trade'],
|
||||
'customerMain_archive' => ['restore', 'info'],
|
||||
'customerMain_specialPrice' => ['edit', 'toggle', 'delete'],
|
||||
'customerMain_goldCredit' => ['detail', 'edit', 'approve', 'reject'],
|
||||
'productsMain_limitedOrder' => ['buy', 'sell', 'list', 'tv', 'edit', 'archive'],
|
||||
'productsMain_archive' => ['restore', 'info'],
|
||||
'ordersMain' => ['info'],
|
||||
'transactionsMain' => ['info'],
|
||||
'accountsMain' => ['toggle', 'delete'],
|
||||
'walletMain' => ['info'],
|
||||
'physicalWithdrawMain' => ['amount', 'approve', 'status', 'factor'],
|
||||
'withdrawMain' => ['confirm', 'factor', 'status', 'weight', 'tahesab', 'zarin'],
|
||||
'pricingMain' => ['details'],
|
||||
'priceTriggers' => ['edit', 'toggle', 'delete'],
|
||||
'conditionalOrders' => ['edit', 'toggle', 'delete'],
|
||||
'accountingMain' => ['doc', 'register', 'send'],
|
||||
'appNotifications' => ['recipients', 'readers', 'edit', 'toggle', 'delete'],
|
||||
'automations' => ['preview', 'log', 'edit', 'toggle', 'delete'],
|
||||
'giftCardMain' => ['info', 'codes', 'edit', 'delete'],
|
||||
'discounts' => ['edit'],
|
||||
'usersMain' => ['info', 'edit', 'delete'],
|
||||
];
|
||||
|
||||
private const ALIASES = [
|
||||
'dashboard' => 'dashboardMain',
|
||||
'main' => 'dashboardMain',
|
||||
@@ -113,21 +138,43 @@ class AdminPageAccess
|
||||
$view = self::toBool($row['view'] ?? false);
|
||||
$edit = self::toBool($row['edit'] ?? false);
|
||||
$delete = self::toBool($row['delete'] ?? false);
|
||||
if ($edit || $delete) {
|
||||
$actions = null;
|
||||
if (is_array($row['actions'] ?? null)) {
|
||||
$actions = [];
|
||||
foreach (self::ACTIONS[$key] ?? [] as $actionKey) {
|
||||
$actions[$actionKey] = self::toBool($row['actions'][$actionKey] ?? false);
|
||||
}
|
||||
if (array_key_exists('edit', $actions)) {
|
||||
$edit = $actions['edit'];
|
||||
}
|
||||
if (array_key_exists('delete', $actions)) {
|
||||
$delete = $actions['delete'];
|
||||
}
|
||||
}
|
||||
if ($edit || $delete || ($actions && in_array(true, $actions, true))) {
|
||||
$view = true;
|
||||
}
|
||||
if (!$view) {
|
||||
$edit = false;
|
||||
$delete = false;
|
||||
if (is_array($actions)) {
|
||||
foreach ($actions as $actionKey => $enabled) {
|
||||
$actions[$actionKey] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$view && !$edit && !$delete) {
|
||||
if (!$view && !$edit && !$delete && !($actions && in_array(true, $actions, true))) {
|
||||
continue;
|
||||
}
|
||||
$out[$key] = [
|
||||
$stored = [
|
||||
'view' => $view,
|
||||
'edit' => $edit,
|
||||
'delete' => $delete,
|
||||
];
|
||||
if (is_array($actions) && $actions) {
|
||||
$stored['actions'] = $actions;
|
||||
}
|
||||
$out[$key] = $stored;
|
||||
}
|
||||
|
||||
return $out;
|
||||
@@ -163,11 +210,12 @@ class AdminPageAccess
|
||||
if (!is_array($row)) {
|
||||
return false;
|
||||
}
|
||||
if ($action === 'delete') {
|
||||
return !empty($row['delete']);
|
||||
}
|
||||
if ($action === 'edit') {
|
||||
return !empty($row['edit']);
|
||||
if ($action === 'delete' || $action === 'edit') {
|
||||
$actions = $row['actions'] ?? null;
|
||||
if (is_array($actions) && array_key_exists($action, $actions)) {
|
||||
return !empty($actions[$action]);
|
||||
}
|
||||
return !empty($row[$action]);
|
||||
}
|
||||
return !empty($row['view']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user