Habari\Plugins::changed_since_last_activation PHP Method

changed_since_last_activation() public static method

Detects whether the plugins that exist have changed since they were last activated.
public static changed_since_last_activation ( ) : boolean
return boolean true if the plugins have changed, false if not.
    public static function changed_since_last_activation()
    {
        $old_plugins = Options::get('plugins_present');
        // If the plugin list was never stored, then they've changed.
        if (!is_array($old_plugins)) {
            return true;
        }
        // add base path onto stored path
        foreach ($old_plugins as $old_plugin) {
            $old_plugin = HABARI_PATH . $old_plugin;
        }
        // If the file list is not identical, then they've changed.
        $new_plugin_files = Plugins::list_all();
        $old_plugin_files = Utils::array_map_field($old_plugins, 'file');
        if (count(array_intersect($new_plugin_files, $old_plugin_files)) != count($new_plugin_files)) {
            return true;
        }
        // If the files are not identical, then they've changed.
        $old_plugin_checksums = Utils::array_map_field($old_plugins, 'checksum');
        $new_plugin_checksums = array_map('md5_file', $new_plugin_files);
        if (count(array_intersect($old_plugin_checksums, $new_plugin_checksums)) != count($new_plugin_checksums)) {
            return true;
        }
        return false;
    }