Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

send_collection_to_admin()

Description

Send collection to administrators - used if $send_collection_to_admin is enabled

Parameters

ColumnTypeDefaultDescription
$collection int Collection ID

Return

boolean

Location

include/collections_functions.php lines 6783 to 6863

Definition

 
function send_collection_to_admin(int $collection)
    {
    if(!
is_int_loose($collection))
        {
        return 
false;
        }
       
    global 
$lang$userref$applicationname$baseurl$admin_resource_access_notifications;
    
    
// Get details about the collection:
    
$collectiondata get_collection($collection);
    
$collection_name $collectiondata['name'];
    
$resources_in_collection count(get_collection_resources($collection));

    
// Only do this if it is the user's own collection
    
if($collectiondata['user'] != $userref)
        {
        return 
false;
        }

    
$collectionsent false;
    
// Create a copy of the collection for admin:
    
$admin_copy create_collection(-1$lang['send_collection_to_admin_emailedcollectionname']);
    
copy_collection($collection$admin_copy);
    
$collection_id $admin_copy;

    
// Get the user (or username) of the contributor:
    
$user get_user($userref);
    if(isset(
$user) && trim($user['fullname']) != '')
        {
        
$user $user['fullname'];
        }
    else
        {
        
$user $user['username'];
        }

    
// Build mail and send it:
    
$subject $applicationname ': ' $lang['send_collection_to_admin_emailsubject'] . $user;

    
$message $user $lang['send_collection_to_admin_usercontributedcollection'] . "\n\n";
    
$message .= $baseurl '/pages/search.php?search=!collection' $collection_id "\n\n";
    
$message .= $lang['send_collection_to_admin_additionalinformation'] . "\n\n";
    
$message .= $lang['send_collection_to_admin_collectionname'] . $collection_name "\n\n";
    
$message .= $lang['send_collection_to_admin_numberofresources'] . $resources_in_collection "\n\n";
    
    
$notification_message $lang['send_collection_to_admin_emailsubject'] . " " $user;
    
$notification_url $baseurl '/?c=' $collection_id;
    
$admin_notify_emails = array();
    
$admin_notify_users = array();
    
$notify_users=get_notification_users(array("e-1","e0")); 
    foreach(
$notify_users as $notify_user)
        {
        
get_config_option($notify_user['ref'],'user_pref_resource_notifications'$send_message$admin_resource_access_notifications);       
        if(
$send_message==false)
            {
            continue;
            }       
        
get_config_option($notify_user['ref'],'email_user_notifications'$send_email);    
        if(
$send_email && $notify_user["email"]!="")
            {
            
$admin_notify_emails[] = $notify_user['email'];             
            }        
        else
            {
            
$admin_notify_users[]=$notify_user["ref"];
            }
        }
    foreach(
$admin_notify_emails as $admin_notify_email)
        {
        
send_mail($admin_notify_email$subject$message'''');
        
$collectionsent true;
        }
    if (
count($admin_notify_users)>0)
        {
        
debug("sending collection to user IDs: " implode(",",$admin_notify_users));
        
message_add($admin_notify_users,$notification_message,$notification_url$userrefMESSAGE_ENUM_NOTIFICATION_TYPE_SCREEN,MESSAGE_DEFAULT_TTL_SECONDS,SUBMITTED_COLLECTION$collection_id);
        
$collectionsent true;
        }
    return 
$collectionsent;
    }

This article was last updated 19th March 2024 07:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.