+ /**
+ * Getter fuer data
+ */
+ function getData () {
+ return $this->data;
+ }
+}
+
+// Function to test the Primera API by getting the amount. If the returned value
+// is not false the API data is valid, else invalid
+function testPrimeraApi () {
+ // Get new instance
+ $api = new PrimeraApi(postRequestParameter('primera_api_name'), postRequestParameter('primera_api_md5'));
+
+ // Was that fine?
+ return ($api->getPrimera() !== false);
+}
+
+// Execute the withdraw of a sponsor only!
+function executePrimeraWithdraw ($primusNick, $userMd5, $amount) {
+ // Is the sponsor extension installed?
+ if (!isExtensionActive('sponsor')) {
+ // No, abort here
+ return false;
+ } elseif (!isSponsor()) {
+ // No sponsor, not allowed to withdraw!
+ return false;
+ }
+
+ // Get new instance
+ $api = new PrimeraApi($primusNick, $userMd5);
+
+ // Prepare purpose
+ eval('$purpose = "' . preCompileCode(getMaskedMessage('PRIMERA_API_PURPOSE_WITHDRAW', getSession('sponsorid'))) . '";');
+
+ // Pay the Primera
+ return $api->payPrimera($primusNick, $amount, $purpose);
+}
+
+// Execute the payout
+function executePrimeraPayout ($primusNick, $userMd5, $amount) {
+ // Get new instance
+ $api = new PrimeraApi(getConfig('primera_api_name'), getConfig('primera_api_md5'));
+
+ // Prepare purpose
+ eval('$purpose = "' . preCompileCode(getMaskedMessage('PRIMERA_API_PURPOSE_PAYOUT', getMemberId())) . '";');
+
+ // Pay the Primera
+ return $api->payPrimera($primusNick, $amount, $purpose);