-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRegistrationAddController.php
More file actions
106 lines (96 loc) · 3.1 KB
/
RegistrationAddController.php
File metadata and controls
106 lines (96 loc) · 3.1 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
<?php
/**
* RegistrationsAdd Controller
*
* @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('AppController', 'Controller');
/**
* RegistrationsAddController
*
* @author Allcreator <info@allcreator.net>
* @package NetCommons\Registrations\Controller
*/
class RegistrationAddController extends RegistrationsAppController {
/**
* use model
*
* @var array
*/
public $uses = array(
'Files.FileModel', // FileUpload
'PluginManager.Plugin',
);
/**
* use components
*
* @var array
*/
public $components = array(
'Files.FileUpload', // FileUpload
'NetCommons.Permission' => array(
//アクセスの権限
'allow' => array(
'add' => 'content_creatable',
),
),
'Registrations.Registrations',
);
/**
* use helpers
*
* @var array
*/
public $helpers = array(
'Registrations.RegistrationStatusLabel',
'Registrations.RegistrationUtil'
);
/**
* add registration display method
*
* @return void
*/
public function add() {
// NetCommonsお約束:投稿権限のある人物しかこのアクションにアクセスできない
// それは$componentsの組み込みでallow => add => content_creatableで担保される
// アクション処理内でチェックする必要はない
// POSTされたデータを読み取り
if ($this->request->isPost()) {
// Postデータをもとにした新登録フォームデータの取得をModelに依頼する
$actionModel = ClassRegistry::init('Registrations.ActionRegistrationAdd', 'true');
if ($registration = $actionModel->createRegistration($this->request->data)) {
$tm = $this->_getRegistrationEditSessionIndex();
// 作成中登録フォームデータをセッションキャッシュに書く
$this->Session->write('Registrations.registrationEdit.' . $tm, $registration);
// 次の画面へリダイレクト
$this->redirect(NetCommonsUrl::actionUrl(array(
'controller' => 'registration_edit',
'action' => 'edit_question',
Current::read('Block.id'),
'frame_id' => Current::read('Frame.id'),
's_id' => $tm,
)));
return;
} else {
// データに不備があった場合
$this->NetCommons->handleValidationError($actionModel->validationErrors);
}
}
// 過去データ 取り出し
$pastRegistrations = $this->Registration->getRegistrationsList(array(), array('limit' => 1000), array('recursive' => -1));
$this->set('pastRegistrations', $pastRegistrations);
//
// NetCommonsお約束:投稿のデータはrequest dataに設定する
//
$this->request->data['Frame'] = Current::read('Frame');
$this->request->data['Block'] = Current::read('Block');
// create_optionが未設定のときは初期値として「NEW」を設定する
if (! $this->request->data('ActionRegistrationAdd.create_option')) {
$this->request->data('ActionRegistrationAdd.create_option', RegistrationsComponent::REGISTRATION_CREATE_OPT_NEW);
}
}
}