设置IsEditable = false表示项目禁用保存/关闭按钮但不保存按钮?

War*_*tus 6 tridion

我开发了一个数据扩展器类,它作用于GetItem和CheckOutItem命令,以进行一些特定于业务的验证,以确定用户是否应该有权修改项目(基本上如果它已超过工作流程中的初始"作者"任务,没有人可以编辑它.默认情况下,Tridion允许工作流程中的"审阅者"编辑项目,这在我们的业务中是禁止的.

我相对肯定这在某一点上有效,但现在却没有.我正在探索可能会发生什么变化的事情,但我想我会问这里以防万一有人有想法.

如果无法修改该项,我将IsEditable属性设置为false.实际上,这会禁用"保存并关闭"按钮和"保存并新建"按钮,但由于某种原因,"保存"按钮已启用.我不太明白为什么会有区别.(我想看看是否有人以某种方式扩展了保存按钮,但我没有看到这样做).有关如何在其他人没有的情况下启用"保存"按钮的任何想法?

谢谢你的任何建议,

〜华纳

public override XmlTextReader ProcessResponse(XmlTextReader reader, PipelineContext context)
{
    using (new Tridion.Logging.Tracer())
    {
        string command = context.Parameters["command"].ToString();
        if (command == CHECKOUT_COMMAND || command == GETITEM_COMMAND)
        {
            XmlDocument xmlDoc = ExtenderUtil.GetExtenderAsXmlDocument(reader);
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
            nsmgr.AddNamespace("tcm", Constants.TcmNamespace);
            try
            {
                //is this a page or component?
                XmlNode thisItemNode = null;
                thisItemNode = xmlDoc.SelectSingleNode("//tcm:Component", nsmgr) ?? xmlDoc.SelectSingleNode("//tcm:Page", nsmgr);
                if (thisItemNode == null) return ExtenderUtil.GetExtenderAsXmlTextReader(xmlDoc);
                // need to impersonate system admin in order to get workflow version of item later
                Session sessionSystemAdmin = Util.SystemAdminSession;
                XmlAttribute idAttribute = thisItemNode.Attributes.GetNamedItem("ID") as XmlAttribute;
                //if ID attribute is null, we don't have the actual object being used (just a referenced item. so, we'll ignore it)
                if (idAttribute != null)
                {
                    string itemId = idAttribute.Value;
                    VersionedItem tridionObject = Util.ObtainValidTridionIdentifiableObject(sessionSystemAdmin, itemId) as VersionedItem;
                    //logic has been moved to separate method, just for maintainablility...
                    //the logic may change when workflow code is finished.
                    bool allowSave = IsItemValidForEdit(tridionObject, nsmgr);
                    if (!allowSave)
                    {
                        //not the WIP ("author") task... make item read-only
                        Logger.WriteVerbose("setting iseditable to false for item: " + itemId);
                        XmlAttribute isEditableAttribute = thisItemNode.Attributes.GetNamedItem("IsEditable") as XmlAttribute;
                        isEditableAttribute.Value = "false";
                    }
                }
            }
            catch (Exception e)
            {
                Logger.WriteError("problem with get item data extender", ErrorCode.CMS_DATAEXTENDER_GETITEM_FAILURE, e);
            }
            return ExtenderUtil.GetExtenderAsXmlTextReader(xmlDoc);
        }
        else
        {
            return reader;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

War*_*tus 1

解决方案是真正检查整个解决方案,并绝对肯定最近没有人偷偷添加一些东西来扰乱“保存”按钮,并在幕后神奇地启用它。我重新编辑了代码以展示我最初是如何拥有它的。它确实有效。它将禁用保存、保存/关闭、保存/新建按钮并禁用所有字段。很抱歉我浪费了弗兰克的时间。希望出于历史目的而将其放在这里可能会对将来有类似需求的其他人派上用场。