Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

comment MDL-27024 Cleaned up use of undefined property $this->link

  • Loading branch information...
commit d2d4bccec1409257d82885f382765f8399cc6d9a 1 parent eb9d692
@samhemelryk samhemelryk authored
Showing with 28 additions and 13 deletions.
  1. +28 −13 comment/lib.php
View
41 comment/lib.php
@@ -87,6 +87,7 @@ class comment {
private static $comment_area = null;
private static $comment_page = null;
private static $comment_component = null;
+
/**
* Construct function of comment class, initialise
* class members
@@ -265,23 +266,36 @@ private function check_permissions() {
}
/**
+ * Gets a link for this page that will work with JS disabled.
+ *
+ * @global moodle_page $PAGE
+ * @param moodle_page $page
+ * @return moodle_url
+ */
+ public function get_nojslink(moodle_page $page = null) {
+ if ($page === null) {
+ global $PAGE;
+ $page = $PAGE;
+ }
+
+ $link = new moodle_url($page->url, array(
+ 'nonjscomment' => true,
+ 'comment_itemid' => $this->itemid,
+ 'comment_context' => $this->context->id,
+ 'comment_area' => $this->commentarea,
+ ));
+ $link->remove_params(array('nonjscomment', 'comment_page'));
+ return $link;
+ }
+
+ /**
* Prepare comment code in html
* @param boolean $return
* @return mixed
*/
public function output($return = true) {
global $PAGE, $OUTPUT;
- static $template_printed;
-
- $this->link = $PAGE->url;
- $murl = new moodle_url($this->link);
- $murl->remove_params('nonjscomment');
- $murl->param('nonjscomment', 'true');
- $murl->param('comment_itemid', $this->itemid);
- $murl->param('comment_context', $this->context->id);
- $murl->param('comment_area', $this->commentarea);
- $murl->remove_params('comment_page');
- $this->link = $murl->out();
+ static $template_printed;
$options = new stdClass();
$options->client_id = $this->cid;
@@ -319,9 +333,10 @@ public function output($return = true) {
if (!empty($this->viewcap)) {
// print commenting icon and tooltip
$icon = $OUTPUT->pix_url('t/collapsed');
+ $link = $this->get_nojslink($PAGE)->out();
$html .= <<<EOD
<div class="mdl-left">
-<a class="showcommentsnonjs" href="{$this->link}">{$strshowcomments}</a>
+<a class="showcommentsnonjs" href="{$link}">{$strshowcomments}</a>
EOD;
if ($this->env != 'block_comments') {
$html .= <<<EOD
@@ -461,7 +476,7 @@ public function get_pagination($page = 0) {
}
if (!empty(self::$nonjs)) {
// used in non-js interface
- return $OUTPUT->paging_bar($count, $page, $CFG->commentsperpage, $this->link, 'comment_page');
+ return $OUTPUT->paging_bar($count, $page, $CFG->commentsperpage, $this->get_nojslink(), 'comment_page');
} else {
// return ajax paging bar
$str = '';
Please sign in to comment.
Something went wrong with that request. Please try again.