Skip to content

Commit

Permalink
Update to current OU live version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason.Platts committed May 27, 2022
1 parent 9a6370a commit b723f21
Show file tree
Hide file tree
Showing 14 changed files with 259 additions and 100 deletions.
11 changes: 10 additions & 1 deletion amd/build/export.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions amd/build/export.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 61 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ function oublog_clarify_tags($tags) {
}

foreach ($tags as $idx => $tag) {
$tag = core_text::strtolower(trim($tag));
$tag = trim($tag);
if (empty($tag)) {
unset($tags[$idx]);
continue;
Expand Down Expand Up @@ -3398,11 +3398,12 @@ function oublog_can_grade($course, $oublog, $cm, $groupid=0) {
* @param object $masterblog master oublog object.
* @param object $cmmaster course-module object of master blog.
* @param object $coursemaster course object of master blog.
* @param bool $showuseridentityfields show user identity fields.
* @return array user participation
*/
function oublog_get_participation($oublog, $context, $groupid = 0, $cm,
$course, $start = null, $end = null, $sort = 'u.firstname,u.lastname', $masterblog = null, $cmmaster = null,
$coursemaster = null) {
$coursemaster = null, $showuseridentityfields = false) {
global $DB;

// get user objects
Expand All @@ -3417,6 +3418,11 @@ function oublog_get_participation($oublog, $context, $groupid = 0, $cm,
if (empty($users)) {
return array();
}

if ($showuseridentityfields) {
oublog_load_user_identity_data($context, $users);
}

if ($oublog->individual > 0) {
$groupid = 0;
}
Expand Down Expand Up @@ -3508,6 +3514,59 @@ function oublog_get_participation($oublog, $context, $groupid = 0, $cm,
return $users;
}

/**
* Loads the identity fields data for each user.
*
* @param object $context current context
* @param array $users
* @throws coding_exception
* @throws dml_exception
*/
function oublog_load_user_identity_data($context, $users) {
global $DB;

if (empty($users)) {
return;
}

// Get user identity fields.
$extrafields = \core_user\fields::get_identity_fields($context);
if (empty($extrafields)) {
return;
}

$api = \core_user\fields::for_identity($context);
[
'selects' => $selects,
'joins' => $joins,
'params' => $params
] = (array) $api->get_sql('u', true);

$userids = array_map(function($user) {
return $user->id;
}, $users);

list($insql, $inparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
$params = array_merge($params, $inparams);

// Get fields data for users.
$sql = "SELECT u.id $selects
FROM {user} u $joins
WHERE u.id $insql ";
$rows = $DB->get_records_sql($sql, $params);

// Set fields data for users.
foreach ($rows as $row) {
foreach ($users as $user) {
if ($user->id == $row->id) {
foreach ($extrafields as $field) {
$user->$field = $row->$field;
}
}
}
}
}

/**
* Returns user participation to view in userparticipation.php
*
Expand Down
2 changes: 1 addition & 1 deletion mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function get_data() {
$data->introonpost = 0;
}
if (!empty($data->tagslist)) {
$data->tagslist = core_text::strtolower(trim($data->tagslist));
$data->tagslist = trim($data->tagslist);
}
if (empty($data->restricttags)) {
$data->restricttags = 0;
Expand Down
2 changes: 1 addition & 1 deletion participation.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}

$participation = oublog_get_participation($oublog, $context, $groupid, $cm, $course, $start, $end,
'u.firstname,u.lastname', $masterblog, $cmmaster, $coursemaster);
'u.firstname,u.lastname', $masterblog, $cmmaster, $coursemaster, true);
$PAGE->navbar->add(get_string('userparticipation', 'oublog'));
$PAGE->set_title(format_string($oublog->name));
$PAGE->set_heading(format_string($oublog->name));
Expand Down
Loading

0 comments on commit b723f21

Please sign in to comment.