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

create_periodic_email()

Description

Creates a new automatic periodic e-mail report

Parameters

ColumnTypeDefaultDescription
$user
$report
$period
$email_days
$user_groups array
$search_params array

Location

include/reporting_functions.php lines 338 to 373

Definition

 
function create_periodic_email($user$report$period$email_days, array $user_groups, array $search_params)
    {
    if (
$email_days 1)
        {
        
$email_days 1# Minimum email frequency is daily.
        
}
    
# Delete any matching rows for this report/period.
    
$query "DELETE FROM report_periodic_emails
              WHERE user = ?
              AND report = ?
              AND period = ?"
;
    
$parameters=array("i",$user"i",$report"i",$period);
    
ps_query($query,$parameters);

    
# Insert a new row.
    
$query "INSERT INTO report_periodic_emails 
                        (user, report, period, email_days, search_params)
                 VALUES (?,?,?,?,?)"
;
    
$parameters=array("i",$user"i",$report"i",$period"i",$email_days
                      
"s",json_encode($search_paramsJSON_UNESCAPED_UNICODE JSON_NUMERIC_CHECK));
    
ps_query($query,$parameters);

    
$ref sql_insert_id();
    
    
# Send to all users?
    
if (
        
checkperm('m')
        && !empty(
$user_groups)
        ) {
            
$ugstring=implode(",",$user_groups);
            
ps_query("UPDATE report_periodic_emails SET user_groups = ? WHERE ref = ?",array("s",$ugstring"i",$ref));
        }

    
# Return
    
return true;
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 7th November 2024 17:40 Europe/London time.