-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReservationSettingsComponent.php
More file actions
177 lines (158 loc) · 4.46 KB
/
ReservationSettingsComponent.php
File metadata and controls
177 lines (158 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
/**
* ReservationSettingsComponent.php
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Ryuji AMANO <ryuji@ryus.co.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
App::uses('Component', 'Controller');
App::uses('BlockTabsHelper', 'Blocks.View/Helper');
/**
* Class ReservationSettingsComponent
*/
class ReservationSettingsComponent extends Component {
/**
* タブの定数(表示方法変更)
*
* @var string
*/
const MAIN_TAB_FRAME_SETTING = BlockTabsHelper::MAIN_TAB_FRAME_SETTING;
/**
* タブの定数(施設設定)
*
* @var string
*/
const MAIN_TAB_LOCATION_SETTING = 'location_settings';
/**
* タブの定数(施設カテゴリ設定)
*
* @var string
*/
const MAIN_TAB_CATEGORY_SETTING = 'category_settings';
/**
* タブの定数(時間枠設定)
*
* @var string
*/
const MAIN_TAB_TIMEFRAME_SETTING = 'timeframe_settings';
/**
* タブの定数(予約のインポート)
*
* @var string
*/
const MAIN_TAB_IMPORT_RESERVATIONS = 'import_reservations';
/**
* タブの定数(メール設定)
*
* @var string
*/
const MAIN_TAB_MAIL_SETTING = BlockTabsHelper::MAIN_TAB_MAIL_SETTING;
/**
* パーミッション定数(サイト管理者)
*
* @var string
*/
const PERMISSION_LOCATION_EDITABLE = 'location_editable';
/**
* パーミッション定数(ページ設定できる権限)
*
* @var string
*/
const PERMISSION_ROOM_EDITABLE = 'room_editable';
/**
* パーミッション
*
*
* @var string value=site_editable or page_editable
*/
public $permission = self::PERMISSION_LOCATION_EDITABLE;
/**
* BlockTabsHelper設定
*
* @var array
*/
public $blockTabs = array();
/**
* BlockTabsHelper設定
*
* @var array
*/
protected $_adminBlockTabs = array(
//画面上部のタブ設定
'mainTabs' => array(
self::MAIN_TAB_CATEGORY_SETTING => [ //施設カテゴリ設定
'label' => ['reservations', 'Location category setting'],
'url' => array('controller' => 'reservation_location_categories', 'action' => 'edit')
],
self::MAIN_TAB_LOCATION_SETTING => array( //施設設定
'label' => ['reservations', 'Location setting'],
'url' => array('controller' => 'reservation_locations', 'action' => 'index')
),
self::MAIN_TAB_TIMEFRAME_SETTING => array( //時間枠設定
'label' => ['reservations', 'TimeFrame setting'],
'url' => array('controller' => 'reservation_timeframes', 'action' => 'index')
),
self::MAIN_TAB_IMPORT_RESERVATIONS => array( //予約のインポート
'label' => ['reservations', 'Import Reservations'],
'url' => array('controller' => 'reservation_import', 'action' => 'edit')
),
self::MAIN_TAB_FRAME_SETTING => array( //表示設定変更
'url' => array('controller' => 'reservation_frame_settings')
),
self::MAIN_TAB_MAIL_SETTING => array( //メール設定
'url' => array('controller' => 'reservation_mail_settings'),
),
),
'mainTabsOrder' => [
self::MAIN_TAB_FRAME_SETTING,
self::MAIN_TAB_LOCATION_SETTING,
self::MAIN_TAB_CATEGORY_SETTING,
self::MAIN_TAB_TIMEFRAME_SETTING,
self::MAIN_TAB_MAIL_SETTING,
self::MAIN_TAB_IMPORT_RESERVATIONS
],
);
/**
* BlockTabsHelper設定
*
* @var array
*/
protected $_generalBlockTabs = array(
//画面上部のタブ設定
'mainTabs' => array(
self::MAIN_TAB_FRAME_SETTING => array( //表示設定変更
'url' => array('controller' => 'reservation_frame_settings')
),
),
'mainTabsOrder' => [
self::MAIN_TAB_FRAME_SETTING,
],
);
/**
* Called after the Controller::beforeFilter() and before the controller action
*
* @param Controller $controller Controller with components to startup
* @return void
* @throws ForbiddenException
*/
public function startup(Controller $controller) {
//サイト管理者のみ編集可=ページ編集権限があり、サイト管理が使えるユーザ
$isAdmin = Current::permission('page_editable') && Current::allowSystemPlugin('site_manager');
$controller->set('isAdmin', $isAdmin);
if ($isAdmin) {
$this->blockTabs = $this->_adminBlockTabs;
} else {
$this->blockTabs = $this->_generalBlockTabs;
}
if ($this->permission === self::PERMISSION_LOCATION_EDITABLE &&
$controller->viewVars['isAdmin'] ||
$this->permission === self::PERMISSION_ROOM_EDITABLE &&
Current::permission('page_editable')) {
$controller->helpers['Blocks.BlockTabs'] = $this->blockTabs;
return;
}
throw new ForbiddenException('Permission denied');
}
}