2

我想根据自定义规则限制对记录的编辑。我能够限制列表视图,但似乎无法使编辑限制起作用。

在自定义控制器中,我有

class CustomOpportunitiesController extends SugarController { 

protected function action_editview() {
    $this->bean = new CustomOpportunity();
    // parent::action_editview(); // There is no action_editview() in SugarController
    $this->view_object_map['bean'] = $this->bean;
    $this->view = 'edit';
}

但是,当我添加它时,每当我尝试编辑记录时,它都会转到创建记录!

也绝对没有(有用的)文档。 http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.5/02_Application_Framework/ACL

版本 6.5.13。

(我在子类中也有代码,但现在已被注释掉。)

class CustomOpportunity extends Opportunity {
    // function ACLAccess($view,$is_owner='not_set') {  ...
4

1 回答 1

2

有多种方法可以实现这一目标。如果我们在您的代码中使用自定义控制器,您可以试试这个:

public function action_editview()
{
    /* Set view */
    if (/*your condition here*/)
    {
        $this->view = 'noaccess';
    }
    else
    {
        $this->view = 'edit';
    }
}

希望这可以帮助!

附言。您的代码似乎会创建新记录的原因似乎是由于“$this->bean = new CustomOpportunity();” -line,在这里你用一个新的记录覆盖你要编辑的 bean :-)

于 2014-02-25T11:29:19.790 回答