source: extensions/Register_FluxBB/tags/2.1.1/main.inc.php @ 3779

Revision 3779, 5.8 KB checked in by Eric, 11 years ago (diff)

2.1.2 : Compatibility bug fixed when used with DynamicRecentPeriod plugin

  • Property svn:eol-style set to LF
Line 
1<?php
2/*
3Plugin Name: Register FluxBB
4Version: 2.1.2
5Description: Link user registration from Piwigo to FluxBB forum (registration, password changing, deletion) - Original Nicco's NBC_LinkUser2PunBB plugin upgraded to Piwigo / Liez l'inscription des utilisateurs de Piwigo avec votre forum FluxBB - Portage du plugin NBC_LinkUser2PunBB de Nicco vers Piwigo
6Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=252
7Author: Eric
8Author URI: http://www.infernoweb.net
9*/
10
11/*
12--------------------------------------------------------------------------------
13  Author     : Eric
14    email    : lucifer@infernoweb.net
15    website  : http://www.infernoweb.net
16    PWG user : http://forum.phpwebgallery.net/profile.php?id=1106
17--------------------------------------------------------------------------------
18
19:: HISTORY
20
212.0.0b                  - 23/11/08  - Initial release. Basic changes to be available for Piwigo 2.0RC4
22
232.0.1b                  - 24/11/08  - Small bug correction on submit button display
24
252.0.2                   - 19/02/09      - Language pack correction
26
272.1.0                   - 25/04/09  - Admin panel with tabsheets
28                                                        - Radio buttons functionnalities corrections (now radio buttons show the configuration saved in database)
29                                                        - Language files (fr - en) improvement
30
312.1.1                   - 30/04/09      - Bux fixed on profile update
32
332.1.2                   - 22/08/09      - Compatibility bug fixed when used with DynamicRecentPeriod plugin
34
35--------------------------------------------------------------------------------
36*/
37
38// pour faciliter le debug - make debug easier :o)
39//ini_set('error_reporting', E_ALL);
40//ini_set('display_errors', true);
41
42if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
43
44define('Register_FluxBB_DIR' , basename(dirname(__FILE__)));
45define('Register_FluxBB_PATH' , PHPWG_PLUGINS_PATH . Register_FluxBB_DIR . '/');
46include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php');
47
48/* plugin administration */
49add_event_handler('get_admin_plugin_menu_links', 'Register_FluxBB_admin_menu');
50
51function Register_FluxBB_admin_menu($menu)
52{
53  array_push($menu, array(
54      'NAME' => 'Register FluxBB',
55      'URL'  => get_admin_plugin_menu_link(Register_FluxBB_PATH.'admin/Register_FluxBB_admin.php')));
56      return $menu;
57}
58
59
60/* user creation*/
61add_event_handler('register_user', 'Register_FluxBB_Adduser');
62
63function Register_FluxBB_Adduser($register_user)
64{
65        global $conf;
66       
67  include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php');
68
69  FluxBB_Adduser($register_user['id'], $register_user['username'], $conf['pass_convert']($_POST['password']), $register_user['email']);
70}
71
72
73/* user deletion */
74add_event_handler('delete_user', 'Register_FluxBB_Deluser');
75
76function Register_FluxBB_Deluser($user_id)
77{
78        include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php');
79
80  FluxBB_Deluser( FluxBB_Searchuser($user_id), true );
81}
82
83
84
85add_event_handler('init', 'Register_FluxBB_InitPage');
86 
87function Register_FluxBB_InitPage()
88{
89  global $conf, $user ;
90  include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php');
91
92/* user update */
93  if (script_basename() == 'profile')
94  {
95    if (isset($_POST['validate']))
96    {
97      $errors = array();
98
99      $int_pattern = '/^\d+$/';
100      if (empty($_POST['nb_image_line'])
101          or (!preg_match($int_pattern, $_POST['nb_image_line'])))
102      {
103        $errors[] = l10n('nb_image_line_error');
104      }
105   
106      if (empty($_POST['nb_line_page'])
107          or (!preg_match($int_pattern, $_POST['nb_line_page'])))
108      {
109        $errors[] = l10n('nb_line_page_error');
110      }
111   
112      if ($_POST['maxwidth'] != ''
113          and (!preg_match($int_pattern, $_POST['maxwidth'])
114               or $_POST['maxwidth'] < 50))
115      {
116        $errors[] = l10n('maxwidth_error');
117      }
118      if ($_POST['maxheight']
119           and (!preg_match($int_pattern, $_POST['maxheight'])
120                 or $_POST['maxheight'] < 50))
121      {
122        $errors[] = l10n('maxheight_error');
123      }
124        // periods must be integer values, they represents number of days
125        /* Commented to fix compatibility problem with Dynamic Recent Period Plugin */
126        /* This don't impact the plugin functionnalities */
127        /*if (!preg_match($int_pattern, $_POST['recent_period'])
128            or $_POST['recent_period'] <= 0)
129        {
130          $errors[] = l10n('periods_error') ;
131        }*/
132   
133      if (isset($_POST['mail_address']))
134      {
135        $mail_error = validate_mail_address($user['id'],$_POST['mail_address']);
136        if (!empty($mail_error))
137        {
138          $errors[] = $mail_error;
139        }
140      }
141   
142      if (!empty($_POST['use_new_pwd']))
143      {
144        // password must be the same as its confirmation
145        if ($_POST['use_new_pwd'] != $_POST['passwordConf'])
146        {
147          $errors[] = l10n('New password confirmation does not correspond');
148        }
149   
150        if ( !defined('IN_ADMIN') )
151        {// changing password requires old password
152          $query = '
153            SELECT '.$conf['user_fields']['password'].' AS password
154            FROM '.USERS_TABLE.'
155            WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
156          ;';
157          list($current_password) = mysql_fetch_row(pwg_query($query));
158     
159          if ($conf['pass_convert']($_POST['password']) != $current_password)
160          {
161            $errors[] = l10n('Current password is wrong');
162          }
163        }
164      }
165   
166      if (count($errors) == 0)
167      {
168        include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php');
169     
170        $query = '
171          SELECT '.$conf['user_fields']['username'].' AS username
172          FROM '.USERS_TABLE.'
173          WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
174        ;';
175        list($username) = mysql_fetch_row(pwg_query($query));
176
177        FluxBB_Updateuser($user['id'], $username, $conf['pass_convert']($_POST['use_new_pwd']), $_POST['mail_address']);
178      }
179    }
180  }
181}
182
183?>
Note: See TracBrowser for help on using the repository browser.