Пример #1
0
    /// <summary>
    /// Logs "delete" activity
    /// </summary>
    /// <param name="node">Node to log the activity for</param>
    private void LogDeleteActivity(TreeNode node)
    {
        if ((node == null) || !LogActivity)
        {
            return;
        }

        Activity activity = new ActivityUserContributionDelete(node, node.GetDocumentName(), AnalyticsContext.ActivityEnvironmentVariables);

        activity.Log();
    }
    /// <summary>
    /// UniGrid action buttons event handler.
    /// </summary>
    protected void gridDocs_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        // Edit document
        case "edit":
            // Check group's permission to edit document if allowed
            if (CheckGroupPermission("editpages"))
            {
                editDoc.NodeID           = ValidationHelper.GetInteger(actionArgument, 0);
                editDoc.Action           = "edit";
                editDoc.CheckPermissions = CheckPermissions;
                editDoc.AllowDelete      = AllowDelete && CheckGroupPermission("deletepages");

                pnlEdit.Visible = true;
                pnlList.Visible = false;
            }
            break;

        // Delete document
        case "delete":
            // Check banned IP
            if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete))
            {
                AddAlert(GetString("general.bannedip"));
                return;
            }

            TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);

            // Delete specified node
            int      documentId = ValidationHelper.GetInteger(actionArgument, 0);
            TreeNode node       = DocumentHelper.GetDocument(documentId, tree);
            if (node != null)
            {
                // Check user's permission to delete document if allowed
                bool hasUserDeletePermission = !CheckPermissions || IsUserAuthorizedToDeleteDocument(node);
                // Check group's permission to delete document if allowed
                hasUserDeletePermission &= CheckGroupPermission("deletepages");

                if (hasUserDeletePermission)
                {
                    DocumentHelper.DeleteDocument(node, tree, false, false, true);
                    if (LogActivity)
                    {
                        Activity activity = new ActivityUserContributionDelete(node, node.GetDocumentName(), AnalyticsContext.ActivityEnvironmentVariables);
                        activity.Log();
                    }

                    // Fire OnAfterDelete
                    RaiseOnAfterDelete();

                    ReloadData();
                }
                // Access denied - not authorized to delete the document
                else
                {
                    AddAlert(String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), node.NodeAliasPath));
                    return;
                }
            }
            break;
        }
    }