-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRegistrationFrameSettingsController.php
More file actions
138 lines (127 loc) · 3.63 KB
/
RegistrationFrameSettingsController.php
File metadata and controls
138 lines (127 loc) · 3.63 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
<?php
/**
* Registrations FrameSettingsController
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Allcreator <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('RegistrationBlocksController', 'Registrations.Controller');
/**
* RegistrationFrameSettingsController
*
* @author Allcreator <info@allcreator.net>
* @package NetCommons\Registrations\Controller
*
* @property RegistrationFrameSetting RegistrationFrameSetting
*/
class RegistrationFrameSettingsController extends RegistrationBlocksController {
/**
* layout
*
* @var array
*/
public $layout = 'NetCommons.setting';
/**
* use model
*
* @var array
*/
public $uses = array(
'Blocks.Block',
'Frames.Frame',
'Registrations.Registration',
'Registrations.RegistrationFrameSetting',
'Registrations.RegistrationFrameDisplayRegistration',
);
/**
* use components
*
* @var array
*/
public $components = array(
'NetCommons.Permission' => array(
//アクセスの権限
'allow' => array(
'edit' => 'page_editable',
),
),
'Registrations.Registrations',
'Paginator',
);
/**
* use helpers
*
* @var array
*/
public $helpers = array(
'NetCommons.Date',
'Registrations.RegistrationUtil',
'Blocks.BlockTabs' => array(
'mainTabs' => array(
'block_index' => array('url' => array('controller' => 'registration_blocks')),
'role_permissions' => array('url' => array('controller' => 'registration_block_role_permissions')),
'frame_settings' => array('url' => array('controller' => 'registration_frame_settings')),
),
),
);
/**
* edit method
*
* @return void
*/
public function edit() {
// Postデータ登録
if ($this->request->isPut() || $this->request->isPost()) {
if ($this->RegistrationFrameSetting->saveFrameSettings($this->request->data)) {
$this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array(
'class' => 'success',
));
$this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
$this->NetCommons->handleValidationError($this->RegistrationFrameSetting->validationErrors);
}
$conditions = array(
'block_id' => Current::read('Block.id'),
'is_latest' => true,
);
$this->paginate = array(
'fields' => array('Registration.*', 'RegistrationFrameDisplayRegistration.*'),
'conditions' => $conditions,
'page' => 1,
'sort' => RegistrationsComponent::DISPLAY_SORT_TYPE_NEW_ARRIVALS,
'limit' => 1000,
'direction' => 'desc',
'recursive' => -1,
'joins' => array(
array(
'table' => 'registration_frame_display_registrations',
'alias' => 'RegistrationFrameDisplayRegistration',
'type' => 'LEFT',
'conditions' => array(
'RegistrationFrameDisplayRegistration.registration_key = Registration.key',
'RegistrationFrameDisplayRegistration.frame_key' => Current::read('Frame.key'),
),
)
)
);
$registrations = $this->paginate('Registration');
$frame = $this->RegistrationFrameSetting->find('first', array(
'conditions' => array(
'frame_key' => Current::read('Frame.key'),
),
'order' => 'RegistrationFrameSetting.id DESC'
));
if (!$frame) {
$frame = $this->RegistrationFrameSetting->getDefaultFrameSetting();
}
$this->set('registrations', $registrations);
$this->set('registrationFrameSettings', $frame['RegistrationFrameSetting']);
$this->request->data['RegistrationFrameSetting'] = $frame['RegistrationFrameSetting'];
$this->request->data['Frame'] = Current::read('Frame');
$this->request->data['Block'] = Current::read('Block');
}
}