public function archive_plugin_version($folderpath, $component, $version, $overwrite=false) {

        if ($component !== clean_param($component, PARAM_SAFEDIR)) {
            // This should never happen, but just in case.
            throw new moodle_exception('unexpected_plugin_component_format', 'core_plugin', '', null, $component);
        }

        if ((string)$version !== clean_param((string)$version, PARAM_FILE)) {
            // Prevent some nasty injections via $plugin->version tricks.
            throw new moodle_exception('unexpected_plugin_version_format', 'core_plugin', '', null, $version);
        }

        if (empty($component) or empty($version)) {
            return false;
        }

        if (!is_dir($folderpath)) {
            return false;
        }

        $archzip = $this->temproot.'/archive/'.$component.'/'.$version.'.zip';

        if (file_exists($archzip) and !$overwrite) {
            return true;
        }

        $tmpzip = make_request_directory().'/'.$version.'.zip';
        $zipped = $this->zip_plugin_folder($folderpath, $tmpzip);

        if (!$zipped) {
            return false;
        }

        // Assert that the file looks like a valid one.
        list($expectedtype, $expectedname) = core_component::normalize_component($component);
        $actualname = $this->get_plugin_zip_root_dir($tmpzip);
        if ($actualname !== $expectedname) {
            // This should not happen.
            throw new moodle_exception('unexpected_archive_structure', 'core_plugin');
        }

        make_writable_directory(dirname($archzip));
        return rename($tmpzip, $archzip);
    }
public function archive_plugin_version($folderpath, $component, $version, $overwrite=false) {

        if ($component !== clean_param($component, PARAM_SAFEDIR)) {
            // This should never happen, but just in case.
            throw new moodle_exception('unexpected_plugin_component_format', 'core_plugin', '', null, $component);
        }

        if ((string)$version !== clean_param((string)$version, PARAM_FILE)) {
            // Prevent some nasty injections via $plugin->version tricks.
            throw new moodle_exception('unexpected_plugin_version_format', 'core_plugin', '', null, $version);
        }

        if (empty($component) or empty($version)) {
            return false;
        }

        if (!is_dir($folderpath)) {
            return false;
        }

        $archzip = $this->temproot.'/archive/'.$component.'/'.$version.'.zip';

        if (file_exists($archzip) and !$overwrite) {
            return true;
        }

        $tmpzip = make_request_directory().'/'.$version.'.zip';
        $zipped = $this->zip_plugin_folder($folderpath, $tmpzip);

        if (!$zipped) {
            return false;
        }

        // Assert that the file looks like a valid one.
        list($expectedtype, $expectedname) = core_component::normalize_component($component);
        $actualname = $this->get_plugin_zip_root_dir($tmpzip);
        if ($actualname !== $expectedname) {
            // This should not happen.
            throw new moodle_exception('unexpected_archive_structure', 'core_plugin');
        }

        make_writable_directory(dirname($archzip));
        return rename($tmpzip, $archzip);
    }
public function archive_plugin_version ( $ folderpath , $ component , $ version , $ overwrite = false ) { if ( $ component !== clean_param ( $ component , PARAM_SAFEDIR ) ) { // This should never happen, but just in case. throw new moodle_exception ( 'unexpected_plugin_component_format' , 'core_plugin' , '' , null , $ component ) ; } if ( ( string ) $ version !== clean_param ( ( string ) $ version , PARAM_FILE ) ) { // Prevent some nasty injections via $plugin->version tricks. throw new moodle_exception ( 'unexpected_plugin_version_format' , 'core_plugin' , '' , null , $ version ) ; } if ( empty ( $ component ) or empty ( $ version ) ) { return false ; } if ( ! is_dir ( $ folderpath ) ) { return false ; } $ archzip = $ this -> temproot . '/archive/' . $ component . '/' . $ version . '.zip' ; if ( file_exists ( $ archzip ) and ! $ overwrite ) { return true ; } $ tmpzip = make_request_directory ( ) . '/' . $ version . '.zip' ; $ zipped = $ this -> zip_plugin_folder ( $ folderpath , $ tmpzip ) ; if ( ! $ zipped ) { return false ; } // Assert that the file looks like a valid one. list ( $ expectedtype , $ expectedname ) = core_component :: normalize_component ( $ component ) ; $ actualname = $ this -> get_plugin_zip_root_dir ( $ tmpzip ) ; if ( $ actualname !== $ expectedname ) { // This should not happen. throw new moodle_exception ( 'unexpected_archive_structure' , 'core_plugin' ) ; } make_writable_directory ( dirname ( $ archzip ) ) ; return rename ( $ tmpzip , $ archzip ) ; }
Archive the current plugin on-disk version.

@param string $folderpath full path to the plugin folder
@param string $component
@param int $version
@param bool $overwrite overwrite existing archive if found
@return bool
Archive the current plugin on - disk version .