source: extensions/user_custom_fields/initregister.php @ 32592

Last change on this file since 32592 was 32592, checked in by ddtddt, 3 years ago

[user_custom_fields] delete use ED tag in register

File size: 3.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | User Custom Fields plugin for Piwigo by TEMMII                        |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2016-2021 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
24add_event_handler('loc_end_page_header', 'ucfI', 55 );
25function 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
32function ucfIT($content, &$smarty){
33  $search = '/(<fieldset>).*(<\/fieldset>)/is';
34  return preg_replace($search, '{$UCF_REGISTER_ADD}', $content);
35}
36
37add_event_handler('loc_end_page_header', 'ucfinit');
38function ucfinit(){
39  global $template;
40  $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
41        if($PAED['state'] == 'active'){
42                add_event_handler('AP_render_content', 'get_user_language_desc');
43    }
44  $tab_user_register=tab_user_custom_fields_register();
45  while ($info_users = pwg_db_fetch_assoc($tab_user_register)) {
46        $items = array(
47                'UCFID' => $info_users['id_ucf'],
48                'UCFWORDING' => trigger_change('AP_render_content', $info_users['wording']),
49                'UCFOBLIGATORY' => $info_users['obligatory'],
50        );
51        $template->append('add_uers_register', $items);
52  }
53}
54
55
56add_event_handler('register_user_check', 'ucfT');
57function ucfT($errors){
58  global $prefixeTable,$conf;
59  if (count($errors) == 0){
60        $next = pwg_db_fetch_assoc(pwg_query("SHOW TABLE STATUS LIKE '".USERS_TABLE."';"));
61        $next_id = $next['Auto_increment'];
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?>
Note: See TracBrowser for help on using the repository browser.