Beispiel #1
0
 /**
  * Validate that dates in table data respect timezones
  */
 public function test_logtablerespectstimezones()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/datahub/lib.php';
     // Force timezone to a particular value.
     set_config('forcetimezone', 10);
     // Time display format for all relevant fields.
     $timeformat = get_string('displaytimeformat', 'local_datahub');
     // Create a test user.
     $this->create_test_user();
     // Create a log record.
     $this->create_db_log();
     // Expected strings.
     $targetstartdisplay = userdate(1000000001, $timeformat, 99, false);
     $startdisplay = userdate(1000000002, $timeformat, 99, false);
     $enddisplay = userdate(1000000003, $timeformat, 99, false);
     // Obtain table data.
     $logs = rlip_get_logs();
     $table = rlip_get_log_table($logs);
     // Validate number of rows.
     $this->assertEquals(count($table->data), 1);
     // Validate time values in row data.
     $datum = reset($table->data);
     $this->assertEquals($datum[4], $targetstartdisplay);
     $this->assertEquals($datum[5], $startdisplay);
     $this->assertEquals($datum[6], $enddisplay);
 }
Beispiel #2
0
require_once '../../config.php';
require_once $CFG->dirroot . '/lib/adminlib.php';
require_once $CFG->dirroot . '/local/datahub/lib.php';
require_once $CFG->dirroot . '/local/datahub/lib/rlip_log_filtering.class.php';
//permissions checking
require_login();
$context = context_system::instance();
require_capability('moodle/site:config', $context);
//page information
$page = optional_param('page', 0, PARAM_INT);
$baseurl = $CFG->wwwroot . '/local/datahub/viewlogs.php';
//header
admin_externalpage_setup('rliplogs');
$PAGE->requires->css('/local/datahub/styles.css');
echo $OUTPUT->header();
//filters
$filtering = new rlip_log_filtering();
list($extrasql, $params) = $filtering->get_sql_filter();
//top paging bar
$numrecords = rlip_count_logs($extrasql, $params);
echo $OUTPUT->paging_bar($numrecords, $page, RLIP_LOGS_PER_PAGE, $baseurl);
$filtering->display_add();
$filtering->display_active();
//display main table
$logs = rlip_get_logs($extrasql, $params, $page);
$table = rlip_get_log_table($logs);
echo rlip_log_table_html($table);
//bottom paging bar
echo $OUTPUT->paging_bar($numrecords, $page, RLIP_LOGS_PER_PAGE, $baseurl);
//footer
echo $OUTPUT->footer();