DataExtension and canView [closed]

情到浓时终转凉″ 提交于 2019-12-12 02:59:52

问题


I like to second this question from the forum:
http://www.silverstripe.org/data-model-questions/show/23484

In short:
Is it possible to apply the permission methods:

canView, canEdit, canDelete, canCreate etc  

via DataExtension?

I tried but couldnt succeed yet and i wonder if i am missing something?

Subclassing would probably do, but as there are empty permission methods in DataExtension, of what purpose are they?

public function canEdit($member) {
}

回答1:


Assuming SS3.0+ the short answer is, it depends.

The straight DataObject->can[Create|Edit|View|Delete] methods can't be extended in that fashion, but descendants of SiteTree mostly can.

The function of interest here is DataObject->extendedCan which is called by all the SiteTree can* methods but not the DataObject can* methods.

Of course you can always ensure this method is called in your DataObject sub-classes.

Be aware that this can get very complex if multiple extensions are extending these functions. Here is some important documentation from the DataObject class:

Process tri-state responses from permission-alterting extensions. The extensions are expected to return one of three values:

  • false: Disallow this permission, regardless of what other extensions say
  • true: Allow this permission, as long as no other extensions return false
  • NULL: Don't affect the outcome

It's also worth noting that any user with the ADMIN permissions will slip through all of these checks. The only way to change permissions on objects for ADMIN users is sub-classing DataObject.



来源:https://stackoverflow.com/questions/16758844/dataextension-and-canview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!