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

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 6828 to 6908

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 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.