source: extensions/Register_PunBB/reg_punbb_synchro.php @ 27153

Last change on this file since 27153 was 7809, checked in by Eric, 13 years ago

Commit of latest plugin version (1.3a) as a startup base for further developpements

  • Property svn:eol-style set to LF
File size: 3.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Plugin Name : Register_PunBB                                          |
4// | Plugin Version : 1.3a                                                 |
5// | File Version : 0.2                                                    |
6// | Plugin Version author : Eric <lucifer@infernoweb.net>                 |
7// | Plugin description :                                                  |
8// | Ce plugin permet l'enregistrement d'un utilisateur directement dans   |
9// | PunBB (http://www.punbb.org) - This plugin allows to automatically    |
10// | register a PWG user in a PunBB forum (http://www.punbb.org)           |
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27// *********************************************
28// ** Correspondence table re synchronization **
29// *********************************************
30
31include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
32
33// Empty the ids from table
34$query_1 = "TRUNCATE ".PLUGIN_REGISTER_PUNBB_ID.";";
35$result_1 = pwg_query($query_1);
36
37// Selection of all PWG accounts
38$query = "
39        SELECT id AS id_pwg, username
40                FROM ".USERS_TABLE.";
41        ";
42$result = pwg_query($query);
43
44while($data = mysql_fetch_array($result))
45{
46    // Selection of PunBB user's id in relation with PWG user's id
47    $query_2 = "
48            SELECT id AS id_punbb
49                        FROM ".$conf['punbb_prefix']."users
50                        WHERE username = '".$data['username']."';
51                ";
52    $result_2 = pwg_query($query_2);
53
54    while($data_1 = mysql_fetch_array($result_2))
55    {
56        // Insert PWG id and PunBB id in correspondence table
57        $query_3 = "
58                INSERT INTO ".PLUGIN_REGISTER_PUNBB_ID." (id_user_pwg, id_user_punbb)
59                VALUES (".$data['id_pwg'].", ".$data_1['id_punbb'].");";
60        $result_3 = pwg_query($query_3);
61    }
62}
63echo 'Re synchronization done !';
64
65//TODO: Get re synchro result into a template
66?>
Note: See TracBrowser for help on using the repository browser.