1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2006 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class ktai_do_o_insert_c_member extends OpenPNE_Action |
---|
8 | { |
---|
9 | function isSecure() |
---|
10 | { |
---|
11 | return false; |
---|
12 | } |
---|
13 | |
---|
14 | function execute($requests) |
---|
15 | { |
---|
16 | //<PCKTAI |
---|
17 | if (defined('OPENPNE_REGIST_FROM') && |
---|
18 | !((OPENPNE_REGIST_FROM & OPENPNE_REGIST_FROM_KTAI) >> 1)) { |
---|
19 | openpne_redirect('ktai', 'page_o_login'); |
---|
20 | } |
---|
21 | //> |
---|
22 | |
---|
23 | // --- リクエスト変数 |
---|
24 | $ses = $requests['ses']; |
---|
25 | // ---------- |
---|
26 | |
---|
27 | //--- 権限チェック |
---|
28 | //セッションが有効 |
---|
29 | |
---|
30 | // セッションが有効かどうか |
---|
31 | if (!$pre = c_member_ktai_pre4session($ses)) { |
---|
32 | // 無効の場合、login へリダイレクト |
---|
33 | openpne_redirect('ktai', 'page_o_login'); |
---|
34 | } |
---|
35 | //--- |
---|
36 | |
---|
37 | $errors = array(); |
---|
38 | |
---|
39 | $validator = new OpenPNE_Validator(); |
---|
40 | $validator->addRequests($_REQUEST); |
---|
41 | $validator->addRules($this->_getValidateRules()); |
---|
42 | if (!$validator->validate()) { |
---|
43 | $errors = $validator->getErrors(); |
---|
44 | } |
---|
45 | |
---|
46 | $prof = $validator->getParams(); |
---|
47 | |
---|
48 | //--- c_profile の項目をチェック |
---|
49 | $validator = new OpenPNE_Validator(); |
---|
50 | $validator->addRequests($_REQUEST['profile']); |
---|
51 | $validator->addRules($this->_getValidateRulesProfile()); |
---|
52 | if (!$validator->validate()) { |
---|
53 | $errors = array_merge($errors, $validator->getErrors()); |
---|
54 | } |
---|
55 | |
---|
56 | // 値の整合性をチェック(DB) |
---|
57 | $c_member_profile_list = do_config_prof_check_profile($validator->getParams(), $_REQUEST['public_flag']); |
---|
58 | |
---|
59 | // 必須項目チェック |
---|
60 | $profile_list = db_common_c_profile_list4null(); |
---|
61 | foreach ($profile_list as $profile) { |
---|
62 | if ($profile['disp_regist'] && |
---|
63 | $profile['is_required'] && |
---|
64 | !$c_member_profile_list[$profile['name']]['value'] |
---|
65 | ) { |
---|
66 | $errors[$profile['name']] = "{$profile['caption']}を入力してください"; |
---|
67 | break; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | // 生年月日のチェック |
---|
72 | if (!t_checkdate($prof['birth_month'], $prof['birth_day'], $prof['birth_year'])) { |
---|
73 | $errors[] = '生年月日を正しく入力してください'; |
---|
74 | } |
---|
75 | if (t_isFutureDate($prof['birth_day'], $prof['birth_month'], $prof['birth_year'])) { |
---|
76 | $errors[] = '生年月日を未来に設定することはできません'; |
---|
77 | } |
---|
78 | |
---|
79 | // 入力エラー |
---|
80 | if ($errors) { |
---|
81 | ktai_display_error($errors); |
---|
82 | } |
---|
83 | |
---|
84 | // insert c_member |
---|
85 | $prof['ktai_address'] = $pre['ktai_address']; |
---|
86 | $prof['c_member_id_invite'] = $pre['c_member_id_invite']; |
---|
87 | |
---|
88 | switch ($prof['public_flag_birth_year']) { |
---|
89 | case "public": |
---|
90 | default: |
---|
91 | $prof['public_flag_birth_year'] = "public"; |
---|
92 | break; |
---|
93 | case "friend": |
---|
94 | $prof['public_flag_birth_year'] = "friend"; |
---|
95 | break; |
---|
96 | case "private": |
---|
97 | $prof['public_flag_birth_year'] = "private"; |
---|
98 | break; |
---|
99 | } |
---|
100 | |
---|
101 | if (!$c_member_id = k_do_insert_c_member($prof)) { |
---|
102 | openpne_redirect('ktai', 'page_o_login'); |
---|
103 | } |
---|
104 | // insert c_member_profile |
---|
105 | do_config_prof_update_c_member_profile($c_member_id, $c_member_profile_list); |
---|
106 | |
---|
107 | // insert c_friend(紹介者) |
---|
108 | db_friend_insert_c_friend($c_member_id, $pre['c_member_id_invite']); |
---|
109 | |
---|
110 | //管理画面で指定したコミュニティに強制参加 |
---|
111 | $c_commu_id_list = db_commu_regist_join_list(); |
---|
112 | foreach ($c_commu_id_list as $c_commu_id) { |
---|
113 | do_inc_join_c_commu($c_commu_id, $c_member_id); |
---|
114 | } |
---|
115 | |
---|
116 | // delete c_member_ktai_pre |
---|
117 | k_do_delete_c_member_ktai_pre($pre['c_member_ktai_pre_id']); |
---|
118 | |
---|
119 | |
---|
120 | do_insert_c_member_mail_send($c_member_id, $prof['password'], $pre['ktai_address']); |
---|
121 | |
---|
122 | openpne_redirect('ktai', 'page_o_regist_end'); |
---|
123 | } |
---|
124 | |
---|
125 | function _getValidateRules() |
---|
126 | { |
---|
127 | return array( |
---|
128 | 'nickname' => array( |
---|
129 | 'type' => 'string', |
---|
130 | 'required' => '1', |
---|
131 | 'caption' => 'ニックネーム', |
---|
132 | 'max' => '40', |
---|
133 | ), |
---|
134 | 'birth_year' => array( |
---|
135 | 'type' => 'int', |
---|
136 | 'required' => '1', |
---|
137 | 'caption' => '生まれた年', |
---|
138 | 'min' => '1901', |
---|
139 | 'max' => date('Y'), |
---|
140 | ), |
---|
141 | 'birth_month' => array( |
---|
142 | 'type' => 'int', |
---|
143 | 'required' => '1', |
---|
144 | 'caption' => '誕生月', |
---|
145 | 'min' => '1', |
---|
146 | 'max' => '12', |
---|
147 | ), |
---|
148 | 'birth_day' => array( |
---|
149 | 'type' => 'int', |
---|
150 | 'required' => '1', |
---|
151 | 'caption' => '誕生日', |
---|
152 | 'min' => '1', |
---|
153 | 'max' => '31', |
---|
154 | ), |
---|
155 | 'public_flag_birth_year' => array( |
---|
156 | 'type' => 'string', |
---|
157 | ), |
---|
158 | 'password' => array( |
---|
159 | 'type' => 'regexp', |
---|
160 | 'regexp' => '/^[a-z0-9]+$/i', |
---|
161 | 'required' => '1', |
---|
162 | 'caption' => 'パスワード', |
---|
163 | 'min' => '6', |
---|
164 | 'max' => '12', |
---|
165 | ), |
---|
166 | 'c_password_query_id' => array( |
---|
167 | 'type' => 'int', |
---|
168 | 'required' => '1', |
---|
169 | 'caption' => '秘密の質問', |
---|
170 | 'required_error' => '秘密の質問を選択してください', |
---|
171 | ), |
---|
172 | 'password_query_answer' => array( |
---|
173 | 'type' => 'string', |
---|
174 | 'required' => '1', |
---|
175 | 'caption' => '秘密の質問の答え', |
---|
176 | ), |
---|
177 | ); |
---|
178 | } |
---|
179 | |
---|
180 | function _getValidateRulesProfile() |
---|
181 | { |
---|
182 | $rules = array(); |
---|
183 | $profile_list = db_common_c_profile_list4null(); |
---|
184 | foreach ($profile_list as $profile) { |
---|
185 | if ($profile['disp_regist']) { |
---|
186 | $rule = array( |
---|
187 | 'type' => 'int', |
---|
188 | 'required' => $profile['is_required'], |
---|
189 | 'caption' => $profile['caption'], |
---|
190 | ); |
---|
191 | switch ($profile['form_type']) { |
---|
192 | case 'text': |
---|
193 | case 'textlong': |
---|
194 | case 'textarea': |
---|
195 | $rule['type'] = $profile['val_type']; |
---|
196 | $rule['regexp'] = $profile['val_regexp']; |
---|
197 | $rule['min'] = $profile['val_min']; |
---|
198 | ($profile['val_max']) and $rule['max'] = $profile['val_max']; |
---|
199 | break; |
---|
200 | case 'checkbox': |
---|
201 | $rule['is_array'] = '1'; |
---|
202 | break; |
---|
203 | } |
---|
204 | $rules[$profile['name']] = $rule; |
---|
205 | } |
---|
206 | } |
---|
207 | return $rules; |
---|
208 | } |
---|
209 | } |
---|
210 | |
---|
211 | ?> |
---|