<?php
/**
* Report controller
*
* @author Mark Nielsen
* @version $Id$
* @package blocks/helloworld
*/
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
/**
* Default screen
*/
public function view_action() {
global $CFG, $COURSE;
#### DEMO CODE ####
require_once($CFG->dirroot.'/blocks/helloworld/report/users.php');
$report = new blocks_helloworld_report_users($this->url, $COURSE->id);
$output = $this->mroutput->render($report);
// Alternative syntax...
// $output = $this->mroutput->render(
// new blocks_helloworld_report_users($this->url, $COURSE->id)
// );
#### DEMO CODE ####
return $this->output->heading('Demo of mr_report_abstract').
$this->helper->highlight(__CLASS__, __FUNCTION__, true).
$output;
}
/**
* Report JSON endpoint
*/
public function autocomplete_action() {
global $DB;
$query = required_param('query', PARAM_TEXT);
$json = new stdClass;
$json->results = $DB->get_records_select('user', 'username LIKE ?', array("%$query%"), 'username', 'id, username AS text');
$json->results =
array_values($json->results); // Makes proper JSON
die;
}
}