1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | User Custom Fields plugin for Piwigo by TEMMII | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2016-2022 ddtddt http://temmii.com/piwigo/ | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | This program is free software; you can redistribute it and/or modify | |
---|
8 | // | it under the terms of the GNU General Public License as published by | |
---|
9 | // | the Free Software Foundation | |
---|
10 | // | | |
---|
11 | // | This program is distributed in the hope that it will be useful, but | |
---|
12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
14 | // | General Public License for more details. | |
---|
15 | // | | |
---|
16 | // | You should have received a copy of the GNU General Public License | |
---|
17 | // | along with this program; if not, write to the Free Software | |
---|
18 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
19 | // | USA. | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | |
---|
22 | //add prefiter |
---|
23 | |
---|
24 | add_event_handler('loc_end_page_header', 'ucfI', 55 ); |
---|
25 | function ucfI(){ |
---|
26 | global $template; |
---|
27 | $template->set_prefilter('register', 'ucfIT'); |
---|
28 | $template->set_filename('ucf_register_add', realpath(UCF_PATH.'ucf_register_add.tpl')); |
---|
29 | $template->assign_var_from_handle('UCF_REGISTER_ADD', 'ucf_register_add'); |
---|
30 | } |
---|
31 | |
---|
32 | function ucfIT($content){ |
---|
33 | $search = '/(<fieldset>).*(<\/fieldset>)/is'; |
---|
34 | return preg_replace($search, '{$UCF_REGISTER_ADD}', $content); |
---|
35 | } |
---|
36 | |
---|
37 | add_event_handler('loc_end_page_header', 'ucfinit'); |
---|
38 | function ucfinit(){ |
---|
39 | global $template, $pwg_loaded_plugins; |
---|
40 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
41 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
42 | } |
---|
43 | $tab_user_register=tab_user_custom_fields_register(); |
---|
44 | while ($info_users = pwg_db_fetch_assoc($tab_user_register)) { |
---|
45 | $items = array( |
---|
46 | 'UCFID' => $info_users['id_ucf'], |
---|
47 | 'UCFWORDING' => trigger_change('AP_render_content', $info_users['wording']), |
---|
48 | 'UCFOBLIGATORY' => $info_users['obligatory'], |
---|
49 | ); |
---|
50 | $template->append('add_uers_register', $items); |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | add_event_handler('register_user_check', 'ucfT'); |
---|
56 | function ucfT($errors){ |
---|
57 | global $prefixeTable, $conf; |
---|
58 | if (count($errors) == 0){ |
---|
59 | $next = pwg_db_fetch_assoc(pwg_query("SHOW TABLE STATUS LIKE '".USERS_TABLE."';")); |
---|
60 | $next_id = $next['Auto_increment']; |
---|
61 | |
---|
62 | |
---|
63 | foreach ($_POST['data'] AS $id_ucf => $data) { |
---|
64 | $query = 'INSERT ' . $prefixeTable . 'user_custom_fields_data(id_user,id_ucf,data) VALUES (' . $next_id . ',' . $id_ucf . ',"' . $data . '");'; |
---|
65 | pwg_query($query); |
---|
66 | } |
---|
67 | } |
---|
68 | return $errors; |
---|
69 | } |
---|
70 | |
---|
71 | ?> |
---|