Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_notification_users_by_owner_field()

Description

Get users to notify for requested resources "owned" by particular groups. Configurable using a metadata field
($owner_field) and a defined map ($owner_field_mappings).

value contains an array with at least a "ref" and "email" keys.

Parameters

ColumnTypeDefaultDescription
$users array List of notification users {@see get_notification_users()}. Any array structure where each
$resources array List of resource IDs

Return

array Returns user ID (key) and email (value)

Location

include/request_functions.php lines 1228 to 1265

Definition

 
function get_notification_users_by_owner_field(array $users, array $resources)
    {
    
$users_map_ref_email array_column($users'email''ref');

    if(!
can_use_owner_field())
        {
        return 
$users_map_ref_email;
        }

    global 
$owner_field$owner_field_mappings;

    
$users_to_notify = [];

    
// Build a list of owner field nodes belonging to the incoming list of resources; true means get full node details 
    
$resource_nodes get_resource_nodes_batch($resources, [$owner_field], true);
    
    
// There are resources, but there is no routing data (ie. no owners to route to), so no users are filtered out
    
if(!empty($resources) && empty($resource_nodes))
        {
        return 
$users_map_ref_email;
        }

    
// Determine which users should be notified based on the owner field value and its mappings
    
foreach($resource_nodes as $rtf_rns)
        {
        
$owner_field_node_id $rtf_rns[$owner_field][0]['ref'] ?? 0;
        
$mapped_group $owner_field_mappings[$owner_field_node_id] ?? 0;
        if(
$owner_field_node_id && $mapped_group 0)
            {
            
// Build a list of userrefs within the mapped group
            
$group_users array_column(get_users($mapped_group'''u.username'false, -11false'u.ref'), 'ref');
            
// Each of the userrefs which is a member of the mapped group will be notified
            
$users_to_notify += array_intersect_key($users_map_ref_emailarray_flip($group_users));
            }
        }

    return 
$users_to_notify;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 18th November 2024 16:40 Europe/London time.