9baf07006e7d85dd48f894b332123dd6b5d45269
[mailer.git] / inc / extensions / ext-online.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 01/14/2005 *
4  * ===================                          Last change: 01/14/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-online.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Who is where online?                             *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Wer befindet sich wo gerade Online?              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Version number
44 setThisExtensionVersion('0.0.6');
45
46 // Version history array (add more with , '0.1.0' and so on)
47 setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6'));
48
49 switch (getExtensionMode()) {
50         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
51                 // SQL commands to run
52                 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_online`');
53                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_online` (
54 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
55 `sid` VARCHAR(32) NOT NULL DEFAULT '',
56 `ip` VARCHAR(15) NOT NULL DEFAULT '',
57 `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
58 `refid` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
59 `module` VARCHAR(255) NOT NULL DEFAULT '',
60 `action` VARCHAR(255) NOT NULL DEFAULT '',
61 `what` VARCHAR(255) NOT NULL DEFAULT '',
62 `is_admin` ENUM('Y','N') NOT NULL DEFAULT 'N',
63 `is_member` ENUM('Y','N') NOT NULL DEFAULT 'N',
64 `timestamp` VARCHAR(10) NOT NULL DEFAULT 0,
65 PRIMARY KEY (`id`),
66 INDEX (`userid`),
67 INDEX (`refid`),
68 INDEX `admin_member` (`is_admin`, `is_member`)
69 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci");
70                 addAdminMenuSql('misc','usr_online','Online-Statistik','Eine Liste von derzeit &quot;Online&quot; Usern. Doppelte Eintr&auml;ge k&ouml;nnte auf mangelnden Cookie-Support des Browsers oder auf einen Spider hindeuten.', 1);
71                 break;
72
73         case 'remove': // Do stuff when removing extension
74                 // SQL commands to run
75                 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_online`');
76                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='usr_online'");
77                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='online'");
78
79                 // Unregister filter
80                 unregisterFilter(__FUNCTION__, __LINE__, 'init', 'UPDATE_ONLINE_LIST', true, isExtensionDryRun());
81                 break;
82
83         case 'activate': // Do stuff when admin activates this extension
84                 // SQL commands to run
85                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `action`='online' LIMIT 1");
86                 break;
87
88         case 'deactivate': // Do stuff when admin deactivates this extension
89                 // SQL commands to run
90                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N', `locked`='Y' WHERE `action`='online' LIMIT 1");
91                 break;
92
93         case 'update': // Update an extension
94                 switch (getCurrentExtensionVersion()) {
95                         case '0.0.1': // SQL queries for v0.0.1
96                                 // Update notes (these will be set as task text!)
97                                 setExtensionUpdateNotes("Fehler <u>Unknown column 'visibled' in 'field list'</u> behoben.");
98                                 break;
99
100                         case '0.0.2': // SQL queries for v0.0.2
101                                 // Update notes (these will be set as task text!)
102                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
103                                 break;
104
105                         case '0.0.3': // SQL queries for v0.0.3
106                                 // Update notes (these will be set as task text!)
107                                 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
108                                 break;
109
110                         case '0.0.4': // SQL queries for v0.0.4
111                                 // Update notes (these will be set as task text!)
112                                 setExtensionUpdateNotes("Erstellung der Datenbanktabelle `{?_MYSQL_PREFIX?}_online` in diese Erweiterung ausgelagert.");
113                                 break;
114
115                         case '0.0.5': // SQL queries for v0.0.5
116                                 // Add guest menu
117                                 addGuestMenuSql('online', NULL, 'Jetzt Online', 'Y', 'N', 2);
118
119                                 // Register filter
120                                 registerFilter('init', 'UPDATE_ONLINE_LIST', false, true, isExtensionDryRun());
121
122                                 // Update notes (these will be set as task text!)
123                                 setExtensionUpdateNotes("Hinzuf&uuml;gen des Men&uuml;punktes &quot;Jetzt Online&quot; wird nun von dieser Erweiterung erledigt. Filter hinzugef&uuml;gt.");
124                                 break;
125
126                         case '0.0.6': // SQL queries for v0.0.6
127                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_online` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL,
128 CHANGE `refid` `refid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL');
129
130                                 // Update notes (these will be set as task text!)
131                                 setExtensionUpdateNotes("Spalten userid und refid erlauben nun <stron>null</strong>.");
132                                 break;
133                 } // END - switch
134                 break;
135
136         case 'modify': // When the extension got modified
137                 break;
138
139         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
140                 break;
141
142         case 'init': // Do stuff when extension is initialized
143                 break;
144
145         default: // Unknown extension mode
146                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
147                 break;
148 } // END - switch
149
150 // [EOF]
151 ?>