// //==================================================================================================== /// <summary> /// Open dataset for the record specified /// </summary> /// <param name="contentName"></param> /// <param name="recordId"></param> /// <param name="selectFieldList"></param> /// <param name="activeOnly"></param> /// <returns></returns> public override bool OpenRecord(string contentName, int recordId, string selectFieldList, bool activeOnly) { try { if (!cs.openRecord(contentName, recordId, selectFieldList)) { return(false); } if (!activeOnly || cs.getBoolean("active")) { return(true); } cs.close(); return(false); } catch (Exception ex) { LogController.logError(cp.core, ex); throw; } }
// //==================================================================================================== /// <summary> /// GetAjaxDefaultAddonOptionStringClass remote method /// </summary> /// <param name="cp"></param> /// <returns></returns> public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { string returnHtml = ""; try { using (CoreController core = ((CPClass)cp).core) { using (var csData = new CsModel(core)) { string AddonGuid = core.docProperties.getText("guid"); csData.open(AddonModel.tableMetadata.contentName, "ccguid=" + DbController.encodeSQLText(AddonGuid)); if (csData.ok()) { string addonArgumentList = csData.getText("argumentlist"); bool addonIsInline = csData.getBoolean("IsInline"); string jsonCommand = ""; returnHtml = AddonController.getDefaultAddonOptions(core, addonArgumentList, AddonGuid, addonIsInline, csData.getText("name"), ref jsonCommand); } } } } catch (Exception ex) { cp.Site.ErrorReport(ex); } return(returnHtml); }
// //==================================================================================================== /// <summary> /// Checks if the member is a content manager for the specific content, Which includes transversing up the tree to find the next rule that applies. Member must be checked for authenticated and main_IsAdmin already /// </summary> /// <param name="core"></param> /// <param name="contentId"></param> /// <param name="returnAllowEdit"></param> /// <param name="returnAllowAdd"></param> /// <param name="returnAllowDelete"></param> /// <param name="usedContentIdList"></param> //======================================================================== // private static UserContentPermissions getUserAuthoringPermissions_ContentManager(CoreController core, ContentMetadataModel cdef, List <int> usedContentIdList) { var result = new UserContentPermissions { allowAdd = false, allowDelete = false, allowEdit = false, allowSave = false }; try { if (usedContentIdList.Contains(cdef.id)) { // // failed usedContentIdList test, this content id was in the child path // throw new ArgumentException("ContentID [" + cdef.id + "] was found to be in it's own parentid path."); } else if (cdef.id < 1) { // // ----- not a valid contentname // } else if (core.doc.contentAccessRights_NotList.Contains(cdef.id)) { // // ----- was previously found to not be a Content Manager // } else if (core.doc.contentAccessRights_List.Contains(cdef.id)) { // // ----- was previously found to be a Content Manager // result.allowEdit = true; result.allowSave = true; result.allowAdd = core.doc.contentAccessRights_AllowAddList.Contains(cdef.id); result.allowDelete = core.doc.contentAccessRights_AllowDeleteList.Contains(cdef.id); } else { // // ----- Must test it // string SQL = "SELECT ccGroupRules.ContentID,allowAdd,allowDelete" + " FROM ccGroupRules RIGHT JOIN ccMemberRules ON ccGroupRules.GroupId = ccMemberRules.GroupID" + " WHERE (" + " (ccMemberRules.memberId=" + DbController.encodeSQLNumber(core.session.user.id) + ")" + " AND(ccMemberRules.active<>0)" + " AND(ccGroupRules.active<>0)" + " AND(ccGroupRules.ContentID=" + cdef.id + ")" + " AND((ccMemberRules.DateExpires is null)OR(ccMemberRules.DateExpires>" + DbController.encodeSQLDate(core.doc.profileStartTime) + "))" + ");"; using (var csData = new CsModel(core)) { csData.openSql(SQL); if (csData.ok()) { result.allowEdit = true; result.allowSave = true; result.allowAdd = csData.getBoolean("allowAdd"); result.allowDelete = csData.getBoolean("allowDelete"); } } // if (!result.allowEdit) { // // ----- Not a content manager for this one, check the parent if (cdef.parentId > 0) { var parentCdef = ContentMetadataModel.create(core, cdef.parentId); usedContentIdList.Add(cdef.id); getUserAuthoringPermissions_ContentManager(core, cdef, usedContentIdList); } } if (result.allowEdit) { // // ----- Was found to be true // core.doc.contentAccessRights_List.Add(cdef.id); if (result.allowEdit) { core.doc.contentAccessRights_AllowAddList.Add(cdef.id); } if (result.allowDelete) { core.doc.contentAccessRights_AllowDeleteList.Add(cdef.id); } } else { // // ----- Was found to be false // core.doc.contentAccessRights_NotList.Add(cdef.id); } } } catch (Exception ex) { LogController.logError(core, ex); throw; } return(result); }
// //======================================================================== /// <summary> /// Control edit tab /// </summary> /// <param name="core"></param> /// <param name="adminData"></param> /// <returns></returns> public static string get(CoreController core, AdminDataModel adminData, EditorEnvironmentModel editorEnv) { string result = null; try { bool disabled = false; // var tabPanel = new StringBuilderLegacyController(); if (string.IsNullOrEmpty(adminData.adminContent.name)) { // // Content not found or not loaded if (adminData.adminContent.id == 0) { // LogController.logError(core, new GenericException("No content definition was specified for this page")); return(HtmlController.p("No content was specified.")); } else { // // Content Definition was not specified LogController.logError(core, new GenericException("The content definition specified for this page [" + adminData.adminContent.id + "] was not found")); return(HtmlController.p("No content was specified.")); } } // // ----- Authoring status bool FieldRequired = false; List <string> TabsFound = new List <string>(); foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if ((field.editTabName.ToLowerInvariant().Equals("control info")) && (field.authorable) && (field.active)) { tabPanel.add(EditorRowClass.getEditorRow(core, field, adminData, editorEnv)); } } // // ----- RecordID { string fieldValue = (adminData.editRecord.id == 0) ? "(available after save)" : adminData.editRecord.id.ToString(); string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, ""); string fieldHelp = "This is the unique number that identifies this record within this content."; tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Record Number", fieldHelp, true, false, "")); } // // -- Active { string htmlId = "fieldActive"; string fieldEditor = HtmlController.checkbox("active", adminData.editRecord.active, htmlId, disabled, "", adminData.editRecord.userReadOnly); string fieldHelp = "When unchecked, add-ons can ignore this record as if it was temporarily deleted."; tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Active", fieldHelp, false, false, htmlId)); } // // -- GUID { string guidSetHtmlId = "guidSet" + GenericController.getRandomInteger(core).ToString(); string guidInputHtmlId = "guidInput" + GenericController.getRandomInteger(core).ToString(); string fieldValue = GenericController.encodeText(adminData.editRecord.fieldsLc["ccguid"].value); string fieldEditor = ""; if (adminData.editRecord.userReadOnly) { // // -- readonly fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, ""); } else if (string.IsNullOrEmpty(fieldValue)) { // // add a set button string setButton = "<input id=\"" + guidSetHtmlId + "\" type=\"submit\" value=\"Set\" class=\"btn btn-primary btn-sm\">"; string setButtonWrapped = "<div class=\"input-group-append\">" + setButton + "</div>"; string inputCell = AdminUIEditorController.getTextEditor(core, "ccguid", "", false, guidInputHtmlId); fieldEditor = HtmlController.div(inputCell + setButtonWrapped, "input-group"); string newGuid = GenericController.getGUID(true); string onClickFn = "function(e){e.preventDefault();e.stopPropagation();$('#" + guidInputHtmlId + "').val('" + newGuid + "');}"; string script = "$('body').on('click','#" + guidSetHtmlId + "'," + onClickFn + ")"; core.html.addScriptCode(script, "Admin edit control-info-tab guid set button"); } else { // // field is read-only except for developers fieldEditor = AdminUIEditorController.getTextEditor(core, "ccguid", fieldValue, !core.session.isAuthenticatedDeveloper(), guidInputHtmlId); } string FieldHelp = "This is a unique number that identifies this record globally. A GUID is not required, but when set it should never be changed. GUIDs are used to synchronize records. When empty, you can create a new guid. Only Developers can modify the guid."; tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "GUID", FieldHelp, false, false, guidInputHtmlId)); } // // ----- EID (Encoded ID) { if (GenericController.toUCase(adminData.adminContent.tableName) == GenericController.toUCase("ccMembers")) { string htmlId = "fieldGuid"; bool AllowEId = (core.siteProperties.getBoolean("AllowLinkLogin", true)) || (core.siteProperties.getBoolean("AllowLinkRecognize", true)); string fieldHelp = "This string is an authentication token that can be used in the URL for the next 15 minutes to log in as this user."; string fieldEditor = ""; if (!AllowEId) { fieldEditor = "(link login and link recognize are disabled in security preferences)"; } else if (adminData.editRecord.id == 0) { fieldEditor = "(available after save)"; } else { string eidQueryString = "eid=" + WebUtility.UrlEncode(SecurityController.encodeToken(core, adminData.editRecord.id, core.doc.profileStartTime.AddMinutes(15))); string sampleUrl = core.webServer.requestProtocol + core.webServer.requestDomain + "/" + core.siteProperties.serverPageDefault + "?" + eidQueryString; if (core.siteProperties.getBoolean("AllowLinkLogin", true)) { fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be logged in as this person."; } else { fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be recognized in as this person, but not logged in."; } fieldHelp += " To enable, disable or modify this feature, use the security tab on the Preferences page."; fieldHelp += "<br>For example: " + sampleUrl; fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_eid", eidQueryString, true, htmlId); } tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Member Link Login Querystring", fieldHelp, true, false, htmlId)); } } // // ----- Controlling Content { string HTMLFieldString = ""; string FieldHelp = "The content in which this record is stored. This is similar to a database table."; ContentFieldMetadataModel field = null; if (adminData.adminContent.fields.ContainsKey("contentcontrolid")) { field = adminData.adminContent.fields["contentcontrolid"]; // // if this record has a parent id, only include CDefs compatible with the parent record - otherwise get all for the table FieldHelp = GenericController.encodeText(field.helpMessage); FieldRequired = GenericController.encodeBoolean(field.required); int FieldValueInteger = (adminData.editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : adminData.editRecord.contentControlId; if (!core.session.isAuthenticatedAdmin()) { HTMLFieldString = HTMLFieldString + HtmlController.inputHidden("contentControlId", FieldValueInteger); } else { string RecordContentName = adminData.editRecord.contentControlId_Name; string TableName2 = MetadataController.getContentTablename(core, RecordContentName); int TableId = MetadataController.getRecordIdByUniqueName(core, "Tables", TableName2); // // Test for parentid int ParentId = 0; bool ContentSupportsParentId = false; if (adminData.editRecord.id > 0) { using (var csData = new CsModel(core)) { if (csData.openRecord(RecordContentName, adminData.editRecord.id)) { ContentSupportsParentId = csData.isFieldSupported("ParentID"); if (ContentSupportsParentId) { ParentId = csData.getInteger("ParentID"); } } } } bool IsEmptyList = false; if (core.session.isAuthenticatedAdmin()) { // // administrator, and either ( no parentid or does not support it), let them select any content compatible with the table string sqlFilter = "(ContentTableID=" + TableId + ")"; int contentCId = MetadataController.getRecordIdByUniqueName(core, ContentModel.tableMetadata.contentName, ContentModel.tableMetadata.contentName); HTMLFieldString += AdminUIEditorController.getLookupContentEditor(core, "contentcontrolid", FieldValueInteger, contentCId, ref IsEmptyList, adminData.editRecord.userReadOnly, "", "", true, sqlFilter); FieldHelp = FieldHelp + " (Only administrators have access to this control. Changing the Controlling Content allows you to change who can author the record, as well as how it is edited.)"; } } } if (string.IsNullOrEmpty(HTMLFieldString)) { HTMLFieldString = adminData.editRecord.contentControlId_Name; } tabPanel.add(AdminUIController.getEditRow(core, HTMLFieldString, "Controlling Content", FieldHelp, FieldRequired, false, "")); } // // ----- Created By { string FieldHelp = "The people account of the user who created this record."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else if (adminData.editRecord.createdBy == null) { fieldValue = "(not set)"; } else { int FieldValueInteger = adminData.editRecord.createdBy.id; if (FieldValueInteger == 0) { fieldValue = "(not set)"; } else { using (var csData = new CsModel(core)) { csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false); if (!csData.ok()) { fieldValue = "#" + FieldValueInteger + ", (deleted)"; } else { fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name"); if (!csData.getBoolean("active")) { fieldValue += " (inactive)"; } } csData.close(); } } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdBy", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created By", FieldHelp, FieldRequired, false, "")); } // // ----- Created Date { string FieldHelp = "The date and time when this record was originally created."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else { if (GenericController.encodeDateMinValue(adminData.editRecord.dateAdded) == DateTime.MinValue) { fieldValue = "(not set)"; } else { fieldValue = adminData.editRecord.dateAdded.ToString(); } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdDate", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created Date", FieldHelp, FieldRequired, false, "")); } // // ----- Modified By { string FieldHelp = "The people account of the last user who modified this record."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else if (adminData.editRecord.modifiedBy == null) { fieldValue = "(not set)"; } else { int FieldValueInteger = adminData.editRecord.modifiedBy.id; if (FieldValueInteger == 0) { fieldValue = "(not set)"; } else { using (var csData = new CsModel(core)) { csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false); if (!csData.ok()) { fieldValue = "#" + FieldValueInteger + ", (deleted)"; } else { fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name"); if (!csData.getBoolean("active")) { fieldValue += " (inactive)"; } } csData.close(); } } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified By", FieldHelp, FieldRequired, false, "")); } // // ----- Modified Date { string FieldHelp = "The date and time when this record was last modified."; string fieldValue = ""; if (adminData.editRecord == null) { fieldValue = "(not set)"; } else if (adminData.editRecord.id == 0) { fieldValue = "(available after save)"; } else { if (GenericController.encodeDateMinValue(adminData.editRecord.modifiedDate) == DateTime.MinValue) { fieldValue = "(not set)"; } else { fieldValue = adminData.editRecord.modifiedDate.ToString(); } } string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, ""); tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified Date", FieldHelp, false, false, "")); } string s = AdminUIController.editTable(tabPanel.text); result = AdminUIController.getEditPanel(core, true, "Control Information", "", s); adminData.editSectionPanelCount += 1; tabPanel = null; } catch (Exception ex) { LogController.logError(core, ex); } return(result); }
// //======================================================================== /// <summary> /// Display a field in the admin index form /// </summary> /// <param name="core"></param> /// <param name="adminData"></param> /// <param name="fieldName"></param> /// <param name="CS"></param> /// <param name="IsLookupFieldValid"></param> /// <param name="IsEmailContent"></param> /// <returns></returns> public static string getGridCell(CoreController core, AdminDataModel adminData, string fieldName, CsModel csData, bool IsLookupFieldValid, bool IsEmailContent) { try { var Stream = new StringBuilderLegacyController(); var field = adminData.adminContent.fields[fieldName.ToLowerInvariant()]; if (field.password) { // // -- do not list password fields Stream.add("****"); } else { int Pos = 0; switch (field.fieldTypeId) { case CPContentBaseClass.FieldTypeIdEnum.File: case CPContentBaseClass.FieldTypeIdEnum.FileImage: { string filename = csData.getText(field.nameLc); filename = GenericController.strReplace(filename, "\\", "/"); Pos = filename.LastIndexOf("/") + 1; if (Pos != 0) { filename = filename.Substring(Pos); } Stream.add(filename); break; } case CPContentBaseClass.FieldTypeIdEnum.Lookup: { if (IsLookupFieldValid) { Stream.add(csData.getText("LookupTable" + field.id + "Name")); } else if (field.lookupList != "") { string[] lookups = field.lookupList.Split(','); int LookupPtr = csData.getInteger(field.nameLc) - 1; if (LookupPtr <= lookups.GetUpperBound(0)) { if (LookupPtr >= 0) { Stream.add(lookups[LookupPtr]); } } } else { Stream.add(" "); } break; } case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: { if (IsLookupFieldValid) { Stream.add(csData.getText("LookupTable" + field.id + "Name")); } else { Stream.add(csData.getText(field.nameLc)); } break; } case CPContentBaseClass.FieldTypeIdEnum.Boolean: { if (csData.getBoolean(field.nameLc)) { Stream.add("yes"); } else { Stream.add("no"); } break; } case CPContentBaseClass.FieldTypeIdEnum.Currency: { string fieldValueText = csData.getText(field.nameLc); if (string.IsNullOrWhiteSpace(fieldValueText)) { Stream.add(fieldValueText); break; } Stream.add(string.Format("{0:C}", csData.getNumber(field.nameLc))); break; } case CPContentBaseClass.FieldTypeIdEnum.LongText: case CPContentBaseClass.FieldTypeIdEnum.HTML: case CPContentBaseClass.FieldTypeIdEnum.HTMLCode: { string fieldValueText = csData.getText(field.nameLc); if (fieldValueText.Length > 50) { fieldValueText = fieldValueText.left(50) + "[more]"; } Stream.add(fieldValueText); break; } case CPContentBaseClass.FieldTypeIdEnum.FileText: case CPContentBaseClass.FieldTypeIdEnum.FileCSS: case CPContentBaseClass.FieldTypeIdEnum.FileXML: case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: { string filename = csData.getText(field.nameLc); if (!string.IsNullOrEmpty(filename)) { string Copy = core.cdnFiles.readFileText(filename); Stream.add(Copy); } break; } case CPContentBaseClass.FieldTypeIdEnum.Redirect: case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: { Stream.add("n/a"); break; } case CPContentBaseClass.FieldTypeIdEnum.Date: { // // -- if minvalue, use blank, if no time-part, do short-date DateTime cellValueDate = csData.getDate(field.nameLc); if (cellValueDate.Equals(DateTime.MinValue)) { Stream.add(""); } else if (cellValueDate.Equals(cellValueDate.Date)) { Stream.add(cellValueDate.ToShortDateString()); } else { Stream.add(cellValueDate.ToString()); } break; } default: { string valueString = csData.getText(field.nameLc); if (string.IsNullOrWhiteSpace(valueString)) { Stream.add(valueString); break; } Stream.add(csData.getText(field.nameLc)); break; } } } return(HtmlController.encodeHtml(Stream.text)); } catch (Exception ex) { LogController.logError(core, ex); throw; } }
// //==================================================================================================== // public static string exportAscii_GetAsciiExport(CoreController core, string ContentName, int PageSize, int PageNumber) { string result = ""; try { string Delimiter = null; string Copy = ""; string TableName = null; string FieldNameVariant = null; string FieldName = null; string UcaseFieldName = null; string iContentName = null; System.Text.StringBuilder sb = new System.Text.StringBuilder(); string TestFilename; // TestFilename = "AsciiExport" + GenericController.getRandomInteger(core) + ".txt"; // iContentName = GenericController.encodeText(ContentName); if (PageSize == 0) { PageSize = 1000; } if (PageNumber == 0) { PageNumber = 1; } // // ----- Check for special case iContentNames // core.webServer.setResponseContentType("text/plain"); core.html.enableOutputBuffer(false); TableName = DbController.getDbObjectTableName(MetadataController.getContentTablename(core, iContentName)); switch (GenericController.toUCase(TableName)) { case "CCMEMBERS": // // ----- People and member content export // if (!core.session.isAuthenticatedAdmin()) { sb.Append("Warning: You must be a site administrator to export this information."); } else { using (var csData = new CsModel(core)) { csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber); // // ----- print out the field names // if (csData.ok()) { sb.Append("\"EID\""); Delimiter = ","; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { FieldName = GenericController.encodeText(FieldNameVariant); UcaseFieldName = GenericController.toUCase(FieldName); if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD")) { sb.Append(Delimiter + "\"" + FieldName + "\""); } FieldNameVariant = csData.getNextFieldName(); } sb.Append(Environment.NewLine); } // // ----- print out the values // while (csData.ok()) { if (!(csData.getBoolean("Developer"))) { Copy = SecurityController.encodeToken(core, csData.getInteger("ID"), core.doc.profileStartTime.AddDays(30)); sb.Append("\"" + Copy + "\""); Delimiter = ","; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { FieldName = GenericController.encodeText(FieldNameVariant); UcaseFieldName = GenericController.toUCase(FieldName); if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD")) { Copy = csData.getText(FieldName); if (!string.IsNullOrEmpty(Copy)) { Copy = GenericController.strReplace(Copy, "\"", "'"); Copy = GenericController.strReplace(Copy, Environment.NewLine, " "); Copy = GenericController.strReplace(Copy, "\r", " "); Copy = GenericController.strReplace(Copy, "\n", " "); } sb.Append(Delimiter + "\"" + Copy + "\""); } FieldNameVariant = csData.getNextFieldName(); } sb.Append(Environment.NewLine); } csData.goNext(); } } } // End Case break; default: // // ----- All other content // if (!core.session.isAuthenticatedContentManager(iContentName)) { sb.Append("Error: You must be a content manager to export this data."); } else { using (var csData = new CsModel(core)) { csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber); // // ----- print out the field names if (csData.ok()) { Delimiter = ""; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + FieldNameVariant + "\""); Delimiter = ","; FieldNameVariant = csData.getNextFieldName(); } core.wwwFiles.appendFile(TestFilename, Environment.NewLine); } // // ----- print out the values while (csData.ok()) { Delimiter = ""; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { switch (csData.getFieldTypeId(GenericController.encodeText(FieldNameVariant))) { case CPContentBaseClass.FieldTypeIdEnum.FileText: case CPContentBaseClass.FieldTypeIdEnum.FileCSS: case CPContentBaseClass.FieldTypeIdEnum.FileXML: case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: Copy = csData.getTextEncoded(GenericController.encodeText(FieldNameVariant)); break; case CPContentBaseClass.FieldTypeIdEnum.Lookup: Copy = csData.getText(GenericController.encodeText(FieldNameVariant)); break; case CPContentBaseClass.FieldTypeIdEnum.Redirect: case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: break; default: Copy = csData.getText(GenericController.encodeText(FieldNameVariant)); break; } if (!string.IsNullOrEmpty(Copy)) { Copy = GenericController.strReplace(Copy, "\"", "'"); Copy = GenericController.strReplace(Copy, Environment.NewLine, " "); Copy = GenericController.strReplace(Copy, "\r", " "); Copy = GenericController.strReplace(Copy, "\n", " "); } core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + Copy + "\""); Delimiter = ","; FieldNameVariant = csData.getNextFieldName(); } core.wwwFiles.appendFile(TestFilename, Environment.NewLine); csData.goNext(); } } } break; } result = core.wwwFiles.readFileText(TestFilename); core.wwwFiles.deleteFile(TestFilename); } catch (Exception ex) { LogController.logError(core, ex); } return(result); }
// //======================================================================== // public static void processJoinForm(CoreController core) { try { string ErrorMessage = ""; string FirstName = null; string LastName = null; string FullName = null; string Email = null; int errorCode = 0; // string loginForm_Username = ""; string loginForm_Password = ""; loginForm_Username = core.docProperties.getText("username"); loginForm_Password = core.docProperties.getText("password"); // if (!GenericController.encodeBoolean(core.siteProperties.getBoolean("AllowMemberJoin", false))) { ErrorController.addUserError(core, "This site does not accept public main_MemberShip."); } else { if (!core.session.isNewCredentialOK(loginForm_Username, loginForm_Password, ref ErrorMessage, ref errorCode)) { ErrorController.addUserError(core, ErrorMessage); } else { if (!(!core.doc.userErrorList.Count.Equals(0))) { using (var csData = new CsModel(core)) { csData.open("people", "ID=" + DbController.encodeSQLNumber(core.session.user.id)); if (!csData.ok()) { LogController.logError(core, new Exception("Could not open the current members account to set the username and password.")); } else { if ((csData.getText("username") != "") || (csData.getText("password") != "") || (csData.getBoolean("admin")) || (csData.getBoolean("developer"))) { // // if the current account can be logged into, you can not join 'into' it // core.session.logout(); } FirstName = core.docProperties.getText("firstname"); LastName = core.docProperties.getText("lastname"); FullName = FirstName + " " + LastName; Email = core.docProperties.getText("email"); csData.set("FirstName", FirstName); csData.set("LastName", LastName); csData.set("Name", FullName); csData.set("username", loginForm_Username); csData.set("password", loginForm_Password); core.session.authenticateById(core.session.user.id, core.session); } csData.close(); } } } } PersonModel.invalidateCacheOfRecord <PersonModel>(core.cpParent, core.session.user.id); } catch (Exception ex) { LogController.logError(core, ex); throw; } }