Commit 9cfbb97a authored by Maria Sorica's avatar Maria Sorica Committed by Robert Lyon

Bug 1734174: Users Privacy Statement page

The page displays the current privacy statement that the user has consented to.
behatnotneeded

Change-Id: I03d79f538b0a3775cf49c0ed39a05b3a98c8bf04
parent dece7ed9
<?php
/**
*
* @package mahara
* @subpackage admin
* @author Catalyst IT Ltd
* @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.
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'settings/privacy');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'account');
define('SECTION_PAGE', 'userprivacy');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('docroot') . 'lib/user.php');
define('TITLE', get_string('privacy', 'admin'));
if (!is_logged_in()) {
throw new AccessDeniedException();
}
// Get all institutions of a user.
$userinstitutions = array_keys($USER->get('institutions'));
// Include the 'mahara' institution so that we may show the site privacy statement as well.
array_push($userinstitutions, 'mahara');
// Get all the latest privacy statement (institution and site) the user has agreed to.
$data = get_latest_privacy_versions($userinstitutions);
// JQuery logic for panel hide/show.
// Needed here because there are multiple dropdown panels on this page.
$js = <<< EOF
function showPanel(el) {
elementid = $(el).attr('id');
$("#dropdown" + elementid).toggleClass("collapse");
}
EOF;
$smarty = smarty();
setpageicon($smarty, 'icon-umbrella');
$smarty->assign('results', $data);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->display('account/userprivacy.tpl');
......@@ -1334,4 +1334,7 @@ $string['lastversion'] = 'Privacy statements must have unique version names of u
$string['versionalreadyexist'] = 'A privacy statement with the version name "%s" already exists.';
$string['siteprivacystatement'] = 'Site privacy statement';
$string['addoneversionlink'] = '<a href="%s">Add one</a> if you need it.';
$string['versionfor'] = 'Privacy statement for version "%s" is as follows:';
\ No newline at end of file
$string['versionfor'] = 'Privacy statement for version "%s" is as follows:';
$string['institutionprivacystatement'] = 'Institution privacy statement';
$string['userprivacypagedescription'] = 'Displayed are the current privacy statements to which you consented.';
$string['lastupdated'] = 'Last updated on';
......@@ -3218,3 +3218,25 @@ function get_site_admins() {
// just in case there is something horribly wrong.
return false;
}
/**
* Returns a list of the latest privacy statements of each institution the current user belongs to.
*
* @param $institutions an array of the institutions to which the current user belongs to.
* @returns array of stdclass objects containing the latest privacy statements the user has agreed to.
*/
function get_latest_privacy_versions($institutions = array()) {
global $USER;
// Get the latest Privacy Statements the user has agreed to.
$latestversions = get_records_sql_assoc("
SELECT s.id, s.version, s.content, s.ctime, s.institution
FROM {site_content_version} s
INNER JOIN (SELECT MAX(id) as current, institution
FROM {site_content_version}
GROUP BY institution) s2 ON s.institution = s2.institution AND s.id = s2.current
JOIN {usr_agreement} u ON s2.current = u.sitecontentid AND u.usr = ?
WHERE s.institution IN (" . join(',',array_map('db_quote',$institutions)) . ")", array($USER->get('id')));
return $latestversions;
}
......@@ -3041,11 +3041,17 @@ function right_nav() {
'weight' => 10,
'iconclass' => 'user'
),
'settings/privacy' => array(
'path' => 'settings/privacy',
'url' => 'account/userprivacy.php',
'title' => get_string('privacy', 'admin'),
'weight' => 30
),
'settings/notifications' => array(
'path' => 'settings/notifications',
'url' => 'account/activity/preferences/index.php',
'title' => get_string('notifications'),
'weight' => 30,
'weight' => 40,
'iconclass' => 'flag'
),
);
......
{include file="header.tpl"}
<div class="lead">{str tag="userprivacypagedescription" section="admin"}</div>
{foreach from=$results item=result key=key}
<div class="panel panel-default" id="{$result->id}" onclick="showPanel(this)">
<div class="last form-group collapsible-group">
<fieldset class="pieform-fieldset last collapsible">
<legend>
<h4>
<a href="#dropdown" data-toggle="collapse" aria-expanded="false" aria-controls="dropdown" class="collapsed">
{if $result->institution == 'mahara'}
{str tag="siteprivacystatement" section="admin"}
{else}
{str tag="institutionprivacystatement" section="admin"}
{/if}
<span class="icon icon-chevron-down collapse-indicator right pull-right"> </span>
</a>
</h4>
</legend>
<div class="fieldset-body collapse" id="dropdown{$result->id}">
<span class="text-midtone pull-right">{str tag="lastupdated" section="admin"} {$result->ctime|date_format:'%d %B %Y %H:%M %p'}</span>
<br>
{$result->content|safe}
</div>
</fieldset>
</div>
</div>
{/foreach}
{include file="footer.tpl"}
......@@ -114,7 +114,7 @@ Scenario: Checking menu items are available as Admin User (Bug 1467368)
When I press "Show menu for Institutions"
Then I should see "Settings" in the "Institutions sub-menu" property
And I should see "Static pages" in the "Institutions sub-menu" property
And I should see "Legal" in the "Configure site sub-menu" property
And I should see "Legal" in the "Institutions sub-menu" property
And I should see "Members" in the "Institutions sub-menu" property
And I should see "Staff" in the "Institutions sub-menu" property
And I should see "Administrators" in the "Institutions sub-menu" property
......@@ -170,7 +170,7 @@ Scenario: Checking menu items are available as Institution Administrator (Bug 14
Then I should not see "Profile completion" in the "Institutions sub-menu" property
And I should see "Settings" in the "Institutions sub-menu" property
And I should see "Static pages" in the "Institutions sub-menu" property
And I should see "Legal" in the "Configure site sub-menu" property
And I should see "Legal" in the "Institutions sub-menu" property
And I should see "Members" in the "Institutions sub-menu" property
And I should see "Staff" in the "Institutions sub-menu" property
And I should see "Administrators" in the "Institutions sub-menu" property
......
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