X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Fuser_functions.php;h=75f0edf54bb65790ab68a85e30c2815055d96fbf;hp=566c762b0c3752b84821dd0849dcd09c4ca36fe9;hb=b0ed0547ba277e815ca38b3333b191149a88019c;hpb=8ed6af64e47d41cb94b4f9b57a046f3d9089375f diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 566c762b0c..75f0edf54b 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -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 // ----------------------------------------------------------------------------