Commit 762eb128 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1044878: Editing duplicated content"

parents f32aad1f 62d8203a
......@@ -219,8 +219,13 @@ function updateTextContent(a) {
jQuery('#instconf_tagsreadonly_container').removeClass('d-none');
}
jQuery('#instconf_edit_container').removeClass('d-none');
jQuery('#instconf_otherblocksmsg_container').removeClass('d-none');
jQuery('#instconf_edit').trigger('change');
jQuery('#instconf_otherblocksmsg_container').removeClass('d-none');
jQuery('#artefactid_data input.radio').each(function() {
if (jQuery(this).prop('checked')) {
jQuery('#textbox_blockcount').html(jQuery(this).attr('data-count'));
}
});
}
jQuery('#chooseartefactlink').on('click', function(e) {
e.preventDefault();
......@@ -233,7 +238,7 @@ jQuery('#chooseartefactlink').on('click', function(e) {
jQuery('#instconf_artefactid_container').toggleClass('d-none');
jQuery('#instconf_managenotes_container').toggleClass('d-none');
});
jQuery('#instconf #instconf_edit').on('change',function() {
jQuery('#instconf #instconf_edit').on('change',function(){
if (jQuery(this).prop('checked')) {
jQuery('#instconf_textreadonly_container').addClass('d-none');
jQuery('#instconf_text_container').removeClass('d-none');
......@@ -241,7 +246,7 @@ jQuery('#instconf #instconf_edit').on('change',function() {
else {
jQuery('#instconf_textreadonly_container').removeClass('d-none');
jQuery('#instconf_text_container').addClass('d-none');
tinyMCE.get('instconf_text').setContent(jQuery('#instconf_textreadonly_display').html());
tinyMCE.activeEditor.getBody().innerHTML = jQuery('#instconf_textreadonly_display').html();
}
});
jQuery('#instconf a.copytextboxnote').each(function() {
......
......@@ -2030,24 +2030,26 @@ function artefact_get_owner_info($ids) {
$ids
);
$wwwroot = get_config('wwwroot');
foreach ($data as &$d) {
if ($d->institution == 'mahara') {
$name = get_config('sitename');
$url = $wwwroot;
}
else if ($d->institution) {
$name = $d->displayname;;
$url = $wwwroot . 'institution/index.php?institution=' . $d->institution;
}
else if ($d->group) {
$name = $d->groupname;;
$url = group_homepage_url((object) array('id' => $d->group, 'urlid' => $d->groupurlid));
}
else {
$name = display_name($d);
$url = profile_url($d);
if ($data) {
foreach ($data as &$d) {
if ($d->institution == 'mahara') {
$name = get_config('sitename');
$url = $wwwroot;
}
else if ($d->institution) {
$name = $d->displayname;;
$url = $wwwroot . 'institution/index.php?institution=' . $d->institution;
}
else if ($d->group) {
$name = $d->groupname;;
$url = group_homepage_url((object)array('id' => $d->group, 'urlid' => $d->groupurlid));
}
else {
$name = display_name($d);
$url = profile_url($d);
}
$d = (object)array('name' => $name, 'url' => $url);
}
$d = (object) array('name' => $name, 'url' => $url);
}
return $data;
}
......
......@@ -3506,12 +3506,14 @@ class View {
if (!empty($data['ownerinfo'])) {
require_once(get_config('docroot') . 'artefact/lib.php');
$userid = ($group || $institution) ? null : $USER->get('id');
foreach (artefact_get_owner_info(array_keys($artefacts)) as $k => $v) {
if ($artefacts[$k]->owner !== $userid
|| $artefacts[$k]->group !== $group
|| $artefacts[$k]->institution !== $institution) {
$artefacts[$k]->ownername = $v->name;
$artefacts[$k]->ownerurl = $v->url;
if (artefact_get_owner_info(array_keys($artefacts))) {
foreach (artefact_get_owner_info(array_keys($artefacts)) as $k => $v) {
if ($artefacts[$k]->owner !== $userid
|| $artefacts[$k]->group !== $group
|| $artefacts[$k]->institution !== $institution) {
$artefacts[$k]->ownername = $v->name;
$artefacts[$k]->ownerurl = $v->url;
}
}
}
}
......@@ -3523,10 +3525,16 @@ class View {
$artefact = call_static_method($blocktypeclass, 'artefactchooser_get_element_data', $artefact);
}
$artefact->blockcount = 0;
if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefact->id)) {
$blocks = array_unique($blocks);
$artefact->blockcount = count($blocks);
}
// Build the radio button or checkbox for the artefact
$formcontrols = '';
if ($selectone) {
$formcontrols .= '<input type="radio" class="radio" id="' . hsc($elementname . '_' . $artefact->id)
$formcontrols .= '<input type="radio" class="radio" data-count="' . $artefact->blockcount . '" id="' . hsc($elementname . '_' . $artefact->id)
. '" name="' . hsc($elementname) . '" value="' . hsc($artefact->id) . '"';
if ($value == $artefact->id) {
$formcontrols .= ' checked="checked"';
......
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