-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRegistrationAnswerFileBehavior.php
More file actions
61 lines (55 loc) · 1.64 KB
/
RegistrationAnswerFileBehavior.php
File metadata and controls
61 lines (55 loc) · 1.64 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
<?php
/**
* RegistrationValidate Behavior
*
* @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
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('RegistrationAnswerBehavior', 'Registrations.Model/Behavior');
/**
* Email Behavior
*
* @package Registrations\Registrations\Model\Befavior\Answer
* @author Allcreator <info@allcreator.net>
*/
class RegistrationAnswerFileBehavior extends RegistrationAnswerBehavior {
/**
* this answer type
*
* @var int
*/
protected $_myType = RegistrationsComponent::TYPE_FILE;
/**
* answerMaxLength 登録が登録フォームが許す最大長を超えていないかの確認
*
* @param object $model use model
* @param array $data Validation対象データ
* @param array $question 登録データに対応する項目
* @param int $max 最大長
* @return bool
*/
public function answerMaxLength($model, $data, $question, $max) {
if ($question['question_type'] != $this->_myType) {
return true;
}
return Validation::maxLength($data['answer_value'], $max);
}
/**
* answerValidation 登録内容の正当性
*
* @param object $model use model
* @param array $data Validation対象データ
* @param array $question 登録データに対応する項目
* @param array $allAnswers 入力された登録すべて
* @return bool
*/
public function answerFileValidation($model, $data, $question, $allAnswers) {
if ($question['question_type'] != $this->_myType) {
return true;
}
return Validation::email($data['answer_value']);
}
}