Skip to content
Snippets Groups Projects
Commit 0116a0bf authored by Sergio Vergata's avatar Sergio Vergata
Browse files

added

parent ef78de5a
No related branches found
No related tags found
No related merge requests found
Showing
with 1184 additions and 0 deletions
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
sudo: required
language: php
dist: xenial
services:
- mysql
php:
- 7.2
env:
global:
- MOODLE_BRANCH=master
- IGNORE_PATHS=amd/build,amd/src/bootstrap.js
- IGNORE_NAMES=*.txt,moodle.css,moodle-rtl.css,moodle_min.css,editor.css,editor_min.css,Gruntfile.js
- DB=mysqli
matrix:
- php: 7.2
env: DB=mysqli TASK=PHPUNIT
cache:
directories:
- $HOME/.composer/cache
- $HOME/.npm
before_install:
- cd ../..
- composer selfupdate
- composer create-project -n --no-dev moodlerooms/moodle-plugin-ci ci ^1
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
install:
- moodle-plugin-ci install
script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
- moodle-plugin-ci codechecker
- moodle-plugin-ci csslint
- moodle-plugin-ci jshint
#- moodle-plugin-ci phpunit
\ No newline at end of file
# Admin presets for Moodle
Block to export and import Moodle administration settings
## Build status
[![Build Status](https://travis-ci.org/DigiDago/moodle-block_admin_presets.svg?branch=master)](https://travis-ci.org/DigiDago/moodle-block_admin_presets)
## Features
* Export system settings to XML files
* Import presets files
* Preset preview and partial load
* Allows rollback
* Option to autoexclude the sensitive data when exporting settings (you can edit the sensitive settings list in Site Administration -> Plugins -> Blocks -> Admin presets)
* Third parties plugins supported
## See also
* Modules and Plugins entry: https://moodle.org/plugins/view.php?plugin=block_admin_presets
Maintainer
============
AdminPreset was initialy developed by David Monllaó. It is currently maintained by Pimenko team.
Any Problems, questions, suggestions
===================
If you have a problem with this block, suggestions for improvement, drop an email at :
- Pimenko : contact@pimenko.com
- Github : https://github.com/DigiDago/moodle-block_admin_presets
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
class block_admin_presets extends block_list {
/**
* @throws coding_exception
*/
public function init() {
$this->title = get_string('pluginname', 'block_admin_presets');
}
public function get_content() {
global $CFG, $OUTPUT;
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if (!has_capability('moodle/site:config', context_system::instance())) {
$this->content = '';
return $this->content;
}
$this->content->items[] = $OUTPUT->pix_icon("i/backup",
get_string('actionexport', 'block_admin_presets'),
"moodle", array("class" => "icon")) . '<a title="' .
get_string('actionexport', 'block_admin_presets') .
'" href="' . $CFG->wwwroot . '/blocks/admin_presets/index.php?action=export">' .
get_string('actionexport', 'block_admin_presets') .
'</a>';
$this->content->items[] = $OUTPUT->pix_icon("i/restore",
get_string('actionimport', 'block_admin_presets'),
"moodle", array("class" => "icon")) .
'<a title="' . get_string('actionimport', 'block_admin_presets') .
'" href="' . $CFG->wwwroot .
'/blocks/admin_presets/index.php?action=import">' .
get_string('actionimport', 'block_admin_presets') .
'</a>';
$this->content->items[] = $OUTPUT->pix_icon("i/repository",
get_string('actionbase', 'block_admin_presets'),
"moodle", array("class" => "icon")) .
'<a title="' .
get_string('actionbase', 'block_admin_presets') .
'" href="' .
$CFG->wwwroot .
'/blocks/admin_presets/index.php">'
. get_string('actionbase', 'block_admin_presets') . '</a>';
return $this->content;
}
public function applicable_formats() {
return array('site' => true);
}
public function has_config() {
return true;
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class preset_deleted extends \core\event\base {
public static function get_name() {
return get_string('eventpresetdeleted', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} has deleted the preset with id {$this->objectid}.";
}
public function get_legacy_logdata() {
return array($this->courseid, 'block_admin_presets', 'delete', '',
$this->objectid, $this->contextinstanceid);
}
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class preset_downloaded extends \core\event\base {
public static function get_name() {
return get_string('eventpresetdownloaded', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} has downloaded the preset with id {$this->objectid}.";
}
public function get_url() {
return new \moodle_url('/blocks/admin_presets/index.php',
array('action' => 'export', 'mode' => 'download_xml', 'id' => $this->objectid, 'sesskey' => sesskey()));
}
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class preset_exported extends \core\event\base {
public static function get_name() {
return get_string('eventpresetexported', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} has exported the preset with id {$this->objectid}.";
}
public function get_url() {
return new \moodle_url('/blocks/admin_presets/index.php',
array('action' => 'load', 'mode' => 'preview', 'id' => $this->objectid));
}
public function get_legacy_logdata() {
return array($this->courseid, 'block_admin_presets', 'export', '',
$this->objectid, $this->contextinstanceid);
}
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class preset_imported extends \core\event\base {
public static function get_name() {
return get_string('eventpresetimported', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} has imported the preset with id {$this->objectid}.";
}
public function get_url() {
return new \moodle_url('/blocks/admin_presets/index.php',
array('action' => 'load', 'mode' => 'preview', 'id' => $this->objectid));
}
public function get_legacy_logdata() {
return array($this->courseid, 'block_admin_presets', 'import', '',
$this->objectid, $this->contextinstanceid);
}
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class preset_loaded extends \core\event\base {
public static function get_name() {
return get_string('eventpresetloaded', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} has loaded the preset with id {$this->objectid}.";
}
public function get_url() {
return new \moodle_url('/blocks/admin_presets/index.php',
array('action' => 'load', 'mode' => 'preview', 'id' => $this->objectid));
}
public function get_legacy_logdata() {
return array($this->courseid, 'block_admin_presets', 'load', '',
$this->objectid, $this->contextinstanceid);
}
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class preset_previewed extends \core\event\base {
public static function get_name() {
return get_string('eventpresetpreviewed', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} has previewed the preset with id {$this->objectid}.";
}
public function get_url() {
return new \moodle_url('/blocks/admin_presets/index.php',
array('action' => 'load', 'mode' => 'preview', 'id' => $this->objectid));
}
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class preset_reverted extends \core\event\base {
public static function get_name() {
return get_string('eventpresetreverted', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} has reverted the preset with id {$this->objectid}.";
}
public function get_legacy_logdata() {
return array($this->courseid, 'block_admin_presets', 'rollback', '',
$this->objectid, $this->contextinstanceid);
}
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_presets\event;
defined('MOODLE_INTERNAL') || die();
class presets_listed extends \core\event\base {
public static function get_name() {
return get_string('eventpresetslisted', 'block_admin_presets');
}
public function get_description() {
return "User {$this->userid} listed the system presets.";
}
public function get_url() {
return new \moodle_url('/block/admin_presets/index.php');
}
public function get_legacy_logdata() {
return array($this->courseid, 'block_admin_presets', 'base', '',
$this->objectid, $this->contextinstanceid);
}
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'block_admin_presets';
}
}
<?php
// This file is part of The Course Module Navigation Block
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace block_admin_presets\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\null_provider;
class provider implements
// This plugin does not store any personal user data.
null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:null_reason';
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/admin_presets:addinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW
)
)
);
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/admin_presets/db" VERSION="20120314" COMMENT="Admin presets block tables, to store exported/imported presets" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd">
<TABLES>
<TABLE NAME="block_admin_presets" COMMENT="Table to store presets data" NEXT="block_admin_presets_it">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="userid"
NEXT="comments"/>
<FIELD NAME="comments" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" PREVIOUS="name"
NEXT="site"/>
<FIELD NAME="site" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="comments"
NEXT="author"/>
<FIELD NAME="author" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="site"
NEXT="moodleversion"/>
<FIELD NAME="moodleversion" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" PREVIOUS="author"
NEXT="moodlerelease"/>
<FIELD NAME="moodlerelease" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"
PREVIOUS="moodleversion" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0"
SEQUENCE="false" PREVIOUS="moodlerelease" NEXT="timeimported"/>
<FIELD NAME="timeimported" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0"
SEQUENCE="false" PREVIOUS="timecreated"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="block_admin_presets_it" COMMENT="Table to store settings" PREVIOUS="block_admin_presets"
NEXT="block_admin_presets_it_a">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true"
NEXT="adminpresetid"/>
<FIELD NAME="adminpresetid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="id" NEXT="plugin"/>
<FIELD NAME="plugin" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" PREVIOUS="adminpresetid"
NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="plugin"
NEXT="value"/>
<FIELD NAME="value" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" PREVIOUS="name"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="adminpresetid" UNIQUE="false" FIELDS="adminpresetid"/>
</INDEXES>
</TABLE>
<TABLE NAME="block_admin_presets_it_a"
COMMENT="Admin presets items attributes. For settings with attributes (extra values like 'advanced')"
PREVIOUS="block_admin_presets_it" NEXT="block_admin_presets_app">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="itemid"/>
<FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="itemid"
NEXT="value"/>
<FIELD NAME="value" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" PREVIOUS="name"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="itemid" UNIQUE="false" FIELDS="itemid"/>
</INDEXES>
</TABLE>
<TABLE NAME="block_admin_presets_app" COMMENT="Applied presets" PREVIOUS="block_admin_presets_it_a"
NEXT="block_admin_presets_app_it">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true"
NEXT="adminpresetid"/>
<FIELD NAME="adminpresetid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="id" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="adminpresetid" NEXT="time"/>
<FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="userid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="adminpresetid" UNIQUE="false" FIELDS="adminpresetid"/>
</INDEXES>
</TABLE>
<TABLE NAME="block_admin_presets_app_it"
COMMENT="Admin presets applied items. To maintain the relation with config_log"
PREVIOUS="block_admin_presets_app" NEXT="block_admin_presets_app_it_a">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true"
NEXT="adminpresetapplyid"/>
<FIELD NAME="adminpresetapplyid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="id" NEXT="configlogid"/>
<FIELD NAME="configlogid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="adminpresetapplyid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="configlogid" UNIQUE="false" FIELDS="configlogid" NEXT="adminpresetapplyid"/>
<INDEX NAME="adminpresetapplyid" UNIQUE="false" FIELDS="adminpresetapplyid" PREVIOUS="configlogid"/>
</INDEXES>
</TABLE>
<TABLE NAME="block_admin_presets_app_it_a" COMMENT="Attributes of the applied items"
PREVIOUS="block_admin_presets_app_it">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true"
NEXT="adminpresetapplyid"/>
<FIELD NAME="adminpresetapplyid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="id" NEXT="configlogid"/>
<FIELD NAME="configlogid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false"
PREVIOUS="adminpresetapplyid" NEXT="itemname"/>
<FIELD NAME="itemname" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false"
COMMENT="Necessary to rollback" PREVIOUS="configlogid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="configlogid" UNIQUE="false" FIELDS="configlogid" NEXT="adminpresetapplyid"/>
<INDEX NAME="adminpresetapplyid" UNIQUE="false" FIELDS="adminpresetapplyid" PREVIOUS="configlogid"/>
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* @param int $oldversion
* @param object $block
* @return bool
* @throws coding_exception
* @throws ddl_exception
* @throws ddl_field_missing_exception
* @throws ddl_table_missing_exception
* @throws downgrade_exception
* @throws moodle_exception
* @throws upgrade_exception
* @global moodle_database $DB
*/
function xmldb_block_admin_presets_upgrade($oldversion, $block) {
global $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2011063000) {
// Changing type of field moodleversion on table admin_preset to char.
$table = new xmldb_table('admin_preset');
$field = new xmldb_field('moodleversion', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, 'author');
// Launch change of type for field moodleversion.
$dbman->change_field_type($table, $field);
upgrade_block_savepoint(true, 2011063000, 'admin_presets');
}
// Renaming DB tables.
if ($oldversion < 2012031401) {
$tablenamechanges = array('admin_preset' => 'block_admin_presets',
'admin_preset_apply' => 'block_admin_presets_app',
'admin_preset_apply_item' => 'block_admin_presets_app_it',
'admin_preset_apply_item_attr' => 'block_admin_presets_app_it_a',
'admin_preset_item' => 'block_admin_presets_it',
'admin_preset_item_attr' => 'block_admin_presets_it_a');
// Just in case it gets to the max number of chars defined in the XSD.
try {
// Renaming the tables.
foreach ($tablenamechanges as $from => $to) {
$table = new xmldb_table($from);
if ($dbman->table_exists($table)) {
$dbman->rename_table($table, $to);
}
}
// Print error and rollback changes.
} catch (Exception $e) {
// Rollback tablename changes.
foreach ($tablenamechanges as $to => $from) {
$table = new xmldb_table($from);
if ($dbman->table_exists($table)) {
$dbman->rename_table($table, $to);
}
}
$debuginfo = get_string('errorupgradetablenamesdebug', 'block_admin_presets');
throw new moodle_exception('errorupgradetablenames', 'block_admin_presets', '', null, $debuginfo);
}
upgrade_block_savepoint(true, 2012031401, 'admin_presets');
}
return true;
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/formslib.php');
class admin_presets_export_form extends moodleform {
public function definition() {
global $USER, $OUTPUT;
$mform = &$this->_form;
// Preset attributes.
$mform->addElement('header', 'general',
get_string('presetsettings', 'block_admin_presets'));
$mform->addElement('text', 'name', get_string('name'), 'maxlength="254" size="60"');
$mform->addRule('name', null, 'required', null, 'client');
$mform->setType('name', PARAM_TEXT);
$mform->addElement('editor', 'comments', get_string('comments'));
$mform->setType('comments', PARAM_CLEANHTML);
$mform->addElement('text', 'author',
get_string('author', 'block_admin_presets'), 'maxlength="254" size="60"');
$mform->setType('author', PARAM_TEXT);
$mform->setDefault('author', $USER->firstname . ' ' . $USER->lastname);
$mform->addElement('checkbox', 'excludesensiblesettings',
get_string('autohidesensiblesettings', 'block_admin_presets'));
// Moodle settings table.
$mform->addElement('header', 'general',
get_string('adminsettings', 'block_admin_presets'));
$mform->addElement('html', '<div id="settings_tree_div" class="ygtv-checkbox"><img src="' .
$OUTPUT->pix_icon('i/loading_small', get_string('loading',
'block_admin_presets')) . '"/></div><br/>');
// Submit.
$mform->addElement('submit', 'admin_presets_submit', get_string('savechanges'));
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/formslib.php');
class admin_presets_import_form extends moodleform {
public function definition() {
$mform = &$this->_form;
$mform->addElement('header', 'general',
get_string('selectfile', 'block_admin_presets'));
// File upload
$mform->addElement('filepicker', 'xmlfile',
get_string('selectfile', 'block_admin_presets'));
$mform->addRule('xmlfile', null, 'required');
// Rename input
$mform->addElement('text', 'name',
get_string('renamepreset', 'block_admin_presets'), 'maxlength="254" size="40"');
$mform->setType('name', PARAM_TEXT);
$mform->addElement('submit', 'admin_presets_submit', get_string('savechanges'));
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/formslib.php');
class admin_presets_load_form extends moodleform {
private $preview;
public function __construct($url, $preview = false) {
$this->preview = $preview;
parent::__construct($url);
}
public function definition() {
global $OUTPUT;
$mform = &$this->_form;
// Moodle settings table.
$mform->addElement('header', 'general',
get_string('adminsettings', 'block_admin_presets'));
$class = '';
if (!$this->preview) {
$class = 'ygtv-checkbox';
}
$mform->addElement('html', '<div id="settings_tree_div" class="' . $class .
'"><img src="' . $OUTPUT->pix_icon('i/loading_small',
get_string('loading', 'block_admin_presets')) . '"/></div>');
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// Submit.
if (!$this->preview) {
$mform->addElement('submit', 'admin_presets_submit',
get_string('loadselected', 'block_admin_presets'));
}
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin presets block main controller
*
* @package blocks/admin_presets
* @copyright 2019 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | DigiDago
* @orignalauthor David Monllaó <david.monllao@urv.cat>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
$action = optional_param('action', 'base', PARAM_ALPHA);
$mode = optional_param('mode', 'show', PARAM_ALPHAEXT);
require_login();
if (!$context = context_system::instance()) {
print_error('wrongcontext', 'error');
}
require_capability('moodle/site:config', $context);
// Loads the required action class and form.
$classname = 'admin_presets_' . $action;
$formname = $classname . '_form';
$formpath = $CFG->dirroot . '/blocks/admin_presets/forms/' . $formname . '.php';
require_once($CFG->dirroot . '/blocks/admin_presets/lib/' . $classname . '.class.php');
if (file_exists($formpath)) {
require_once($formpath);
}
if (!class_exists($classname)) {
print_error('falseaction', 'block_admin_presets', $action);
}
$url = new moodle_url('/blocks/admin_presets/index.php');
$url->param('action', $action);
$url->param('mode', $mode);
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
$PAGE->set_context($context);
// Executes the required action.
$instance = new $classname();
if (!method_exists($instance, $mode)) {
print_error('falsemode', 'block_admin_presets', $mode);
}
// Executes the required method and displays output.
$instance->$mode();
$instance->log();
$instance->display();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment