【发布时间】:2012-08-11 17:02:59
【问题描述】:
我开发了一个数据扩展器类,它作用于 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;
}
}
}
【问题讨论】:
-
我希望您也应该设置 AllowedActions。但这需要深入研究 JavaScript 代码才能找到答案。
-
问得好,我们是否有兴趣提交Area 51 Tridion specific proposal。如果有时间,请使用同一个 SO 帐户注册。
-
@FrankvanPuffelen,这是我看到的 AllowedActions 的 XML。知道如何理解这告诉我的内容吗?
-
允许的操作是操作值的集合。如果您在 API 文档(例如核心服务 CHM)中查找值,您将找到所有值。这是从上面的属性中解构值的问题。例如。 8402952 解构为“FinishActivityAction、ViewAction、EditAction、SearchAction、RePublishAction、UnPublishAction、PublishAction、UnLocalizeAction、LocalizeAction、RollbackAction、HistoryListAction、UndoCheckOutAction、CheckInAction、CheckOutAction”,因此从中删除 CheckInAction (2) 可能会禁用 CheckIn 按钮。
-
谢谢@FrankvanPuffelen,这给了我一些好的继续。虽然我想要的不是签入按钮,但它是保存按钮。但是,也许禁用签入会帮助我完成这一点。
标签: tridion