Skip to content

Commit

Permalink
Merge pull request #4 from iomad/IOMAD_34_STABLE
Browse files Browse the repository at this point in the history
update my repo
  • Loading branch information
actXc committed May 28, 2018
2 parents 05d5a95 + 583e0fa commit 5a08576
Show file tree
Hide file tree
Showing 77 changed files with 3,346 additions and 1,981 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ matrix:
include:
# Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
- php: 7.2
env: DB=none TASK=GRUNT NVM_VERSION='8.9'
env: DB=none TASK=GRUNT NVM_VERSION='lts/carbon'

exclude:
# MySQL - it's just too slow.
Expand Down
3 changes: 0 additions & 3 deletions admin/roles/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,6 @@ public static function delete_data_for_all_users_in_context(\context $context) {
// Don't belong to the modifier user.

// Remove data from role_assignments.
if (empty($context)) {
return;
}
$DB->delete_records('role_assignments', ['contextid' => $context->id]);
}
/**
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/store/standard/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class provider implements
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
$collection->add_database_table('log', [
$collection->add_database_table('logstore_standard_log', [
'eventname' => 'privacy:metadata:log:eventname',
'userid' => 'privacy:metadata:log:userid',
'relateduserid' => 'privacy:metadata:log:relateduserid',
Expand Down
3 changes: 2 additions & 1 deletion admin/tool/mobile/classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ public static function get_features_list() {
$availablemods = core_plugin_manager::instance()->get_plugins_of_type('mod');
$coursemodules = array();
$appsupportedmodules = array('assign', 'book', 'chat', 'choice', 'data', 'feedback', 'folder', 'forum', 'glossary', 'imscp',
'label', 'lesson', 'lti', 'page', 'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki');
'label', 'lesson', 'lti', 'page', 'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop');

foreach ($availablemods as $mod) {
if (in_array($mod->name, $appsupportedmodules)) {
$coursemodules['$mmCourseDelegate_mmaMod' . ucfirst($mod->name)] = $mod->displayname;
Expand Down
4 changes: 0 additions & 4 deletions auth/oauth2/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ public static function export_user_data(approved_contextlist $contextlist) {
* @param \context $context The context to delete data for.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
if (empty($context)) {
return;
}

if ($context->contextlevel != CONTEXT_USER) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions blocks/iomad_company_admin/company_user_create_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ public function validation($usernew, $files) {
redirect($dashboardurl);
die;
} else if ($data = $mform->get_data()) {
// Trim first and lastnames
$data->firstname = trim($data->firstname);
$data->lastname = trim($data->lastname);

$data->userid = $USER->id;
if ($companyid > 0) {
$data->companyid = $companyid;
Expand Down
4 changes: 4 additions & 0 deletions blocks/iomad_company_admin/editadvanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
$userform->set_data($user);

if ($usernew = $userform->get_data()) {
// Trim first and lastnames
$usernew->firstname = trim($usernew->firstname);
$usernew->lastname = trim($usernew->lastname);

if ($usernew->id == -1) {
$event = \core\event\user_updated::create(array('context' => $systemcontext, 'userid' => $usernew->id, 'relateduserid' => $USER->id));
$event->trigger();
Expand Down
62 changes: 56 additions & 6 deletions blocks/recent_activity/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

namespace block_recent_activity\privacy;

use core_privacy\local\metadata\collection;
use core_privacy\local\request\approved_contextlist;
use core_privacy\local\request\contextlist;

defined('MOODLE_INTERNAL') || die();

/**
Expand All @@ -33,15 +37,61 @@
* @copyright 2018 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
class provider implements \core_privacy\local\metadata\provider,
\core_privacy\local\request\plugin\provider {

/**
* Returns metadata.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {

// This plugin defines a db table but it is not considered personal data and, therefore, not exported or deleted.
$collection->add_database_table('block_recent_activity', [
'courseid' => 'privacy:metadata:block_recent_activity:courseid',
'cmid' => 'privacy:metadata:block_recent_activity:cmid',
'timecreated' => 'privacy:metadata:block_recent_activity:timecreated',
'userid' => 'privacy:metadata:block_recent_activity:userid',
'action' => 'privacy:metadata:block_recent_activity:action',
'modname' => 'privacy:metadata:block_recent_activity:modname'
], 'privacy:metadata:block_recent_activity');

return $collection;
}

/**
* Get the list of contexts that contain user information for the specified user.
*
* @param int $userid The user to search.
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
return new contextlist();
}

/**
* Export all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts to export information for.
*/
public static function export_user_data(approved_contextlist $contextlist) {
}

/**
* Delete all data for all users in the specified context.
*
* @param \context $context The specific context to delete data for.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
}

/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
* Delete all user data for the specified user, in the specified contexts.
*
* @return string
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
*/
public static function get_reason() : string {
return 'privacy:metadata';
public static function delete_data_for_user(approved_contextlist $contextlist) {
}
}
7 changes: 7 additions & 0 deletions blocks/recent_activity/lang/en/block_recent_activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@

$string['pluginname'] = 'Recent activity';
$string['privacy:metadata'] = 'The recent activity block contains a cache of data stored elsewhere in Moodle.';
$string['privacy:metadata:block_recent_activity'] = 'Temporary log of recent teacher activity. Removed after two days';
$string['privacy:metadata:block_recent_activity:action'] = 'Action: created, updated or deleted';
$string['privacy:metadata:block_recent_activity:cmid'] = 'Course module id';
$string['privacy:metadata:block_recent_activity:courseid'] = 'Course id';
$string['privacy:metadata:block_recent_activity:modname'] = 'Module type name (for delete action)';
$string['privacy:metadata:block_recent_activity:timecreated'] = 'Time when action was performed';
$string['privacy:metadata:block_recent_activity:userid'] = 'User performing the action';
$string['recent_activity:addinstance'] = 'Add a new recent activity block';
$string['recent_activity:viewaddupdatemodule'] = 'View added and updated modules in recent activity block';
$string['recent_activity:viewdeletemodule'] = 'View deleted modules in recent activity block';
9 changes: 7 additions & 2 deletions blocks/rss_client/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,21 @@ public static function get_contexts_for_userid(int $userid) : contextlist {
* @param approved_contextlist $contextlist The approved contexts to export information for.
*/
public static function export_user_data(approved_contextlist $contextlist) {
$rssdata = [];
$results = static::get_records($contextlist->get_user()->id);
foreach ($results as $result) {
$data = (object) [
$rssdata[] = (object) [
'title' => $result->title,
'preferredtitle' => $result->preferredtitle,
'description' => $result->description,
'shared' => \core_privacy\local\request\transform::yesno($result->shared),
'url' => $result->url
];

}
if (!empty($rssdata)) {
$data = (object) [
'feeds' => $rssdata,
];
\core_privacy\local\request\writer::with_context($contextlist->current())->export_data([
get_string('pluginname', 'block_rss_client')], $data);
}
Expand Down
13 changes: 8 additions & 5 deletions blocks/rss_client/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,21 @@ public function test_export_user_data() {
$user = $this->getDataGenerator()->create_user();
$context = context_user::instance($user->id);

$this->add_rss_feed($user);
$this->add_rss_feed($user);

$writer = \core_privacy\local\request\writer::with_context($context);
$this->assertFalse($writer->has_any_data());
$this->export_context_data_for_user($user->id, $context, 'block_rss_client');

$data = $writer->get_data([get_string('pluginname', 'block_rss_client')]);
$this->assertEquals('BBC News - World', $data->title);
$this->assertEquals('World News', $data->preferredtitle);
$this->assertEquals('Description: BBC News - World', $data->description);
$this->assertEquals(get_string('no'), $data->shared);
$this->assertEquals('http://feeds.bbci.co.uk/news/world/rss.xml?edition=uk', $data->url);
$this->assertCount(2, $data->feeds);
$feed1 = reset($data->feeds);
$this->assertEquals('BBC News - World', $feed1->title);
$this->assertEquals('World News', $feed1->preferredtitle);
$this->assertEquals('Description: BBC News - World', $feed1->description);
$this->assertEquals(get_string('no'), $feed1->shared);
$this->assertEquals('http://feeds.bbci.co.uk/news/world/rss.xml?edition=uk', $feed1->url);
}

/**
Expand Down
4 changes: 0 additions & 4 deletions calendar/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ public static function export_user_preferences(int $userid) {
* @param context $context Transform the specific context to delete data for.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
if (empty($context)) {
return;
}

// Delete all Calendar Events in the specified context in batches.
if ($eventids = array_keys(self::get_calendar_event_ids_by_context($context))) {
self::delete_batch_records('event', 'id', $eventids);
Expand Down
4 changes: 0 additions & 4 deletions cohort/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ public static function export_user_data(approved_contextlist $contextlist) {
* @param context $context A user context.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
if (empty($context)) {
return;
}

if (!$context instanceof \context_system && !$context instanceof \context_coursecat) {
return;
}
Expand Down
55 changes: 27 additions & 28 deletions course/format/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ protected function section_header($section, $course, $onsectionpage, $sectionret
$o .= $this->section_availability($section);

$o .= html_writer::start_tag('div', array('class' => 'summary'));
$o .= $this->format_summary_text($section);
if ($section->uservisible || $section->visible) {
// Show summary if section is available or has availability restriction information.
// Do not show summary if section is hidden but we still display it because of course setting
// "Hidden sections are shown in collapsed form".
$o .= $this->format_summary_text($section);
}
$o .= html_writer::end_tag('div');

return $o;
Expand Down Expand Up @@ -443,13 +448,18 @@ protected function section_summary($section, $course, $mods) {
}
$o .= $this->output->heading($title, 3, 'section-title');

$o .= $this->section_availability($section);
$o.= html_writer::start_tag('div', array('class' => 'summarytext'));
$o.= $this->format_summary_text($section);

if ($section->uservisible || $section->visible) {
// Show summary if section is available or has availability restriction information.
// Do not show summary if section is hidden but we still display it because of course setting
// "Hidden sections are shown in collapsed form".
$o .= $this->format_summary_text($section);
}
$o.= html_writer::end_tag('div');
$o.= $this->section_activity_summary($section, $course, null);

$o .= $this->section_availability($section);

$o .= html_writer::end_tag('div');
$o .= html_writer::end_tag('li');

Expand Down Expand Up @@ -552,6 +562,10 @@ protected function section_availability_message($section, $canviewhidden) {
if (!$section->visible) {
if ($canviewhidden) {
$o .= $this->courserenderer->availability_info(get_string('hiddenfromstudents'), 'ishidden');
} else {
// We are here because of the setting "Hidden sections are shown in collapsed form".
// Student can not see the section contents but can see its name.
$o .= $this->courserenderer->availability_info(get_string('notavailable'), 'ishidden');
}
} else if (!$section->uservisible) {
if ($section->availableinfo) {
Expand Down Expand Up @@ -769,20 +783,11 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
$course = course_get_format($course)->get_course();

// Can we view the section in question?
if (!($sectioninfo = $modinfo->get_section_info($displaysection))) {
// This section doesn't exist
print_error('unknowncoursesection', 'error', null, $course->fullname);
return;
}

if (!$sectioninfo->uservisible) {
if (!$course->hiddensections) {
echo $this->start_section_list();
echo $this->section_hidden($displaysection, $course->id);
echo $this->end_section_list();
}
// Can't view this section.
return;
if (!($sectioninfo = $modinfo->get_section_info($displaysection)) || !$sectioninfo->uservisible) {
// This section doesn't exist or is not available for the user.
// We actually already check this in course/view.php but just in case exit from this function as well.
print_error('unknowncoursesection', 'error', course_get_url($course),
format_string($course->fullname));
}

// Copy activity clipboard..
Expand Down Expand Up @@ -891,18 +896,12 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
continue;
}
// Show the section if the user is permitted to access it, OR if it's not available
// but there is some available info text which explains the reason & should display.
// but there is some available info text which explains the reason & should display,
// OR it is hidden but the course has a setting to display hidden sections as unavilable.
$showsection = $thissection->uservisible ||
($thissection->visible && !$thissection->available &&
!empty($thissection->availableinfo));
($thissection->visible && !$thissection->available && !empty($thissection->availableinfo)) ||
(!$thissection->visible && !$course->hiddensections);
if (!$showsection) {
// If the hiddensections option is set to 'show hidden sections in collapsed
// form', then display the hidden section message - UNLESS the section is
// hidden by the availability system, which is set to hide the reason.
if (!$course->hiddensections && $thissection->available) {
echo $this->section_hidden($section, $course->id);
}

continue;
}

Expand Down
15 changes: 12 additions & 3 deletions enrol/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ public static function export_user_data(approved_contextlist $contextlist) {
public static function delete_data_for_all_users_in_context(\context $context) {
global $DB;

if (empty($context)) {
return;
}
// Sanity check that context is at the User context level.
if ($context->contextlevel == CONTEXT_COURSE) {
$sql = "SELECT ue.id
Expand Down Expand Up @@ -230,4 +227,16 @@ protected static function delete_user_data(string $sql, array $params) {
$DB->delete_records_select('user_enrolments', "id $sql", $params);
}

/**
* Get the subcontext for export.
*
* @param array $subcontext Any additional subcontext to use.
* @return array The array containing the full subcontext, i.e. [enrolments, subcontext]
*/
public static function get_subcontext(array $subcontext) {
return array_merge(
[get_string('privacy:metadata:user_enrolments', 'core_enrol')],
$subcontext
);
}
}
Loading

0 comments on commit 5a08576

Please sign in to comment.