Commit 50a14e7a authored by Rebecca Blundell's avatar Rebecca Blundell Committed by Robert Lyon
Browse files

Bug 1765674: Make registration revokable and data always visible

- changed some lang strings to make them work whether registered or not.
- made Registration box always visible
- added functionality to remove registration
- removed option to change email setting. Registration means sending
- added registration_firstsent field to use for telling the admin how
  long their site has been regiestered.
- removed switch for "Send weekly updates" from "Site options" page as
  it seemed confusing to have it in 2 places with different wording.
- updated failing behat tests

Change-Id: I47609df6a0ae34932e5c0d2d34a338fe08c7570a
parent c6f82f81
......@@ -37,11 +37,12 @@ if (isset($upgrades['core']) && !empty($upgrades['core']->install)) {
if (!get_config('registration_lastsent')
|| get_config('new_registration_policy')) {
$register = true;
// If this is true, we changed to make weekly updates mandatory since this site registered. So tell them.
if (get_config('registration_lastsent') && !get_config('registration_firstsent')) {
set_config('new_registration_policy', true);
$closed = get_config('siteclosedbyadmin');
$closeform = pieform(array(
'name' => 'close_site',
......@@ -84,11 +85,12 @@ $smarty->assign('upgrades', $upgrades);
if (isset($sitedata)) {
$smarty->assign('sitedata', $sitedata);
$firstregistered = get_config('registration_firstsent');
$smarty->assign('firstregistered', $firstregistered ? format_date($firstregistered) : false);
if (isset($register)) {
$smarty->assign('register', $register);
$smarty->assign('register', true);
$smarty->assign('newregisterpolicy', get_config('new_registration_policy'));
$smarty->assign('sendweeklyupdates', get_config('registration_sendweeklyupdates'));
$smarty->assign('closed', $closed);
$smarty->assign('closeform', $closeform);
$smarty->assign('clearcachesform', $clearcachesform);
......@@ -18,12 +18,23 @@ define('SECTION_PLUGINNAME', 'admin');
require(get_config('libroot') . 'registration.php');
define('TITLE', get_string('Register', 'admin'));
define('TITLE', get_string('Registration', 'admin'));
if (!get_config('registration_lastsent')
|| get_config('new_registration_policy')) {
// This runs register_site in registration.php, which is what displays the form and the button for emails.
if (!get_config('registration_lastsent')) {
$register = register_site();
else {
if (get_config('new_registration_policy')) {
$registration_update = get_string('newregistrationpolicyinfo', 'admin');
$registered = register_site(true);
$firstregistered = (get_config('registration_firstsent'));
// The $firstregistered might be false if site registered before we kept this info. Otherwise format as date.
if ($firstregistered) {
$firstregistered = format_date($firstregistered);
$smarty = smarty();
......@@ -32,5 +43,9 @@ setpageicon($smarty, 'icon-star');
if (isset($register)) {
$smarty->assign('register', $register);
else if (isset($registered)) {
$smarty->assign('registered', $registered);
$smarty->assign('firstregistered', $firstregistered);
......@@ -94,14 +94,6 @@ $siteoptionform = array(
'defaultvalue' => get_config('homepageinfo'),
'disabled' => in_array('homepageinfo', $OVERRIDDEN),
'registration_sendweeklyupdates' => array(
'type' => 'switchbox',
'title' => get_string('sendweeklyupdates', 'admin'),
'description' => get_string('sendweeklyupdatesdescription2', 'admin'),
'defaultvalue' => get_config('registration_sendweeklyupdates'),
'help' => true,
'disabled' => in_array('registration_sendweeklyupdates', $OVERRIDDEN),
'usersettings' => array(
......@@ -821,7 +813,7 @@ function siteoptions_submit(Pieform $form, $values) {
'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap',
'registration_sendweeklyupdates', 'mathjax', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
'mathjax', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
'showselfsearchsideblock', 'nousernames', 'searchplugin', 'showtagssideblock',
'tagssideblockmaxtags', 'country', 'userscanchooseviewthemes', 'internalnotificationexpire',
......@@ -240,25 +240,28 @@ $string['filemissingdesc'] = 'File %s%s is missing from server';
// Register your Mahara
$string['Field'] = 'Field';
$string['Value'] = 'Value';
$string['datathatwillbesent'] = 'Data that will be sent';
$string['dataincluded'] = 'Data included';
$string['datathathavebeensent'] = 'Data that has been sent';
$string['sendweeklyupdates'] = 'Send weekly updates?';
$string['sendweeklyupdatesdescription2'] = 'Allow your site to send weekly updates to with some statistics about your site.';
$string['newregistrationpolicyinfo'] = '<p>We have updated our registration data policy to require registered sites to provide weekly updates of their data. Please follow the link below to confirm or remove your registration.</p>';
$string['registerwithmahara'] = 'Register with';
$string['remainregistered'] = 'Remain registered?';
$string['Register'] = 'Register';
$string['Registration'] = 'Registration';
$string['registrationcancelled'] = 'You can choose to register at any time by going to the <a href="%sadmin/registersite.php">site registration page</a>.';
$string['registrationfailedtrylater'] = 'Registration failed with error code %s. Please try again later.';
$string['registrationsuccessfulthanksforregistering'] = 'Registration successful - thanks for registering.';
$string['registeryourmaharasite'] = 'Register your Mahara site';
$string['registeryourmaharasitesummary'] = '
<p>You can choose to register your Mahara site with <a href=""></a> and help us to build up a picture of the Mahara installations around the world. Registering will remove this notice.</p>
<p>You can register your site and preview the information that will be sent on the <strong><a href="%sadmin/registersite.php">site registration page.</a></strong></p>';
$string['registermaharasite'] = 'Site registration';
$string['registeryoursitesummary'] = '
<p>Registering your Mahara site with <a href=""></a> helps us to build up a picture of the Mahara installations around the world.</p>';
$string['registeryourmaharasitedetail'] = '
<p>You can choose to register your Mahara site with <a href=""></a>. Registration is free and helps us build up a picture of the Mahara installations around the world.</p>
<p>You can see the information that will be sent to - nothing that can personally identify any of your users will be sent.</p>
<p>If you tick &quot;send weekly updates&quot;, Mahara will automatically send an update to once a week with your updated information.</p>
<p>Registering will remove this notice. You will be able to change whether you send weekly updates on the <a href="%sadmin/site/options.php">site options</a> page.</p>';
$string['siteregistered'] = 'Your site has been registered. You can turn weekly updates on and off on the <a href="%sadmin/site/options.php">site options</a> page.</p>';
$string['newsiteregistrationpolicy'] = '<p>In Mahara 15.10, we have updated the policy to send data to Please confirm your registration.</p>';
<p>You can see the information that will be sent to Nothing that can personally identify any of your users will be sent. If you choose to register, Mahara will automatically send your updated information to once a week.</p>';
$string['registrationremoved'] = 'Your site\'s registration has been removed. You can re-register with at any time.';
$string['sendingweeklyupdates'] = 'You are currently sending weekly updates.';
$string['siteisregisteredsince'] = 'Your site has been registered with <a href=""></a> since %s.';
$string['siteisregistered'] = 'Your site is registered with <a href=""></a>.';
$string['registeredinfo'] = 'Updated information about your site is being sent to weekly. You can see what is being sent in the &quot;Data included&quot; section below. Nothing that can personally identify any of your users is sent.</p><p>To remove registration of your site, change the &quot;Remain registered&quot; switch to &quot;No&quot; and press the &quot;Save&quot; button.';
$string['siteregistrationpolicy'] = '<p>To ensure our statistics accurately show how Mahara is being used, registration now includes sending us weekly updates. Please review and confirm your registration by clicking &quot;Save&quot; below.</p>';
// Close site
$string['Close'] = 'Close';
<!-- @license GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Send weekly updates</h3>
<p>If you tick &quot;send weekly updates&quot;, your site will automatically send an update to once a week with updated information about your installation.</p>
<p>The information sent is high-level statistical information - no personal information about any of your users is sent. You can review the type of information that is sent before you register your site (which you can do from the administrator homepage).</p>
......@@ -20,7 +20,7 @@ defined('INTERNAL') || die();
* @return string that is the registation form
* @ingroup Registration
function register_site() {
function register_site($registered = null) {
$strfield = get_string('Field', 'admin');
$strvalue = get_string('Value', 'admin');
$info = <<<EOF
......@@ -35,18 +35,22 @@ function register_site() {
$data = registration_data();
// Format each line of data to be sent.
foreach($data as $key => $val) {
$info .= '<tr><th>'. hsc($key) . '</th><td>' . hsc($val) . "</td></tr>\n";
$info .= '</tbody></table>';
// Check if site is already registered and set the text for the Register swithbox accordingly
$register_label = ($registered) ? get_string('remainregistered', 'admin') : get_string('registerwithmahara', 'admin');
$form = array(
'name' => 'register',
'autofocus' => false,
'elements' => array(
'whatsent' => array(
'type' => 'fieldset',
'legend' => get_string('datathatwillbesent', 'admin'),
'legend' => get_string('dataincluded', 'admin'),
'collapsible' => true,
'collapsed' => true,
'class' => 'last',
......@@ -57,15 +61,15 @@ EOF;
'sendweeklyupdates' => array(
'registeryesno' => array(
'type' => 'switchbox',
'title' => get_string('sendweeklyupdates', 'admin'),
'defaultvalue' => true,
'title' => $register_label,
'defaultvalue' => get_config('registration_sendweeklyupdates'),
'register' => array(
'type' => 'submitcancel',
'class' => 'btn-primary',
'value' => array(get_string('Register', 'admin'), get_string('cancel', 'mahara')),
'value' => array(get_string('save', 'mahara'), get_string('cancel', 'mahara')),
......@@ -78,6 +82,25 @@ EOF;
function register_submit(Pieform $form, $values) {
global $SESSION;
// If there is a timecode in this field, the site was registered at this time.
$registered = get_config('registration_lastsent');
// Depending on if the site was registered previously and what value was submitted in the 'registeryesno' field,
// there are three options:
// 1. cancel (i.e, the user made no changes)
if (!$registered && !$values['registeryesno'] || $registered && $values['registeryesno']) {
// Not registered, not registering OR registered and registering - cancel
if ($registered && !get_config ('registration_firstsent')) {
set_config('registration_firstsent', time());
// 2. remove registation
else if ($registered && !$values['registeryesno']) {
// 3. registering, continue
$result = registration_send_data();
$data = json_decode($result->data);
......@@ -87,7 +110,10 @@ function register_submit(Pieform $form, $values) {
else {
set_config('registration_lastsent', time());
set_config('registration_sendweeklyupdates', $values['sendweeklyupdates']);
if (!get_config('registration_firstsent')) {
set_config('registration_firstsent', time());
set_config('registration_sendweeklyupdates', $values['registeryesno']);
if (get_config('new_registration_policy')) {
set_config('new_registration_policy', false);
......@@ -114,6 +140,21 @@ function register_submit(Pieform $form, $values) {
* Runs when the 'Remove' button is clicked
function remove_registration() {
global $SESSION;
set_config('registration_lastsent', 0);
set_config('registration_sendweeklyupdates', 0);
if (get_config('new_registration_policy')) {
set_config('new_registration_policy', 0);
$SESSION->add_ok_msg(get_string('registrationremoved', 'admin'));
* Runs when registration form is cancelled
......@@ -121,7 +162,7 @@ function register_cancel_register() {
global $SESSION;
if (get_config('new_registration_policy')) {
set_config('new_registration_policy', -1);
set_config('new_registration_policy', 0);
$SESSION->add_ok_msg(get_string('registrationcancelled', 'admin', get_config('wwwroot')), false);
......@@ -75,11 +75,20 @@
{if $register}
<div class="panel panel-success register-site">
<h3 class="panel-heading">{str tag=registeryourmaharasite section=admin} <span class="icon icon-star pull-right" role="presentation" aria-hidden="true"></span></h3>
<h3 class="panel-heading">{str tag=registermaharasite section=admin} <span class="icon icon-star pull-right" role="presentation" aria-hidden="true"></span></h3>
<div class="panel-body">
{str tag=registeryourmaharasitesummary section=admin args=$WWWROOT}
{if $newregisterpolicy}
<strong>{str tag=newregistrationpolicyinfo section=admin}</strong>
{str tag=registeryoursitesummary section=admin args=$WWWROOT}
{if $firstregistered}
<p>{str tag=siteisregisteredsince section=admin args=$firstregistered}</p>
{if $sendweeklyupdates}
<p>{str tag=sendingweeklyupdates section=admin}</p>
<a class="panel-footer" href="{$WWWROOT}admin/registersite.php">{str tag=Register section=admin} <span class="icon icon-arrow-circle-right pull-right" role="presentation" aria-hidden="true"></span></a>
<a class="panel-footer" href="{$WWWROOT}admin/registersite.php">{str tag=Registration section=admin} <span class="icon icon-arrow-circle-right pull-right" role="presentation" aria-hidden="true"></span></a>
{include file='header.tpl'}
<div id="register-site-full">
<h1> {if isset($PAGEICON)}
<span class="{$PAGEICON}"></span>
{str tag=registeryourmaharasite section=admin}
<div class="panel panel-default col-md-9">
<div class="panel-body">
{if get_config('new_registration_policy')}
{str tag=newsiteregistrationpolicy section=admin}
{str tag=siteregistrationpolicy section=admin}
{if $register}
{str tag=registeryourmaharasitedetail section=admin args=$WWWROOT}
{str tag=siteregistered section=admin args=$WWWROOT}
{if $firstregistered}
<p><strong>{str tag=siteisregisteredsince section=admin args=$firstregistered}</strong></p>
{str tag=registeredinfo section=admin}
<p><strong>{str tag=siteisregistered section=admin}</strong></p>
{str tag=registeredinfo section=admin}
......@@ -9,7 +9,7 @@ Scenario: Closing the site
Given I log in as "admin" with password "Kupuh1pa!"
And I choose "Admin home" from administration menu
# Verifying I'm on the right page
And I should see "Register your Mahara site"
And I should see "Site registration"
And I scroll to the base of id "close_site"
And I press "Close"
And I should see "Reopen site"
......@@ -13,7 +13,6 @@ Scenario: Turning the switches on and off on the Site Options page (Bug 1431569)
# Changing all the switches from their default settings
And I set the following fields to these values:
| Show homepage / dashboard information | 0 |
| Send weekly updates? | 1 |
| Users can choose page themes | 1 |
| Display remote avatars | 1 |
| Users can hide real names | 1 |
Supports Markdown
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