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

set_slideshow()

Description

Create/ Update a slideshow image record. Use NULL for $ref to create new records.

Parameters

ColumnTypeDefaultDescription
$ref integer ID of the slideshow image. Use NULL to create a new record
$resource_ref integer null ID of the resource this slideshow is related to. Use NULL if no link is required
$homepage_show integer 1 Set to 1 if slideshow image should appear on the home page
$featured_collections_show integer 1 Set to 1 if slideshow image should appear on the featured collections page
$login_show integer 0 Set to 1 if slideshow image should appear on the login page

Return

boolean|integer Returns ID of the slideshow image(new/ updated), FALSE otherwise

Location

include/slideshow_functions.php lines 14 to 66

Definition

 
function set_slideshow($ref$resource_ref null$homepage_show 1$featured_collections_show 1$login_show 0)
{
    if (
        (!
is_null($ref) && !is_numeric($ref))
        || (!(
is_null($resource_ref) || trim($resource_ref) == '') && !is_numeric($resource_ref))
        || !
is_numeric($homepage_show)
        || !
is_numeric($featured_collections_show)
        || !
is_numeric($login_show)
    ) {
        return 
false;
    }

    
$ref            = ((int) $ref $ref null);
    
$resource_ref   = ((int) $resource_ref $resource_ref null);

    
$query "
        INSERT INTO slideshow (ref, resource_ref, homepage_show, featured_collections_show, login_show)
             VALUES (?, ?, ?, ?, ?)
                 ON DUPLICATE KEY
             UPDATE resource_ref = ?,
                    homepage_show = ?,
                    featured_collections_show = ?,
                    login_show = ?"
;
    
$query_params = array(
        
"i",$ref,
        
"i",$resource_ref,
        
"i",$homepage_show,
        
"i",$featured_collections_show,
        
"i",$login_show,
        
"i",$resource_ref,
        
"i",$homepage_show,
        
"i",$featured_collections_show,
        
"i",$login_show,
    );

    
ps_query($query$query_params);

    
// Clear cache
    
clear_query_cache("slideshow");

    
$new_ref sql_insert_id();
    if (
is_null($ref) && $new_ref != 0) {
        
log_activity("Added new slideshow image"LOG_CODE_CREATEDnull'slideshow''ref'$new_ref);

        return 
$new_ref;
    } elseif (!
is_null($ref) && $new_ref != && $ref == $new_ref) {
        
log_activity("Updated slideshow image"LOG_CODE_EDITEDnull'slideshow''ref'$ref);

        return 
$new_ref;
    }

    return 
false;
}

This article was last updated 11th February 2025 20:35 Europe/London time based on the source file dated 11th February 2025 11:15 Europe/London time.