Commit ae6c3fd9 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Maria Sorica

Bug 1739688: 'Strict privacy switch'

Created switch in site options. When set to 'yes',
it disables the multiple institution per user switch.

To do: When set to 'yes', force user to accept T&C
and privacy statement. Will be resolved in another
bug report #1741799

behatnotneeded

Change-Id: Ie62fb34a6c7cbf8e5b9bce93e76dc7c4a05376b9
parent 3bd4bf51
......@@ -286,12 +286,13 @@ $siteoptionform = array(
'collapsed' => true,
'legend' => get_string('institutionsettingslegend', 'admin'),
'elements' => array(
'requireregistrationconfirm' => array(
'institutionstrictprivacy' => array(
'type' => 'switchbox',
'title' => get_string('requireregistrationconfirm', 'admin'),
'description' => get_string('requireregistrationconfirmdescription1', 'admin'),
'defaultvalue' => get_config('requireregistrationconfirm'),
'title' => get_string('institutionstrictprivacy', 'admin'),
'description' => get_string('institutionstrictprivacydescription', 'admin'),
'defaultvalue' => get_config('institutionstrictprivacy'),
'help' => true,
'disabled' => users_in_multiple_institutions() || get_config('usersallowedmultipleinstitutions'),
),
'usersallowedmultipleinstitutions' => array(
'type' => 'switchbox',
......@@ -301,6 +302,13 @@ $siteoptionform = array(
'help' => true,
'disabled' => in_array('usersallowedmultipleinstitutions', $OVERRIDDEN),
),
'requireregistrationconfirm' => array(
'type' => 'switchbox',
'title' => get_string('requireregistrationconfirm', 'admin'),
'description' => get_string('requireregistrationconfirmdescription1', 'admin'),
'defaultvalue' => get_config('requireregistrationconfirm'),
'help' => true,
),
'institutionexpirynotification' => array(
'type' => 'expiry',
'title' => get_string('institutionexpirynotification', 'admin'),
......@@ -797,6 +805,7 @@ function siteoptions_submit(Pieform $form, $values) {
'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap',
'registration_sendweeklyupdates', 'mathjax', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
'institutionstrictprivacy',
'showselfsearchsideblock', 'nousernames', 'searchplugin', 'showtagssideblock',
'tagssideblockmaxtags', 'country', 'userscanchooseviewthemes', 'internalnotificationexpire',
'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
......@@ -847,6 +856,15 @@ function siteoptions_submit(Pieform $form, $values) {
db_commit();
}
}
// Make sure we have valid strict privacy and multi institutions settings
if (users_in_multiple_institutions()) {
$values['institutionstrictprivacy'] = false;
}
else {
if (!empty($values['institutionstrictprivacy'])) {
$values['usersallowedmultipleinstitutions'] = false;
}
}
// if public views are disabled, sitemap generation must also be disabled.
if ($values['allowpublicviews'] == false) {
$values['generatesitemap'] = false;
......@@ -954,7 +972,10 @@ function siteoptions_submit(Pieform $form, $values) {
$form->reply(PIEFORM_OK, array('message' => $message, 'goto' => '/admin/site/options.php'));
}
$usermultipleinstitutions = (!empty(users_in_multiple_institutions()) ? "true" : "false");
$js = <<<EOF
var usersinmultipleinstitutions = {$usermultipleinstitutions};
jQuery(document).ready(function() {
var j = jQuery.noConflict();
var overrideuseraccountlifetime = j('#siteoptions input[name=defaultaccountlifetimeupdate]');
......@@ -990,7 +1011,18 @@ jQuery(document).ready(function() {
});
// initial setup
overrideuseraccountlife(defaultaccountlifetime.val());
jQuery('#siteoptions_institutionstrictprivacy').click(function() {
multipleinstitutionscheckallowed();
});
jQuery('#siteoptions_usersallowedmultipleinstitutions').click(function() {
strictprivacycheckallowed();
});
multipleinstitutionscheckallowed();
strictprivacycheckallowed();
});
EOF;
$thispage = json_encode(get_config('wwwroot') . 'admin/site/options.php');
......
......@@ -15,6 +15,32 @@ var forceReloadElements = ['sitename', 'lang', 'theme',
'defaultaccountlifetimeupdate'];
var isReloadRequired = false;
// if strict privacy is enabled, disables multiple institutions per user
function multipleinstitutionscheckallowed() {
var target = jQuery('#siteoptions_usersallowedmultipleinstitutions');
if (jQuery('#siteoptions_institutionstrictprivacy').is(':checked')) {
target.prop('disabled', true);
target.prop('checked', false);
}
else {
target.prop('disabled', false);
}
}
// if multiple institution per user is enabled, disables strict privacy
function strictprivacycheckallowed() {
if (!usersinmultipleinstitutions) {
var target = jQuery('#siteoptions_institutionstrictprivacy');
if (jQuery('#siteoptions_usersallowedmultipleinstitutions').is(':checked')) {
target.prop('disabled', true);
target.prop('checked', false);
}
else {
target.prop('disabled', false);
}
}
}
var checkReload = (function($) {
// Disconnects the pieform submit handler and changes the form target back to
// the page itself (rather than pieform's hidden iframe), so a full post/reload
......@@ -50,12 +76,23 @@ var checkReload = (function($) {
connectElements();
// Javascript success handler for the form. Re-wires up the elements
return function(form, data) {
update_allowpublicprofiles();
isReloadRequired = false;
connectElements();
jQuery('#siteoptions_institutionstrictprivacy').click(function() {
multipleinstitutionscheckallowed();
});
jQuery('#siteoptions_usersallowedmultipleinstitutions').click(function() {
strictprivacycheckallowed();
});
multipleinstitutionscheckallowed();
strictprivacycheckallowed();
formSuccess(form, data);
};
}(jQuery));
......@@ -450,6 +450,8 @@ $string['trustedsites'] = 'Trusted sites';
$string['updatesiteoptions'] = 'Update site options';
$string['usersallowedmultipleinstitutions'] = 'Users allowed multiple institutions';
$string['usersallowedmultipleinstitutionsdescription1'] = 'Allow users to be members of several institutions at the same time.';
$string['institutionstrictprivacy'] = 'Strict privacy';
$string['institutionstrictprivacydescription'] = 'Turn on this option when your site needs to adhere to the <a href="https://www.eugdpr.org/">GDPR</a> ';
$string['requireregistrationconfirm'] = 'Confirm registration';
$string['requireregistrationconfirmdescription1'] = 'Force all institutions to approve new self-registered accounts.';
$string['userscanchooseviewthemes'] = 'Users can choose page themes';
......
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Strict privacy</h3>
<p>Turning on this option will require everyone on the site to accept the terms and conditions and the privacy statement for the site. If institutions have their own statements, members of the institution will need to consent to that as well.</p> <p>This option is not available if the site has people in multiple institutions. If you need to enable strict privacy, you will need to make changes to these accounts first and have them in one institution only.</p>
<p>For more information and any text changes you may need to make to your terms and conditions and privacy statement, please consult your lawyer. The Mahara project cannot provide legal advice.</p>
<p>Find out more about the <a href="https://www.eugdpr.org/">GDPR</a>.</p>
......@@ -4815,6 +4815,19 @@ function get_user_institution_comment_threads($userid = null) {
return false;
}
/**
* Returns the user id of users in multiple institutions
*
* @return array user ids (or false)
*/
function users_in_multiple_institutions() {
$sql = "SELECT usr
FROM {usr_institution}
GROUP BY usr
HAVING COUNT(usr) > 1";
return get_records_sql_array($sql);
}
/**
* Returns all directories of installed plugins except for local
* from the current codebase.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment