mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-63013 tool_policy: Policy agreement style can be defined now
The patch introduces a new property of a policy document called "Agreement style". It allows the admin to define if the policy should be accepted together with all others on the consent page (legacy and default behaviour) or on its page before the consent page is reached (the new optional behaviour).
This commit is contained in:
parent
674ef9baac
commit
23b663ed55
7 changed files with 80 additions and 5 deletions
|
@ -89,6 +89,8 @@ class policydoc extends moodleform {
|
|||
api::policy_content_field_options());
|
||||
$mform->addRule('content_editor', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('selectyesno', 'agreementstyle', get_string('policypriorityagreement', 'tool_policy'));
|
||||
|
||||
if (!$formdata->id || $formdata->status == policy_version::STATUS_DRAFT) {
|
||||
// Creating a new version or editing a draft/archived version.
|
||||
$mform->addElement('hidden', 'minorchange');
|
||||
|
|
|
@ -69,6 +69,12 @@ class policy_version extends persistent {
|
|||
/** @var int Policy version has been archived. */
|
||||
const STATUS_ARCHIVED = 2;
|
||||
|
||||
/** @var int Policy to be accepted together with others on the consent page. */
|
||||
const AGREEMENTSTYLE_CONSENTPAGE = 0;
|
||||
|
||||
/** @var int Policy to be accepted on its own page before reaching the consent page. */
|
||||
const AGREEMENTSTYLE_OWNPAGE = 1;
|
||||
|
||||
/**
|
||||
* Return the definition of the properties of this model.
|
||||
*
|
||||
|
@ -106,6 +112,14 @@ class policy_version extends persistent {
|
|||
'policyid' => [
|
||||
'type' => PARAM_INT,
|
||||
],
|
||||
'agreementstyle' => [
|
||||
'type' => PARAM_INT,
|
||||
'choices' => [
|
||||
self::AGREEMENTSTYLE_CONSENTPAGE,
|
||||
self::AGREEMENTSTYLE_OWNPAGE,
|
||||
],
|
||||
'default' => self::AGREEMENTSTYLE_CONSENTPAGE,
|
||||
],
|
||||
'revision' => [
|
||||
'type' => PARAM_TEXT,
|
||||
'default' => '',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="admin/tool/policy/db" VERSION="20180307" COMMENT="The plugin allows to manage various policy documents that users have to accept to use the site."
|
||||
<XMLDB PATH="admin/tool/policy/db" VERSION="20180829" COMMENT="The plugin allows to manage various policy documents that users have to accept to use the site."
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
|
@ -26,6 +26,7 @@
|
|||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Timestamp of when the policy version was created."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Timestamp of when the policy version was last modified."/>
|
||||
<FIELD NAME="policyid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="ID of the policy document we are version of."/>
|
||||
<FIELD NAME="agreementstyle" TYPE="int" LENGTH="3" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="How this agreement should flow: 0 - on the consent page, 1 - on a separate page before reaching the consent page."/>
|
||||
<FIELD NAME="revision" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false" COMMENT="Human readable version of the policy document"/>
|
||||
<FIELD NAME="summary" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Policy text summary"/>
|
||||
<FIELD NAME="summaryformat" TYPE="int" LENGTH="3" NOTNULL="true" SEQUENCE="false" COMMENT="Format of the summary field"/>
|
||||
|
|
53
admin/tool/policy/db/upgrade.php
Normal file
53
admin/tool/policy/db/upgrade.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
// This file is part of Moodle - https://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/>.
|
||||
|
||||
/**
|
||||
* Plugin upgrade steps are defined here.
|
||||
*
|
||||
* @package tool_policy
|
||||
* @category upgrade
|
||||
* @copyright 2018 David Mudrák <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Execute the plugin upgrade steps from the given old version.
|
||||
*
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_tool_policy_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2018082900) {
|
||||
// Add field agreementstyle to the table tool_policy_versions.
|
||||
$table = new xmldb_table('tool_policy_versions');
|
||||
$field = new xmldb_field('agreementstyle', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'policyid');
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2018082900, 'tool', 'policy');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -129,6 +129,7 @@ $string['policydoctype2'] = 'Third parties policy';
|
|||
$string['policydoctype99'] = 'Other policy';
|
||||
$string['policydocuments'] = 'Policy documents';
|
||||
$string['policynamedversion'] = 'Policy {$a->name} (version {$a->revision} - {$a->id})';
|
||||
$string['policypriorityagreement'] = 'Show policy before showing other policies';
|
||||
$string['policyversionacceptedinbehalf'] = 'Consent for this policy has been given on your behalf.';
|
||||
$string['policyversionacceptedinotherlang'] = 'Consent for this policy version has been given in a different language.';
|
||||
$string['previousversions'] = '{$a} previous versions';
|
||||
|
|
|
@ -85,9 +85,13 @@ function tool_policy_before_standard_html_head() {
|
|||
&& empty($USER->policyagreed)
|
||||
&& (isguestuser() || !isloggedin())) {
|
||||
$output = $PAGE->get_renderer('tool_policy');
|
||||
$page = new \tool_policy\output\guestconsent();
|
||||
|
||||
$message = $output->render($page);
|
||||
try {
|
||||
$page = new \tool_policy\output\guestconsent();
|
||||
$message = $output->render($page);
|
||||
} catch (dml_read_exception $e) {
|
||||
// During upgrades, the new plugin code with new SQL could be in place but the DB not upgraded yet.
|
||||
$message = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $message;
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2018051400; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2018082900; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2018050800; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_policy'; // Full name of the plugin (used for diagnostics).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue