Ejemplo n.º 1
0
 internal CMSPageViewModel(CMSPage pageContent)
 {
     this.PageId    = pageContent.PageId;
     this.PageTitle = pageContent.PageTitle;
     this.CreatedOn = pageContent.CreatedOn;
     this.PageName  = pageContent.PageName;
 }
    protected void gridMatrix_OnItemChanged(object sender, int rowItemId, int colItemId, bool allow)
    {
        // roleId and permissionId possitions differ according to the page where control is used
        int roleId       = (mRoleId > 0) ? colItemId : rowItemId;
        int permissionId = (mRoleId > 0) ? rowItemId : colItemId;

        // Check "Manage" permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Permissions", "Manage"))
        {
            CMSPage.RedirectToCMSDeskAccessDenied("CMS.Permissions", "Manage");
        }

        // Check permission for the given column
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Permissions", "Manage"))
        {
            CMSPage.RedirectToSiteManagerAccessDenied("CMS.Permissions", "Manage");
        }

        if (allow)
        {
            RolePermissionInfoProvider.SetRolePermissionInfo(roleId, permissionId);
        }
        else
        {
            RolePermissionInfoProvider.DeleteRolePermissionInfo(roleId, permissionId);
        }

        // Reload content before rows
        gridMatrix.ContentBeforeRows = GetBeforeRowsContent(SiteID, ValidationHelper.GetInteger(SelectedID, 0), SelectedType, SelectedUserID);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Executes custom grid actions.
    /// </summary>
    /// <param name="actionName">Name of the action</param>
    /// <param name="actionArgument">Argument for the action</param>
    private void Control_OnAction(string actionName, object actionArgument)
    {
        switch (actionName)
        {
        case "delete":
            if (QueriesCanBeDeleted)
            {
                QueryInfo     queryInfo = QueryInfoProvider.GetQueryInfo(ValidationHelper.GetInteger(actionArgument, 0));
                DataClassInfo classInfo = ((DataClassInfo)Page.EditedObjectParent);
                if ((queryInfo != null) && (classInfo != null) && (queryInfo.ClassID == classInfo.ClassID))
                {
                    queryInfo.Delete();
                }
                else
                {
                    CMSPage.RedirectToInformation("editedobject.notexists");
                }
            }
            else
            {
                Control.ShowError(ResHelper.GetString("cms.query.customization.deletedisabled"));
            }

            break;
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register the scripts
        ScriptHelper.RegisterProgress(Page);

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);
        CMSPage page = Page as CMSPage;

        if (page != null)
        {
            versionsElem.InfoLabel  = page.CurrentMaster.InfoLabel;
            versionsElem.ErrorLabel = page.CurrentMaster.ErrorLabel;
        }
        versionsElem.AfterDestroyHistory      += versionsElem_AfterDestroyHistory;
        versionsElem.CombineWithDefaultCulture = false;

        if (Node != null)
        {
            // Check read permissions
            if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied)
            {
                RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath));
            }

            ReloadData();
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Unigrid button clicked.
 /// </summary>
 protected void gridElem_OnAction(string actionName, object actionArgument)
 {
     // Perform 'remove' action
     if (actionName == "remove")
     {
         // Delete the object
         int         accountId = ValidationHelper.GetInteger(actionArgument, 0);
         AccountInfo account   = AccountInfoProvider.GetAccountInfo(accountId);
         if (account != null)
         {
             // User has no permission to modify site accounts
             if (((account.AccountSiteID > 0) && !modifySiteAccounts) || !ContactGroupHelper.AuthorizedModifyContactGroup(cgi.ContactGroupSiteID, false))
             {
                 CMSPage.RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyAccounts");
             }
             // User has no permission to modify global accounts
             else if ((account.AccountSiteID == 0) && !modifyGlobalAccounts || !ContactGroupHelper.AuthorizedModifyContactGroup(cgi.ContactGroupSiteID, false))
             {
                 CMSPage.RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyGlobalAccounts");
             }
             // User has permission
             else
             {
                 // Get the relationship object
                 ContactGroupMemberInfo mi = ContactGroupMemberInfoProvider.GetContactGroupMemberInfoByData(cgi.ContactGroupID, accountId, ContactGroupMemberTypeEnum.Account);
                 if (mi != null)
                 {
                     ContactGroupMemberInfoProvider.DeleteContactGroupMemberInfo(mi);
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Unigrid button clicked.
 /// </summary>
 protected void gridElem_OnAction(string actionName, object actionArgument)
 {
     if (actionName == "remove")
     {
         // User has permission modify
         if (modifyAccountContact)
         {
             int relationId = ValidationHelper.GetInteger(actionArgument, 0);
             AccountContactInfo relation = AccountContactInfoProvider.GetAccountContactInfo(relationId);
             if (relation != null)
             {
                 // We need to invalidate the contact as we might have modified some of its relationships and data in the cache might not be valid
                 AccountContactInfoProvider.DeleteAccountContactInfo(relation);
             }
         }
         // User doesn't have sufficient permissions
         else
         {
             if (SiteID > 0)
             {
                 CMSPage.RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyContacts");
             }
             else
             {
                 CMSPage.RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyGlobalContacts");
             }
         }
     }
 }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if ((MembershipContext.AuthenticatedUser == null) || !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Content", "MyDeskDashBoardItem"))
     {
         CMSPage.RedirectToUIElementAccessDenied("CMS.Content", "MyDeskDashBoardItem");
     }
 }
    /// <summary>
    /// Validates this step.
    /// </summary>
    public override bool IsValid()
    {
        // Check modify permissions
        if (ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems)
        {
            // Check 'ModifyOrders' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission(EcommercePermissions.ORDERS_MODIFY))
            {
                CMSPage.RedirectToAccessDenied(ModuleName.ECOMMERCE, "EcommerceModify OR ModifyOrders");
            }
        }

        // Allow to go to the next step only if shopping cart contains some products
        bool IsValid = !ShoppingCart.IsEmpty;

        if (!IsValid)
        {
            HideCartContent();
        }

        if (ShoppingCart.IsCreatedFromOrder)
        {
            IsValid = true;
        }

        if (!IsValid)
        {
            lblError.Text = GetString("ecommerce.error.insertsomeproducts");
        }

        return(IsValid);
    }
Ejemplo n.º 9
0
 /// <summary>
 /// Checks modify permission for contact group.
 /// </summary>
 private void CheckModifyPermissions()
 {
     if (!CheckPermissions("cms.contactmanagement", "Modify"))
     {
         CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "Modify");
     }
 }
    protected void btnHdnDelete_Click(object sender, EventArgs e)
    {
        // Check 'Modify' permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "Modify"))
        {
            CMSPage.RedirectToAccessDenied("cms.reporting", "Modify");
        }

        // Check whether object is defined
        if (!String.IsNullOrEmpty(hdnItemId.Value))
        {
            // Get id
            int id = ValidationHelper.GetInteger(hdnItemId.Value, 0);

            // Switch by type
            switch (ItemType)
            {
            // Graph
            case ReportItemType.Graph:
            case ReportItemType.HtmlGraph:
                ReportGraphInfoProvider.DeleteReportGraphInfo(id);
                break;

            // Table
            case ReportItemType.Table:
                ReportTableInfoProvider.DeleteReportTableInfo(id);
                break;

            // Value
            case ReportItemType.Value:
                ReportValueInfoProvider.DeleteReportValueInfo(id);
                break;
            }
        }
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSPage page            = Parent.Page as CMSPage;
        bool    developmentMode = (page != null) ? page.CurrentMaster.DevelopmentMode : SettingsKeyProvider.DevelopmentMode;

        if (developmentMode && CMSContext.CurrentUser.UserSiteManagerAdmin)
        {
            // Debug
            lnkDebug.NavigateUrl = "~/CMSModules/System/Debug/System_ViewRequest.aspx?guid=" + DebugHelper.CurrentRequestLogs.RequestGUID;
            lnkDebug.Target      = "_blank";

            // Localization
            btnLocalize.HorizontalPosition = HorizontalPositionEnum.Right;
            btnLocalize.OffsetY            = -20;
            btnLocalize.OffsetX            = 1;

            btnLocalize.MouseButton            = MouseButtonEnum.Both;
            btnLocalize.MenuControlPath        = "~/CMSAdminControls/UI/Development/Localize.ascx";
            btnLocalize.Image.ImageUrl         = GetImageUrl("Objects/CMS_UICulture/list.png");
            btnLocalize.Image.CausesValidation = false;

            imgDebug.ImageUrl      = GetImageUrl("CMSModules/CMS_System/debug.png");
            imgDebug.AlternateText = GetString("Administration-System.Debug");
        }
        else
        {
            Visible = false;
        }
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Items changed event handler.
    /// </summary>
    private void UniSelector_OnItemsSelected(object sender, EventArgs e)
    {
        if (AuthorizationHelper.AuthorizedModifyContact(false) || AuthorizationHelper.AuthorizedReadContact(false))
        {
            // Get new items from selector
            string newValues = ValidationHelper.GetString(contactSelector.Value, null);

            if (!String.IsNullOrEmpty(newValues))
            {
                string[] newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                int previousStop = 0;
                string where = FetchNextContacts(ref previousStop, newItems, 1000);

                while (!String.IsNullOrEmpty(where))
                {
                    AccountContactInfoProvider.SetContactsIntoAccount(ai.AccountID, "ContactID IN (" + where + ")", ValidationHelper.GetInteger(hdnRoleID.Value, 0));

                    where = FetchNextContacts(ref previousStop, newItems, 1000);
                }

                gridElem.ReloadData();
                pnlUpdate.Update();
                contactSelector.Value = null;
            }
        }
        // No permission modify
        else
        {
            CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "Modify");
        }
    }
Ejemplo n.º 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Redirect to the web site root by default
        string returnUrl = URLHelper.ResolveUrl("~/");

        // Check whether on-site editing is enabled
        if (PortalHelper.IsOnSiteEditingEnabled(CMSContext.CurrentSiteName))
        {
            CurrentUserInfo cui = CMSContext.CurrentUser;
            // Check the permissions
            if ((cui != null) && cui.IsEditor && cui.IsAuthorizedPerResource("cms.content", "ExploreTree") && cui.IsAuthorizedPerResource("cms.content", "Read"))
            {
                // Set edit-live view mode
                PortalContext.SetViewMode(ViewModeEnum.EditLive);
            }
            else
            {
                // Redirect to access denied page when the current user does not have permissions for the OnSite editing
                CMSPage.RedirectToUINotAvailable();
            }

            // Try get return URL
            string queryUrl = QueryHelper.GetString("returnurl", String.Empty);
            if (!String.IsNullOrEmpty(queryUrl) && (queryUrl.StartsWith("~/") || queryUrl.StartsWith("/")))
            {
                // Remove return url duplication if exist
                int commaIndex = queryUrl.IndexOfCSafe(",", 0, false);
                if (commaIndex > 0)
                {
                    queryUrl = queryUrl.Substring(0, commaIndex);
                }
                returnUrl = URLHelper.ResolveUrl(queryUrl);
            }
            // Use default alias path if return url isn't defined
            else
            {
                string aliasPath = PageInfoProvider.GetDefaultAliasPath(URLHelper.GetCurrentDomain(), CMSContext.CurrentSiteName);
                if (!String.IsNullOrEmpty(aliasPath))
                {
                    // Get the document which will be displayed for the default alias path
                    TreeProvider tr   = new TreeProvider();
                    TreeNode     node = tr.SelectSingleNode(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, true);
                    if (node != null)
                    {
                        aliasPath = node.NodeAliasPath;
                    }

                    returnUrl = DocumentURLProvider.GetUrl(aliasPath);
                    returnUrl = URLHelper.ResolveUrl(returnUrl);
                }
            }

            // Remove view mode value from query string
            returnUrl = URLHelper.RemoveParameterFromUrl(returnUrl, "viewmode");
        }

        // Redirect to the requested page
        URLHelper.Redirect(returnUrl);
    }
 /// <summary>
 /// Checks the specified permission.
 /// </summary>
 private void CheckPermissions(string permissionName)
 {
     // Check 'Modify' permission
     if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", permissionName))
     {
         CMSPage.RedirectToCMSDeskAccessDenied("cms.form", permissionName);
     }
 }
        public HttpResponseMessage GetPageById(int id)
        {
            CMSPage page = cmsService.GetPageById(id);
            ItemResponse <CMSPage> itemResponse = new ItemResponse <CMSPage>();

            itemResponse.Item = page;
            return(Request.CreateResponse(HttpStatusCode.OK, itemResponse));
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Checks the specified permission.
 /// </summary>
 private void CheckPermissions(string permissionName)
 {
     // Check 'Modify' permission
     if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", permissionName))
     {
         CMSPage.RedirectToAccessDenied("cms.form", permissionName);
     }
 }
Ejemplo n.º 17
0
    protected void btnSignOut_Click(object sender, EventArgs e)
    {
        // Usual sign out
        string signOutUrl = URLHelper.ApplicationPath.TrimEnd('/') + "/default.aspx";

        // LiveID sign out URL is set if this LiveID session
        CMSPage.SignOut(signOutUrl);
    }
        public ActionResult Create(CMSPage page)
        {
            DBCMSEntities dbContext = new DBCMSEntities();
            var           Id        = dbContext.AddPage(page.Id, page.Slug, page.PTitle, page.PKeyword, page.PDescription, page.PageContent, page.IsActive, page.IsDelete);

            Response.Redirect("/admin/details/" + Id);

            return(View());
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CMSPage cMSPage = await db.CMSPage.FindAsync(id);

            db.CMSPage.Remove(cMSPage);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 20
0
    void librarySecurity_OnCheckPermissions(string permissionType, CMSAdminControl sender)
    {
        MediaLibraryInfo mli = MediaLibraryInfoProvider.GetMediaLibraryInfo(QueryHelper.GetInteger("libraryid", 0));

        if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(mli, "Read"))
        {
            CMSPage.RedirectToCMSDeskAccessDenied("cms.medialibrary", "Read");
        }
    }
Ejemplo n.º 21
0
 internal EditCMSPageModel(CMSPage pageContent)
 {
     this.PageId          = pageContent.PageId;
     this.PageName        = pageContent.PageName;
     this.PageTitle       = pageContent.PageTitle;
     this.PageContent     = pageContent.PageContent;
     this.MetaTitle       = pageContent.MetaTitle;
     this.MetaKeywords    = pageContent.MetaKeywords;
     this.MetaDescription = pageContent.MetaDescription;
 }
Ejemplo n.º 22
0
    /// <summary>
    /// Returns WHERE condition
    /// </summary>
    private string GetWhereCondition()
    {
        string where = "(ContactGroupMemberContactGroupID = " + cgi.ContactGroupID + ")";
        where        = SqlHelper.AddWhereCondition(where, "((AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID > 0 AND AccountMergedWithAccountID IS NULL))");

        // Filter site objects
        if (siteID > 0)
        {
            if (readSiteAccounts)
            {
                where = SqlHelper.AddWhereCondition(where, "(AccountSiteID = " + siteID + ")");
                accountSelector.SiteID = siteID;
            }
            else
            {
                CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ReadAccounts");
            }
        }
        // Current group is global object
        else if (siteID == 0)
        {
            // In CMS Desk display current site and global objects
            if (!ContactHelper.IsSiteManager)
            {
                if (readSiteAccounts && readGlobalAccounts)
                {
                    where = SqlHelper.AddWhereCondition(where, "(AccountSiteID IS NULL) OR (AccountSiteID = " + SiteContext.CurrentSiteID + ")");
                    accountSelector.SiteID = UniSelector.US_GLOBAL_AND_SITE_RECORD;
                }
                else if (readGlobalAccounts)
                {
                    where = SqlHelper.AddWhereCondition(where, "(AccountSiteID IS NULL)");
                    accountSelector.SiteID = UniSelector.US_GLOBAL_RECORD;
                }
                else if (readSiteAccounts)
                {
                    where = SqlHelper.AddWhereCondition(where, "AccountSiteID = " + SiteContext.CurrentSiteID);
                    accountSelector.SiteID = SiteContext.CurrentSiteID;
                }
                else
                {
                    CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ReadGlobalAccounts|ReadAccounts");
                }
            }
            // In Site manager display for global contact group all site and global contacts
            else
            {
                // No WHERE condition required = displaying all data

                // Set contact selector only
                accountSelector.SiteID = UniSelector.US_ALL_RECORDS;
            }
        }
        return(where);
    }
Ejemplo n.º 23
0
    /// <summary>
    /// Returns WHERE condition
    /// </summary>
    private string GetWhereCondition()
    {
        string where = "(ContactGroupMemberContactGroupID = " + cgi.ContactGroupID + ")";
        where        = SqlHelperClass.AddWhereCondition(where, "((ContactSiteID IS NULL AND ContactGlobalContactID IS NULL) OR (ContactSiteID > 0 AND ContactMergedWithContactID IS NULL))");

        // Filter site objects
        if (siteID > 0)
        {
            if (readSiteContacts)
            {
                where = SqlHelperClass.AddWhereCondition(where, "(ContactSiteID = " + siteID.ToString() + ")");
                contactSelector.SiteID = siteID;
            }
            else
            {
                CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ReadContacts");
            }
        }
        // Current group is global object
        else if (siteID == 0)
        {
            // In CMS Desk display current site and global objects
            if (!ContactHelper.IsSiteManager)
            {
                if (readSiteContacts && readGlobalContacts)
                {
                    where = SqlHelperClass.AddWhereCondition(where, "(ContactSiteID IS NULL) OR (ContactSiteID = " + CMSContext.CurrentSiteID + ")");
                    contactSelector.SiteID = UniSelector.US_GLOBAL_OR_SITE_RECORD;
                }
                else if (readGlobalContacts)
                {
                    where = SqlHelperClass.AddWhereCondition(where, "(ContactSiteID IS NULL)");
                    contactSelector.SiteID = UniSelector.US_GLOBAL_RECORD;
                }
                else if (readSiteContacts)
                {
                    where = SqlHelperClass.AddWhereCondition(where, "ContactSiteID = " + CMSContext.CurrentSiteID);
                    contactSelector.SiteID = CMSContext.CurrentSiteID;
                }
                else
                {
                    pnlSelector.Visible = false;
                }
            }
            // In Site manager display for global contact group all site and global contacts
            else
            {
                // No WHERE condition required = displaying all data

                // Set contact selector only
                contactSelector.SiteID = UniSelector.US_ALL_RECORDS;
            }
        }
        return(where);
    }
Ejemplo n.º 24
0
 private void RestorePages(CMSPage page)
 {
     page.Deleted = false;
     if (page.Children.Any())
     {
         foreach (var cmsPage in page.Children)
         {
             RestorePages(cmsPage);
         }
     }
 }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Body")] CMSPage cMSPage)
        {
            if (ModelState.IsValid)
            {
                db.Entry(cMSPage).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(cMSPage));
        }
Ejemplo n.º 26
0
        void LoadBackingContentData()
        {
            int backingContentId = 0;

            if (_backingContent == null && HttpContext.Request.QueryString["backingcontentid"] != null && int.TryParse(HttpContext.Request.QueryString["backingcontentid"], out backingContentId))
            {
                _backingContentId        = backingContentId;
                ViewBag.BackingContentId = backingContentId;
                _backingContent          = N2.Find.Items.Where.ID.Eq(backingContentId).Select <CMSPage>().FirstOrDefault();
            }
        }
Ejemplo n.º 27
0
        public void UpdatePage(CMSPage page)
        {
            var existing = _pageContext.Return().FirstOrDefault(x => x.Location == page.Location);

            if (existing != null)
            {
                page.LastModified = DateTime.Now;
                _pageContext.Update(page);
            }
            CreatePage(page);
        }
 private void deleteRecursive(CMSPage page)
 {
     if (page.Children.Any())
     {
         foreach (var child in page.Children)
         {
             deleteRecursive(child);
         }
     }
     db.CMSPages.DeleteOnSubmit(page);
 }
Ejemplo n.º 29
0
        public async Task <IActionResult> Create([Bind("Id,Title,Body,Footer,Url,Quote")] CMSPage cmsPage)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cmsPage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(cmsPage));
        }
Ejemplo n.º 30
0
        public void CMSCreateArticleWithLongTitle()
        {
            LoginUser   user      = AccessExcelData.GetTLoginUserData("CreateNewArticle");
            BlogArticle article   = AccessExcelData.GetArticleTestData("CreateArticleWithLongTitle");
            LoginPage   loginPage = new LoginPage(driver);
            CMSPage     cmsPage   = new CMSPage(driver);

            loginPage.NavigateTo();
            loginPage.FillCredentials(user);
            cmsPage.FillArticleForm(article);
            Assert.IsTrue(cmsPage.ErrorMessageForEmptyTitleOrContent.Contains(article.ArticleErrorMessage));
        }