source: extensions/Register_PunBB/reg_punbb_deluser.php @ 9885

Revision 7809, 3.9 KB checked in by Eric, 9 years ago (diff)

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

  • Property svn:eol-style set to LF
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// ** Delete user from the PunBB users table **
29// ********************************************
30
31// Load Plugin settings from database
32load_conf_from_db('param like \'punbb\\_%\'');
33
34global $conf;
35
36// ID selection in the pwg/punbb correspondence table
37$query = "
38        SELECT id_user_punbb, id_user_pwg FROM ".PLUGIN_REGISTER_PUNBB_ID."
39        WHERE id_user_pwg = ".$user_id.";
40    ";
41$result = pwg_query($query);
42
43while($data = mysql_fetch_array($result))
44{
45    // If equal to 0 then all posts and topics from deleted user will be deleted too
46    if ($conf['punbb_del_pt'] == 0)
47    {
48        // Deletion of user's posts
49        $query_1 = "
50                DELETE FROM ".$conf['punbb_prefix']."posts
51                WHERE poster_id = ".$data['id_user_punbb'].";
52            ";
53        $result_1 = pwg_query($query_1);
54
55        // Username selection
56        $query_2 = "
57                SELECT username FROM ".USERS_TABLE."
58                WHERE id = ".$data['id_user_pwg'].";
59            ";
60        $result_2 = pwg_query($query_2);
61        while ($data_1 = mysql_fetch_array($result_2))
62        {
63            // Deletion of user's topics
64            $query_3 = "
65                    DELETE FROM ".$conf['punbb_prefix']."topics
66                    WHERE poster = '".$data_1['username']."';
67                ";
68            $result_3 = pwg_query($query_3);
69        }
70    }
71
72    // Deletion of user's subscriptions
73    $query_4 = "
74            DELETE FROM ".$conf['punbb_prefix']."subscriptions
75            WHERE user_id = ".$data['id_user_punbb'].";
76        ";
77    $result_4 = pwg_query($query_4);
78
79    // Deletion of user's account
80    $query_5 = "
81            DELETE FROM ".$conf['punbb_prefix']."users
82            WHERE id = ".$data['id_user_punbb'].";
83        ";
84    $result_5 = pwg_query($query_5);
85
86    // Deletion of user's correspondence in pwg/punbb correspondence table
87    $query_6 = "
88            DELETE FROM ".PLUGIN_REGISTER_PUNBB_ID."
89            WHERE id_user_pwg = ".$user_id.";
90        ";
91    $result_6 = pwg_query($query_6);
92}
93?>
Note: See TracBrowser for help on using the repository browser.