roles - 根据用户角色将自定义字段设置为只读

标签 roles sugarcrm

在我的任务 editviewdefs.php 中...这对我有用。该字段是只读的,不能编辑。 有人可以帮我让“类型”=>“只读”仅在用户角色匹配“信贷员”时适用吗?

    array (
      0 => '',
      1 => 
      array (
        'name' => 'processor_signoff_c',
        'label' => 'LBL_PROCESSOR_SIGNOFF',
        'type' => 'readonly',
      ),
    ),

我使用的是 6.5.14 社区版。

最佳答案

解决方法如下:

文件 => 自定义/模块/任务/ View /view.edit.php

/**
 * @see SugarView::display()
 */
public function display()
{
    if($this->ev->isDuplicate){
            $this->bean->status = $this->bean->getDefaultStatus();
    } //if

    global $current_user;

    // check if current user is in specific role
            $isEnabledRole = in_array("ITOperation", ACLRole::getUserRoleNames($current_user->id));
            if($isEnabledRole)
                $this->ev->ss->assign('readOnly', 'readonly = "readonly"');
            else
                $this->ev->ss->assign('readOnly', '');

    parent::display();
}

文件 => 自定义/模块/任务/元数据/editviewdefs.php

    array (

      array (
        'name' => 'description',
    'customCode' => '<input type="text" title="" value="{$fields.description.value}" id="description" name="description" {$readOnly}>',
      ),
    ),
  ),

对于复选框输入类型则: 文件 => 自定义/模块/任务/ View /view.edit.php

            if($isEnabledRole) {
                $this->ev->ss->assign('readOnly', 'readonly = "readonly"');
                $this->ev->ss->assign('disabled', 'disabled');
            } else {
                $this->ev->ss->assign('readOnly', '');
                $this->ev->ss->assign('disabled', '');
            }

文件 => 自定义/模块/任务/元数据/editviewdefs.php

      array (
        'name' => 'processor_signoff_c',
        'label' => 'LBL_PROCESSOR_SIGNOFF',
        'customCode' => '<input type="hidden" name="processor_signoff_c" value="0"><input type="checkbox" id="processor_signoff_c" name="processor_signoff_c" value="1" {if $fields.processor_signoff_c.value == "1"} checked {/if} {$disabled}>',
      ),

再见, 安东尼奥。

关于roles - 根据用户角色将自定义字段设置为只读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18585612/

相关文章:

javascript - SugarCRM 中的 Javascript 密码验证文件在哪里?

elasticsearch - Elasticsearch无法与Sugarcrm 7.5.0.1一起使用

java - Sugar CRM - Java 客户端 - 登录

javascript - 具有角色的帐户 MeteorJS

java - 在 Spring Security (Spring Boot 2.x) 中,我如何为 @Pre/PostAuthorize 和检查角色提供自己的实现?

asp.net-mvc-4 - 新的 MVC 4 Internet 模板中使用 simplemembership 进行基于角色的身份验证

java - @Rolesallowed 是如何工作的

jquery - $ 未在 sugarcrm 中定义且不重复

SugarCRM:添加自定义帮助程序类

具有给定角色的 PostgreSQL 触发器