Example #1
0
 /**
  * Constructor
  *
  * @param mr_preferences $preferences Preferences to store paging information
  * @param moodle_url $url Current URL
  */
 public function __construct(mr_preferences $preferences, moodle_url $url)
 {
     $this->url = $url;
     $this->preferences = $preferences;
     $defultperpage = $this->preferences->get($this->REQUEST_PERPAGE, $this->perpage);
     $this->page = optional_param($this->REQUEST_PAGE, 0, PARAM_INT);
     $this->perpage = optional_param($this->REQUEST_PERPAGE, $defultperpage, PARAM_INT);
     // Save for later
     $this->preferences->set($this->REQUEST_PERPAGE, $this->perpage);
 }
Example #2
0
 /**
  * Remove preferences for this filter
  *
  * @param string $name A specific preference to delete, if NULL all are deleted
  * @return mr_html_filter_abstract
  */
 public function preferences_delete($name = NULL)
 {
     if (is_null($name)) {
         $names = array_keys($this->preferences_defaults());
     } else {
         $names = array($name);
     }
     foreach ($names as $name) {
         $this->preferences->delete($name);
     }
     return $this;
 }
Example #3
0
 /**
  * Run the report SQL and retrieve rows for rendering or exporting.
  *
  * This method also sends the export to the browser if the
  * user is exporting the report.
  *
  * @return void
  */
 public function run()
 {
     // Initialize the tables and the filters
     $this->table_init();
     $this->filter_init();
     if ($this->filter instanceof mr_html_filter) {
         $this->filter->set_report($this);
     }
     // Determine if we are doing AJAX
     if (!$this->is_exporting() and $this->config->ajax and $this->preferences->get('forceajax', $this->config->ajaxdefault)) {
         if (optional_param('tjson', 0, PARAM_BOOL)) {
             // Filling on AJAX request
             $this->table_fill();
         }
     } else {
         // Normal fill...
         $this->table_fill();
     }
     // If exporting, send it to the browser
     if ($this->is_exporting()) {
         $this->export->send();
     }
 }
Example #4
0
 /**
  * Store sort and weight based on current settings
  *
  * @return void
  */
 protected function save_sortorder()
 {
     // Store sorting information if necessary
     if ($this->sort != $this->defaultsort) {
         // Sort not the same as default, save
         $this->preferences->set('sort', $this->sort);
     } else {
         // Sort same as default, remove
         $this->preferences->delete('sort');
     }
     if ($this->order != $this->defaultorder) {
         // Order not the same as default, save
         $this->preferences->set('order', $this->order);
     } else {
         // Order same as default, remove
         $this->preferences->delete('order');
     }
 }