From 27fe9e412b8135638c9298e38e6fcca3094cc53e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 11 Mar 2018 22:31:15 +0400 Subject: Fixed table in the latest version of Moodle Signed-off-by: Valentin Popov --- classes/webhooks_table.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'classes/webhooks_table.php') diff --git a/classes/webhooks_table.php b/classes/webhooks_table.php index 9598e8d..3e97a17 100644 --- a/classes/webhooks_table.php +++ b/classes/webhooks_table.php @@ -24,6 +24,8 @@ defined("MOODLE_INTERNAL") || die(); +require_once(__DIR__ . "/../lib.php"); + require_once($CFG->libdir . "/tablelib.php"); /** @@ -58,11 +60,24 @@ class local_webhooks_table extends table_sql { $this->define_table_configs(); } + /** + * Query the database for results to display in the table. + * + * @param number $pagesize + * @param boolean $useinitialsbar + */ + public function query_db($pagesize, $useinitialsbar = false) { + $listrecords = local_webhooks_get_list_records(); + $total = count($listrecords); + + $this->pagesize($pagesize, $total); + $this->rawdata = local_webhooks_get_list_records($this->get_page_start(), $this->get_page_size()); + } + /** * Defines the basic settings of the table. */ public function define_table_configs() { - $this->set_sql("*", "{local_webhooks_service}", "1"); $this->collapsible(false); $this->is_downloadable(false); $this->no_sorting("actions"); @@ -124,11 +139,16 @@ class local_webhooks_table extends table_sql { * Specifies the display of a column with events. * * @param object $row Data from the database. - * @return string Displayed data. + * @return number Displayed data. */ public function col_events($row) { - $eventlist = local_webhooks_deserialization_data($row->events); - return count($eventlist); + $result = 0; + + if (!empty($row->events)) { + $result = count($row->events); + } + + return $result; } /** -- cgit v1.2.3