Exemplo n.º 1
0
    protected object gridHistory_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        sourceName = sourceName.ToLowerInvariant();
        switch (sourceName)
        {
        case "rollback":
        {
            CMSGridActionButton imgRollback = ((CMSGridActionButton)sender);
            int versionId = ValidationHelper.GetInteger(imgRollback.CommandArgument, 0);
            if (!WorkflowManager.CheckStepPermissions(Node, WorkflowActionEnum.Approve) || !CanModify || (CheckedOutByAnotherUser && !CanCheckIn) || (versionId == Node.DocumentCheckedOutVersionHistoryID))
            {
                imgRollback.Enabled = false;
            }
        }
        break;

        case "allowdestroy":
        {
            CMSGridActionButton imgDestroy = ((CMSGridActionButton)sender);
            int versionId = ValidationHelper.GetInteger(imgDestroy.CommandArgument, 0);
            if (!CanDestroy || (CheckedOutByAnotherUser && !CanCheckIn) || (versionId == Node.DocumentCheckedOutVersionHistoryID))
            {
                imgDestroy.Enabled = false;
            }
        }
        break;

        case "modifiedwhenby":
            DataRowView data         = (DataRowView)parameter;
            DateTime    modifiedwhen = ValidationHelper.GetDateTime(data["ModifiedWhen"], DateTimeHelper.ZERO_TIME);
            int         userId       = ValidationHelper.GetInteger(data["ModifiedByUserID"], 0);

            var tr = new ObjectTransformation("cms.user", userId);
            tr.EncodeOutput   = false;
            tr.Transformation = string.Format("{0} <br /> {{% Object.GetFormattedUserName()|(encode) %}}", UniGridFunctions.UserDateTimeGMT(modifiedwhen));
            return(tr);
        }

        return(parameter);
    }