MDL-40052 events: Add get_url() api to various report content_viewed classes
authorAnkit Agarwal <ankit@moodle.com>
Tue, 20 Aug 2013 03:14:17 +0000 (11:14 +0800)
committerDamyon Wiese <damyon@moodle.com>
Tue, 27 Aug 2013 07:26:38 +0000 (15:26 +0800)
report/log/classes/event/content_viewed.php
report/loglive/classes/event/content_viewed.php
report/outline/classes/event/content_viewed.php
report/participation/classes/event/content_viewed.php
report/stats/classes/event/content_viewed.php

index 47f1ded..b8c6bf4 100644 (file)
@@ -31,5 +31,17 @@ namespace report_log\event;
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class content_viewed extends \core\event\content_viewed {
+
+    /**
+     * Returns relevant URL.
+     * 
+     * @return \moodle_url
+     */
+    public function get_url() {
+        if (!empty($this->other['url'])) {
+            return new \moodle_url($this->other['url']);
+        }
+        return new \moodle_url('report/log/index.php', array('id' => $this->courseid));
+    }
 }
 
index b27c469..1038322 100644 (file)
@@ -31,5 +31,17 @@ namespace report_loglive\event;
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class content_viewed extends \core\event\content_viewed {
+
+    /**
+     * Returns relevant URL.
+     *
+     * @return \moodle_url
+     */
+    public function get_url() {
+        if (!empty($this->other['url'])) {
+            return new \moodle_url($this->other['url']);
+        }
+        return new \moodle_url('report/loglive/index.php', array('id' => $this->courseid));
+    }
 }
 
index f59ed1e..97f1b0d 100644 (file)
@@ -31,5 +31,17 @@ namespace report_outline\event;
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class content_viewed extends \core\event\content_viewed {
+
+    /**
+     * Returns relevant URL.
+     *
+     * @return \moodle_url
+     */
+    public function get_url() {
+        if (!empty($this->other['url'])) {
+            return new \moodle_url($this->other['url']);
+        }
+        return new \moodle_url('report/outline/index.php', array('id' => $this->courseid));
+    }
 }
 
index 495b1ff..1702628 100644 (file)
@@ -31,5 +31,17 @@ namespace report_participation\event;
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class content_viewed extends \core\event\content_viewed {
+
+    /**
+     * Returns relevant URL.
+     *
+     * @return \moodle_url
+     */
+    public function get_url() {
+        if (!empty($this->other['url'])) {
+            return new \moodle_url($this->other['url']);
+        }
+        return new \moodle_url('report/participation/index.php', array('id' => $this->courseid));
+    }
 }
 
index 374e284..e29544c 100644 (file)
@@ -31,5 +31,17 @@ namespace report_stats\event;
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class content_viewed extends \core\event\content_viewed {
+
+    /**
+     * Returns relevant URL.
+     *
+     * @return \moodle_url
+     */
+    public function get_url() {
+        if (!empty($this->other['url'])) {
+            return new \moodle_url($this->other['url']);
+        }
+        return new \moodle_url('report/stats/index.php', array('id' => $this->courseid));
+    }
 }