source: extensions/user_custom_fields/initregister.php @ 31962

Last change on this file since 31962 was 31846, checked in by ddtddt, 7 years ago

[extensions] - user_custom_fields -

File size: 3.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | User Custom Fields plugin for Piwigo                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2016-2017 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                $template->assign('useED',1);
44    }else{
45        $template->assign('useED',0);
46    }
47  $tab_user_register=tab_user_custom_fields_register();
48  while ($info_users = pwg_db_fetch_assoc($tab_user_register)) {
49        $items = array(
50                'UCFID' => $info_users['id_ucf'],
51                'UCFWORDING' => trigger_change('AP_render_content', $info_users['wording']),
52                'UCFOBLIGATORY' => $info_users['obligatory'],
53        );
54        $template->append('add_uers_register', $items);
55  }
56}
57
58
59add_event_handler('register_user_check', 'ucfT');
60function ucfT($errors){
61  global $prefixeTable,$conf;
62  if (count($errors) == 0){
63        $next = pwg_db_fetch_assoc(pwg_query("SHOW TABLE STATUS LIKE '".USERS_TABLE."';"));
64        $next_id = $next['Auto_increment'];
65 
66        foreach ($_POST['data'] AS $id_ucf => $data) {
67          $query = 'INSERT ' . $prefixeTable . 'user_custom_fields_data(id_user,id_ucf,data) VALUES (' . $next_id . ',' . $id_ucf . ',"' . $data . '");';
68          pwg_query($query);
69        }       
70  }
71  return $errors;
72}
73
74?>
Note: See TracBrowser for help on using the repository browser.