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

activate_plugin()

Parameters

ColumnTypeDefaultDescription
$name

Location

include/plugin_functions.php lines 19 to 61

Definition

 
function activate_plugin($name)
    {
    
$plugin_dir get_plugin_path($name);
    if (
file_exists($plugin_dir))
        {
        
$plugin_yaml get_plugin_yaml($namefalse);
        
# If no yaml, or yaml file but no description present, attempt to read an 'about.txt' file
        
if ('' == $plugin_yaml['desc'])
            {
            
$about $plugin_dir $name '/about.txt';
            if(
file_exists($about))
                {
                
$plugin_yaml['desc'] = substr(file_get_contents($about), 095) . '...';
                }
            }

        
# Add/Update plugin information.
        # Check if the plugin is already in the table.
        
$c ps_value("SELECT name as value FROM plugins WHERE name = ?", array("s"$name), '');

        if (
$c == '')
            {
            
ps_query("INSERT INTO plugins (name) VALUE (?)", array("s"$name));
            }

        
ps_query("UPDATE plugins SET config_url = ?, descrip = ?, author = ?, inst_version = ?, priority = ?, update_url = ?, info_url = ?, disable_group_select = ?,
        title = ?, icon = ? WHERE name = ?"
, array("s"$plugin_yaml['config_url'], "s"$plugin_yaml['desc'], "s"$plugin_yaml['author'], "d"$plugin_yaml['version'],
        
"i"$plugin_yaml['default_priority'], "s"$plugin_yaml['update_url'], "s"$plugin_yaml['info_url'], "i"$plugin_yaml['disable_group_select'], "s",
        
$plugin_yaml['title'], "s"$plugin_yaml['icon'], "s"$plugin_yaml['name']));

        
log_activity(nullLOG_CODE_ENABLED$plugin_yaml['version'], 'plugins''inst_version'$plugin_yaml['name'], 'name'''nulltrue);

        
// Clear query cache
        
clear_query_cache("plugins");

        
hook("after_activate_plugin","",array($name));
        return 
true;
        }
    else
        {
        return 
false;
        }
    }

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