]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions/ext-transfer.php
Heacy rewrite/cleanup:
[mailer.git] / inc / extensions / ext-transfer.php
index 6b89ad4da8405ebd3e0c8506548fd11c3e349dcd..2dc04f171a7e27d3a841898967be25411a4249ad 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 10/07/2004 *
- * ================                             Last change: 07/08/2007 *
+ * Mailer v0.2.1-FINAL                                Start: 10/07/2004 *
+ * ===================                          Last change: 07/08/2007 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : ext-transfer.php                                 *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Punktetransfers zwischen Mitgliedern             *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
+       die();
+} // END - if
 
 // Version number
-$EXT_VERSION = "0.2.9";
-
-// Auto-set extension version
-if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
-
-// Version history array (add more with , "0.1" and so on)
-$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9");
-
-switch ($EXT_LOAD_MODE)
-{
-case "register": // Do stuff when installation is running
-       // SQL commands to run
-       $SQLs[] = "DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_transfers_in`";
-       $SQLs[] = "DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_transfers_out`";
-
-       // Transfer from a member
-       $SQLs[] = "CREATE TABLE `{!_MYSQL_PREFIX!}_user_transfers_in` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-from_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-reason VARCHAR(255) NOT NULL DEFAULT '',
-time_trans VARCHAR(14) NOT NULL DEFAULT 0,
-trans_id VARCHAR(12) NOT NULL DEFAULT '',
-KEY (userid),
-KEY (from_uid),
-PRIMARY KEY(id)
-) Type=MyISAM";
-
-       // Transfers to a member
-       $SQLs[] = "CREATE TABLE `{!_MYSQL_PREFIX!}_user_transfers_out` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-to_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-reason VARCHAR(255) NOT NULL DEFAULT '',
-time_trans VARCHAR(14) NOT NULL DEFAULT 0,
-trans_id VARCHAR(12) NOT NULL DEFAULT '',
-KEY (userid),
-KEY (to_uid),
-PRIMARY KEY(id)
-) Type=MyISAM";
-
-       // Admin menu
-       $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer', NULL, '{!POINTS!}-Transfer','Verwalten Sie hier die {!POINTS!}-Transaktionen zwischen Ihren Mitgliedern.', 7)";
-       $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer','list_transfer','Auflisten','Hier bekommen Sie alle ein- und ausgehende Transaktionen aufgelistet.', 1)";
-       $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer','config_transfer','Einstellungen','Stellen Sie ein, wie viele Transaktionen aufgelistet werden sollen und wie alt diese werden d&uuml;rfen. Die evtl. installierte autopurge-Erweiterung kann dann automatisch die veralteten Transktionen l&ouml;schen.', 2)";
-       $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer','del_transfer','Manuell l&ouml;schen','Hier k&ouml;nnen Sie - abgesehen von der automatischen L&ouml;schung - Transaktionen selber l&ouml;schen. Bitte beachten Sie, dass immer aus- und eingehende Transaktionen gleichzeitig gel&ouml;scht werden.', 3)";
-
-       // Member menu
-       $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('main','transfer','{!POINTS!}-Transfer','Y','Y', 5)";
-
-       // Add config values
-       $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD transfer_max BIGINT(20) UNSIGNED NOT NULL DEFAULT '50'";
-       $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD transfer_age BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(getConfig('one_day')*28)."'";
-       $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD transfer_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '".getConfig('one_day')."'";
-       $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD transfer_balance BIGINT(20) UNSIGNED NOT NULL DEFAULT 100";
-       $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD transfer_code BIGINT(20) UNSIGNED NOT NULL DEFAULT 5";
-
-       // Add row(s) to user's data
-       $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD opt_in ENUM('Y','N') NOT NULL DEFAULT 'N'";
-       break;
-
-case "remove": // Do stuff when removing extension
-       // SQL commands to run
-       $SQLs[] = "DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_transfers_in`";
-       $SQLs[] = "DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_transfers_out`";
-       $SQLs[] = "DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE action='transfer' LIMIT 4";
-       $SQLs[] = "DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE what='transfer' LIMIT 1";
-       $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` DROP opt_in";
-       break;
-
-case "activate": // Do stuff when admin activates this extension
-       // SQL commands to run
-       $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE what='transfer' LIMIT 1";
-       break;
-
-case "deactivate": // Do stuff when admin deactivates this extension
-       // SQL commands to run
-       $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE what='transfer' LIMIT 1";
-       break;
-
-case "update": // Update an extension
-       switch ($EXT_VER)
-       {
-       case "0.0.2": // SQL queries for v0.0.2
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Fehler <div class=\"admin_failed\">Warning: Missing argument 2 for create_timestamp_from_selections() in {!PATH!}inc/libs/pro_functions.php on line 227</div> behoben.";
-               break;
-
-       case "0.0.3": // SQL queries for v0.0.3
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "&Uuml;berfl&uuml;ssige unset()-Anweisungen aus der what-config_transfer.php entfernt. Dies wird bereits von der eigenen Funktion ADMIN_SAVE_SETTINGS() erledigt.";
-               break;
-
-       case "0.0.3": // SQL queries for v0.0.3
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.";
-               break;
-
-       case "0.0.5": // SQL queries for v0.0.5
-               $SQLs[] = "ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD ap_transfer ENUM('Y','N') NOT NULL DEFAULT 'Y'";
-
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Link <em>Auflisten</em> im Admin-Bereich hatte das eingeloggte Mitglied und nicht den eingeloggten Admin abgefragt. Automatisches L&ouml;schen von veraltete Eintr&auml;gen kann unabh&auml;ngig von der autopurge-Erweiterung de-/aktiviert werden. Bitte aktualisieren Sie auch die beiden Admin-Templates!";
-               break;
-
-       case "0.0.6": // SQL queries for v0.0.6
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.";
-               break;
+setThisExtensionVersion('0.3.0');
 
-       case "0.0.7": // SQL queries for v0.0.7
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";
-               break;
+// Version history array (add more with , '0.0.1' and so on)
+setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0'));
 
-       case "0.0.8": // SQL queries for v0.0.8
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Problem mit E in Transaktionsnummer beseitigt.";
+switch (getExtensionMode()) {
+       case 'setup': // Do stuff when installation is running
                break;
 
-       case "0.0.9": // SQL queries for v0.0.9
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Problem mit Speicherung der Einstellungen beseitigt.";
-               break;
-
-       case "0.1.0": // SQL queries for v0.2.1
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.";
-               break;
+       case 'remove': // Do stuff when removing extension
+               // SQL commands to run
+               addDropTableSql('user_transfers_in');
+               addDropTableSql('user_transfers_out');
+               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='transfer'");
+               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='transfer' LIMIT 1");
+               addExtensionDropTableColumnSql('user_data', 'opt_in');
 
-       case "0.1.1": // SQL queries for v0.1.1
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Design &quot;Solid-Business&quot; eingebaut.";
+               // Unregister points data
+               unregisterExtensionPointsData('transfer');
                break;
 
-       case "0.1.2": // SQL queries for v0.1.2
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Seit <a href=\"#\">Patch 340</a> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";
+       case 'activate': // Do stuff when admin activates this extension
+               // SQL commands to run
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='transfer' LIMIT 1");
                break;
 
-       case "0.1.3": // SQL queries for v0.1.3
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.";
+       case 'deactivate': // Do stuff when admin deactivates this extension
+               // SQL commands to run
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='transfer' LIMIT 1");
                break;
 
-       case "0.1.4": // SQL queries for v0.1.4
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Link zum Mitgliedsprofil in Funktion <u>ADMIN_USER_PROFILE_LINK()</u> ausgelagert.";
+       case 'update': // Update an extension
                break;
 
-       case "0.1.5": // SQL queries for v0.1.5
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Template <u>admin_config_transfer_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!";
+       case 'modify': // When the extension got modified
                break;
 
-       case "0.1.6": // SQL queries for v0.1.6
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "W&ouml;rter <strong>Mailtausch</strong>, <strong>Mailtausches</strong> und <strong>Mailtauscher</strong> sind austauschbar.";
+       case 'test': // For testing purposes
                break;
 
-       case "0.1.7": // SQL queries for v0.1.7
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Wort <strong>Punkte</strong> dynamisiert.";
+       case 'init': // When extension is initialized
+               if ((isDailyResetEnabled()) && (getConfig('ap_transfer') == 'Y')) {
+                       // Automatically remove outdated or not displayed transactions
+                       autoPurgeTransfers(getConfig('transfer_max'), getConfig('transfer_age'));
+               } // END - if
                break;
 
-       case "0.1.8": // SQL queries for v0.1.8
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.";
+       default: // Unknown extension mode
+               reportBug(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
                break;
+} // END - switch
 
-       case "0.1.9": // SQL queries for v0.1.9
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Parser-Error im Mitgliedsbereich beseitigt.";
-               break;
-
-       case "0.2.0": // SQL queries for v0.2.0
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Abspeichern von Einstellungen repariert.";
-               break;
-
-       case "0.2.1": // SQL queries for v0.2.1
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Durchf&uuml;hrung des Transfers korregiert.";
-               break;
-
-       case "0.2.2": // SQL queries for v0.2.2
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Sicherheitsupdate f&uuml;r die Include-Befehle.";
-               break;
-
-       case "0.2.3": // SQL queries for v0.2.3
-               $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'list_transfer')";
-               $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'del_transfer')";
-               $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu_las` (la_id, la_action, la_what) VALUES ('config', '', 'config_transfer')";
-
-               // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin
-               $EXT_UPDATE_DEPENDS = "sql_patches";
-
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Erweiterung in's neue Men&uuml;system integriert.";
-               break;
-
-       case "0.2.4": // SQL queries for v0.2.4
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "<strong>Touring-Code wiederholen</strong> nach <strong>Touring-Code eingeben</strong> hin ge&auml;ndert.";
-               break;
-
-       case "0.2.5": // SQL queries for v0.2.5
-               $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET action='extras', sort='5' WHERE what='transfer' LIMIT 1";
-
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett ge&auml;ndert.";
-               break;
-
-       case "0.2.6": // SQL queries for v0.2.6
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.";
-               break;
-
-       case "0.2.7": // SQL queries for v0.2.7
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Die {!POINTS!} k&ouml;nnen nun wieder wie gewohnt transferiert werden. Der Grund f&uuml;r <em>{--TRANSFER_INVALID_PASSWORD--}</em> war, dass der Cookie-Hash ein anderer ist, als der in der Datenbank... :-/";
-               break;
-
-       case "0.2.8": // SQL queries for v0.2.8
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Fehlermeldung <em>Notice: Undefined index: to_uid in {!PATH!}/inc/modules/member/what-transfer.php on line 301</em> gefixt. Danke an <a href=\"http://forum.mxchange.org/profile-8.html\" target=\"_blank\" title=\"Forumprofil von Piter01\">Piter01</a>.";
-               break;
-
-       case "0.2.9": // SQL queries for v0.2.9
-               // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert.";
-               break;
-       }
-       break;
-
-case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
-       break;
-
-default: // Do stuff when extension is loaded
-       if ((isBooleanConstantAndTrue('__DAILY_RESET')) && (getConfig('ap_transfer') == "Y")) {
-               // Automatically remove outdated or not displayed transactions
-               TRANSFER_AUTPPURGE(getConfig('transfer_max'), getConfig('transfer_age'));
-       }
-       break;
-}
-
-//
+// [EOF]
 ?>