Fixed table in the latest version of Moodle
Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
		@@ -24,6 +24,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
defined("MOODLE_INTERNAL") || die();
 | 
					defined("MOODLE_INTERNAL") || die();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require_once(__DIR__ . "/../lib.php");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require_once($CFG->libdir . "/tablelib.php");
 | 
					require_once($CFG->libdir . "/tablelib.php");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -58,11 +60,24 @@ class local_webhooks_table extends table_sql {
 | 
				
			|||||||
        $this->define_table_configs();
 | 
					        $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.
 | 
					     * Defines the basic settings of the table.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function define_table_configs() {
 | 
					    public function define_table_configs() {
 | 
				
			||||||
        $this->set_sql("*", "{local_webhooks_service}", "1");
 | 
					 | 
				
			||||||
        $this->collapsible(false);
 | 
					        $this->collapsible(false);
 | 
				
			||||||
        $this->is_downloadable(false);
 | 
					        $this->is_downloadable(false);
 | 
				
			||||||
        $this->no_sorting("actions");
 | 
					        $this->no_sorting("actions");
 | 
				
			||||||
@@ -124,11 +139,16 @@ class local_webhooks_table extends table_sql {
 | 
				
			|||||||
     * Specifies the display of a column with events.
 | 
					     * Specifies the display of a column with events.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param  object $row Data from the database.
 | 
					     * @param  object $row Data from the database.
 | 
				
			||||||
     * @return string      Displayed data.
 | 
					     * @return number      Displayed data.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function col_events($row) {
 | 
					    public function col_events($row) {
 | 
				
			||||||
        $eventlist = local_webhooks_deserialization_data($row->events);
 | 
					        $result = 0;
 | 
				
			||||||
        return count($eventlist);
 | 
					
 | 
				
			||||||
 | 
					        if (!empty($row->events)) {
 | 
				
			||||||
 | 
					            $result = count($row->events);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $result;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user