Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sugarcrm 如果分配的用户是login SuiteRM,则在弹出列表视图中筛选记录_Sugarcrm_Suitecrm - Fatal编程技术网

Sugarcrm 如果分配的用户是login SuiteRM,则在弹出列表视图中筛选记录

Sugarcrm 如果分配的用户是login SuiteRM,则在弹出列表视图中筛选记录,sugarcrm,suitecrm,Sugarcrm,Suitecrm,我想筛选记录,以便分配的用户只能从弹出列表视图中查看分配给他的记录 我没有在角色管理中这样做的原因是,如果我将一个用户分配给一个客户端记录,那么具有相同角色的其他用户将无法看到它,因此我将角色->列表选项卡设置为“全部”,并在列表视图中添加自定义代码,只有登录用户才能看到自己的记录。 这就是我所做的 <?php require_once('include/MVC/View/views/view.popup.php'); class AccountsViewPopup e

我想筛选记录,以便分配的用户只能从弹出列表视图中查看分配给他的记录

我没有在角色管理中这样做的原因是,如果我将一个用户分配给一个客户端记录,那么具有相同角色的其他用户将无法看到它,因此我将角色->列表选项卡设置为“全部”,并在列表视图中添加自定义代码,只有登录用户才能看到自己的记录。

这就是我所做的

<?php

    require_once('include/MVC/View/views/view.popup.php');

    class AccountsViewPopup extends ViewPopup
    {
        public function display()
        {
            parent::display(); // TODO: Change the autogenerated stub

            require_once 'modules/ACLRoles/ACLRole.php';
            $ACLRole = new ACLRole();
            $roles = $ACLRole->getUserRoles($GLOBALS['current_user']->id);

            if (in_array('User1', $roles)) {

                global $db, $current_user;

                $this->where .= " AND accounts.assigned_user_id = '$current_user->id' AND deleted=0 ";
            }
        }
    }

仅用于列表视图
自定义/modules/MODULE\u NAME/views/view.list.php

以下是帮助代码:

require_once('include/MVC/View/views/view.list.php');
class MODULE_NAMEViewList extends ViewList {

    function listViewProcess() {
        global $current_user;
        $this->params['custom_where'] = ' AND module_name.name = "test" ';

        parent::listViewProcess();
}

}


对于列表和弹出视图(两者)

您需要更改实际准备查询的
create\u new\u list\u query
函数中的逻辑。一些模块在bean级别覆盖了它(例如,请参见
modules/Leads/Lead.php

如果要以升级安全的方式覆盖它,请在自定义目录中创建一个文件,例如:
custom/modules/Leads/Lead.php
,然后从核心bean类扩展它,如下所示:

<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once('modules/Leads/Lead.php');
class CustomLead extends Lead {

    function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false)
    { 
        // Code from create_new_list_query in and then modify it accordingly. 
    }
}
<?php
$objectList['Leads'] = 'Lead';
$beanList['Leads'] = 'CustomLead';
$beanFiles['CustomLead'] = 'custom/modules/Leads/Lead.php';
?>

仅用于列表视图
自定义/modules/MODULE\u NAME/views/view.list.php

以下是帮助代码:

require_once('include/MVC/View/views/view.list.php');
class MODULE_NAMEViewList extends ViewList {

    function listViewProcess() {
        global $current_user;
        $this->params['custom_where'] = ' AND module_name.name = "test" ';

        parent::listViewProcess();
}

}


对于列表和弹出视图(两者)

您需要更改实际准备查询的
create\u new\u list\u query
函数中的逻辑。一些模块在bean级别覆盖了它(例如,请参见
modules/Leads/Lead.php

如果要以升级安全的方式覆盖它,请在自定义目录中创建一个文件,例如:
custom/modules/Leads/Lead.php
,然后从核心bean类扩展它,如下所示:

<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once('modules/Leads/Lead.php');
class CustomLead extends Lead {

    function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false)
    { 
        // Code from create_new_list_query in and then modify it accordingly. 
    }
}
<?php
$objectList['Leads'] = 'Lead';
$beanList['Leads'] = 'CustomLead';
$beanFiles['CustomLead'] = 'custom/modules/Leads/Lead.php';
?>

我知道这已经得到了回答,但还是决定发布我的解决方案。不久前(7.10.7),我也有同样的问题。 PopupView具有方法
getCustomWhereClause()
,您可以在自定义视图中实现该方法。 它必须返回包含条件的字符串

例如:

custom/modules/Meetings/views/view.popup.php    
/*class declaration and other stuff*/
protected function getCustomWhereClause()
{
    global $current_user;
    return " ( {$this->bean->table_name}.assigned_user_id='{$current_user->id}') ";
}

请记住在开头和结尾至少留一个空格,因为SuiteCRM实际上忘记添加它,这可能会导致查询中断(但在日志中很容易找到)。

我知道这已经得到了回答,但还是决定发布我的解决方案。不久前(7.10.7),我也有同样的问题。 PopupView具有方法
getCustomWhereClause()
,您可以在自定义视图中实现该方法。 它必须返回包含条件的字符串

例如:

custom/modules/Meetings/views/view.popup.php    
/*class declaration and other stuff*/
protected function getCustomWhereClause()
{
    global $current_user;
    return " ( {$this->bean->table_name}.assigned_user_id='{$current_user->id}') ";
}

请记住在开头和结尾至少留一个空格,因为SuiteCRM实际上忘记添加它,这可能会导致查询中断(但在日志中很容易找到)。

我也尝试过这样做,但似乎没有执行。也许我会再试一试。我尝试过这个解决方案,但只有列表视图可以覆盖,而不是弹出列表视图。更新了我的答案,包括弹出视图的解决方案。我也尝试过,但似乎没有执行。也许我会再试一试。我尝试过解决方案,但只有列表视图可以覆盖,而不是弹出列表视图。更新了我的答案,以包括弹出视图的解决方案