variables.logApp = 'ptProfile'; variables.logComponent = 'ProfileService'; variables.enableDebugLogging = false; variables.externalDataDSN = "commonspot-external"; var verify = StructNew(); var pageName = ""; var pageTitle = ""; var pageDesc = ""; var templateID = 0; var subsiteID = 0; var pageCreateRes = StructNew(); var pageCreateID = 0; var profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.userid); var profileRoles = profileObj.getRoles(); var profileSiteVars = profileObj.getSiteVars(); var profileDataValues = profileObj.getDataValues(); var profileUserID = profileObj.getProfileUserID(); var logMethod = 'createProfilePage'; var logMsg = ''; var logData = StructNew(); // Rip out any unfriendly strings var regEx = "[^a-zA-Z0-9 ]"; // Create only the single role profile page // Verify that the role argument exists and user has permissions verify = verifyRoleData(arguments.profileType, profileSiteVars, profileRoles); if ( variables.enableDebugLogging ) { logMsg = 'verify role'; logData = verify; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } if ( verify.errorFlag EQ false ) { // Make the page name and title safe for CS pageName = buildProfilePageName(userid=profileUserID,profileType=arguments.profileType); pageTitle = buildProfilePageTitle(userid=profileUserID,profileType=arguments.profileType); pageDesc = buildProfilePageDescription(userid=profileUserID,profileType=arguments.profileType); subsiteID = server.ADF.environment[request.site.id].ptProfile.roles["#UCASE(arguments.profileType)#"].SUBSITE_ID; templateID = server.ADF.environment[request.site.id].ptProfile.roles["#UCASE(arguments.profileType)#"].TEMPLATE_ID; try { pageCreateRes = handlePageCreate(pageName, templateID, subsiteID, pageTitle, pageDesc, arguments.profileType, profileDataValues.uniqueID, profileUserID); if ( variables.enableDebugLogging ) { logMsg = 'handlePageCreate called!'; logData = pageCreateRes; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } } catch(any ex) { logMsg = 'handlePageCreate failed!'; logData = ex; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } // verify we get the pageid back if ( pageCreateRes.pageCreated ) pageCreateID = pageCreateRes.newpageid; } return pageCreateID; var retStruct = StructNew(); retStruct.errorFlag = false; retStruct.errorMsg = ""; // Verify that the role argument exists and user has permissions if ( NOT StructKeyExists(arguments.profileRoles,"#UCASE(arguments.profileType)#") ) { // Handle error for profile type not exists retStruct.errorFlag = true; retStruct.errorMsg = "Profile Page Creation Error: Profile type does not exist."; return retStruct; } else if ( arguments.profileRoles["#UCASE(arguments.profileType)#"].permission NEQ true ) { // Handle error for profile user doesn't have permissions. retStruct.errorFlag = true; retStruct.errorMsg = "Profile Page Creation Error: Profile user does not have permissions."; return retStruct; } // Verify the subsite has been defined for the role if ( NOT StructKeyExists(arguments.profileSiteVars.roles[arguments.profileType], "SUBSITE_ID") ) { // Handle error for profile role subsite id is not defined in the site config. retStruct.errorFlag = true; retStruct.errorMsg = "Profile Page Creation Error: Profile role subsite id is not defined in the site config."; return retStruct; } else if ( arguments.profileSiteVars.roles[arguments.profileType].SUBSITE_ID LTE 0 ) { // Handle error for profile role subsite id is not valid. retStruct.errorFlag = true; retStruct.errorMsg = "Profile Page Creation Error: Profile role subsite id is not valid in site config."; return retStruct; } // Verify the template id has been defined for the role if ( NOT StructKeyExists(arguments.profileSiteVars.roles[arguments.profileType], "TEMPLATE_ID") ) { // Handle error for profile role template id is not defined in the site config. retStruct.errorFlag = true; retStruct.errorMsg = "Profile Page Creation Error: Profile role template id is not defined in the site config."; return retStruct; } else if ( arguments.profileSiteVars.roles[arguments.profileType].TEMPLATE_ID LTE 0 ) { // Handle error for profile role subsite id is not valid. retStruct.errorFlag = true; retStruct.errorMsg = "Profile Page Creation Error: Profile role template id is not valid in site config."; return retStruct; } return retStruct; var csPage = ""; var stdMetadata = structNew(); var custMetadata = structNew(); var pageResult = StructNew(); var defaultCat = 0; var logMethod = 'handlePageCreate'; var logMsg = ''; var logData = StructNew(); select ID from generalCategories where categoryTypeID = 1 and isActive=1 and isDefault=1 // build metadata stdMetadata.name = arguments.pageName; stdMetadata.title = arguments.pageTitle; stdMetadata.description = arguments.pageDesc; stdMetadata.templateID = arguments.templateID; stdMetadata.subsiteID = arguments.subsiteID; //stdMetadata.includeInIndex = "1,8"; // OLD CCAPI createPage page and search index Parameter stdMetadata.caption = arguments.pageTitle; stdMetadata.publicationDate = dateformat(now(), "yyyy-mm-dd") & " " & timeformat(now(),"HH:mm:ss"); stdMetadata.categoryid = defaultCat; stdMetadata.showInList = ""; if ( arguments.addToPageIndex ) stdMetadata.showInList = ListAppend(stdMetadata.showInList,"PageIndex",','); if ( arguments.addToSearchResults ) stdMetadata.showInList = ListAppend(stdMetadata.showInList,"SearchResults",','); // Get the custom metadata from the template (fix for CS CCAPI custom metadata inheritance issue) custMetadata = application.ptProfile.csData.getCustomMetadata(pageid=stdMetadata.templateID,convertTaxonomyTermsToIDs=1); /* Build the Custom Metadata the CS version*/ custMetadata['Profiles'] = structNew(); custMetadata['Profiles']['type'] = arguments.profileType; custMetadata['Profiles']['userid'] = arguments.profileUserID; custMetadata['Profiles']['uniqueID'] = arguments.profileUUID; // Call the CCAPI to build the page pageResult = application.ptProfile.profileDAO.profilePageCreateCMDAPI(stdMetadata, custMetadata); //OLD: pageResult = application.ptProfile.profileDAO.profilePageCreateCCAPI(stdMetadata, custMetadata); if ( variables.enableDebugLogging ) { logMsg = 'profilePageCreateCMDAPI called!'; logData = pageResult; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } return pageResult; // Create the page var pageResult = application.ptProfile.csContent.populateContent("profile", arguments.dataValues); return pageResult; // Get the profile object var profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.userid); var profileRoles = profileObj.getRoles(); var roleKey = StructKeyList(profileRoles); var i = 1; var retProfCreated = false; // Return variable var pageObject = ''; var logMethod = 'verifyPageCreateRoles'; var logMsg = ''; var logData = StructNew(); // Loop over the role struct for ( i = 1; i LTE ListLen(roleKey); i = i + 1 ) { // Check the role permissions if ( profileRoles[ListGetAt(roleKey,i)].permission ) { // Check if any page has been created yet if ( profileRoles[ListGetAt(roleKey,i)].pageID LTE 0 ) { // Call the page creation function pageID = createProfilePage(arguments.userid, ListGetAt(roleKey,i)); if ( variables.enableDebugLogging ) { logMsg = 'userid: #arguments.userid# - pageID: #pageID#'; logData = ListGetAt(roleKey,i); application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } // Store this back in the return variable retProfCreated = true; } else { /* START - Not sure we are making it to this logic --- need to move outside of this IF block */ pageID = profileRoles[ListGetAt(roleKey,i)].pageID; if ( !application.ptProfile.csData.isCSPageActive(pageID=pageID) ) { pageObject = Server.CommonSpot.ObjectFactory.getObject("Page"); pageObject.saveActivationState(pageID,"Active"); if ( variables.enableDebugLogging ) { logMsg = 'Reactivated Page - userid: #arguments.userid# - pageID: #pageID#'; logData = ListGetAt(roleKey,i); application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } // Store this back the reactivate page in the return variable retProfCreated = true; } else { if ( variables.enableDebugLogging ) { logMsg = 'Page Is Active - userid: #arguments.userid# - pageID: #pageID#'; logData = ListGetAt(roleKey,i); application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } } /* END - Not sure we are making it to this logic */ } } } return retProfCreated; var retStatus = false; // Return variable var ccapiResult = StructNew(); // Get the profile object var profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.userid); var profileRoles = profileObj.getRoles(); var roleKey = StructKeyList(profileRoles); var itmKey = ""; var sparams = StructNew(); var i = 1; var siteVars = server.ADF.environment[request.site.id].ptProfile; var statusData = StructNew(); var sKey = ''; // Loop over the role struct for ( i = 1; i LTE ListLen(roleKey); i = i + 1 ) { itmKey = ListGetAt(roleKey, i); // Check the role permissions if ( profileRoles[itmKey].permission ) { // Check if any page has been created yet if ( profileRoles[itmKey].pageID GT 0 ) { // Load the sparams sparams.pageid = profileRoles[itmKey].pageID; sparams.subsiteid = siteVars.roles[itmKey].SUBSITE_ID; // Call the page deletion function ccapiResult = application.ptProfile.profileDAO.profilePageDeleteCCAPI(sparams); // Set the status from the deleted ROLE page if ( StructKeyExists(ccapiResult,'pageDeleted') AND ccapiResult.pageDeleted ) statusData[itmKey] = true; else statusData[itmKey] = false; // Call Post Page Delete function afterVerifyPageDelete(userid=arguments.userid,pageid=sparams.pageid,deleteStatus=statusData[itmKey]); } } } // If one Profile ROLE page is NOT deleted... do not delete profile for ( sKey IN statusData ) { retStatus = statusData[sKey]; if ( retStatus EQ false ) break; } return retStatus; var retStatus = false; // Return variable var profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.userid); var profileRoles = profileObj.getRoles(); var roleKey = StructKeyList(profileRoles); var itmKey = ""; var i = 1; var statusData = StructNew(); var pageObject = Server.CommonSpot.ObjectFactory.getObject("Page"); var pageid = ''; var logMethod = 'verifyPageDeactivate'; var logData = StructNew(); // Loop over the role struct for ( i = 1; i LTE ListLen(roleKey); i = i + 1 ) { itmKey = ListGetAt(roleKey, i); statusData[itmKey] = false; // Check the role permissions if ( profileRoles[itmKey].permission ) { // Load the sparams pageid = profileRoles[itmKey].pageID; // Check if any page has been created yet if ( IsNumeric(pageid) AND pageid GT 0 ) { // Call the page deactivation function try { statusData[itmKey] = true; pageObject.saveActivationState(pageid,"Inactive"); } catch(any ex) { logMsg = 'saveActivationState Failed: pageid:#pageid# userid:#arguments.userid#'; logData = ex; application.ptprofile.log.doTextLogging(variables.logComponent,variables.logComponent,variables.logApp,logMsg,logData); } // Call Post Page Deactivate function afterVerifyPageDeactivate(userid=arguments.userid,pageid=pageid,deleteStatus=statusData[itmKey]); } } } // If one Profile ROLE page is NOT deactivated... return false for ( sKey IN statusData ) { retStatus = statusData[sKey]; if ( retStatus EQ false ) break; } return retStatus; var retStatus = ""; var createStatus = StructNew(); var pageStatus = ""; var profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.dataValues.userid); var profileCEPageID = profileObj.GetProfileCEDataPageID(); var profileCreateType = 'update'; var logMethod = 'autoCreateProfile'; var logData = StructNew(); // Check if a profile record page id already exists if ( profileCEPageID GT 0 ) arguments.dataValues.dataPageID = profileCEPageID; // Create the profile record createStatus = handleProfileRecordCreate(arguments.dataValues); retStatus = createStatus.contentUpdated; if ( retStatus EQ true ) { if ( profileCEPageID LTE 0 ) { profileCreateType = 'new'; profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.dataValues.userid); profileDataPageID = profileObj.GetProfileCEDataPageID(); } logMsg = 'profile DataPageID: ' & profileCEPageID & ' (' & profileCreateType & ')'; logData = createStatus; application.ptprofile.log.doTextLogging('profileService','autoCreateProfile','ptProfile',logMsg,logData); } // Create the profile pages pageStatus = verifyPageCreateRoles(arguments.dataValues.userid); return retStatus; var retQuery = QueryNew("temp"); SELECT *, id AS external_id FROM profile_import WHERE userid = ORDER BY userid var extQry = arguments.qry; var keyField = arguments.keyFieldName; var r = 1; var userID = ''; var ccArr = ArrayNew(1); var ccData = StructNew(); var ccKey = ''; var row = 1; var profileObj = ''; var ccFieldData = application.ptProfile.ceData.defaultFieldStruct('profile'); var ccDataKeyList = StructKeyList(ccFieldData,','); var retQry = QueryNew(ccDataKeyList); var addQryRow = false; var logMethod = 'scanProfileDataForChanges'; var logMsg = ''; var logMsgExtraA = ''; var logMsgExtraB = ''; var logMsgValueLen = 150; var aValue = ''; var bValue = ''; var enableOneWaySync = application.ptProfile.getOneWaySyncStatus(); // true = removes profiles from CS - "one-way sync" (not just an "import" of the external data) for ( r=1; r LTE extQry.RecordCount; r++ ) { addQryRow = false; ccKey = ''; userID = TRIM(extQry[keyField][r]); ccArr = application.ptProfile.profileDAO.getProfileData( fieldName="userID", fieldVal=userID ); ccData = StructNew(); if ( ArrayLen(ccArr) AND StructKeyExists(ccArr[1],"values") ) ccData = ccArr[1].values; /* if ( StructIsEmpty(ccData) ) { // Returns a struct that has memebers/keys but no data if the UserID does not exist profileObj = server.ADF.objectFactory.getBean('profile').initProfile(userID); ccData = profileObj.getDataValues(); }*/ // Check if the Element data is not empty if ( NOT StructIsEmpty(ccData) ) { // Check if data is different for ( ccKey IN ccData ) { if ( StructKeyExists(ccFieldData,ccKey) AND StructKeyExists(extQry,ccKey) ) { aValue = trim(ccData[ccKey]); bValue = trim(extQry[ccKey][r]); // unescape the data come from different sources aValue = server.commonspot.udf.html.unescape(aValue); bValue = server.commonspot.udf.html.unescape(bValue); // remove return and newline combinations aValue = REReplace(aValue, "(\r\n|\n\r|\n|\r)","","all"); bValue = REReplace(bValue, "(\r\n|\n\r|\n|\r)","","all"); // escape extended characters (no affect) //aValue = application.ADF.data.escapeExtendedChars(str=aValue); //bValue = application.ADF.data.escapeExtendedChars(str=bValue); // remove special characters aValue = application.ADF.data.filterInternationlChars(aValue); bValue = application.ADF.data.filterInternationlChars(bValue); if ( hash(aValue) NEQ hash(bValue) ) { addQryRow = true; if ( arguments.logDiffs ) { logMsg = 'Field: '; logMsg = logMsg & ccKey; logMsg = logMsg & ': '; logMsgExtraA = ''; logMsgExtraB = ''; if ( LEN(TRIM(aValue)) ) { logMsg = logMsg & " PROFILE"; if ( LEN(aValue) GT logMsgValueLen ) { logMsg = logMsg & " HASH: (" & hash(aValue) & ")"; logMsgExtraA = 'PROFILE: '; logMsgExtraA = logMsgExtraA & LEFT(aValue,logMsgValueLen); } else logMsg = logMsg & ": " & aValue; } else logMsg = logMsg & ": " & '[[no value]]'; logMsg = logMsg & ' != '; if ( LEN(TRIM(bValue)) ) { logMsg = logMsg & " EXTERNAL"; if ( LEN(bValue) GT logMsgValueLen ) { logMsg = logMsg & " HASH: " & hash(bValue) & ")"; logMsgExtraB = 'EXTERNAL: '; logMsgExtraB = logMsgExtraB & LEFT(bValue,logMsgValueLen); } else logMsg = logMsg & ": " & bValue; } else logMsg = logMsg & ": " & '[[no value]]'; //WriteOutput('
' & logMsg & '
'); application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg); // Log Samples of long content if ( LEN(TRIM(logMsgExtraA)) ) application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsgExtraA); if ( LEN(TRIM(logMsgExtraB)) ) application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsgExtraB); // What is actually different (debug) //var diffChars = application.ADF.data.listDiff(list1=aValue,list2=bValue,delimiters=" "); //application.ptprofile.log.doTextLogging(variables.logComponent,logMethod&"DIFF",variables.logApp,diffChars); } // end logging logging logic block // If we find one difference we can stop looking and add the row break; } } } } else { addQryRow = true; } if ( !addQryRow AND enableOneWaySync ) { // Do we have a valid sync table row syncRow = application.ptProfile.profileSync.getSyncRecordByUserID(userid=userid); if ( syncRow.RecordCount EQ 0 ) addQryRow = true; } // Build Return qry if ( addQryRow ) { QueryAddRow(retQry, 1); for ( ccKey IN ccFieldData ) { if ( StructKeyExists(ccFieldData,ccKey) AND StructKeyExists(extQry,ccKey) ) { QuerySetCell( retQry, ccKey, extQry[ccKey][r], row ); } } row++; } } return retQry;
var sParams = StructNew(); var retStruct = structNew(); var profileData = ""; var logFile = ""; var autoCreateStatus = false; var pageID = 0; // For the new page activation logic var pageObject = ''; var profileObj = ''; var profileRoles = ''; var roleKey = ''; var i = ''; var logMethod = 'populateProfileFromExternalData'; var logFile = "Profiles.log"; // var logFile = "#DateFormat(now(),'YYYYMMDD')#.Profiles.log"; // check that we got a valid userid if (LEN(arguments.userid)) { // if dataPageID is NOT defined then check if the record exists by "userid" if (arguments.dataPageID LTE 0) { // Check with CEData if we just didn't pass in the datapageid profileData = application.ptProfile.profileDAO.getProfileData(fieldName="userid", fieldVal=arguments.userid); // Check the return if ( arrayLen(profileData) ) arguments.dataPageID = profileData[1].pageID; } // build the ccapi param struct sParams = buildCCAPIParams(arguments.userid, arguments.dataPageID); // Set a flag for if the content was updated retStruct.profileUpdated = sParams.tempUpdateReq; //if (sParams.error eq false) if ( LEN(sParams.userid) ) { // if dataPageID is defined then we are doing an update if (arguments.dataPageID GT 0) sParams["dataPageID"] = arguments.dataPageID; // Check the return "tempUpdateReq" exists and is T/F if ( structKeyExists(sParams, "tempUpdateReq") AND sParams.tempUpdateReq ) { // Call the Auto Create Profile function to handle all the CCAPI work autoCreateStatus = autoCreateProfile(sParams); } else { sParams['tempUpdateReq'] = false; } if ( variables.enableDebugLogging ) { logMsg = logMsg & ' sParams: '; //logMsg = logMsg & 'page ID: ' & pageID; logData = sParams; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } /* START - new page activation logic --- move to its own function!! */ /* profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.userid); profileRoles = profileObj.getRoles(); roleKey = StructKeyList(profileRoles); // Loop over the role struct for ( i = 1; i LTE ListLen(roleKey); i = i + 1 ) { // Add the page Re-activation here.... pageID = profileRoles[ListGetAt(roleKey,i)].pageID; if ( !application.ptProfile.csData.isCSPageActive(pageID=pageID) ) { pageObject = Server.CommonSpot.ObjectFactory.getObject("Page"); pageObject.saveActivationState(pageID,"Active"); if ( variables.enableDebugLogging ) { logMsg = 'Reactivated Page - userid: #arguments.userid# - pageID: #pageID#'; logData = ListGetAt(roleKey,i); application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } // Store this back the reactivate page in the return variable retProfCreated = true; } else { if ( variables.enableDebugLogging ) { logMsg = 'Page Is Active - userid: #arguments.userid# - pageID: #pageID#'; logData = ListGetAt(roleKey,i); application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } } } // roleKey - loop */ /* END - new page activation logic --- move to its own function!! */ // Update Sync Record the after Profile AutoCreate updateSyncAfterAutoCreateProfile(externalID=sParams.external_id,userid=sParams.userid,requiredUpdate=sParams['tempUpdateReq']); // Run the After the Profile AutoCreate (sync if the the update is required or NOT) afterAutoCreateProfile(externalID=sParams.external_id,userid=sParams.userid,requiredUpdate=sParams['tempUpdateReq']); retStruct.error = false; // Check if the struct fields exist for lastname if ( (StructKeyExists(sParams, "lastname")) ) retStruct.lastname = sParams["lastname"]; else retStruct.lastname = ""; // Check if the struct fields exist for firstname if ( (StructKeyExists(sParams, "firstname")) ) retStruct.firstname = sParams["firstname"]; else retStruct.firstname = ""; // Add Log Entry application.ptProfile.utils.logAppend("#logComponent# - Method: #logMethod# - UserID: #arguments.userid# - PageID: #arguments.dataPageID# - Profile Updated: #sParams.tempUpdateReq# - @ #now()#",logFile); return retStruct; } else { // Set the return struct retStruct.error = true; retStruct.errorMsg = "The specified userid record was not found in external datasource."; // Add Log Entry application.ptProfile.utils.logAppend("#variables.logComponent# - Method: #logMethod# - Error: #retStruct.errorMsg# - UserID: #arguments.userid# - PageID: #arguments.dataPageID# - LoggedInUser: #session.user.userid# - @ #now()#",logFile); return retStruct; } } else { // Set the return struct retStruct.error = true; retStruct.errorMsg = "UserID argument is blank."; // Add Log Entry application.ptProfile.utils.logAppend("#variables.logComponent# - Method: #logMethod# - Error: #retStruct.errorMsg# - UserID: #arguments.userid# - PageID: #arguments.dataPageID# - LoggedInUser: #session.user.userid# - @ #now()#",logFile); return retStruct; } var retData = StructNew(); var profileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.userid); var profileDataPageID = profileObj.GetProfileCEDataPageID(); var profileRoles = profileObj.GetRoles(); var profileData = profileObj.getElementData(); var rKey = ''; var csPageID = 0; var profileData = StructNew(); var profilePageSM = StructNew(); var logMethod = 'updateSyncAfterAutoCreateProfile'; var logMethodAlt = ''; var logMsg = ''; var logData = StructNew(); var logFile = "AutoCreateProfile.log"; var enableOneWaySync = getOneWaySyncStatus(); // true = removes profiles from CS - "one-way sync" (not just an "import" of the external data) var addSyncRow = false; if ( enableOneWaySync ) { if ( arguments.requiredUpdate ) addSyncRow = true; if ( !addSyncRow ) { // Do we have a valid sync table row syncRow = application.ptProfile.profileSync.getSyncRecordByUserID(userid=arguments.userid); if ( syncRow.RecordCount EQ 0 ) addSyncRow = true; } for ( rKey IN profileRoles ) { if ( StructKeyExists(profileRoles[rKey],'pageID') AND profileRoles[rKey].pageID GT 0 ) { csPageID = profileRoles[rKey].pageID; profilePageSM = application.ptProfile.csData.getCSObjectStandardMetadata(csPageID=csPageID); if ( addSyncRow ) { try { retData = application.ptProfile.profileSync.saveSyncRecord(externalID=arguments.externalID,pageid=csPageID,datapageid=profileDataPageID,userID=arguments.userID,profileData=profileData,pageData=profilePageSM); } catch (any excpt) { logFile = "AutoCreateProfile-Error.html"; application.ptProfile.utils.logAppend("#variables.logComponent# - Method: #logMethod# - Error: UserID: #arguments.userid# - PageID: #csPageID# - LoggedInUser: #session.user.userid# - @ #now()#",logFile); application.ptProfile.utils.logAppend(excpt,logFile); /* if ( variables.enableDebugLogging ) { logMsg = 'profilePageSM: '; logMsg = logMsg & 'page ID: ' & csPageID; logData = profilePageSM; application.ptprofile.log.doTextLogging('profileService',logMethod,'ptProfile',logMsg,logData); }*/ } } } } } /* Usually this function will be customized in the local site in the /_cs_apps/pt_profile/components/profileService.cfc */ var ccData = StructNew(); var extData = QueryNew("temp"); var erpError = false; var erpErrorMsg = ""; var updateReq = false; var extElementFields = ''; // get the profile object for the user profileObj = server.ADF.objectFactory.getBean('profile').initProfile(arguments.userid); // load the current profile data into the ccdata struct ccData = profileObj.getDataValues(); // Get the external data for the userid extData = getExternalProfileData(userid=arguments.userid); // Get the keylist if ( isQuery(extData) ) { // 2012-11-21 - Fix for RAILO to get the query column names. extElementFields = arrayToList(extData.GetColumnNames()); } // Loop over the external data and load into ccData for (i=1; i LTE ListLen(extElementFields); i=i+1) { currKey = ListGetAt(extElementFields,i); if ( StructKeyExists(ccData, currKey) ) { // Check if any difference in the fields // 2012-12-18 - MFC - Updated to TRIM the values if ( TRIM(extData[currKey][1]) NEQ TRIM(ccData[currKey]) ) { updateReq = true; // Set the field into the main data struct // 2012-11-21 - Added TRIM to prevent whitespace from the external data values. ccData[currKey] = TRIM(extData[currKey][1]); } } } // Set the update required into the element data as a temp variable ccData['tempUpdateReq'] = updateReq; // check that a profile uuid exists, if not we are creating the element instance if ( (NOT StructKeyExists(ccData, "uniqueID")) OR (LEN(ccData["uniqueID"]) LTE 0) ) ccData["uniqueID"] = createUUID(); if ( (NOT StructKeyExists(ccData, "external_id")) OR (LEN(ccData["external_id"]) LTE 0) ) ccData.external_id = extData['external_id']; // set the error flags into the return struct //ccData.error = erpError; //ccData.errorMsg = erpErrorMsg; return ccData; var retHTML = ""; var userIDVal = URLDecode(arguments.userID); var roleVal = URLDecode(arguments.Role); var lbActionVal = URLDecode(arguments.lbAction); var pageCreateJS = ''; application.ptProfile.scripts.loadJQuery(); application.ptProfile.scripts.addFooterJS(pageCreateJS,"TERTIARY");

Create Profile Pages

// Create the page pageIDResult = createProfilePage(userIDVal, roleVal);
Page Created Successfully!

Click Here to close this window.
Page Creation Failed!

Click Here to close this window.

Please login to manage your profile.


Problem occurred with the Profile Application.

Please contact your administrator.
var retHtml = ""; var loggedInUserID = request.user.userid; var profileObj = ""; var profileRoles = StructNew(); var profileElementData = StructNew(); var profileSiteVars = StructNew(); var roleKey = ""; var i = 1; // Check if the User is Logged In if ( loggedInUserID NEQ "anonymous" ){ // load the logged in users profile obj profileObj = server.ADF.objectFactory.getBean("profile").initProfile(loggedInUserID); profileRoles = profileObj.getRoles(); roleKey = StructKeyList(profileRoles); profileSiteVars = profileObj.getSiteVars(); profileElementData = profileObj.getElementData(); configStruct = application.ptProfile.getAppConfig(); // Check that name is valid in the profile retHTML = ""; retHTML = retHTML & "
"; retHTML = retHTML & ""; // does the logged in user match the profile page user if ( (loggedInUserID eq arguments.currentPageUserID) AND (profileElementData.pageID GT 0) ) { retHTML = retHTML & "Edit Profile"; retHTML = retHTML & "|"; retHTML = retHTML & "Profile Dashboard"; } else if ( (loggedInUserID neq arguments.currentPageUserID) AND (profileElementData.pageID GT 0) ) { // Loop over the role struct for ( i = 1; i LTE ListLen(roleKey); i = i + 1 ) { // Check the role permissions if ( profileRoles[ListGetAt(roleKey,i)].permission ) { // Check if any page has been created yet if ( profileRoles[ListGetAt(roleKey,i)].pageID GT 0 ) { // Output a Page Link for each role retHTML = retHTML & "My Profile"; retHTML = retHTML & "|"; } } } retHTML = retHTML & "Profile Dashboard"; } else { // No profile so put the user at the dashboard to create retHTML = retHTML & "Profile Dashboard"; } retHTML = retHTML & "|"; retHTML = retHTML & "Logout"; retHTML = retHTML & ""; } else { retHTML = "
Login to Edit Your Profile
"; } return retHTML; var retStatus = "false"; // Return variable var profileData = StructNew(); var pageDelStatus = "false"; var postDelStatus = false; // Valid the users security that they are a content contributor if ( application.ptProfile.cssecurity.isValidContributor() ) { formID = application.ptProfile.cedata.getFormIDFromPageID(arguments.dataPageID); // Get the profile data from the data page id profileData = application.ptProfile.cedata.getElementInfoByPageID(arguments.dataPageID, formID); // Call the delete profile page if ( StructKeyExists(profileData,"values") AND StructKeyExists(profileData.values,"userID") AND LEN(TRIM(profileData.values.userID)) ) { pageDelStatus = verifyPageDelete(profileData.values.userID); // Set the status if ( pageDelStatus EQ "true" ) { // Call CEData to delete application.ptProfile.cedata.deleteCE(arguments.dataPageID); retStatus = "Success"; } else retStatus = pageDelStatus; } else { retStatus = "No profile record was found for the provided userid."; } } else { retStatus = "Logged in user does not have enough permissions to delete the profile."; } return retStatus; // Number of accounts to update on a pass through var updatePassCount = arguments.passCount; // Minutes to pause var pauseMinutes = arguments.delayMinutes; // Query user id field name var qryFieldName = arguments.usernameFld; // Log file name var logFile = arguments.logFileName; var i = 1; var d = 1; var profileObj = StructNew(); var profileCEPageID = 0; var profileUserID = ""; var profile = ""; var schedTaskURL = ""; var syncProfileQry = QueryNew('tmp'); var enableOneWaySync = application.ptProfile.getOneWaySyncStatus(); // true = removes profiles from CS - "one-way sync" (not just an "import" of the external data) // Set the schedule params scheduleParams.delay = arguments.delayMinutes; //minutes till next schedule item scheduleParams.tasksPerBatch = arguments.passCount; //how many tasks to do per iteration // Build the command array cmdArray = ArrayNew(1); // Get all the external profile data extProfileData = getExternalProfileData(); if ( arguments.scanForChangesOnSchedule ) extProfileData = scanProfileDataForChanges(qry=extProfileData); // Loop over the user ID fields for ( i=1; i LTE extProfileData.recordCount; i++ ) { // Build the schedule task to call "populateProfileFromExternalData" // Build the temp command to keep calling tempCmd = StructNew(); tempCmd.app = "ptprofile"; tempCmd.bean = "profileService"; tempCmd.method = "populateProfileFromExternalData"; tempCmd.args = StructNew(); tempCmd.args.userid = extProfileData.userid[i]; tempCmd.args.dataPageID = 0; // Add the temp call to the command ArrayAppend(cmdArray, tempCmd); } if ( enableOneWaySync ) { // Get all the sync profile records syncProfileQry = afterImportCleanUpProfileQry(); // Loop over the user ID fields for ( d=1; d LTE syncProfileQry.recordCount; d++ ) { // Build the schedule tasks for "removeProfileMissingFromExternalData" to cleanup removed profiles tempCmd = StructNew(); tempCmd.app = "ptprofile"; tempCmd.bean = "profileService"; tempCmd.method = "removeProfileMissingFromExternalData"; tempCmd.args = StructNew(); tempCmd.args.userid = syncProfileQry.userid[d]; tempCmd.args.external_id = syncProfileQry.external_id[d]; tempCmd.args.dataPageID = syncProfileQry.datapageid[d]; // Add the temp call to the command ArrayAppend(cmdArray, tempCmd); } } // Load into the Scheduler application.ptProfile.scheduler.scheduleProcess(scheduleName="Profile-Bulk-Import", commands=cmdArray, scheduleParams=scheduleParams, startProcessNow=false); // Pause the scheduler sleep(2000); application.ptProfile.scheduler.pauseSchedule(scheduleName="Profile-Bulk-Import"); // Wait 2 more seconds and resume the scheduler sleep(2000); application.ptProfile.scheduler.resumeSchedule(scheduleName="Profile-Bulk-Import"); var photoPageID = 0; var photoImgURL = ""; // Check if the field is using the CS Image Gallery if ( ListContains(arguments.photo,':') ) { photoPageID = ListLast(arguments.photo,":"); if ( ListContains(photoPageID, "&") ) { photoPageID = ListFirst(photoPageID, "&"); photoImgURL = application.ptProfile.csdata.getImagePageURL(photoPageID); } else if ( ListContains(photoPageID, "|") ) { photoPageID = ListFirst(photoPageID, "|"); photoImgURL = application.ptProfile.csdata.getImagePageURL(photoPageID); } } return photoImgURL; var logMethod = 'handleEdit'; var logMethodAlt = ''; var logMsg = ''; var logData = StructNew(); // Verify the roles against the creating pages pageIDResult = verifyPageCreateRoles(arguments.userid); if ( variables.enableDebugLogging ) { logMsg = 'userID: #arguments.userid#'; logData = pageIDResult; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } return true; var profileData = StructNew(); var currProfileObj = server.ADF.objectFactory.getBean("profile").initProfile(arguments.userid); var currProfileRoles = currProfileObj.getRoles(); var currProfileData = currProfileObj.getElementData(); profileData.profileURL = ""; profileData.photoURL = ""; //profileData.photoURL = application.ptPhotoGallery.renderService.getCommunityPhotoURL('profiles', arguments.photoSize); profileData.fullName = currProfileData.Values.firstname & " " & currProfileData.Values.lastname; profileData.firstName = currProfileData.Values.firstname; profileData.lastname = currProfileData.Values.lastname; profileData.uniqueID = currProfileData.Values.uniqueID; profileData.bio = currProfileData.Values.bio; // Set the profile page URL if ( currProfileRoles[arguments.profileRole].permission ) profileData.profileURL = currProfileRoles[arguments.profileRole].pageurl; // Set the profile image //if ( LEN(currProfileData.Values.photo) ) // profileData.photoURL = application.ptPhotoGallery.photoService.getPhotoURLbyPhotoID(currProfileData.Values.photo, 'profiles', arguments.photoSize); return profileData; // Get the profile data by the UID var profileData = application.ptProfile.profileDAO.getProfileData(fieldName="uniqueID",fieldVal=arguments.profileUID); var logMethod = 'handleCreate'; var logMethodAlt = ''; var logMsg = ''; var logData = StructNew(); // Pass the userID to the handleEdit function to create the pages if ( ArrayLen(profileData) ) { if ( variables.enableDebugLogging ) { logMsg = 'profileData[1].values.userID'; logData = profileData[1].values.userID; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } handleEdit(profileData[1].values.userID); afterProfileCreate(profileData[1].values.userID); } return true; var delStatus = false; var logFile = "Profiles.log"; var logErrorFile = "Profiles-Error.html"; var postDelStatus = StructNew(); var logMethod = 'removeProfileMissingFromExternalData'; var logMethodAlt = ''; var logMsg = ''; var logData = StructNew(); var dropType = getOneSyncDropType(); if ( dropType EQ 'deactivate' ) { postDelStatus.status = false; delStatus = verifyPageDeactivate(userid=arguments.userID); if ( variables.enableDebugLogging ) { logMsg = 'verifyPageDeactivate: '; logData = delStatus; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } } else if ( dropType EQ 'delete' ) { try { postDelStatus.status = false; // Make sure we are logged in if ( application.ADF.ccapi.loggedIn() EQ 'false' ) { // construct the CCAPI object application.ADF.ccapi.initCCAPI(); application.ADF.ccapi.login(); } delStatus = handleProfileDelete(dataPageID=arguments.dataPageID); if ( variables.enableDebugLogging ) { logMsg = 'handleProfileDelete: '; logData = delStatus; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); logMsg = 'request.user: '; logData = request.user; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } // Add results to Profiles.log logMethodAlt = logMethod & ': handleProfileDelete'; application.ptProfile.utils.logAppend("#variables.logComponent# - Method: #logMethodAlt# - UserID: #arguments.userid# - DataPageID: #arguments.dataPageID# - Profile Removed: #delStatus# - @ #now()#",logFile); // Logout (not used... logs out everybody) // application.ADF.ccapi.logout(); } catch (any expt) { if ( NOT StructKeyExists(request,"removeProfileError") ) { application.ptProfile.utils.logAppend("#variables.logComponent# - Method: #logMethod# - UserID: #arguments.userid# - DataPageID: #arguments.dataPageID# - Error: Profile Remove Failed - @ #now()#",logErrorFile); application.ptProfile.utils.logAppend(cfcatch,logErrorFile); request.removeProfileError = true; } } } if ( delStatus EQ true OR FindNoCase('success',delStatus) OR FindNoCase('No profile record was found',delStatus) ) { // If handleProfileDelete() is successful, run the afterHandleProfileDelete() postDelStatus = afterHandleProfileDelete(userID=arguments.userID,status=true); if ( variables.enableDebugLogging ) { logMsg = 'afterHandleProfileDelete: '; logData = postDelStatus; application.ptprofile.log.doTextLogging(variables.logComponent,logMethod,variables.logApp,logMsg,logData); } logMethodAlt = logMethod & ': afterHandleProfileDelete'; application.ptProfile.utils.logAppend("#variables.logComponent# - Method: #logMethodAlt# - UserID: #arguments.userid# - DataPageID: #arguments.dataPageID# - Profile Sync Record Removed: #postDelStatus.status# - @ #now()#",logFile); } var retQry = QueryNew('userid,datapageid'); var enableOneWaySync = getOneWaySyncStatus(); // true = removes profiles from CS - "one-way sync" (not just an "import" of the external data) if ( enableOneWaySync ) { // Get Sync Records to drop retQry = application.ptProfile.profileSync.getSyncProfileQryForDrop(); } return retQry; var retData = StructNew(); var enableOneWaySync = getOneWaySyncStatus(); // true = removes profiles from CS - "one-way sync" (not just an "import" of the external data) // Do Not delete Sync record unless the specified profile page was successfully deleted if ( arguments.status EQ true ) { if ( enableOneWaySync ) { // Delete the Sync Table Records(s) for the specific page retData = application.ptProfile.profileSync.deleteSyncRecordByPageID(pageid=arguments.pageid); } // TODO: Add Page Delete / Sync Record Success Logging } return retData; var retData = StructNew(); var enableOneWaySync = getOneWaySyncStatus(); // true = removes profiles from CS - "one-way sync" (not just an "import" of the external data) // Do Not delete Sync record unless the Profile was successfully deleted if ( arguments.status EQ true ) { if ( enableOneWaySync ) { // Delete the Sync Table Records(s) for the specific user retData = application.ptProfile.profileSync.deleteSyncRecordByUserID(userid=arguments.userid); // TODO: Add Profile Delete / Sync Record(s) Success Logging } } return retData; var retData = StructNew(); /* * CUSTOMIZE AT THE SITE LEVEL */ return retData; /* * CUSTOMIZE AT THE SITE LEVEL */ var retStr = ''; var profileCE = getProfileCEName(); var profileIDField = getProfileIdField(); var pageNameField = getPageNameField(); var profileData = ''; var profileDataValues = StructNew(); // check if we are using the DEFAULT field if ( pageNameField EQ "userid" ) retStr = arguments.userid; else { profileData = application.ptProfile.profileDAO.getDataValues(profileCE, profileIDField, arguments.userid, ""); profileDataValues = profileData.values; if ( StructKeyExists(profileDataValues,pageNameField) ) retStr = profileDataValues[pageNameField]; // Special Exception for the Email field if ( FindNoCase("email",pageNameField) ) retStr = ListFirst(retStr,"@"); } retStr = application.ptProfile.csData.buildCSPageName(contentTitle=retStr); return TRIM(retStr); var retStr = ''; var profileCE = getProfileCEName(); var profileIDField = getProfileIdField(); var profileData = ''; var profileDataValues = StructNew(); profileData = application.ptProfile.profileDAO.getDataValues(profileCE, profileIDField, arguments.userid, ""); profileDataValues = profileData.values; if ( LEN(profileDataValues.firstName) OR LEN(profileDataValues.lastName) ) { retStr = profileDataValues.firstName & " " & profileDataValues.lastName; retStr = "Profile " & TRIM(retStr); } else retStr = "Profile " & arguments.userid; return TRIM(retStr);; var retStr = ''; var profileCE = getProfileCEName(); var profileIDField = getProfileIdField(); var profileData = ''; var profileDataValues = StructNew(); // IF CUSTOMIZING AT THE SITE LEVEL -- Uncomment to use info from the Profile data to build the description //profileData = application.ptProfile.profileDAO.getDataValues(profileCE, profileIDField, arguments.userid, ""); //profileDataValues = profileData.values; retStr = arguments.profileType & " Profile Page"; return TRIM(retStr);