Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions resources/lang/en/exment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@
'all_user_viewable_flg' => 'All Users Can View',
'all_user_accessable_flg' => 'All Users Can Access',
'inherit_parent_permission' => 'Viewable with Permissions of Parent data',
'editable_with_parent' => 'Need Edit Permission for Parend data',
'add_parent_menu_flg' => 'Add Menu',
'add_notify_flg' => 'Add To Notification',
'add_parent_menu' => 'Target Parent Menu',
Expand Down Expand Up @@ -1278,6 +1279,7 @@
'all_user_viewable_flg' => 'If set to YES, all users will be able to view all the data in this table.',
'all_user_accessable_flg' => 'If set to YES, all users will be able to see all the data in this table.<br/>*It is not displayed on the menu or list page, it can be displayed only with internal data or reference from another table.',
'inherit_parent_permission' => 'If set to YES, the data can be viewed based on the the parent data(1:N) permissions. However, you must have viewing or similar permissions for this table itself.',
'editable_with_parent' => 'If set to YES, you need edit permissions for the parent data(1:N) to edit the data in this table.',
'add_parent_menu_flg' => 'After creating custom table, you can add it to the menu. To add it, please set it to YES. *It will be displayed after updating the browser. <br /> *It can be set only when new table is created. When updating please set it from "Menu" page.',
'add_parent_menu' => 'Please select the menu name to be parent.',
'add_notify_flg' => 'You can add settings for performing in-system notification to authorized users when creating/updating/sharing/commenting data, after creating a new table. Please add YES if you want to add.<br/>* It can be set only when creating a new table. Please set from the "notification" page when updating.',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/ja/exment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@
'all_user_viewable_flg' => '全ユーザーが閲覧可能',
'all_user_accessable_flg' => '全ユーザーが参照可能',
'inherit_parent_permission' => '親データの権限で閲覧可能',
'editable_with_parent' => '親データの編集権限が必要',
'add_parent_menu_flg' => 'メニューに追加する',
'add_notify_flg' => '通知に追加する',
'add_parent_menu' => '追加先の親メニュー',
Expand Down Expand Up @@ -1279,6 +1280,7 @@
'all_user_viewable_flg' => 'YESにした場合、すべてのユーザーが、このテーブルのすべてのデータを閲覧可能になります。',
'all_user_accessable_flg' => 'YESにした場合、すべてのユーザーが、このテーブルのすべてのデータを参照可能になります。<br/>※メニューや一覧画面では表示されず、内部データや、他のテーブルからの参照でのみ表示できます。',
'inherit_parent_permission' => 'YESにした場合、親データ(1対多)の権限でデータを閲覧できます。ただし、このテーブル自体に担当者の閲覧等の権限を持っている必要があります。',
'editable_with_parent' => 'YESにした場合、このテーブルのデータを編集するには親データ(1対多)の編集権限が必要になります。',
'add_parent_menu_flg' => '新規作成後、メニューに追加することができます。追加する場合はYESにしてください。<br/>※ブラウザ更新後に表示されます。<br />※テーブルの新規作成時のみ設定できます。更新時は「メニュー」画面より設定してください。',
'add_parent_menu' => '親にするメニュー名を選択してください。',
'add_notify_flg' => 'データの新規作成・更新・共有、コメント時に、権限のあるユーザーに、システム内通知を行う設定を、テーブルの新規作成後に追加することができます。追加する場合はYESにしてください。<br/>※テーブルの新規作成時のみ設定できます。更新時は「通知」画面より設定してください。',
Expand Down
3 changes: 3 additions & 0 deletions src/Controllers/CustomTableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ protected function form($id = null)
if ($has_parent) {
$form->switchbool('inherit_parent_permission', exmtrans("custom_table.inherit_parent_permission"))->help(exmtrans("custom_table.help.inherit_parent_permission"))
->default("0");

$form->switchbool('editable_with_parent', exmtrans("custom_table.editable_with_parent"))->help(exmtrans("custom_table.help.editable_with_parent"))
->default("1");
}
})->disableHeader();

Expand Down
16 changes: 12 additions & 4 deletions src/DataItems/Grid/DefaultGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,18 @@ protected function manageRowAction($grid)
$enableCreate = false;
}

if (!is_null($parent_value = $actions->row->getParentValue(null, true)) && $parent_value->enableEdit(true) !== true) {
$enableCreate = false;
$enableEdit = false;
$enableDelete = false;
if (!is_null($parent_value = $actions->row->getParentValue(null, true))) {
if (boolval($custom_table->getOption('editable_with_parent')??1)) {
if ($parent_value->enableEdit(true) !== true) {
$enableCreate = false;
$enableEdit = false;
$enableDelete = false;
}
} elseif ($parent_value->enableAccess() !== true) {
$enableCreate = false;
$enableEdit = false;
$enableDelete = false;
}
}

if (!$enableEdit) {
Expand Down
13 changes: 10 additions & 3 deletions src/DataItems/Show/DefaultShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,16 @@ public function createShowForm()
$tools->disableList();
}

if (!is_null($parent_value = $this->custom_value->getParentValue(null, true)) && $parent_value->enableEdit(true) !== true) {
$tools->disableEdit();
$tools->disableDelete();
if (!is_null($parent_value = $this->custom_value->getParentValue(null, true))) {
if (boolval($this->custom_table->getOption('editable_with_parent')??1)) {
if ($parent_value->enableEdit(true) !== true) {
$tools->disableEdit();
$tools->disableDelete();
}
} elseif ($parent_value->enableAccess() !== true) {
$tools->disableEdit();
$tools->disableDelete();
}
}

if ($this->modal) {
Expand Down
26 changes: 22 additions & 4 deletions src/Model/CustomValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -1794,8 +1794,17 @@ public function enableEdit($checkFormAction = false)
return ErrorCode::WORKFLOW_LOCK();
}

if (!is_null($parent_value = $this->getParentValue()) && ($code = $parent_value->enableEdit($checkFormAction)) !== true) {
return $code;
// check parent permission
if (!is_null($parent_value = $this->getParentValue())) {
if (boolval($this->custom_table->getOption('editable_with_parent')??1)) {
if (($code = $parent_value->enableEdit($checkFormAction)) !== true) {
return $code;
}
} else {
if (($code = $parent_value->enableAccess()) !== true) {
return $code;
}
}
}

if ($this->trashed()) {
Expand Down Expand Up @@ -1834,8 +1843,17 @@ public function enableDelete($checkFormAction = false)
return ErrorCode::DELETE_DISABLED();
}

if (!is_null($parent_value = $this->getParentValue()) && ($code = $parent_value->enableDelete($checkFormAction)) !== true) {
return $code;
// check parent permission
if (!is_null($parent_value = $this->getParentValue())) {
if (boolval($this->custom_table->getOption('editable_with_parent')??1)) {
if (($code = $parent_value->enableDelete($checkFormAction)) !== true) {
return $code;
}
} else {
if (($code = $parent_value->enableAccess()) !== true) {
return $code;
}
}
}

return true;
Expand Down
Loading