Commit 1c59266f authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge changes I5441c05e,I3c2a6505

* changes:
  Don't show the "leave feedback" link to logged-out users
  Annotation feedback JS shouldn't rely on window's URL path.
parents 598e09b0 7ab38a32
......@@ -227,49 +227,44 @@ function connectAddAnnotationFeedbackForms() {
}
function connectAnnotationFeedbackLinks() {
if (window.location.pathname == '/view/view.php') {
// The annotation feedback link is only the view page.
$j(function() {
var links = getElementsByTagAndClassName('a', 'annotationfeedbacklink');
forEach(links, function(link) {
var idprefix = 'annotation_feedback_link_';
if (getNodeAttribute(link, 'id').substring(0, idprefix.length) == idprefix) {
if ($(link)) {
disconnectAll(link);
connect(link, 'onclick', function(e) {
var blockid = getNodeAttribute(link, 'id').substring(idprefix.length);
var chtml = $j('#annotationfeedbacktable_' + blockid).parent();
// Add a 'close' link at the bottom of the list for convenience.
if ($j('#closer_' + blockid).length == 0) {
var closer = $j('<a id="closer_' + blockid + '" href="#" class="close-link">Close</a>').click(function(e) {
$j(this).parent().toggle(400, function() {
link.focus();
});
e.preventDefault();
});
chtml.append(closer);
}
var links = getElementsByTagAndClassName('a', 'annotationfeedbacklink');
forEach(links, function(link) {
var idprefix = 'annotation_feedback_link_';
if (getNodeAttribute(link, 'id').substring(0, idprefix.length) == idprefix) {
chtml.toggle(400, function() {
if (chtml.is(':visible')) {
chtml.find('a').first().focus();
}
else {
link.focus();
}
});
if ($(link)) {
disconnectAll(link);
connect(link, 'onclick', function(e) {
var blockid = getNodeAttribute(link, 'id').substring(idprefix.length);
var chtml = $j('#annotationfeedbacktable_' + blockid).parent();
// Add a 'close' link at the bottom of the list for convenience.
if ($j('#closer_' + blockid).length == 0) {
var closer = $j('<a id="closer_' + blockid + '" href="#" class="close-link">Close</a>').click(function(e) {
$j(this).parent().toggle(400, function() {
link.focus();
});
e.preventDefault();
});
chtml.append(closer);
}
}
});
});
}
chtml.toggle(400, function() {
if (chtml.is(':visible')) {
chtml.find('a').first().focus();
}
else {
link.focus();
}
});
e.preventDefault();
});
}
}
});
}
addLoadEvent(connectAddAnnotationFeedbackForms);
addLoadEvent(connectAnnotationFeedbackLinks);
......
......@@ -941,6 +941,7 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
* @param bool $editing Whether we are view edit mode or not
*/
public function get_annotation_feedback_for_view($annotationartefact, $view, $blockid, $html = true, $editing = false) {
global $USER;
if (!is_object($annotationartefact) || !is_object($view)) {
throw new MaharaException(get_string('annotationinformationerror', 'artefact.annotation'));
}
......@@ -972,7 +973,7 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
$smarty->assign('annotationfeedbackcount', $annotationfeedbackcount);
$smarty->assign('annotationfeedback', $annotationfeedback);
$smarty->assign('editing', $editing);
$smarty->assign('allowfeedback', $annotationartefact->get('allowcomments'));
$smarty->assign('allowfeedback', $USER->is_logged_in() && $annotationartefact->get('allowcomments'));
$render = $smarty->fetch('artefact:annotation:annotationfeedbackview.tpl');
return array($annotationfeedbackcount, $render);
}
......
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