+// Get points data for given extension's name
+function getPointsDataArrayFromSubject ($subject) {
+ // Extension sql_patches must be up-to-date
+ if (isExtensionInstalledAndOlder('sql_patches', '0.8.2')) {
+ // Please update ext-sql_patches
+ debug_report_bug(__FUNCTION__, __LINE__, 'sql_patches is out-dated. Please update to at least 0.8.2 to continue. subject=' . $subject);
+ } // END - if
+
+ // Remove any double-dot from it
+ $subjectArray = explode(':', $subject);
+ $subject = $subjectArray[0];
+ unset($subjectArray);
+
+ // If we have cache, shortcut it here
+ if (isset($GLOBALS['cache_array']['points_data'][$subject])) {
+ // Return it
+ return $GLOBALS['cache_array']['points_data'][$subject];
+ } // END - if
+
+ // Now checkout the entry in database table
+ $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `column_name`, `locked_mode`, `payment_method`, `notify_recipient` FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s' LIMIT 1",
+ array($subject), __FUNCTION__, __LINE__);
+
+ // Do we have an entry?
+ if (SQL_NUMROWS($result) == 1) {
+ // Then load it
+ $pointsData = SQL_FETCHARRAY($result);
+
+ // Add all entries to our cache array
+ foreach ($pointsData as $key=>$value) {
+ $GLOBALS['cache_array']['points_data'][$subject][$key] = $value;
+ } // END - foreach
+ } else {
+ // Register this automatically
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`, `column_name`, `locked_mode`, `payment_method`, `notify_recipient`) VALUES ('%s','points','LOCKED','REFERAL','N')",
+ array($subject), __FUNCTION__, __LINE__);
+
+ // Re-request it
+ return getPointsDataArrayFromSubject($subject);
+ }
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return it
+ return $GLOBALS['cache_array']['points_data'][$subject];
+}
+
+// Determines the right points column name for given subject and 'locked'
+function getPointsColumnNameFromSubjectLocked ($subject, $isLocked) {
+ // Get the points_data entry
+ $pointsData = getPointsDataArrayFromSubject($subject);
+
+ // Regular points by default
+ $columnName = $pointsData['column_name'];
+
+ // Are the points locked?
+ if (($isLocked === true) && ($pointsData['locked_mode'] == 'LOCKED')) {
+ // Locked points, so prefix it
+ $columnName = 'locked_' . $pointsData['column_name'];
+ } // END - if
+
+ // Return the result
+ return $columnName;
+}
+
+// Determines the payment method for given extension and 'locked'
+function getPaymentMethodFromSubject ($subject) {
+ // Get the points_data entry
+ $pointsData = getPointsDataArrayFromSubject($subject);
+
+ // Regular points by default
+ $paymentMethod = $pointsData['payment_method'];
+
+ // Return the result
+ return $paymentMethod;
+}
+
+// Checks wether notification of points recipient is enabled
+function isPaymentRecipientNotificationEnabled ($subject) {
+ // Get the points_data entry
+ $pointsData = getPointsDataArrayFromSubject($subject);
+
+ // Is it enabled?
+ $isEnabled = ($pointsData['notify_recipient'] == 'Y');
+
+ // Return the result
+ return $isEnabled;
+}
+