简体   繁体   English

Drupal7根据用户组织过滤可见的Web表单

[英]Drupal7 Filter visible webforms based on user organization

We have a Drupal 7 site. 我们有一个Drupal 7网站。

We have a 'User X' that selected what organization they belong to when they registered;organization field. 我们有一个“用户X”,用于选择他们在注册时所属的组织;“组织”字段。 But note, this is not a role - it's just like they selected what company name they belong to. 但是请注意,这不是角色-就像他们选择了所属的公司名称一样。

We have Webforms assigned to different organizations (again, company, not role) by a data value in one of the form's fields; 我们已经通过表单字段之一中的数据值将Web表单分配给了不同的组织(再次是公司,不是角色); organization field. 组织领域。 A 'User Y' assigns this data value to the webform. “用户Y”将此数据值分配给网络表单。

We need to filter what webforms 'User X' can see, by organization field. 我们需要按组织字段过滤“用户X”可以看到的Web表单。

The filter will be the organization 'User X' selected when registering, compared to the entered data in the organization field in the webform by 'User Y'. 与“用户Y”在网络表单中组织字段中输入的数据相比,过滤器将是注册时选择的组织“用户X”。

How do I make this filter work? 如何使此过滤器起作用? How do I filter what Webforms 'User X' can see? 如何过滤“用户X”可以看到的Webforms?

I think you'll need to write a hook_menu access_callback for each form that checks to see if the user is in the particular organization. 我认为您需要为每种检查用户是否在特定组织中的表单编写一个hook_menu access_callback。 It would be helpful to you if there was some naming convention that allowed you to use the same menu hook for all the forms like: 如果有一些命名约定可以使您对所有形式使用相同的菜单钩,这将对您有所帮助:

$form_id = 'form_org_1' 

and

$user->org = 'org_1'

but that's probably not the case. 但事实并非如此。 Hopefully there aren't a lot of forms/orgs. 希望没有很多表格/组织。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM