Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

activate_plugin()

Parameters

ColumnTypeDefaultDescription
$name

Location

include/plugin_functions.php lines 19 to 73

Definition

 
function activate_plugin($name)
    {
    
$plugin_dir get_plugin_path($name);
    if (
file_exists($plugin_dir))
        {
        
$plugin_yaml get_plugin_yaml("$plugin_dir/$name.yaml"false);
        
# 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) . '...';
                }
            }
            
        
# escape the plugin information
        
$plugin_yaml_esc = array();
        foreach (
array_keys($plugin_yaml) as $thekey)
            {
            
$plugin_yaml_esc[$thekey] = escape_check($plugin_yaml[$thekey]);
            }
    
        
# Add/Update plugin information.
        # Check if the plugin is already in the table.
        
$c sql_value("SELECT name as value FROM plugins WHERE name='$name'",'');

        if (
$c == '')
            {
            
sql_query("INSERT INTO plugins(name) VALUE ('$name')");
            }

        
sql_query("UPDATE plugins SET config_url='{$plugin_yaml_esc['config_url']}', " .
            
"descrip='{$plugin_yaml_esc['desc']}', author='{$plugin_yaml_esc['author']}', " .
            
"inst_version='{$plugin_yaml_esc['version']}', " .
            
"priority='{$plugin_yaml_esc['default_priority']}', " .
            
"update_url='{$plugin_yaml_esc['update_url']}', info_url='{$plugin_yaml_esc['info_url']}', " .
            
"disable_group_select='{$plugin_yaml_esc['disable_group_select']}', " .
            
"title='{$plugin_yaml_esc['title']}', " .
            
"icon='{$plugin_yaml_esc['icon']}'" .
            
"WHERE name='{$plugin_yaml_esc['name']}'");

        
log_activity(nullLOG_CODE_ENABLED$plugin_yaml_esc['version'], 'plugins''inst_version'$plugin_yaml_esc['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 14th July 2020 03:05 Europe/London time based on the source file dated 2nd July 2020 09:08 Europe/London time.