Skip to content

Commit 8e1fb57

Browse files
committed
Version 1.1.0 リリース
1 parent fba3bc5 commit 8e1fb57

File tree

9 files changed

+83
-32
lines changed

9 files changed

+83
-32
lines changed

Config/setting.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
'adminsName' => [
1919
'admins'
2020
],
21-
'allowedAdminAllOperation' => TRUE,
22-
'allowedAllUserGroupUploads' => FALSE,
23-
'allowedAllUserGroupDblogs' => FALSE
21+
'allowedAdminAllOperation' => TRUE,
22+
'allowedAllUserGroupUploads' => FALSE,
23+
'allowedAllUserGroupDblogs' => FALSE,
24+
'allowedAllUserGroupBlogPosts' => TRUE
2425
]
2526
];

Event/OperationHelperEventListener.php

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function formAfterForm(CakeEvent $event)
3939
$View->plugin = 'Operation';
4040

4141
$View->BcBaser->css('Operation.admin/style');
42+
$View->BcBaser->js('Operation.admin/script');
4243

4344
switch ($event->data['id']) {
4445
case 'SiteAdminEditForm':

Event/OperationModelEventListener.php

+27-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function beforeFind(CakeEvent $event)
9494

9595
$Model = $event->subject();
9696
$modelName = $Model->name;
97-
if (!in_array($modelName, ['Content', 'Site', 'UploaderFile', 'Dblog'])) return TRUE;
97+
if (!in_array($modelName, ['Content', 'Site', 'UploaderFile', 'Dblog', 'BlogPost'])) return TRUE;
9898

9999
$loginUser = BcUtil::loginUser();
100100
$userGroup = $loginUser['UserGroup']['name'];
@@ -123,14 +123,14 @@ public function beforeFind(CakeEvent $event)
123123
if ($allowedUploads === TRUE) break;
124124

125125
$event->data[0]['conditions'][] = [
126-
'User.user_group_id' => $loginUser['user_group_id']
126+
'User4Operation.user_group_id' => $loginUser['user_group_id']
127127
];
128128
$event->data[0]['joins'][] = [
129129
'type' => 'LEFT',
130130
'table' => 'users',
131-
'alias' => 'User',
131+
'alias' => 'User4Operation',
132132
'conditions' => [
133-
'UploaderFile.user_id = User.id'
133+
'UploaderFile.user_id = User4Operation.id'
134134
]
135135
];
136136
break;
@@ -143,6 +143,29 @@ public function beforeFind(CakeEvent $event)
143143
'User.user_group_id' => $loginUser['user_group_id']
144144
];
145145
break;
146+
147+
case 'BlogPost':
148+
$allowedBlogPosts = Configure::read('Operation.admin.allowedAllUserGroupBlogPosts');
149+
if ($allowedBlogPosts === TRUE) break;
150+
151+
if (!empty($event->data[0]['fields'])
152+
&& ($event->data[0]['fields'] == 'MAX(BlogPost.no) AS max'
153+
|| (is_array($event->data[0]['fields']) && in_array('MAX(BlogPost.no) AS max', $event->data[0]['fields'])))) {
154+
break;
155+
}
156+
157+
$event->data[0]['conditions'][] = [
158+
'User4Operation.user_group_id' => $loginUser['user_group_id']
159+
];
160+
$event->data[0]['joins'][] = [
161+
'type' => 'LEFT',
162+
'table' => 'users',
163+
'alias' => 'User4Operation',
164+
'conditions' => [
165+
'BlogPost.user_id = User4Operation.id'
166+
]
167+
];
168+
break;
146169
}
147170

148171
return TRUE;

README.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ $config['Operation'] = [
1919
        'adminsName' => [
2020
            'admins'
2121
        ],
22-
        'allowedAdminAllOperation'   => TRUE,
23-
        'allowedAllUserGroupUploads' => FALSE,
24-
        'allowedAllUserGroupDblogs'  => FALSE
22+
        'allowedAdminAllOperation'   => TRUE,
23+
        'allowedAllUserGroupUploads' => FALSE,
24+
        'allowedAllUserGroupDblogs'   => FALSE,
25+
'allowedAllUserGroupBlogPosts' => TRUE
2526
    ]
2627
];
2728
```
@@ -44,4 +45,10 @@ $config['Operation'] = [
4445
ダッシュボードの最近の動きに表示するログを設定します。
4546
`Operation.admin.allowedAdminAllOperation` が TRUE の場合、管理者権限ユーザーグループは全アカウントのログを表示します。
4647
- TRUE : 全アカウントのログを表示します。
47-
- FALSE : 同じユーザーグループのアカウントのログのみを表示します。
48+
- FALSE : 同じユーザーグループのアカウントのログのみを表示します。
49+
50+
### Operation.admin.allowedAllUserGroupBlogPosts
51+
ブログ記事一覧に表示するブログ記事を設定します。
52+
`Operation.admin.allowedAdminAllOperation` が TRUE の場合、管理者権限ユーザーグループは全アカウントのブログ記事を表示します。
53+
- TRUE : 全アカウントのブログ記事を表示します。
54+
- FALSE : 同じユーザーグループのアカウントのブログ記事のみを表示します。

VERSION.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
1.1.0
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
<tr>
2-
<th>
2+
<th class="bca-form-table__label">
33
<?php echo $this->BcForm->label('Operation.user_group', __d('baser', '管理ユーザーグループ')); ?>
44
</th>
5-
<td>
5+
<td class="bca-form-table__input">
66
<?php echo $this->BcForm->input('Operation.user_group.all', $op['all_user_group']); ?>
77
<?php echo $this->BcForm->error('Operation.user_group.all'); ?>
8-
<ul class="user_group_check_any">
8+
<ul class="op-checkbox-group-any" data-bca-state="open">
99
<?php foreach ($op['any_user_group'] as $i => $user_group) { ?>
10-
<li>
11-
<?php echo $this->BcForm->input($user_group['name'], $user_group['option']); ?>
12-
<?php echo $this->BcForm->label($user_group['name'], $user_group['label']); ?>
13-
</li>
10+
<li><?php echo $this->BcForm->input($user_group['name'], $user_group['option']); ?></li>
1411
<?php } ?>
1512
</ul>
16-
<?php echo $this->BcForm->error('Operationi.user_group.any'); ?>
13+
<?php echo $this->BcForm->error('Operation.user_group.any'); ?>
1714
</td>
1815
</tr>

View/Helper/OperationHelper.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function getSiteId()
6262
*/
6363
public function setCustomField()
6464
{
65-
$Operation = ClassRegistry::init('Operation.Operation');
65+
$Operation = ClassRegistry::init('Operation.Operation');
6666

6767
$siteId = $this->getSiteId();
6868
$userGroup = $Operation->findUserGroups();
@@ -75,12 +75,12 @@ public function setCustomField()
7575
[
7676
'name' => __d('baser', '全ユーザーグループ'),
7777
'value' => 'ALL',
78-
'class' => 'radio_user_group_all'
78+
'class' => 'bca-radio__input'
7979
],
8080
[
8181
'name' => __d('baser', '特定のユーザーグループ'),
8282
'value' => 0,
83-
'class' => 'radio_user_group_any'
83+
'class' => 'bca-radio__input'
8484
]
8585
]
8686
];
@@ -92,19 +92,19 @@ public function setCustomField()
9292

9393
$anyUserGroupOption = [];
9494
foreach ($userGroup as $userGroupId => $array) {
95-
$isChecked = (!empty($array['Operation'][$siteId])) ? 'checked' : NULL;
95+
$isChecked = (!empty($array['Operation'][$siteId]) || in_array($array['UserGroup']['name'], $adminsName) && $allowedAdminAllOperation === TRUE) ? 'checked' : NULL;
9696
$isDisabled = (in_array($array['UserGroup']['name'], $adminsName) && $allowedAdminAllOperation === TRUE) ? 'disabled' : NULL;
9797
$anyUserGroupOption[] = [
9898
'option' => [
9999
'type' => 'checkbox',
100+
'class' => 'bca-checkbox__input',
100101
'value' => 1,
102+
'label' => $array['UserGroup']['title'],
101103
$isChecked,
102104
$isDisabled
103105
],
104-
'name' => 'Operation.user_group.'.$array['UserGroup']['id'],
105-
'label' => $array['UserGroup']['title']
106+
'name' => 'Operation.user_group.'.$array['UserGroup']['id']
106107
];
107-
108108
}
109109

110110
$data = [
@@ -114,7 +114,7 @@ public function setCustomField()
114114
]
115115
];
116116

117-
$this->BcBaser->element('sites/form', $data);
117+
$this->BcBaser->element('Operation.sites/input_operation', $data);
118118
return;
119119
} // end function setCustomField
120120

webroot/css/admin/style.css

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/**
22
* CustomField
33
*/
4-
ul.user_group_check_any,
5-
input.radio_user_group_all:checked ~ ul.user_group_check_any {
4+
ul.op-checkbox-group-any {
65
display: none;
6+
padding: 0;
77
}
8-
input.radio_user_group_any:checked ~ ul.user_group_check_any {
8+
ul.op-checkbox-group-any[data-bca-state="open"] {
99
display: block;
1010
}
11-
ul.user_group_check_any li {
11+
ul.op-checkbox-group-any li {
12+
list-style: none;
1213
background: none;
1314
}

webroot/js/admin/script.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
window.onload = function() {
2+
let radios = document.getElementsByName('data[Operation][user_group][all]');
3+
let checkboxGroup = document.querySelector('ul.op-checkbox-group-any');
4+
5+
radios.forEach(
6+
radio => {
7+
if (radio.checked == true) switchCheckboxGroup(radio.value);
8+
radio.addEventListener('change', e => {
9+
switchCheckboxGroup(e.target.value);
10+
})
11+
}
12+
);
13+
14+
function switchCheckboxGroup(value) {
15+
if (value == 'ALL') {
16+
checkboxGroup.dataset.bcaState = '';
17+
} else {
18+
checkboxGroup.dataset.bcaState = 'open';
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)