-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMailFormHelper.php
More file actions
159 lines (152 loc) · 5.29 KB
/
MailFormHelper.php
File metadata and controls
159 lines (152 loc) · 5.29 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
<?php
/**
* MailFormHelper
*
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('AppHelper', 'View/Helper');
App::uses('MailSettingFixedPhrase', 'Mails.Model');
/**
* MailFormHelper
*
* @package NetCommons\ContentComments\View\Helper
*/
class MailFormHelper extends AppHelper {
/**
* メール設定
*
* #### Sample code
* ##### template file(ctp file) - 通常パターン
* ```php
* <?php echo $this->MailForm->editFrom(
* array(
* array(
* 'mailBodyPopoverMessage' => __d('videos', 'MailSetting.mail_fixed_phrase_body.popover'),
* )
* ),
* NetCommonsUrl::backToIndexUrl('default_setting_action')
* ); ?>
* ```
*
* ##### template file(ctp file) - 問合せ先メールアドレス, 通知する権限 承認メール通知機能を使う 非表示
* ```php
* <?php echo $this->MailForm->editFrom(
* array(
* array(
* 'mailBodyPopoverMessage' => __d('videos', 'MailSetting.mail_fixed_phrase_body.popover'),
* 'useNoticeAuthority' => 0, // 通知する権限 非表示
* )
* ),
* NetCommonsUrl::backToIndexUrl('default_setting_action'),
* 0, // 問合せ先メールアドレス 非表示
* 0, // メール通知機能を使う ヘルプメッセージ 非表示
* 0 // 承認メール通知機能を使う 非表示
* ); ?>
* ```
*
* ##### template file(ctp file) - 回答メールありパターン
* ```php
* <?php echo $this->MailForm->editFrom(
* array(
* array(
* 'mailBodyPopoverMessage' => __d('videos', 'MailSetting.mail_fixed_phrase_body.popover'),
* ),
* array(
* 'mailBodyPopoverMessage' => __d('videos', 'MailSetting.mail_fixed_phrase_body.popover'),
* ),
* ),
* NetCommonsUrl::backToIndexUrl('default_setting_action')
* ); ?>
* ```
*
* ##### template file(ctp file) - メール通知機能を使う ヘルプメッセージ表示
* ```php
* <?php echo $this->MailForm->editFrom(
* array(
* array(
* 'mailBodyPopoverMessage' => __d('videos', 'MailSetting.mail_fixed_phrase_body.popover'),
* )
* ),
* NetCommonsUrl::backToIndexUrl('default_setting_action'),
* 1, // 問合せ先メールアドレス 表示
* 1 // メール通知機能を使う ヘルプメッセージ 表示
* ); ?>
* ```
*
* ##### template file(ctp file) - 承認メール通知機能を使う のみ表示
* ```php
* <?php echo $this->MailForm->editFrom(
* array(),
* NetCommonsUrl::backToIndexUrl('default_setting_action'),
* 0, // 問合せ先メールアドレス 非表示
* 0, // メール通知機能を使う ヘルプメッセージ 非表示
* 1, // 承認メール通知機能を使う 表示
* 0 // メール通知機能を使う 非表示
* ); ?>
* ```
*
* @param array $editForms 編集フォーム設定
* @param string $cancelUrl キャンセルボタン遷移先URL
* @param int $useReplyTo 問合せ先メールアドレスを使う
* @param int $isMailSendHelp メール通知機能を使うヘルプメッセージを表示するか
* @param int $useMailSendApproval 承認メール通知機能を使う を表示するか
* @param int $useMailSend メール通知機能を使う 及び関連項目を表示するか
* @param array $options フォームオプション
* @param string $action 決定ボタン遷移先URL
* @return string HTML tags
*/
public function editFrom($editForms = array(), $cancelUrl = null, $useReplyTo = 0,
$isMailSendHelp = 0, $useMailSendApproval = 1, $useMailSend = 1,
$options = array(), $action = null) {
$output = '';
if (isset($action)) {
$options['url'] = $action;
}
if (count($editForms) == 2) {
// $editForms 2件は、回答メールありと推定
$editForms = Hash::merge(array(
array(
'mailTypeKey' => MailSettingFixedPhrase::DEFAULT_TYPE,
'panelHeading' => __d('mails', 'Posting mail'),
'mailBodyPopoverMessage' => __d('mails', 'MailSetting.mail_fixed_phrase_body.popover'),
'permission' => 'mail_content_receivable',
'useNoticeAuthority' => 1,
'permissionOnly' => false,
),
array(
'mailTypeKey' => MailSettingFixedPhrase::ANSWER_TYPE,
'panelHeading' => __d('mails', 'Answer mail'),
'mailBodyPopoverMessage' => __d('mails', 'MailSetting.mail_fixed_phrase_body.popover.answer'),
'permission' => 'mail_answer_receivable',
'useNoticeAuthority' => 1,
'permissionOnly' => false,
),
), $editForms);
} else {
// 通常
$editForms = Hash::merge(array(
array(
'mailTypeKey' => MailSettingFixedPhrase::DEFAULT_TYPE,
'panelHeading' => __d('mails', 'Posting mail'),
'mailBodyPopoverMessage' => __d('mails', 'MailSetting.mail_fixed_phrase_body.popover'),
'permission' => 'mail_content_receivable',
'useNoticeAuthority' => 1,
'permissionOnly' => false,
),
), $editForms);
}
$output .= $this->_View->element('Mails.edit_form', array(
'editForms' => $editForms,
'useReplyTo' => $useReplyTo,
'isMailSendHelp' => $isMailSendHelp,
'useMailSendApproval' => $useMailSendApproval,
'useMailSend' => $useMailSend,
'cancelUrl' => $cancelUrl,
'options' => $options,
));
return $output;
}
}