Commit 69916a3d authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon

Bug 1813987: User should confirm before the view is translated

there is an account preference we can set for showing
a warning message before translating the layout of an old view.

By default it's true. It can be set to false in the account preferences
or by selecting the option when the message is displayed.
if this preference is set to
true: if we want to edit a view with old layout,
a message will be displayed to confirm we want to translate the layout.
false: The view gets translated on edit without asking the user.

The message has the options to accept, cancel  or don't ask again.

cancel: redirects to the displayed view
don't ask again: sets account preference to false but can be reverted
in account preferences.
accept: will redirect to the view edit page with a parameter
saying the user accepted the translation

behatnotneeded

Change-Id: I84e1a86d3bb494a1955da9cbfbde996b555bb132
parent 1a1d2a69
......@@ -59,6 +59,9 @@ $string['hiderealnamedescription'] = 'Check this box if you have set a display n
$string['showhomeinfo2'] = 'Dashboard information';
$string['showhomeinfodescription1'] = 'Display information about how to use %s on the dashboard.';
$string['showlayouttranslatewarning'] = 'Confirm before changing pages layout';
$string['showlayouttranslatewarningdescription'] = 'Display a warning and request confirmation before changing the layout of a page to the new layout when editing the page';
$string['showprogressbar'] = 'Profile completion progress bar';
$string['showprogressbardescription'] = 'Display progress bar and tips on how to complete your %s profile.';
......
......@@ -518,3 +518,8 @@ $string['bottom'] = 'Bottom';
$string['top'] = 'Top';
$string['blockssizeupdated'] = 'Block sizes were updated successfully';
$string['dimensionsnotset'] = 'Block dimensions not set';
$string['dontaskagain'] = 'Accept and remember';
$string['pleaseconfirmtranslate'] = 'Transform page layout';
$string['confirmtranslationmessage'] = 'As part of Mahara 19.10 we introduced a new way to create pages layout. To be able to edit this page we\'ll need to transform the old layout to the new grid layout.
If you wish to transform this page alone, click \'Accept\'. To transform all pages that you edit and not see this message again, click \'Accept and remember\', this option can be changed in <a href="%s">Settings</a>. To go back to the page click on \'Cancel\'.
';
......@@ -246,6 +246,7 @@ function expected_account_preferences() {
'orderpagesby' => 'latestmodified',
'searchinfields' => 'titleanddescriptionandtags',
'view_details_active' => 0,
'showlayouttranslatewarning' => 1,
);
}
......@@ -451,6 +452,13 @@ function general_account_prefs_form_elements($prefs) {
);
}
$elements['showlayouttranslatewarning'] = array(
'type' => 'switchbox',
'defaultvalue' => $prefs->showlayouttranslatewarning,
'title' => get_string('showlayouttranslatewarning', 'account'),
'description' => get_string('showlayouttranslatewarningdescription', 'account', hsc(get_config('sitename'))),
);
return $elements;
}
......
{include file="header.tpl"}
<div class="center">
<p class="alert alert-warning">{str tag=confirmtranslationmessage section=view arg1=$accountprefsurl}</p>
<form action="{$formurl}" method="post" class="pieform form-inline">
<input type="hidden" id="viewid" name="id" value="{$viewid}">
<input type="hidden" name="sesskey" value="{$SESSKEY}">
<input type="hidden" name="alwaystranslate" value="true">
<div>
<input class="submit btn btn-primary" type="submit" value="{str tag=dontaskagain section=view}">
<a class="btn-secondary submitcancel submit btn" href="{$WWWROOT}view/blocks.php?id={$viewid}&translate=true">
{str tag="accept"}
</a>
<a class="btn-secondary submitcancel cancel" href="{$WWWROOT}view/view.php?id={$viewid}">
{str tag="cancel"}
</a>
</div>
</form>
</div>
{include file="footer.tpl"}
......@@ -169,9 +169,35 @@ if ($view->uses_new_layout() && $view->needs_block_resize_on_load()) {
$blockresizeonload = "true";
}
if (!$view->uses_new_layout()) {
// if it's old row layout, we need to translate to grid layout
save_blocks_in_new_layout($view->get('id'));
$blockresizeonload = "true";
// flag to set the showlayouttranslatewarning=true in account preferences
$alwaystranslate = param_boolean('alwaystranslate', false);
// flag to translate this page
$translate = param_boolean('translate', false);
// if showlayouttranslatewarning is not set in account preferences, then we need to show the warning
$showlayouttranslatewarning = is_null($USER->get_account_preference('showlayouttranslatewarning')) ? 1 : $USER->get_account_preference('showlayouttranslatewarning');
if ($showlayouttranslatewarning && $alwaystranslate) {
$USER->set_account_preference('showlayouttranslatewarning', 0);
$showlayouttranslatewarning = false;
}
if ($showlayouttranslatewarning && !$translate) {
// user needs to confirm that wants to translate old layout page to grid layout
// before we continue
$smarty = smarty(array(), $stylesheets, false, $extraconfig);
$smarty->assign('PAGEHEADING', get_string('pleaseconfirmtranslate', 'view'));
$smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('viewid', $view->get('id'));
$smarty->assign('viewtitle', $view->get('title'));
$smarty->assign('accountprefsurl', get_config('wwwroot') . 'account');
$smarty->display('view/translatewarning.tpl');
exit;
}
else {
// if it's old row layout, we need to translate to grid layout
save_blocks_in_new_layout($view->get('id'));
$blockresizeonload = "true";
}
}
$blocks = $view->get_blocks(true);
$blocksencode = json_encode($blocks);
......
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