Commit 45953f35 authored by Maria Sorica's avatar Maria Sorica Committed by Robert Lyon

Bug 1734182: Add view/edit logic to institution privacy statement

behatnotneeded

Change-Id: If1d564c309ebf32025299035fb8cca4d0981f603
parent 1d3609fa
......@@ -60,41 +60,54 @@ $privacies = get_records_sql_assoc("
$form = false;
if ($versionid !== null) {
$form = pieform(array(
'name' => 'editsitepage',
'jsform' => false,
'jssuccesscallback' => 'contentSaved',
'elements' => array(
'version' => array(
'type' => 'text',
'title' => get_string('version', 'admin'),
'description' => '',
'defaultvalue' => '',
'rules' => array(
'required' => true,
'maxlength' => 15
)
),
'pageinstitution' => array('type' => 'hidden', 'value' => $institution),
'pagetext' => array(
'name' => 'pagetext',
'type' => 'wysiwyg',
'rows' => 25,
'cols' => 100,
'title' => get_string('pagetext', 'admin'),
'defaultvalue' => '',
'rules' => array(
'maxlength' => 65536,
'required' => true
)
),
'submit' => array(
'class' => 'btn-primary',
'type' => 'submit',
'value' => get_string('savechanges', 'admin')
),
)
));
$pageoptions = get_record('site_content_version', 'id', $versionid, 'institution', $institution);
if ($versionid === 0 || $pageoptions) {
$form = pieform(array(
'name' => 'editsitepage',
'jsform' => false,
'jssuccesscallback' => 'contentSaved',
'elements' => array(
'version' => array(
'type' => 'text',
'title' => get_string('version', 'admin'),
'description' => $pageoptions ? get_string('lastversion', 'admin', $pageoptions->version) : '',
'defaultvalue' => '',
'rules' => array(
'required' => true,
'maxlength' => 15
)
),
'pageinstitution' => array('type' => 'hidden', 'value' => $institution),
'pagetext' => array(
'name' => 'pagetext',
'type' => 'wysiwyg',
'rows' => 25,
'cols' => 100,
'title' => get_string('pagetext', 'admin'),
'defaultvalue' => $pageoptions ? $pageoptions->content : '',
'rules' => array(
'maxlength' => 65536,
'required' => true
)
),
'submit' => array(
'class' => 'btn-primary',
'type' => 'submit',
'value' => get_string('savechanges', 'admin')
),
)
));
}
else {
throw new ViewNotFoundException(get_string('institutionprivacystatementnotfound', 'error', $institutionelement['options'][$institution], $versionid));
}
}
function editsitepage_validate(Pieform $form, $values) {
// Check if the version entered by the user already exists
if (record_exists('site_content_version', 'institution', $values['pageinstitution'], 'version', $values['version'])) {
$form->set_error('version', get_string('versionalreadyexist', 'admin', $values['version']));
}
}
function editsitepage_submit(Pieform $form, $values) {
......@@ -151,5 +164,9 @@ $smarty->assign('lastupdated', get_string('lastupdatedon', 'blocktype.externalfe
$smarty->assign('versionid', $versionid);
$smarty->assign('privacies', $privacies);
$smarty->assign('pageeditform', $form);
$smarty->assign('institution', $institution);
$smarty->assign('latestversion', $privacies ? reset($privacies)->version : 0);
$smarty->assign('latestprivacyid', $privacies ? reset($privacies)->id : 0);
$smarty->assign('version', $versionid && $pageoptions ? $pageoptions->version : '');
$smarty->assign('institutionselector', $institutionselector);
$smarty->display('admin/users/institutionprivacy.tpl');
......@@ -95,6 +95,7 @@ $string['accessdeniedexception'] = 'You do not have access to view this page.';
$string['accessdeniednourlsecret'] = 'You do not have access to this functionality. Please provide the value for "urlsecret" from your config.php file as part of the URL.';
$string['accessdeniedbadge'] = 'You do not have access to view this badge.';
$string['siteprivacystatementnotfound'] = 'Site privacy statement with id %s not found.';
$string['institutionprivacystatementnotfound'] = 'Privacy statement for "%s" with id %s not found.';
$string['viewnotfoundexceptiontitle'] = 'Page not found';
$string['viewnotfoundexceptionmessage'] = 'You tried to access a page that does not exist.';
$string['viewnotfound'] = 'Page with id %s not found.';
......
{include file="header.tpl"}
<div class="lead">{str tag="institutionprivacypagedescription" section="admin"}</div>
<div class="panel panel-default">
<div class="last form-group collapsible-group">
<fieldset class="pieform-fieldset last collapsible">
......@@ -20,13 +19,23 @@
</div>
</div>
{if $versionid !== null}
<div class="panel panel-default">
<div class="panel-body">
{$pageeditform|safe}
{if $version == $latestversion}
<div class="lead">{str tag="institutionprivacypagedescription" section="admin"}</div>
<div class="panel panel-default">
<div class="panel-body">
{$pageeditform|safe}
</div>
</div>
</div>
{else}
{foreach from=$privacies item=result key=key}
{if $result->version == $version}
{$result->content|clean_html|safe}
{/if}
{/foreach}
{/if}
{else}
{if $privacies}
<div class="lead">{str tag="institutionprivacypagedescription" section="admin"}</div>
<div class="panel panel-default">
<div class="table-responsive">
<table id="adminstitutionslist" class="fullwidth table table-striped">
......@@ -53,7 +62,21 @@
</td>
<td>{$result->content|truncate:100:"..."|htmlspecialchars_decode|strip_tags}</td>
<td>{$result->ctime|date_format:'%d %b %Y %H:%M'}</td>
<td class="control-buttons"></td>
<td class="control-buttons">
{if $key == $latestprivacyid}
<div class="btn-group">
<a href="{$WWWROOT}admin/users/institutionprivacy.php?institution={$institution}&id={$result->id}" title="{str tag=editversion section='admin' arg1='$result->version'}" class="btn btn-default btn-xs">
<span class="icon icon-pencil icon-lg" role="presentation" aria-hidden="true"></span>
</a>
</div>
{else}
<div class="btn-group">
<a href="{$WWWROOT}admin/users/institutionprivacy.php?institution={$institution}&id={$result->id}" title="{str tag=viewversion section='admin' arg1='$result->version'}" class="btn btn-default btn-xs">
<span class="icon icon-eye icon-lg" role="presentation" aria-hidden="true"></span>
</a>
</div>
{/if}
</td>
</tr>
{/foreach}
</tbody>
......
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