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

import_resource()

Description

Imports a resource from the specified path and updates its details.

This function is used to import resources into the system, particularly through staticsync.php
It creates a new resource entry and updates it with the provided file details.

Parameters

ColumnTypeDefaultDescription
$path string The file path of the resource to import.
$type string The type of the resource being imported.
$title string The title for the imported resource.
$ingest bool false Indicates if the resource is being ingested (default is false).
$extension string '' The file extension of the resource (optional).

Return

int|bool The newly created resource ID if successful, false otherwise.

Location

include/resource_functions.php lines 5036 to 5056

Definition

 
function import_resource($path$type$title$ingest=false$extension='')
    {
    global 
$syncdir,$lang;

    
$r=create_resource($type);
    if(
$r === false)
        {
        return 
false;
        }

    
// Log this in case the original location is not stored anywhere else
    
resource_log(
        
RESOURCE_LOG_APPEND_PREVIOUS,
        
LOG_CODE_CREATED,
        
'',
        
$lang["createdfromstaticsync"],
        
'',
        
$syncdir DIRECTORY_SEPARATOR $path
    
);
    return 
update_resource($r$path$type$title$ingesttrue$extension);
    }

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