-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathQuizFrameSettingsController.php
More file actions
139 lines (131 loc) · 3.52 KB
/
QuizFrameSettingsController.php
File metadata and controls
139 lines (131 loc) · 3.52 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
<?php
/**
* Quizzes 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('QuizzesAppSettingController', 'Quizzes.Controller');
/**
* QuizFrameSettingsController
*
* @author Allcreator <info@allcreator.net>
* @package NetCommons\Quizzes\Controller
*/
class QuizFrameSettingsController extends QuizzesAppSettingController {
/**
* layout
*
* @var array
*/
public $layout = 'NetCommons.setting';
/**
* use model
*
* @var array
*/
public $uses = array(
'Blocks.Block',
'Frames.Frame',
'Quizzes.Quiz',
'Quizzes.QuizFrameSetting',
'Quizzes.QuizFrameDisplayQuiz',
);
/**
* use components
*
* @var array
*/
public $components = array(
'NetCommons.Permission' => array(
//アクセスの権限
'allow' => array(
'edit' => 'page_editable',
),
),
'Quizzes.Quizzes',
'Paginator',
);
/**
* use helpers
*
* @var array
*/
public $helpers = array(
'Blocks.BlockTabs' => array(
'mainTabs' => array(
'block_index' => array('url' => array('controller' => 'quiz_blocks')),
'role_permissions' => array('url' => array('controller' => 'quiz_block_role_permissions')),
'frame_settings' => array('url' => array('controller' => 'quiz_frame_settings')),
'mail_settings' => array('url' => array('controller' => 'quiz_mail_settings')),
),
),
'NetCommons.DisplayNumber',
'NetCommons.Date',
);
/**
* edit method
*
* @return void
*/
public function edit() {
// Postデータ登録
if ($this->request->is('put') || $this->request->is('post')) {
if ($this->QuizFrameSetting->saveFrameSettings($this->request->data)) {
$this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array(
'class' => 'success',
));
$this->redirect(NetCommonsUrl::backToPageUrl(true));
return;
}
$this->NetCommons->handleValidationError($this->QuizFrameSetting->validationErrors);
} else {
$frame = $this->QuizFrameSetting->find('first', array(
'conditions' => array(
'frame_key' => Current::read('Frame.key'),
),
'order' => 'QuizFrameSetting.id DESC'
));
// ここに来る前にbeforeFilterで必ず$frameに相当する情報は作られていることが
// 保証されているのでチェックは行わないことにする
//if (!$frame) {
// $frame = $this->QuizFrameSetting->getDefaultFrameSetting();
//}
$this->request->data['QuizFrameSetting'] = $frame['QuizFrameSetting'];
$this->request->data['Frame'] = Current::read('Frame');
$this->request->data['Block'] = Current::read('Block');
}
$quizzes = $this->Quiz->find('all', array(
'fields' => array(
'Quiz.id',
'Quiz.key',
'Quiz.status',
'Quiz.title',
'Quiz.answer_start_period',
'Quiz.answer_end_period',
'Quiz.modified',
'QuizFrameDisplayQuiz.id',
'QuizFrameDisplayQuiz.frame_key',
'QuizFrameDisplayQuiz.quiz_key',
),
'conditions' => $this->Quiz->getBaseCondition(),
'order' => array('Quiz.created' => 'DESC'),
'recursive' => -1,
'joins' => array(
array(
'table' => 'quiz_frame_display_quizzes',
'alias' => 'QuizFrameDisplayQuiz',
'type' => 'LEFT',
'conditions' => array(
'QuizFrameDisplayQuiz.quiz_key = Quiz.key',
'QuizFrameDisplayQuiz.frame_key' => Current::read('Frame.key'),
),
)
)
));
$this->set('quizzes', $quizzes);
}
}