Beispiel #1
0
 /**
  * Help render mr_report_abstract SQL
  *
  * @param mr_report_abstract $report mr_report_abstract instance
  * @return string
  */
 public function help_render_mr_report_sql(mr_report_abstract $report)
 {
     global $CFG, $USER;
     $output = '';
     $executedsql = $report->get_executedsql();
     $usernames = array('mrsupport', 'mrdev');
     if (!empty($CFG->reportviewsql) and is_array($CFG->reportviewsql)) {
         $usernames = array_merge($usernames, $CFG->reportviewsql);
     }
     if (in_array($USER->username, $usernames) and !empty($executedsql)) {
         $sql = '';
         foreach ($executedsql as $values) {
             list($rawsql, $params) = $values;
             $rawsql = trim($rawsql);
             $sql .= s($rawsql) . "\n\n";
             if (!is_null($params)) {
                 $sql .= s(var_export($params, true)) . "\n\n\n";
             }
         }
         $output = print_collapsible_region($this->output->box('<pre>' . trim($sql) . '</pre>', ''), 'generalbox mr_report_sql', 'mr_report_sql_id', get_string('reportsql', 'local_mr'), 'mr_report_sql_toggle', false, true);
     }
     return $output;
 }