This debug message was to noisy but it is needed in development (where debug-mode...
[mailer.git] / inc / extensions-functions.php
index dc6b67f9b4df11df30ca0907968dca731da54d43..acd01be780c418c1a35bcf3d581f8a5c5d84a0e5 100644 (file)
@@ -2035,6 +2035,62 @@ function addConfigChangeSql ($oldColumnName, $newColumnName, $columnSql) {
        addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` CHANGE `' . $oldColumnName . '` `' . $newColumnName . '` ' . $columnSql);
 }
 
+/**
+ * Checks if given subject is found and if not, adds an SQL query to the
+ * extension registration queue.
+ */
+function registerExtensionPointsData ($subject, $columnName, $lockedMode, $paymentMethod) {
+       // Default is old extension version
+       $add = '';
+
+       // Is the extension equal or newer 0.8.9?
+       if (((isInstallationPhase()) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) {
+               // Then add provider
+               $add = " AND `account_provider`='EXTENSION'";
+       } // END - if
+
+       // Is the 'subject' there?
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ifSqlTableExists(points_data)=' . ifSqlTableExists('points_data') . ',getExtensionMode()=' . getExtensionMode() . ',add=' . $add);
+       if (((!ifSqlTableExists('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) {
+               // Not found so:
+               if ((isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) && (!ifSqlTableExists('points_data'))) {
+                       $dummy = $GLOBALS['previous_extension'][getCurrentExtensionName()];
+                       reportBug(__FUNCTION__, __LINE__, 'previous_extension[' . gettype($dummy) . ']=' . $dummy . ',getCurrentExtensionName()=' . getCurrentExtensionName() . ' - Under development, please report this!');
+               } // END - if
+
+               // ... add an SQL query
+               addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('%s','%s','%s','%s')",
+                       $subject,
+                       $columnName,
+                       $lockedMode,
+                       $paymentMethod
+               ));
+       } // END - if
+}
+
+/**
+ * Checks if given subject is found and if so, adds an SQL query to the
+ * extension unregistration queue.
+ */
+function unregisterExtensionPointsData ($subject) {
+       // Default is old extension version
+       $add = '';
+
+       // Is the extension equal or newer 0.8.9?
+       if (isExtensionInstalledAndNewer('sql_patches', '0.8.9')) {
+               // Then add provider
+               $add = " AND `account_provider`='EXTENSION'";
+       } // END - if
+
+       // Is the 'subject' there?
+       if (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 1) {
+               // Found one or more, so add an SQL query
+               addExtensionSql(sprintf("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s'" . $add . " LIMIT 1",
+                       $subject
+               ));
+       } // END - if
+}
+
 // Enables/disables productive mode for current extension (used only while
 // registration).
 // @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable'