Exemplo n.º 1
0
 //
 //====================================================================================================
 //
 public override void OpenLayout(string layoutRecordNameOrGuid)
 {
     try {
         accum = "";
         LayoutModel layout;
         if (layoutRecordNameOrGuid.isNumeric())
         {
             //
             // -- recordId
             layout = DbBaseModel.create <LayoutModel>(cp, GenericController.encodeInteger(layoutRecordNameOrGuid));
         }
         else if (GenericController.isGuid(layoutRecordNameOrGuid))
         {
             //
             // -- record guid
             layout = LayoutModel.create <LayoutModel>(cp, layoutRecordNameOrGuid);
         }
         else
         {
             //
             // -- record name
             layout = LayoutModel.createByUniqueName <LayoutModel>(cp, layoutRecordNameOrGuid);
         }
         if (layout != null)
         {
             accum = layout.layout.content;
         }
     } catch (Exception ex) {
         LogController.logError(cp.core, ex);
         throw;
     }
 }
        //
        //====================================================================================================
        /// <summary>
        /// setAdminSiteFieldHelp remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                if (cp.User.IsAdmin)
                {
                    int fieldId = cp.Doc.GetInteger("fieldId");
                    var help    = ContentFieldHelpModel.createByFieldId(cp, fieldId);
                    if (help == null)
                    {
                        help         = DbBaseModel.addDefault <ContentFieldHelpModel>(core.cpParent, Processor.Models.Domain.ContentMetadataModel.getDefaultValueDict(core, ContentFieldHelpModel.tableMetadata.contentName));
                        help.fieldId = fieldId;
                    }
                    help.helpCustom = cp.Doc.GetText("helpcustom");
                    help.save(cp);
                    ContentFieldModel contentField = DbBaseModel.create <ContentFieldModel>(core.cpParent, fieldId);
                    if (contentField != null)
                    {
                        ContentMetadataModel.invalidateCache(core, contentField.contentId);
                    }
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Exemplo n.º 3
0
        //
        //========================================================================
        //
        public static void requestDownload(CoreController core, int customReportId)
        {
            //
            // Request the download
            //
            var customReport = DbBaseModel.create <CustomReportModel>(core.cpParent, customReportId);

            if (customReport != null)
            {
                var ExportCSVAddon = DbBaseModel.create <AddonModel>(core.cpParent, addonGuidExportCSV);
                if (ExportCSVAddon == null)
                {
                    LogController.logError(core, new GenericException("ExportCSV addon not found. Task could not be added to task queue."));
                }
                else
                {
                    var docProperties = new Dictionary <string, string> {
                        { "sql", customReport.sqlQuery },
                        { "datasource", "default" }
                    };
                    var cmdDetail = new TaskModel.CmdDetailClass {
                        addonId   = ExportCSVAddon.id,
                        addonName = ExportCSVAddon.name,
                        args      = docProperties
                    };
                    string ExportFilename = "CustomReport_" + customReport.id.ToString("00000000") + ".csv";
                    string reportName     = customReport.name ?? "#" + customReport.id;
                    TaskSchedulerController.addTaskToQueue(core, cmdDetail, false, "Custom Report, " + reportName, ExportFilename);
                }
            }
        }
Exemplo n.º 4
0
 //
 //====================================================================================================
 /// <summary>
 /// getFieldEditorPreference remote method
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
 {
     try {
         CoreController core = ((CPClass)cp).core;
         //
         // -- Email click detected
         EmailDropModel emailDrop = DbBaseModel.create <EmailDropModel>(core.cpParent, core.docProperties.getInteger(rnEmailClickFlag));
         if (emailDrop != null)
         {
             PersonModel recipient = DbBaseModel.create <PersonModel>(core.cpParent, core.docProperties.getInteger(rnEmailMemberId));
             if (recipient != null)
             {
                 EmailLogModel log = DbBaseModel.addDefault <EmailLogModel>(core.cpParent);
                 log.name        = "User " + recipient.name + " clicked link from email drop " + emailDrop.name + " at " + core.doc.profileStartTime.ToString();
                 log.emailDropId = emailDrop.id;
                 log.emailId     = emailDrop.emailId;
                 log.memberId    = recipient.id;
                 log.logType     = EmailLogTypeClick;
                 log.visitId     = cp.Visit.Id;
                 log.save(cp);
             }
         }
     } catch (Exception ex) {
         cp.Site.ErrorReport(ex);
     }
     return("");
 }
        //
        // ====================================================================================================

        public static string get(CPBaseClass cp, PageTemplateModel template)
        {
            try {
                string addonList = "";
                foreach (var rule in DbBaseModel.createList <AddonTemplateRuleModel>(cp, "(templateId=" + template.id + ")"))
                {
                    AddonModel addon = DbBaseModel.create <AddonModel>(cp, rule.addonId);
                    if (addon != null)
                    {
                        addonList += System.Environment.NewLine + "\t\t" + "<IncludeAddon name=\"" + addon.name + "\" guid=\"" + addon.ccguid + "\" />";
                    }
                }
                return(""
                       + System.Environment.NewLine + "\t" + "<Template"
                       + " name=\"" + System.Net.WebUtility.HtmlEncode(template.name) + "\""
                       + " guid=\"" + template.ccguid + "\""
                       + " issecure=\"" + GenericController.getYesNo(template.isSecure) + "\""
                       + " >"
                       + addonList
                       + System.Environment.NewLine + "\t\t" + "<BodyHtml>" + ExportController.tabIndent(cp, ExportController.EncodeCData(template.bodyHTML)) + "</BodyHtml>"
                       + System.Environment.NewLine + "\t" + "</Template>");
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex, "GetAddonNode");
                return(string.Empty);
            }
        }
Exemplo n.º 6
0
 //
 //====================================================================================================
 //
 public override void ExportCsv(string sql, string exportName, string filename)
 {
     try {
         var ExportCSVAddon = DbBaseModel.create <AddonModel>(cp, addonGuidExportCSV);
         if (ExportCSVAddon == null)
         {
             LogController.logError(cp.core, new GenericException("ExportCSV addon not found. Task could not be added to task queue."));
         }
         else
         {
             var cmdDetail = new TaskModel.CmdDetailClass {
                 addonId   = ExportCSVAddon.id,
                 addonName = ExportCSVAddon.name,
                 args      = new Dictionary <string, string> {
                     { "sql", sql },
                     { "ExportName", exportName },
                     { "filename", filename }
                 }
             };
             TaskSchedulerController.addTaskToQueue(cp.core, cmdDetail, false, exportName, filename);
         }
     } catch (Exception) {
         throw;
     }
 }
Exemplo n.º 7
0
        //
        //====================================================================================================
        /// <summary>
        /// Add a user to a group. If gorupId doesnt exist, an error is logged.
        /// </summary>
        /// <param name="core"></param>
        /// <param name="groupId"></param>
        /// <param name="userId"></param>
        /// <param name="dateExpires"></param>
        public static void addUser(CoreController core, int groupId, int userId, DateTime dateExpires)
        {
            var group = DbBaseModel.create <GroupModel>(core.cpParent, groupId);

            if (group == null)
            {
                //
                // -- inactive or invalid groupId
                //LogController.logError(core, new GenericException("addUser called with invalid groupId [" + groupId + "]"));
                return;
            }
            if (userId.Equals(0))
            {
                //
                // -- default to keyboard user
                userId = core.session.user.id;
            }
            PersonModel user = DbBaseModel.create <PersonModel>(core.cpParent, userId);

            if (user == null)
            {
                //
                // -- inactive or invalid userId
                //LogController.logError(core, new GenericException("addUser called with invalid userId [" + userId + "]"));
                return;
            }
            addUser(core, group, user, dateExpires);
        }
Exemplo n.º 8
0
 //
 //=================================================================================
 /// <summary>
 /// Get a record lock status. If session.user is the lock holder, returns unlocked
 /// </summary>
 /// <param name="ContentName"></param>
 /// <param name="recordId"></param>
 /// <param name="ReturnMemberID"></param>
 /// <param name="ReturnDateExpires"></param>
 /// <returns></returns>
 public static editLockClass getEditLock(CoreController core, int tableId, int recordId)
 {
     try {
         var table = DbBaseModel.create <TableModel>(core.cpParent, tableId);
         if (table != null)
         {
             //
             // -- get the edit control for this record (not by this person) with the oldest expiration date
             string criteria             = "(createdby<>" + core.session.user.id + ")and" + getAuthoringControlCriteria(getTableRecordKey(table.id, recordId), AuthoringControls.Editing, core.dateTimeNowMockable);
             var    authoringControlList = DbBaseModel.createList <AuthoringControlModel>(core.cpParent, criteria, "dateexpires desc");
             if (authoringControlList.Count > 0)
             {
                 var person = DbBaseModel.create <PersonModel>(core.cpParent, GenericController.encodeInteger(authoringControlList.First().createdBy));
                 return(new editLockClass {
                     isEditLocked = true,
                     editLockExpiresDate = authoringControlList.First().dateExpires,
                     editLockByMemberId = (person == null) ? 0 : person.id,
                     editLockByMemberName = (person == null) ? "" : person.name
                 });
             }
         }
         ;
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
     return(new editLockClass {
         isEditLocked = false
     });
 }
        //
        //====================================================================================================
        /// <summary>
        /// getFieldEditorPreference remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                //
                // save custom styles
                if (core.session.isAuthenticatedAdmin())
                {
                    int addonId = core.docProperties.getInteger("AddonID");
                    if (addonId > 0)
                    {
                        AddonModel styleAddon = DbBaseModel.create <AddonModel>(core.cpParent, addonId);
                        if (styleAddon.stylesFilename.content != core.docProperties.getText("CustomStyles"))
                        {
                            styleAddon.stylesFilename.content = core.docProperties.getText("CustomStyles");
                            styleAddon.save(core.cpParent);
                            //
                            // Clear Caches
                            //
                            DbBaseModel.invalidateCacheOfRecord <AddonModel>(core.cpParent, addonId);
                        }
                    }
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Exemplo n.º 10
0
 //
 //====================================================================================================
 /// <summary>
 /// getFieldEditorPreference remote method
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
 {
     try {
         CoreController core        = ((CPClass)cp).core;
         int            emailDropId = core.docProperties.getInteger(rnEmailOpenFlag);
         if (emailDropId != 0)
         {
             //
             // -- Email open detected. Log it and redirect to a 1x1 spacer
             EmailDropModel emailDrop = DbBaseModel.create <EmailDropModel>(core.cpParent, emailDropId);
             if (emailDrop != null)
             {
                 PersonModel recipient = DbBaseModel.create <PersonModel>(core.cpParent, core.docProperties.getInteger(rnEmailMemberId));
                 if (recipient != null)
                 {
                     EmailLogModel log = DbBaseModel.addDefault <EmailLogModel>(core.cpParent);
                     log.name        = "User " + recipient.name + " opened email drop " + emailDrop.name + " at " + core.doc.profileStartTime.ToString();
                     log.emailDropId = emailDrop.id;
                     log.emailId     = emailDrop.emailId;
                     log.memberId    = recipient.id;
                     log.logType     = EmailLogTypeOpen;
                     log.visitId     = cp.Visit.Id;
                     log.save(cp);
                 }
             }
         }
         core.webServer.redirect(NonEncodedLink: "" + cdnPrefix + "images/spacer.gif", RedirectReason: "Group Email Open hit, redirecting to a dummy image", IsPageNotFound: false, allowDebugMessage: false);
     } catch (Exception ex) {
         cp.Site.ErrorReport(ex);
     }
     return("");
 }
Exemplo n.º 11
0
        //
        public static AuthenticateResponse authenticateUsernamePassword(CoreController core, string username, string password, string errorPrefix)
        {
            int userId = core.session.getUserIdForUsernameCredentials(username, password);

            if (userId == 0)
            {
                //
                // -- user was not found
                core.webServer.setResponseStatus(WebServerController.httpResponseStatus401_Unauthorized);
                return(new AuthenticateResponse {
                    errors = new List <string> {
                        errorPrefix + " failed."
                    },
                    data = new AuthenticateResponseData()
                });
            }
            else
            {
                if (!core.session.authenticateById(userId, core.session))
                {
                    //
                    // -- username/password login failed
                    core.webServer.setResponseStatus(WebServerController.httpResponseStatus401_Unauthorized);
                    return(new AuthenticateResponse {
                        errors = new List <string> {
                            errorPrefix + " failed."
                        },
                        data = new AuthenticateResponseData()
                    });
                }
                else
                {
                    var user = DbBaseModel.create <PersonModel>(core.cpParent, core.session.user.id);
                    if (user == null)
                    {
                        core.webServer.setResponseStatus(WebServerController.httpResponseStatus401_Unauthorized);
                        return(new AuthenticateResponse {
                            errors = new List <string> {
                                errorPrefix + " user is not valid."
                            },
                            data = new AuthenticateResponseData()
                        });
                    }
                    else
                    {
                        LogController.addSiteActivity(core, errorPrefix + " successful", core.session.user.id, core.session.user.organizationId);
                        return(new AuthenticateResponse {
                            errors = new List <string>(),
                            data = new AuthenticateResponseData {
                                firstName = user.firstName,
                                lastName = user.lastName,
                                email = user.email,
                                avatar = (!string.IsNullOrWhiteSpace(user.thumbnailFilename)) ? core.appConfig.cdnFileUrl + user.thumbnailFilename : (!string.IsNullOrWhiteSpace(user.imageFilename)) ? core.appConfig.cdnFileUrl + user.imageFilename : ""
                            }
                        });
                    }
                }
            }
        }
Exemplo n.º 12
0
        //
        //====================================================================================================
        /// <summary>
        /// Get a group Name
        /// </summary>
        /// <param name="core"></param>
        /// <param name="groupId"></param>
        /// <returns></returns>
        public static string getGroupName(CoreController core, int groupId)
        {
            var group = DbBaseModel.create <GroupModel>(core.cpParent, groupId);

            if (group != null)
            {
                return(group.name);
            }
            return(String.Empty);
        }
Exemplo n.º 13
0
        //
        //====================================================================================================
        //
        public override string GetName(int contentId)
        {
            var content = DbBaseModel.create <ContentModel>(cp, contentId);

            if (content != null)
            {
                return(content.name);
            }
            return(string.Empty);
        }
Exemplo n.º 14
0
        //
        //====================================================================================================
        //
        public override void sendUser(int toUserId, string fromAddress, string subject, string body, bool sendImmediately, bool bodyIsHtml, ref string userErrorMessage)
        {
            PersonModel person = DbBaseModel.create <PersonModel>(cp, toUserId);

            if (person == null)
            {
                userErrorMessage = "An email could not be sent because the user could not be located.";
                return;
            }
            EmailController.queuePersonEmail(cp.core, "Ad Hoc Email", person, fromAddress, subject, body, "", "", sendImmediately, bodyIsHtml, 0, "", false, ref userErrorMessage);
        }
Exemplo n.º 15
0
            //
            // ====================================================================================================
            public static AddonMockDataModel createOrAddSettings(CPBaseClass cp, string settingsGuid)
            {
                AddonMockDataModel result = create <AddonMockDataModel>(cp, settingsGuid);

                if ((result == null))
                {
                    //
                    // -- create default content
                    result              = addDefault <AddonMockDataModel>(cp);
                    result.name         = tableMetadata.contentName + " " + result.id;
                    result.ccguid       = settingsGuid;
                    result.themeStyleId = 0;
                    result.padTop       = false;
                    result.padBottom    = false;
                    result.padRight     = false;
                    result.padLeft      = false;
                    //
                    // -- create custom content
                    result.jsondata = "{\"headline\":\"Hello World\",\"items\":[{\"name\":\"Rock\",\"price\":\"$1.24\"},{\"name\":\"Nice Rock\",\"price\":\"$2.99\"}]}";
                    //
                    DateTime rightNow      = DateTime.Now;
                    var      layout        = DbBaseModel.create <LayoutModel>(cp, Constants.guidAddonMockLayout);
                    string   defaultLayout = "<h2>{{headline}}</h2><ul>{{#items}}<hr><li><div>name: {{name}}</div><div>price: {{price}}</div></li>{{/items}}</ul><hr>";
                    if (layout == null)
                    {
                        //
                        // -- no layout found for the default guid, create now
                        layout                = DbBaseModel.addDefault <LayoutModel>(cp);
                        layout.name           = "Addon Mock Default Layout, " + rightNow.Year + rightNow.Month.ToString().PadLeft(2, '0') + rightNow.Day.ToString().PadLeft(2, '0');
                        layout.ccguid         = Constants.guidAddonMockLayout;
                        layout.layout.content = defaultLayout;
                        layout.save(cp);
                    }
                    if (layout.layout.content != defaultLayout)
                    {
                        //
                        // -- layout does not match default content, they edited it so just create a new record
                        layout                = DbBaseModel.addDefault <LayoutModel>(cp);
                        layout.name           = "Addon Mock Default Layout, " + rightNow.Year + rightNow.Month.ToString().PadLeft(2, '0') + rightNow.Day.ToString().PadLeft(2, '0');
                        layout.ccguid         = cp.Utils.CreateGuid();
                        layout.layout.content = defaultLayout;
                        layout.save(cp);
                    }
                    result.layoutid = layout.id;
                    //
                    result.save(cp);
                    //
                    // -- track the last modified date
                    cp.Content.LatestContentModifiedDate.Track(result.modifiedDate);
                }
                return(result);
            }
Exemplo n.º 16
0
        //
        //====================================================================================================
        /// <summary>
        /// Remove a user from a group.
        /// </summary>
        /// <param name="core"></param>
        /// <param name="groupId"></param>
        /// <param name="userId"></param>
        public static void removeUser(CoreController core, int groupId, int userId)
        {
            var group = DbBaseModel.create <GroupModel>(core.cpParent, groupId);

            if (group != null)
            {
                var user = DbBaseModel.create <PersonModel>(core.cpParent, userId);
                if (user != null)
                {
                    removeUser(core, group, user);
                }
            }
        }
Exemplo n.º 17
0
 //====================================================================================================
 /// <summary>
 /// create a feature list box
 /// </summary>
 /// <param name="cp"></param>
 /// <param name="feature"></param>
 /// <returns></returns>
 public static string getFeatureList(CPBaseClass cp, PortalDataModel portalData, PortalDataFeatureModel feature, string frameRqs)
 {
     try {
         //string activeNavHeading = feature.heading;
         string items = "";
         foreach (KeyValuePair <string, PortalDataFeatureModel> kvp in portalData.featureList)
         {
             PortalDataFeatureModel liFeature = kvp.Value;
             if ((liFeature.parentFeatureId == feature.id) && (liFeature.parentFeatureId != 0))
             {
                 string featureHeading = liFeature.heading;
                 if (string.IsNullOrEmpty(featureHeading))
                 {
                     featureHeading = liFeature.name;
                 }
                 if (liFeature.dataContentId != 0)
                 {
                     //
                     // -- display content button if content is not developeronly, or if this is a developer
                     ContentModel featureContent = DbBaseModel.create <ContentModel>(cp, liFeature.dataContentId);
                     if (featureContent != null)
                     {
                         if ((!featureContent.developerOnly) || (cp.User.IsDeveloper))
                         {
                             string qs = frameRqs;
                             qs     = cp.Utils.ModifyQueryString(qs, "addonid", "", false);
                             qs     = cp.Utils.ModifyQueryString(qs, Constants.rnDstFeatureGuid, "", false);
                             qs     = cp.Utils.ModifyQueryString(qs, "cid", liFeature.dataContentId.ToString());
                             items += "<li><a target=\"_blank\" href=\"?" + qs + "\">" + featureHeading + "</a></li>";
                         }
                     }
                 }
                 else
                 {
                     string qs = cp.Utils.ModifyQueryString(frameRqs, Constants.rnDstFeatureGuid, liFeature.guid);
                     items += "<li><a href=\"?" + qs + "\">" + featureHeading + "</a></li>";
                 }
             }
         }
         FormSimpleClass content = new FormSimpleClass {
             title = feature.heading,
             body  = "<ul class=\"afwButtonList\">" + items + "</ul>"
         };
         return(content.getHtml(cp));
     } catch (Exception ex) {
         cp.Site.ErrorReport(ex, "portalClass.getFeatureList exception");
         throw;
     }
 }
Exemplo n.º 18
0
 //
 //====================================================================================================
 /// <summary>
 /// executes an addon with the name or guid provided, in the context specified.
 /// </summary>
 /// <param name="addonNameOrGuid"></param>
 /// <param name="addonContext"></param>
 /// <returns></returns>
 public string executeAddon(string addonNameOrGuid, CPUtilsBaseClass.addonContext addonContext = CPUtilsBaseClass.addonContext.ContextSimple)
 {
     try {
         if (GenericController.isGuid(addonNameOrGuid))
         {
             //
             // -- call by guid
             AddonModel addon = DbBaseModel.create <AddonModel>(core.cpParent, addonNameOrGuid);
             if (addon == null)
             {
                 throw new GenericException("Addon [" + addonNameOrGuid + "] could not be found.");
             }
             else
             {
                 return(core.addon.execute(addon, new CPUtilsBaseClass.addonExecuteContext {
                     addonType = addonContext,
                     errorContextMessage = "external call to execute addon [" + addonNameOrGuid + "]"
                 }));
             }
         }
         else
         {
             AddonModel addon = AddonModel.createByUniqueName(core.cpParent, addonNameOrGuid);
             if (addon != null)
             {
                 //
                 // -- call by name
                 return(core.addon.execute(addon, new CPUtilsBaseClass.addonExecuteContext {
                     addonType = addonContext,
                     errorContextMessage = "external call to execute addon [" + addonNameOrGuid + "]"
                 }));
             }
             else if (addonNameOrGuid.isNumeric())
             {
                 //
                 // -- compatibility - call by id
                 return(executeAddon(GenericController.encodeInteger(addonNameOrGuid), addonContext));
             }
             else
             {
                 throw new GenericException("Addon [" + addonNameOrGuid + "] could not be found.");
             }
         }
     } catch (Exception ex) {
         Site.ErrorReport(ex);
     }
     return(string.Empty);
 }
Exemplo n.º 19
0
        //
        //====================================================================================================
        /// <summary>
        /// Add a user to a group. if group is missing and argument is name or guid, it is created.
        /// </summary>
        /// <param name="core"></param>
        /// <param name="groupNameIdOrGuid"></param>
        /// <param name="userid"></param>
        /// <param name="dateExpires"></param>
        public static void addUser(CoreController core, string groupNameIdOrGuid, int userid, DateTime dateExpires)
        {
            GroupModel group = null;

            if (groupNameIdOrGuid.isNumeric())
            {
                group = DbBaseModel.create <GroupModel>(core.cpParent, GenericController.encodeInteger(groupNameIdOrGuid));
                if (group == null)
                {
                    LogController.logError(core, new GenericException("addUser called with invalid groupId [" + groupNameIdOrGuid + "]"));
                    return;
                }
            }
            else if (GenericController.isGuid(groupNameIdOrGuid))
            {
                group = DbBaseModel.create <GroupModel>(core.cpParent, groupNameIdOrGuid);
                if (group == null)
                {
                    var defaultValues = ContentMetadataModel.getDefaultValueDict(core, "groups");
                    group         = DbBaseModel.addDefault <GroupModel>(core.cpParent, defaultValues);
                    group.ccguid  = groupNameIdOrGuid;
                    group.name    = groupNameIdOrGuid;
                    group.caption = groupNameIdOrGuid;
                    group.save(core.cpParent);
                }
            }
            else
            {
                group = DbBaseModel.createByUniqueName <GroupModel>(core.cpParent, groupNameIdOrGuid);
                if (group == null)
                {
                    group         = DbBaseModel.addDefault <GroupModel>(core.cpParent, Models.Domain.ContentMetadataModel.getDefaultValueDict(core, "groups"));
                    group.ccguid  = groupNameIdOrGuid;
                    group.name    = groupNameIdOrGuid;
                    group.caption = groupNameIdOrGuid;
                    group.save(core.cpParent);
                }
            }
            var user = DbBaseModel.create <PersonModel>(core.cpParent, userid);

            if (user != null)
            {
                addUser(core, group, user, dateExpires);
            }
        }
Exemplo n.º 20
0
 //
 //====================================================================================================
 /// <summary>
 /// getFieldEditorPreference remote method
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
 {
     try {
         CoreController core = ((CPClass)cp).core;
         //
         // -- click spam block detected
         {
             string recipientEmailToBlock = core.docProperties.getText(rnEmailBlockRecipientEmail);
             if (!string.IsNullOrEmpty(recipientEmailToBlock))
             {
                 List <PersonModel> recipientList = DbBaseModel.createList <PersonModel>(core.cpParent, "(email=" + DbController.encodeSQLText(recipientEmailToBlock) + ")");
                 foreach (var recipient in recipientList)
                 {
                     recipient.allowBulkEmail = false;
                     recipient.save(cp, 0);
                     //
                     // -- Email spam footer was clicked, clear the AllowBulkEmail field
                     EmailController.addToBlockList(core, recipientEmailToBlock);
                     //
                     // -- log entry to track the result of this email drop
                     int emailDropId = core.docProperties.getInteger(rnEmailBlockRequestDropId);
                     if (emailDropId != 0)
                     {
                         EmailDropModel emailDrop = DbBaseModel.create <EmailDropModel>(cp, emailDropId);
                         if (emailDrop != null)
                         {
                             EmailLogModel log = DbBaseModel.addDefault <EmailLogModel>(core.cpParent);
                             log.name        = "User " + recipient.name + " clicked linked spam block from email drop " + emailDrop.name + " at " + core.doc.profileStartTime.ToString();
                             log.emailDropId = emailDrop.id;
                             log.emailId     = emailDrop.emailId;
                             log.memberId    = recipient.id;
                             log.logType     = EmailLogTypeBlockRequest;
                             log.visitId     = cp.Visit.Id;
                             log.save(cp);
                         }
                     }
                 }
             }
             return(cp.Content.GetCopy("Default Email Blocked Response Page", Resources.defaultEmailBlockedResponsePage));
         }
     } catch (Exception ex) {
         cp.Site.ErrorReport(ex);
     }
     return("");
 }
Exemplo n.º 21
0
        //
        //====================================================================================================
        //
        public override int GetId(string GroupNameOrGuid)
        {
            GroupModel group;

            if (GenericController.isGuid(GroupNameOrGuid))
            {
                group = DbBaseModel.create <GroupModel>(cp, GroupNameOrGuid);
            }
            else
            {
                group = DbBaseModel.createByUniqueName <GroupModel>(cp, GroupNameOrGuid);
            }
            if (group != null)
            {
                return(group.id);
            }
            return(0);
        }
Exemplo n.º 22
0
        //
        //=============================================================================
        /// <summary>
        /// A login form that can be added to any page. This is just form with no surrounding border, etc.
        /// </summary>
        /// <returns></returns>
        public static string getLoginForm(CoreController core, bool forceDefaultLoginForm = false)
        {
            string returnHtml = "";

            try {
                int loginAddonId = 0;
                if (!forceDefaultLoginForm)
                {
                    loginAddonId = core.siteProperties.getInteger("Login Page AddonID");
                    if (loginAddonId != 0)
                    {
                        //
                        // -- Custom Login
                        AddonModel addon = DbBaseModel.create <AddonModel>(core.cpParent, loginAddonId);
                        CPUtilsBaseClass.addonExecuteContext executeContext = new CPUtilsBaseClass.addonExecuteContext {
                            addonType           = CPUtilsBaseClass.addonContext.ContextPage,
                            errorContextMessage = "calling login form addon [" + loginAddonId + "] from internal method"
                        };
                        returnHtml = core.addon.execute(addon, executeContext);
                        if (string.IsNullOrEmpty(returnHtml))
                        {
                            //
                            // -- login successful, redirect back to this page (without a method)
                            string QS = core.doc.refreshQueryString;
                            QS = GenericController.modifyQueryString(QS, "method", "");
                            QS = GenericController.modifyQueryString(QS, "RequestBinary", "");
                            //
                            return(core.webServer.redirect("?" + QS, "Login form success"));
                        }
                    }
                }
                if (loginAddonId == 0)
                {
                    //
                    // ----- When page loads, set focus on login username
                    //
                    returnHtml = getLoginForm_Default(core);
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnHtml);
        }
Exemplo n.º 23
0
 //
 // ====================================================================================================
 //
 public static string getLayout(BaseClasses.CPBaseClass CP, string layoutName, string layoutGuid, string layoutFilename)
 {
     try {
         //
         // -- install default detail layout
         LayoutModel layout = DbBaseModel.create <LayoutModel>(CP, layoutGuid);
         if ((layout == null))
         {
             //
             // -- no layout found, create it
             layout        = DbBaseModel.addDefault <LayoutModel>(CP);
             layout.name   = layoutName;
             layout.ccguid = layoutGuid;
             layout.save(CP);
         }
         if (string.IsNullOrEmpty(layout.layout.content))
         {
             //
             // -- content is blank, populate with layoutfilename
             BaseClasses.CPBlockBaseClass block = CP.BlockNew();
             block.Load(CP.CdnFiles.Read(layoutFilename));
             layout.layout.content = block.GetInner("body");
             if (string.IsNullOrEmpty(layout.layout.content))
             {
                 layout.layout.content = block.GetHtml();
             }
             layout.save(CP);
         }
         //
         // --  exit if not editing
         if (!CP.User.IsEditingAnything)
         {
             return(layout.layout.content);
         }
         //
         // -- wrap with edit
         return(CP.Content.GetEditWrapper(layout.layout.content, layout.contentControlId, layout.id));
     } catch (Exception ex) {
         CP.Site.ErrorReport(ex);
         throw;
     }
 }
Exemplo n.º 24
0
 //
 //====================================================================================================
 /// <summary>
 /// executes an addon with the id provided, in the context specified.
 /// </summary>
 /// <param name="addonId"></param>
 /// <param name="addonContext"></param>
 /// <returns></returns>
 public string executeAddon(int addonId, Contensive.BaseClasses.CPUtilsBaseClass.addonContext addonContext = Contensive.BaseClasses.CPUtilsBaseClass.addonContext.ContextSimple)
 {
     try {
         AddonModel addon = DbBaseModel.create <AddonModel>(core.cpParent, addonId);
         if (addon == null)
         {
             throw new GenericException("Addon [#" + addonId.ToString() + "] could not be found.");
         }
         else
         {
             return(core.addon.execute(addon, new CPUtilsBaseClass.addonExecuteContext {
                 addonType = addonContext,
                 errorContextMessage = "external call to execute addon [" + addonId + "]"
             }));
         }
     } catch (Exception ex) {
         Site.ErrorReport(ex);
     }
     return(string.Empty);
 }
        //
        //=============================================================================
        //   Print the manual query form
        //=============================================================================
        //
        private string GetForm_WebsiteFileManager(CoreController core)
        {
            string result = "";

            try {
                string     InstanceOptionString = "AdminLayout=1&filesystem=website files";
                AddonModel addon   = DbBaseModel.create <AddonModel>(core.cpParent, "{B966103C-DBF4-4655-856A-3D204DEF6B21}");
                string     Content = core.addon.execute(addon, new BaseClasses.CPUtilsBaseClass.addonExecuteContext {
                    addonType             = Contensive.BaseClasses.CPUtilsBaseClass.addonContext.ContextAdmin,
                    argumentKeyValuePairs = GenericController.convertQSNVAArgumentstoDocPropertiesList(core, InstanceOptionString),
                    instanceGuid          = "-2",
                    errorContextMessage   = "executing File Manager within website file manager"
                });
                string Description = "Manage files and folders within the Website's file area.";
                string ButtonList  = ButtonApply + "," + ButtonCancel;
                result = AdminUIController.getToolBody(core, "Website File Manager", ButtonList, "", false, false, Description, "", 0, Content);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
Exemplo n.º 26
0
            //
            // ====================================================================================================
            public static ForumModel createOrAddSettings(CPBaseClass cp, string settingsGuid)
            {
                ForumModel result = DbBaseModel.create <ForumModel>(cp, settingsGuid);

                if ((result == null))
                {
                    //
                    // -- create default content
                    result             = DesignBlockBaseModel.addDefault <ForumModel>(cp);
                    result.name        = tableMetadata.contentName + " " + result.id;
                    result.ccguid      = settingsGuid;
                    result.recaptcha   = false;
                    result.headline    = "Lorem Ipsum Dolor Sit Amet";
                    result.description = "<p>Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>";
                    //
                    result.save(cp);
                    //
                    // -- track the last modified date
                    cp.Content.LatestContentModifiedDate.Track(result.modifiedDate);
                }
                return(result);
            }
Exemplo n.º 27
0
        //
        //====================================================================================================
        /// <summary>
        /// Process Login
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                //
                // -- login
                core.doc.continueProcessing = false;
                Dictionary <string, string> addonArguments = new Dictionary <string, string>();
                addonArguments.Add("Force Default Login", "false");
                return(core.addon.execute(DbBaseModel.create <AddonModel>(core.cpParent, addonGuidLoginPage), new CPUtilsBaseClass.addonExecuteContext {
                    addonType = CPUtilsBaseClass.addonContext.ContextPage,
                    argumentKeyValuePairs = addonArguments,
                    forceHtmlDocument = true,
                    errorContextMessage = "Process Login"
                }));
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Exemplo n.º 28
0
        //
        // ====================================================================================================
        /// <summary>
        ///
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(BaseClasses.CPBaseClass cp)
        {
            LibraryFilesModel image = DbBaseModel.create <LibraryFilesModel>(cp, constants.guidTemplateHeaderBrandLibraryFile);

            if (image == null)
            {
                image          = DbBaseModel.addDefault <LibraryFilesModel>(cp);
                image.ccguid   = constants.guidTemplateHeaderBrandLibraryFile;
                image.name     = "Theme-Brand-Img";
                image.filename = GenericController.populateFileField(cp, @"themehelpers\Brand-Default.png", LibraryFilesModel.tableMetadata.tableNameLower, "filename", image.id);
                image.save(cp);
            }
            StringBuilder result = new StringBuilder("<img");

            result.Append(" src=\"" + cp.Http.CdnFilePathPrefix + image.filename + "\"");
            if (!image.width.Equals(0))
            {
                result.Append(" width=\"" + image.width + "\"");
            }
            if (!image.height.Equals(0))
            {
                result.Append(" height=\"" + image.height + "\"");
            }
            if (!string.IsNullOrEmpty(image.description))
            {
                string encodedMsg = cp.Utils.EncodeHTML(image.description);
                result.Append(" alt=\"" + encodedMsg + "\" title=\"" + encodedMsg + "\"");
            }
            result.Append(">");
            //
            // -- if not editing, return a linked image
            if (!cp.User.IsEditingAnything)
            {
                return("<a href=\"/\">" + result.ToString() + "</a>");
            }
            //
            // -- editing, no link
            return(cp.Content.GetEditWrapper(result.ToString(), image.contentControlId, image.id));
        }
 //
 //======================================================================================================
 //
 public static void installNode(CoreController core, XmlNode rootNode, int collectionId, ref bool return_UpgradeOK, ref string return_ErrorMessage, ref bool collectionIncludesDiagnosticAddons)
 {
     return_ErrorMessage = "";
     return_UpgradeOK    = true;
     try {
         string Basename = GenericController.toLCase(rootNode.Name);
         if (Basename == "layout")
         {
             bool   IsFound    = false;
             string layoutName = XmlController.getXMLAttribute(core, ref IsFound, rootNode, "name", "No Name");
             if (string.IsNullOrEmpty(layoutName))
             {
                 layoutName = "No Name";
             }
             string layoutGuid = XmlController.getXMLAttribute(core, ref IsFound, rootNode, "guid", layoutName);
             if (string.IsNullOrEmpty(layoutGuid))
             {
                 layoutGuid = layoutName;
             }
             var layout = DbBaseModel.create <LayoutModel>(core.cpParent, layoutGuid);
             if (layout == null)
             {
                 layout = DbBaseModel.createByUniqueName <LayoutModel>(core.cpParent, layoutName);
             }
             if (layout == null)
             {
                 layout = DbBaseModel.addDefault <LayoutModel>(core.cpParent);
             }
             layout.ccguid                  = layoutGuid;
             layout.name                    = layoutName;
             layout.layout.content          = rootNode.InnerText;
             layout.installedByCollectionId = collectionId;
             layout.save(core.cpParent);
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
Exemplo n.º 30
0
        //
        //========================================================================
        //
        //========================================================================
        //
        public static string get(CoreController core)
        {
            string tempGetForm_Downloads = null;

            try {
                //
                string Button = core.docProperties.getText(RequestNameButton);
                if (Button == ButtonCancel)
                {
                    return(core.webServer.redirect("/" + core.appConfig.adminRoute, "Downloads, Cancel Button Pressed"));
                }
                string ButtonListLeft  = "";
                string ButtonListRight = "";
                string Content         = "";
                //
                if (!core.session.isAuthenticatedAdmin())
                {
                    //
                    // Must be a developer
                    //
                    ButtonListLeft  = ButtonCancel;
                    ButtonListRight = "";
                    Content         = Content + AdminUIController.getFormBodyAdminOnly();
                }
                else
                {
                    int    ContentId = core.docProperties.getInteger("ContentID");
                    string Format    = core.docProperties.getText("Format");
                    //
                    // Process Requests
                    //
                    if (!string.IsNullOrEmpty(Button))
                    {
                        int RowCnt = 0;
                        switch (Button)
                        {
                        case ButtonDelete:
                            RowCnt = core.docProperties.getInteger("RowCnt");
                            if (RowCnt > 0)
                            {
                                int RowPtr = 0;
                                for (RowPtr = 0; RowPtr < RowCnt; RowPtr++)
                                {
                                    if (core.docProperties.getBoolean("Row" + RowPtr))
                                    {
                                        DownloadModel.delete <DownloadModel>(core.cpParent, core.docProperties.getInteger("RowID" + RowPtr));
                                    }
                                }
                            }
                            break;
                        }
                    }
                    //
                    // Build Tab0
                    //
                    string RQS      = core.doc.refreshQueryString;
                    int    PageSize = core.docProperties.getInteger(RequestNamePageSize);
                    if (PageSize == 0)
                    {
                        PageSize = 50;
                    }
                    int PageNumber = core.docProperties.getInteger(RequestNamePageNumber);
                    if (PageNumber == 0)
                    {
                        PageNumber = 1;
                    }
                    string AdminURL = "/" + core.appConfig.adminRoute;
                    int    TopCount = PageNumber * PageSize;
                    //
                    const int ColumnCnt = 5;
                    //
                    // Setup Headings
                    //
                    string[] ColCaption = new string[ColumnCnt + 1];
                    string[] ColAlign   = new string[ColumnCnt + 1];
                    string[] ColWidth   = new string[ColumnCnt + 1];
                    string[,] Cells = new string[PageSize + 1, ColumnCnt + 1];
                    int ColumnPtr = 0;
                    //
                    ColCaption[ColumnPtr] = "&nbsp;";
                    ColAlign[ColumnPtr]   = "center";
                    ColWidth[ColumnPtr]   = "10px";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Name";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "For";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "200px";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Requested";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "200px";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "File";
                    ColAlign[ColumnPtr]   = "Left";
                    ColWidth[ColumnPtr]   = "100px";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    //   Get Downloads available
                    //
                    int DataRowCount = 0;
                    var downloadList = DbBaseModel.createList <DownloadModel>(core.cpParent, "", "id desc", PageSize, PageNumber);
                    int RowPointer   = 0;
                    if (downloadList.Count == 0)
                    {
                        Cells[0, 1] = "There are no download requests";
                        RowPointer  = 1;
                    }
                    else
                    {
                        RowPointer   = 0;
                        DataRowCount = DbBaseModel.getCount <DownloadModel>(core.cpParent);
                        string LinkPrefix = "<a href=\"" + core.appConfig.cdnFileUrl;
                        string LinkSuffix = "\" target=_blank>Download</a>";
                        foreach (var download in downloadList)
                        {
                            if (RowPointer >= PageSize)
                            {
                                break;
                            }
                            var requestedBy = DbBaseModel.create <PersonModel>(core.cpParent, download.requestedBy);
                            Cells[RowPointer, 0] = HtmlController.checkbox("Row" + RowPointer) + HtmlController.inputHidden("RowID" + RowPointer, download.id);
                            Cells[RowPointer, 1] = download.name;
                            Cells[RowPointer, 2] = (requestedBy == null) ? "unknown" : requestedBy.name;
                            Cells[RowPointer, 3] = download.dateRequested.ToString();
                            if (string.IsNullOrEmpty(download.resultMessage))
                            {
                                Cells[RowPointer, 4] = "\r\n<div id=\"pending" + RowPointer + "\">Pending <img src=\"/ccLib/images/ajax-loader-small.gif\" width=16 height=16></div>";
                            }
                            else if (!string.IsNullOrEmpty(download.filename.filename))
                            {
                                Cells[RowPointer, 4] = "<div id=\"pending" + RowPointer + "\">" + LinkPrefix + download.filename.filename + LinkSuffix + "</div>";
                            }
                            else
                            {
                                Cells[RowPointer, 4] = "<div id=\"pending" + RowPointer + "\">error</div>";
                            }
                            RowPointer = RowPointer + 1;
                        }
                    }
                    StringBuilderLegacyController Tab0 = new StringBuilderLegacyController();
                    Tab0.add(HtmlController.inputHidden("RowCnt", RowPointer));
                    string PreTableCopy  = "";
                    string PostTableCopy = "";
                    string Cell          = AdminUIController.getReport(core, RowPointer, ColCaption, ColAlign, ColWidth, Cells, PageSize, PageNumber, PreTableCopy, PostTableCopy, DataRowCount, "ccPanel");
                    Tab0.add(Cell);
                    Content         = Tab0.text;
                    ButtonListLeft  = ButtonCancel + "," + ButtonRefresh + "," + ButtonDelete;
                    ButtonListRight = "";
                    Content         = Content + HtmlController.inputHidden(rnAdminSourceForm, AdminFormDownloads);
                }
                //
                string Caption     = "Download Manager";
                string Description = ""
                                     + "<p>The Download Manager holds all downloads requested from anywhere on the website. It also provides tools to request downloads from any Content.</p>"
                                     + "<p>To add a new download of any content in Contensive, click Export on the filter tab of the content listing page. To add a new download from a SQL statement, use Custom Reports under Reports on the Navigator.</p>";
                int    ContentPadding = 0;
                string ContentSummary = "";
                tempGetForm_Downloads = AdminUIController.getToolBody(core, Caption, ButtonListLeft, ButtonListRight, true, true, Description, ContentSummary, ContentPadding, Content);
                //
                core.html.addTitle(Caption);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(tempGetForm_Downloads);
        }