This debug message was to noisy but it is needed in development (where debug-mode...
[mailer.git] / inc / libs / user_functions.php
index 566c762b0c3752b84821dd0849dcd09c4ca36fe9..75f0edf54bb65790ab68a85e30c2815055d96fbf 100644 (file)
@@ -796,6 +796,33 @@ function createTesterUserAccount () {
        return $isCreated;
 }
 
+// Checks whether the given sub id is fused by current member
+function isMemberSubIdFree ($subId) {
+       // Check it
+       $isFree = (countSumTotalData(getMemberId(), 'user_subids', 'id', 'userid', true, sprintf(" AND `subid`='%s'", $subId)) == 0);
+
+       // Return result
+       return $isFree;
+}
+
+// Prepares given sub id for storage in database
+function prepareSubId ($subId) {
+       // First convert any spaces/dashes to underscores
+       $subId = str_replace(' ', '_', str_replace('-', '_', $subId));
+
+       // Then filter out any unwanted characters
+       $subId = preg_replace('/([^a-zA-Z0-9_])/', '', $subId);
+
+       // Then Check if it is available
+       if (!isMemberSubIdFree($subId)) {
+               // Is not free
+               $subId = false;
+       } // END - if
+
+       // Return prepared sub id
+       return $subId;
+}
+
 //-----------------------------------------------------------------------------
 //                                EL code functions
 //-----------------------------------------------------------------------------
@@ -883,6 +910,17 @@ function doTemplateDisplayUsername ($template, $clear = false, $userid = NULL) {
        return $GLOBALS[__FUNCTION__][$userid];
 }
 
+// ----------------------------------------------------------------------------
+//                             XML call-back functions
+// ----------------------------------------------------------------------------
+
+// For 'doing' add subid, the column-index is required
+function addXmlSpecialMemberAddDoSubid () {
+       // So set it all here
+       $GLOBALS['__COLUMN_INDEX']['doXmlCallbackFunction']  = 'column';
+       $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_index'] = 'column';
+}
+
 // ----------------------------------------------------------------------------
 //                 Wrapper functions for configuration entries
 // ----------------------------------------------------------------------------