Problemas para restaurar curso (copia de seg muy grande)

Re: Problemas para restaurar curso (copia de seg muy grande)

de Josefina Osán -
Número de respuestas: 3
Hola Jose Luis,
Muchas gracias por tu respuesta
es esta la info que me decís??

SystemLinux ws11.intermedia.net.ar 3.10.0-962.3.2.lve1.5.26.9.el7.x86_64 #1 SMP Wed Nov 13 22:12:04 EST 2019 x86_64
Build DateNov 4 2020 11:02:59
Configure Command'./configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/opt/cpanel/ea-php74/root/usr' '--exec-prefix=/opt/cpanel/ea-php74/root/usr' '--bindir=/opt/cpanel/ea-php74/root/usr/bin' '--sbindir=/opt/cpanel/ea-php74/root/usr/sbin' '--sysconfdir=/opt/cpanel/ea-php74/root/etc' '--datadir=/opt/cpanel/ea-php74/root/usr/share' '--includedir=/opt/cpanel/ea-php74/root/usr/include' '--libdir=/opt/cpanel/ea-php74/root/usr/lib64' '--libexecdir=/opt/cpanel/ea-php74/root/usr/libexec' '--localstatedir=/opt/cpanel/ea-php74/root/usr/var' '--sharedstatedir=/opt/cpanel/ea-php74/root/usr/com' '--mandir=/opt/cpanel/ea-php74/root/usr/share/man' '--infodir=/opt/cpanel/ea-php74/root/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/opt/cpanel/ea-php74/root/etc' '--with-config-file-scan-dir=/opt/cpanel/ea-php74/root/etc/php.d' '--disable-debug' '--with-password-argon2=/opt/cpanel/libargon2' '--with-pic' '--without-pear' '--with-bz2' '--with-freetype' '--with-xpm' '--without-gdbm' '--with-gettext' '--with-iconv' '--with-jpeg' '--with-jpeg-dir=/usr' '--with-openssl=/opt/cpanel/ea-openssl11' '--with-openssl-dir=/opt/cpanel/ea-openssl11' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-sockets' '--with-kerberos' '--enable-shmop' '--with-libxml' '--with-system-tzdata' '--with-mhash' '--enable-fpm' '--with-fpm-systemd' '--libdir=/opt/cpanel/ea-php74/root/usr/lib64/php' '--without-mysqli' '--disable-pdo' '--enable-pcntl' '--disable-gd' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-opcache' '--disable-xmlreader' '--disable-xmlwriter' '--without-sqlite3' '--disable-phar' '--disable-fileinfo' '--disable-json' '--without-pspell' '--without-curl' '--disable-posix' '--disable-xml' '--disable-simplexml' '--disable-exif' '--without-gettext' '--without-iconv' '--disable-ftp' '--without-bz2' '--disable-ctype' '--disable-shmop' '--disable-sockets' '--disable-tokenizer' '--disable-sysvmsg' '--disable-sysvshm' '--disable-sysvsem' '--without-gmp' '--disable-calendar' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'PKG_CONFIG_PATH=/opt/cpanel/ea-php74/root/usr/lib64/pkgconfig:/opt/cpanel/ea-php74/root/usr/share/pkgconfig:/usr/lib64/pkgconfig:/opt/cpanel/ea-openssl11/lib64/pkgconfig:/opt/cpanel/ea-libxml2/lib64/pkgconfig:/opt/cpanel/ea-libicu/lib/pkgconfig:/opt/cpanel/ea-oniguruma/lib64/pkgconfig' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -fno-strict-aliasing -Wno-pointer-sign' 'SYSTEMD_LIBS=-lsystemd' 'LIBXML_CFLAGS=-I/opt/cpanel/ea-libxml2/include/libxml2' 'LIBXML_LIBS=-L/opt/cpanel/ea-libxml2/lib64 -lxml2' 'KERBEROS_CFLAGS=-I/usr/include' 'KERBEROS_LIBS=-L/usr/lib64' 'OPENSSL_CFLAGS=-I/opt/cpanel/ea-openssl11/include' 'OPENSSL_LIBS=-L/opt/cpanel/ea-openssl11/lib -lssl -lcrypto -lresolv' 'CURL_CFLAGS=-I/opt/cpanel/libcurl/include' 'CURL_LIBS=-L/opt/cpanel/libcurl/lib64 -lcurl' 'JPEG_CFLAGS=-I/usr/include' 'JPEG_LIBS=-L/usr/lib64 -ljpeg' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' 'SASL_CFLAGS=-I/usr/include' 'SASL_LIBS=-L/usr/lib64' 'XSL_CFLAGS=-I/opt/cpanel/ea-libxml2/include/libxml2' 'XSL_LIBS=-L/opt/cpanel/ea-libxml2/lib64 -lxml2' 'LIBZIP_CFLAGS=-I/opt/cpanel/ea-libzip/include' 'LIBZIP_LIBS=-L/opt/cpanel/ea-libzip/lib64 -lzip'
Server APIFPM/FastCGI
Virtual Directory Supportdisabled
Configuration File (php.ini) Path/opt/cpanel/ea-php74/root/etc
Loaded Configuration File/opt/cpanel/ea-php74/root/etc/php.ini
Scan this dir for additional .ini files/opt/cpanel/ea-php74/root/etc/php.d
Additional .ini files parsed/opt/cpanel/ea-php74/root/etc/php.d/20-bcmath.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-bz2.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-ctype.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-curl.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-dom.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-exif.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-fileinfo.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-ftp.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-gd.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-gettext.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-iconv.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-intl.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-json.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-mbstring.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-mysqlnd.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-pdo.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-phar.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-posix.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-simplexml.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-soap.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-sqlite3.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-tidy.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-tokenizer.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-xml.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-xmlwriter.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-xsl.ini, /opt/cpanel/ea-php74/root/etc/php.d/20-zip.ini, /opt/cpanel/ea-php74/root/etc/php.d/30-mysqli.ini, /opt/cpanel/ea-php74/root/etc/php.d/30-pdo_mysql.ini, /opt/cpanel/ea-php74/root/etc/php.d/30-pdo_sqlite.ini, /opt/cpanel/ea-php74/root/etc/php.d/30-xmlreader.ini, /opt/cpanel/ea-php74/root/etc/php.d/i360.ini, /opt/cpanel/ea-php74/root/etc/php.d/zzzzzzz-pecl.ini

Debug Buildno
Thread Safetydisabled
Zend Signal Handlingenabled
Zend Memory Managerenabled
Zend Multibyte Supportprovided by mbstring
IPv6 Supportenabled
DTrace Supportdisabled
Registered PHP Streamshttps, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
Registered Stream Socket Transportstcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filterszlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*


PHP Version 7.4.11
Directive Local Value Master Value
allow_url_fopen On On
allow_url_include Off Off
arg_separator.input & &
arg_separator.output & &
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset UTF-8 UTF-8
default_mimetype text/html text/html
disable_classes no value no value
disable_functions exec,passthru,shell_exec,system exec,passthru,shell_exec,system
display_errors On Off
display_startup_errors Off Off
doc_root /home/stmlearn/public_html /home/stmlearn/public_html
docref_ext no value no value
docref_root no value no value
enable_dl Off Off
enable_post_data_reading On On
error_append_string no value no value
error_log /home/stmlearn/logs/stm-learning_com_ar.php.error.log /home/stmlearn/logs/stm-learning_com_ar.php.error.log
error_prepend_string no value no value
error_reporting 32767 32759
expose_php Off Off
extension_dir /opt/cpanel/ea-php74/root/usr/lib64/php/modules /opt/cpanel/ea-php74/root/usr/lib64/php/modules
file_uploads On On
hard_timeout 2 2
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path /home/stmlearn/public_html/lib/pear:.:/opt/cpanel/ea-php74/root/usr/share/pear .:/opt/cpanel/ea-php74/root/usr/share/pear
input_encoding no value no value
internal_encoding no value no value
log_errors On On
log_errors_max_len 1024 1024
mail.add_x_header On On
mail.force_extra_parameters no value no value
mail.log no value no value
max_execution_time 10000 30
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time 10000 60
max_input_vars 10000 1000
memory_limit 900M 32M
open_basedir no value no value
output_buffering no value no value
output_encoding no value no value
output_handler no value no value
post_max_size 900M 8M
precision 14 14
realpath_cache_size 4096K 4096K
realpath_cache_ttl 120 120
register_argc_argv On On
report_memleaks On On
report_zend_debug On On
request_order GP GP
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
serialize_precision 17 100
short_open_tag On On
SMTP localhost localhost
smtp_port 25 25
sys_temp_dir no value no value
syslog.facility LOG_USER LOG_USER
syslog.filter no-ctrl no-ctrl
syslog.ident php php
track_errors On Off
unserialize_callback_func no value no value
upload_max_filesize 900M 2M
upload_tmp_dir no value no value
user_dir no value no value
user_ini.cache_ttl 300 300
user_ini.filename .user.ini .user.ini
variables_order GPCS GPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
zend.assertions -1 -1
zend.detect_unicode On On
zend.enable_gc On On
zend.exception_ignore_args Off Off
zend.multibyte Off Off
zend.script_encoding no value no value
zend.signal_check Off Off


los archivos con los que tengo problemas son:

En respuesta a Josefina Osán

Re: Problemas para restaurar curso (copia de seg muy grande)

de Juan Pablo Miranda Aguayo -
Imagen de Moodlers de gran ayuda
Hola, Josefina.

Tal como te comenta José Luis, si ya has subido el/los archivo/s por FTP y tienes habilitado el repositorio "Sistema de archivos" de Moodle, no deberías tener problema con las posibles limitaciones en el peso de los archivos a subir directamente a la plataforma.

Haría falta una captura de pantalla del error que te arroja para poder pensar en alguna causa y una posible solución.
No obstante, imagino que el repositorio lo tienes activado y visible: https://tudominio.com/moodle/admin/repository.php
Luego, has creado una instancia para su utilización: https://tudominio.com/moodle/admin/repositoryinstance.php
Y, finalmente, has creado una carpeta en '/moodledata/repository' (con el mismo nombre de la instancia) donde subir los archivos y desde la que sean llamados desde Moodle tal como se comenta al crear la instancia:
"Necesita crear al menos una carpeta dentro del directorio /home/ruta-hacia/moodledata/repository/ para poder seleccionarla allí."

Por ejemplo, si has creado una instancia llamada "Archivos", en la carpeta 'repository' debe haber una carpeta llamda "Archivos", también. De esta forma:
/home/ruta-hacia/moodledata/repository/Archivos

Saludos.
JP
En respuesta a Juan Pablo Miranda Aguayo

Re: Problemas para restaurar curso (copia de seg muy grande)

de Josefina Osán -
Hola Juan Pablo, Muchas gracias por tu respuesta,
Si, esos fueron los primeros pasos que tomé para iniciar la restauración de los cursos. pero igualmente tuve problemas. igual mando adjunto lo que tengo por si ven que hay algo mal configurado y no me estoy dando cuenta.

Este es el error que me sale al cargar el archivo:


En respuesta a Juan Pablo Miranda Aguayo

Re: Problemas para restaurar curso (copia de seg muy grande)

de Josefina Osán -

repository.php


<?php


require_once(__DIR__ . '/../config.php');

require_once($CFG->dirroot . '/repository/lib.php');

require_once($CFG->libdir . '/adminlib.php');


$repository       = optional_param('repos', '', PARAM_ALPHANUMEXT);

$action           = optional_param('action', '', PARAM_ALPHANUMEXT);

$sure             = optional_param('sure', '', PARAM_ALPHA);

$downloadcontents = optional_param('downloadcontents', false, PARAM_BOOL);


$display = true; // fall through to normal display


$pagename = 'managerepositories';


if ($action == 'edit') {

    $pagename = 'repositorysettings' . $repository;

} else if ($action == 'delete') {

    $pagename = 'repositorydelete';

} else if (($action == 'newon') || ($action == 'newoff')) {

    $pagename = 'repositorynew';

}


// Need to remember this for form

$formaction = $action;


// Check what visibility to show the new repository

if ($action == 'newon') {

    $action = 'new';

    $visible = true;

} else if ($action == 'newoff') {

    $action = 'new';

    $visible = false;

}


admin_externalpage_setup($pagename);


$sesskeyurl = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php?sesskey=' . sesskey();

$baseurl    = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';


$configstr  = get_string('manage', 'repository');


$return = true;


if (!empty($action)) {

    require_sesskey();

}


/**

 * Helper function that generates a moodle_url object

 * relevant to the repository

 */

function repository_action_url($repository) {

    global $baseurl;

    return new moodle_url($baseurl, array('sesskey'=>sesskey(), 'repos'=>$repository));

}


if (($action == 'edit') || ($action == 'new')) {

    $pluginname = '';

    if ($action == 'edit') {

        $repositorytype = repository::get_type_by_typename($repository);

        $classname = 'repository_' . $repositorytype->get_typename();

        $configs = call_user_func(array($classname, 'get_type_option_names'));

        $plugin = $repositorytype->get_typename();

        // looking for instance to edit plugin name

        $instanceoptions = call_user_func(array($classname, 'get_instance_option_names'));

        if (empty($instanceoptions)) {

            $params = array();

            $params['type'] = $plugin;

            $instances = repository::get_instances($params);

            if ($instance = array_pop($instances)) {

                // use the one form db record

                $pluginname = $instance->instance->name;

            }

        }


    } else {

        $repositorytype = null;

        $plugin = $repository;

        $typeid = $repository;

    }

    $PAGE->set_pagetype('admin-repository-' . $plugin);

    // display the edit form for this instance

    $mform = new repository_type_form('', array('pluginname'=>$pluginname, 'plugin' => $plugin, 'instance' => $repositorytype, 'action' => $formaction));

    $fromform = $mform->get_data();


    //detect if we create a new type without config (in this case if don't want to display a setting page during creation)

    $nosettings = false;

    if ($action == 'new') {

        $adminconfignames = repository::static_function($repository, 'get_type_option_names');

        $nosettings = empty($adminconfignames);

    }

    // end setup, begin output


    if ($mform->is_cancelled()){

        redirect($baseurl);

    } else if (!empty($fromform) || $nosettings) {

        require_sesskey();

        if ($action == 'edit') {

            $settings = array();

            foreach($configs as $config) {

                if (!empty($fromform->$config)) {

                    $settings[$config] = $fromform->$config;

                } else {

                    // if the config name is not appear in $fromform

                    // empty this config value

                    $settings[$config] = '';

                }

            }

            $instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');

            if (!empty($instanceoptionnames)) {

                if (property_exists($fromform, 'enablecourseinstances')) {

                    $settings['enablecourseinstances'] = $fromform->enablecourseinstances;

                }

                else {

                    $settings['enablecourseinstances'] = 0;

                }

                if (property_exists($fromform, 'enableuserinstances')) {

                    $settings['enableuserinstances'] = $fromform->enableuserinstances;

                }

                else {

                    $settings['enableuserinstances'] = 0;

                }

            }

            $success = $repositorytype->update_options($settings);

        } else {

            $type = new repository_type($plugin, (array)$fromform, $visible);

            $success = true;

            if (!$repoid = $type->create()) {

                $success = false;

            }

            $data = data_submitted();

        }

        if ($success) {

            // configs saved

            core_plugin_manager::reset_caches();

            redirect($baseurl);

        } else {

            print_error('instancenotsaved', 'repository', $baseurl);

        }

        exit;

    } else {

        echo $OUTPUT->header();

        echo $OUTPUT->heading(get_string('configplugin', 'repository_'.$plugin));

        $displaysettingform = true;

        if ($action == 'edit') {

            $typeoptionnames = repository::static_function($repository, 'get_type_option_names');

            $instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');

            if (empty($typeoptionnames) && empty($instanceoptionnames)) {

                $displaysettingform = false;

            }

        }

        if ($displaysettingform){

            $OUTPUT->box_start();

            $mform->display();

            $OUTPUT->box_end();

        }

        $return = false;


        // Display instances list and creation form

        if ($action == 'edit') {

            $instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');

            if (!empty($instanceoptionnames)) {

                repository::display_instances_list(context_system::instance(), $repository);

            }

        }

    }

} else if ($action == 'show') {

    if (!confirm_sesskey()) {

        print_error('confirmsesskeybad', '', $baseurl);

    }

    $repositorytype = repository::get_type_by_typename($repository);

    if (empty($repositorytype)) {

        print_error('invalidplugin', 'repository', '', $repository);

    }

    $repositorytype->update_visibility(true);

    core_plugin_manager::reset_caches();

    $return = true;

} else if ($action == 'hide') {

    if (!confirm_sesskey()) {

        print_error('confirmsesskeybad', '', $baseurl);

    }

    $repositorytype = repository::get_type_by_typename($repository);

    if (empty($repositorytype)) {

        print_error('invalidplugin', 'repository', '', $repository);

    }

    $repositorytype->update_visibility(false);

    core_plugin_manager::reset_caches();

    $return = true;

} else if ($action == 'delete') {

    $repositorytype = repository::get_type_by_typename($repository);

    if ($sure) {

        $PAGE->set_pagetype('admin-repository-' . $repository);

        if (!confirm_sesskey()) {

            print_error('confirmsesskeybad', '', $baseurl);

        }


        if ($repositorytype->delete($downloadcontents)) {

            core_plugin_manager::reset_caches();

            redirect($baseurl);

        } else {

            print_error('instancenotdeleted', 'repository', $baseurl);

        }

        exit;

    } else {

        echo $OUTPUT->header();


        $message = get_string('confirmremove', 'repository', $repositorytype->get_readablename());


        $output = $OUTPUT->box_start('generalbox', 'notice');

        $output .= html_writer::tag('p', $message);


        $removeurl = new moodle_url($sesskeyurl);

        $removeurl->params(array(

            'action' =>'delete',

            'repos' => $repository,

            'sure' => 'yes',

        ));


        $removeanddownloadurl = new moodle_url($sesskeyurl);

        $removeanddownloadurl->params(array(

            'action' =>'delete',

            'repos'=> $repository,

            'sure' => 'yes',

            'downloadcontents' => 1,

        ));


        $output .= $OUTPUT->single_button($removeurl, get_string('continueuninstall', 'repository'));

        $output .= $OUTPUT->single_button($removeanddownloadurl, get_string('continueuninstallanddownload', 'repository'));

        $output .= $OUTPUT->single_button($baseurl, get_string('cancel'));

        $output .= $OUTPUT->box_end();


        echo $output;


        $return = false;

    }

} else if ($action == 'moveup') {

    $repositorytype = repository::get_type_by_typename($repository);

    $repositorytype->move_order('up');

} else if ($action == 'movedown') {

    $repositorytype = repository::get_type_by_typename($repository);

    $repositorytype->move_order('down');

} else {

    // If page is loaded directly

    echo $OUTPUT->header();

    echo $OUTPUT->heading(get_string('manage', 'repository'));


    // Get strings that are used

    $strshow = get_string('on', 'repository');

    $strhide = get_string('off', 'repository');

    $strdelete = get_string('disabled', 'repository');

    $struninstall = get_string('uninstallplugin', 'core_admin');


    $actionchoicesforexisting = array(

        'show' => $strshow,

        'hide' => $strhide,

        'delete' => $strdelete

    );


    $actionchoicesfornew = array(

        'newon' => $strshow,

        'newoff' => $strhide,

        'delete' => $strdelete

    );


    $output = '';

    $output .= $OUTPUT->box_start('generalbox');


    // Set strings that are used multiple times

    $settingsstr = get_string('settings');

    $disablestr = get_string('disable');


    // Table to list plug-ins

    $table = new html_table();

    $table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr, $struninstall);


    $table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');

    $table->id = 'repositoriessetting';

    $table->data = array();

    $table->attributes['class'] = 'admintable generaltable';


    // Get list of used plug-ins

    $repositorytypes = repository::get_types();

    // Array to store plugins being used

    $alreadyplugins = array();

    if (!empty($repositorytypes)) {

        $totalrepositorytypes = count($repositorytypes);

        $updowncount = 1;

        foreach ($repositorytypes as $i) {

            $settings = '';

            $typename = $i->get_typename();

            // Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)

            $typeoptionnames = repository::static_function($typename, 'get_type_option_names');

            $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');


            if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {

                // Calculate number of instances in order to display them for the Moodle administrator

                if (!empty($instanceoptionnames)) {

                    $params = array();

                    $params['context'] = array(context_system::instance());

                    $params['onlyvisible'] = false;

                    $params['type'] = $typename;

                    $admininstancenumber = count(repository::static_function($typename, 'get_instances', $params));

                    // site instances

                    $admininstancenumbertext = get_string('instancesforsite', 'repository', $admininstancenumber);

                    $params['context'] = array();

                    $instances = repository::static_function($typename, 'get_instances', $params);

                    $courseinstances = array();

                    $userinstances = array();


                    foreach ($instances as $instance) {

                        $repocontext = context::instance_by_id($instance->instance->contextid);

                        if ($repocontext->contextlevel == CONTEXT_COURSE) {

                            $courseinstances[] = $instance;

                        } else if ($repocontext->contextlevel == CONTEXT_USER) {

                            $userinstances[] = $instance;

                        }

                    }

                    // course instances

                    $instancenumber = count($courseinstances);

                    $courseinstancenumbertext = get_string('instancesforcourses', 'repository', $instancenumber);


                    // user private instances

                    $instancenumber =  count($userinstances);

                    $userinstancenumbertext = get_string('instancesforusers', 'repository', $instancenumber);

                } else {

                    $admininstancenumbertext = "";

                    $courseinstancenumbertext = "";

                    $userinstancenumbertext = "";

                }


                $settings .= '<a href="' . $sesskeyurl . '&amp;action=edit&amp;repos=' . $typename . '">' . $settingsstr .'</a>';


                $settings .= $OUTPUT->container_start('mdl-left');

                $settings .= '<br/>';

                $settings .= $admininstancenumbertext;

                $settings .= '<br/>';

                $settings .= $courseinstancenumbertext;

                $settings .= '<br/>';

                $settings .= $userinstancenumbertext;

                $settings .= $OUTPUT->container_end();

            }

            // Get the current visibility

            if ($i->get_visible()) {

                $currentaction = 'show';

            } else {

                $currentaction = 'hide';

            }


            $select = new single_select(repository_action_url($typename, 'repos'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . basename($typename));

            $select->set_label(get_string('action'), array('class' => 'accesshide'));

            // Display up/down link

            $updown = '';

            $spacer = $OUTPUT->spacer(array('height'=>15, 'width'=>15)); // should be done with CSS instead


            if ($updowncount > 1) {

                $updown .= "<a href=\"$sesskeyurl&amp;action=moveup&amp;repos=".$typename."\">";

                $updown .= $OUTPUT->pix_icon('t/up', get_string('moveup')) . "</a>&nbsp;";

            }

            else {

                $updown .= $spacer;

            }

            if ($updowncount < $totalrepositorytypes) {

                $updown .= "<a href=\"$sesskeyurl&amp;action=movedown&amp;repos=".$typename."\">";

                $updown .= $OUTPUT->pix_icon('t/down', get_string('movedown')) . "</a>&nbsp;";

            }

            else {

                $updown .= $spacer;

            }


            $updowncount++;


            $uninstall = '';

            if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $typename, 'manage')) {

                $uninstall = html_writer::link($uninstallurl, $struninstall);

            }


            $table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings, $uninstall);


            if (!in_array($typename, $alreadyplugins)) {

                $alreadyplugins[] = $typename;

            }

        }

    }


    // Get all the plugins that exist on disk

    $plugins = core_component::get_plugin_list('repository');

    if (!empty($plugins)) {

        foreach ($plugins as $plugin => $dir) {

            // Check that it has not already been listed

            if (!in_array($plugin, $alreadyplugins)) {

                $select = new single_select(repository_action_url($plugin, 'repos'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . basename($plugin));

                $select->set_label(get_string('action'), array('class' => 'accesshide'));

                $uninstall = '';

                if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $plugin, 'manage')) {

                    $uninstall = html_writer::link($uninstallurl, $struninstall);

                }

                $table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '', $uninstall);

            }

        }

    }


    $output .= html_writer::table($table);

    $output .= $OUTPUT->box_end();

    print $output;

    $return = false;

}


if ($return) {

    redirect($baseurl);

}

echo $OUTPUT->footer();

________________________________________________________________________________________

repositoryintance.php


<?php


require_once(__DIR__ . '/../config.php');

require_once($CFG->dirroot . '/repository/lib.php');

require_once($CFG->libdir . '/adminlib.php');


require_sesskey();


// id of repository

$edit    = optional_param('edit', 0, PARAM_INT);

$new     = optional_param('new', '', PARAM_PLUGIN);

$hide    = optional_param('hide', 0, PARAM_INT);

$delete  = optional_param('delete', 0, PARAM_INT);

$sure    = optional_param('sure', '', PARAM_ALPHA);

$type    = optional_param('type', '', PARAM_PLUGIN);

$downloadcontents = optional_param('downloadcontents', false, PARAM_BOOL);


$context = context_system::instance();


$pagename = 'repositorycontroller';


if ($edit){

    $pagename = 'repositoryinstanceedit';

} else if ($delete) {

    $pagename = 'repositorydelete';

} else if ($new) {

    $pagename = 'repositoryinstancenew';

}


admin_externalpage_setup($pagename, '', null, new moodle_url('/admin/repositoryinstance.php'));


$baseurl = new moodle_url("/$CFG->admin/repositoryinstance.php", array('sesskey'=>sesskey()));


$parenturl = new moodle_url("/$CFG->admin/repository.php", array(

    'sesskey'=>sesskey(),

    'action'=>'edit',

));


if ($new) {

    $parenturl->param('repos', $new);

} else {

    $parenturl->param('repos', $type);

}


$return = true;


if (!empty($edit) || !empty($new)) {

    if (!empty($edit)) {

        $instance = repository::get_instance($edit);

        if (!$instance->can_be_edited_by_user()) {

            throw new repository_exception('nopermissiontoaccess', 'repository');

        }

        $instancetype = repository::get_type_by_id($instance->options['typeid']);

        $classname = 'repository_' . $instancetype->get_typename();

        $configs  = $instance->get_instance_option_names();

        $plugin = $instancetype->get_typename();

        $typeid = $instance->options['typeid'];

    } else {

        $plugin = $new;

        $typeid = null;

        $instance = null;

    }


    // display the edit form for this instance

    $mform = new repository_instance_form('', array('plugin' => $plugin, 'typeid' => $typeid, 'instance' => $instance, 'contextid' => $context->id));

    // end setup, begin output


    if ($mform->is_cancelled()){

        redirect($parenturl);

        exit;

    } else if ($fromform = $mform->get_data()){

        if ($edit) {

            $settings = array();

            $settings['name'] = $fromform->name;

            if (!$instance->readonly) {

                foreach($configs as $config) {

                    if (isset($fromform->$config)) {

                        $settings[$config] = $fromform->$config;

                    } else {

                        $settings[$config] = null;

                    }

                }

            }

            $success = $instance->set_option($settings);

        } else {

            $success = repository::static_function($plugin, 'create', $plugin, 0, $context, $fromform);

            $data = data_submitted();

        }

        if ($success) {

            core_plugin_manager::reset_caches();

            redirect($parenturl);

        } else {

            print_error('instancenotsaved', 'repository', $parenturl);

        }

        exit;

    } else {

        echo $OUTPUT->header();

        echo $OUTPUT->heading(get_string('configplugin', 'repository_'.$plugin));

        echo $OUTPUT->box_start();

        $mform->display();

        echo $OUTPUT->box_end();

        $return = false;

    }

} else if (!empty($hide)) {

    $instance = repository::get_type_by_typename($hide);

    $instance->hide();

    core_plugin_manager::reset_caches();

    $return = true;

} else if (!empty($delete)) {

    $instance = repository::get_instance($delete);

    if ($instance->readonly) {

        // If you try to delete an instance set as readonly, display an error message.

        throw new repository_exception('readonlyinstance', 'repository');

    } else if (!$instance->can_be_edited_by_user()) {

        throw new repository_exception('nopermissiontoaccess', 'repository');

    }

    if ($sure) {

        if ($instance->delete($downloadcontents)) {

            $deletedstr = get_string('instancedeleted', 'repository');

            core_plugin_manager::reset_caches();

            redirect($parenturl, $deletedstr, 3);

        } else {

            print_error('instancenotdeleted', 'repository', $parenturl);

        }

        exit;

    }


    echo $OUTPUT->header();

    echo $OUTPUT->box_start('generalbox', 'notice');

    $continueurl = new moodle_url($baseurl, array(

        'type' => $type,

        'delete' => $delete,

        'sure' => 'yes',

    ));

    $continueanddownloadurl = new moodle_url($continueurl, array(

        'downloadcontents' => 1

    ));

    $message = get_string('confirmdelete', 'repository', $instance->name);

    echo html_writer::tag('p', $message);


    echo $OUTPUT->single_button($continueurl, get_string('continueuninstall', 'repository'));

    echo $OUTPUT->single_button($continueanddownloadurl, get_string('continueuninstallanddownload', 'repository'));

    echo $OUTPUT->single_button($parenturl, get_string('cancel'));


    echo $OUTPUT->box_end();


    $return = false;

}


if (!empty($return)) {

    redirect($parenturl);

}

echo $OUTPUT->footer();