See how to extend this class

  1. <?php
  2. /**
  3.  * A report for viewing user accounts
  4.  *
  5.  * @package blocks/helloworld
  6.  * @author Mark Nielsen
  7.  */
  8. class blocks_helloworld_report_users extends mr_report_abstract {
  9.     /**
  10.      * Report's init routine
  11.      *
  12.      * @return void 
  13.      */
  14.     public function init({
  15.         $this->config->set(array(
  16.             'export' => '**',
  17.             'perpage' => true,
  18.             'ajax'    => true,
  19.             'perpageopts' => array('all'151050),
  20.         ));
  21.     }
  22.  
  23.     /**
  24.      * The component string, used for get_string() calls
  25.      *
  26.      * @return string 
  27.      */
  28.     public function get_component({
  29.         return 'block_helloworld';
  30.     }
  31.  
  32.     /**
  33.      * Filter setup
  34.      *
  35.      * @return void 
  36.      */
  37.     public function filter_init({
  38.         $url clone($this->url);
  39.         $url->param('action''autocomplete');
  40.  
  41.         $this->filter new mr_html_filter($this->preferences$this->url);
  42.         $this->filter->new_autocomplete('username'get_string('username')$url);
  43.         $this->filter->new_autocompleteid('userid'get_string('usernamebyid''block_helloworld')$urlfalse'id');
  44.     }
  45.  
  46.     /**
  47.      * Table setup
  48.      *
  49.      * @return void 
  50.      */
  51.     public function table_init({
  52.         $this->table new mr_html_table($this->preferences$this->url'username');
  53.         $this->table->add_column('id'''array('display' => false))
  54.                     ->add_column('username'get_string('username'))
  55.                     ->add_column('firstname'get_string('firstname'))
  56.                     ->add_column('lastname'get_string('lastname'))
  57.                     ->add_column('email'get_string('email'))
  58.                     ->add_column('lastaccess'get_string('lastaccess'))
  59.                     ->add_format('lastaccess''date')
  60.                     ->add_format(array('username''firstname''lastname''email')'string');
  61.     }
  62.  
  63.     /**
  64.      * Report SQL
  65.      */
  66.     public function get_sql($fields$filtersql$filterparams{
  67.         $sql "SELECT $fields
  68.                   FROM {user}
  69.                  WHERE $filtersql";
  70.  
  71.         return array($sql$filterparams);
  72.     }
  73. }

Documentation generated on Thu, 28 Jun 2012 16:33:46 -0700 by phpDocumentor 1.4.3