function report_customsql_print_reports($reports, $courseid = null) { global $CFG, $OUTPUT; // DWE Edited By David Elliott on 27-4-2015 // to view assigned reports to teachers // check admin or not - start if (is_siteadmin()) { $context = context_system::instance(); $canedit = has_capability('report/customsql:definequeries', $context); $capabilities = report_customsql_capability_options(); } else { // Set context for teachers $context = get_context_instance(CONTEXT_COURSE, $courseid); $canedit = ''; $capabilities = ''; } // End foreach ($reports as $report) { if (!empty($report->capability) && !has_capability($report->capability, $context)) { continue; } echo html_writer::start_tag('p'); // DWE - David Elliott - passing course id with the url for checking context of the teacher - 27-4-2015 echo html_writer::tag('a', format_string($report->displayname), array('href' => report_customsql_url('view.php?id=' . $report->id . '&cid=' . $courseid))) . ' ' . report_customsql_time_note($report, 'span'); if ($canedit) { $imgedit = html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('t/edit'), 'class' => 'iconsmall', 'alt' => get_string('edit'))); $imgdelete = html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('t/delete'), 'class' => 'iconsmall', 'alt' => get_string('delete'))); echo ' ' . html_writer::tag('span', get_string('availableto', 'report_customsql', $capabilities[$report->capability]), array('class' => 'admin_note')) . ' ' . html_writer::tag('a', $imgedit, array('title' => get_string('editthisreport', 'report_customsql'), 'href' => report_customsql_url('edit.php?id=' . $report->id))) . ' ' . html_writer::tag('a', $imgdelete, array('title' => get_string('deletethisreport', 'report_customsql'), 'href' => report_customsql_url('delete.php?id=' . $report->id))); } echo html_writer::end_tag('p'); echo "\n"; } }
/** * display the rports * @param object $reports, the result of DB query * @param string $type, type of report (manual, daily, weekly or monthly) */ function report_customsql_print_reports_for($reports, $type) { global $OUTPUT; if (empty($reports)) { return; } if (!empty($type)) { $help = html_writer::tag('span', $OUTPUT->help_icon($type . 'header', 'report_customsql')); echo $OUTPUT->heading(get_string($type . 'header', 'report_customsql') . $help, 3); } $context = context_system::instance(); $canedit = has_capability('report/customsql:definequeries', $context); $capabilities = report_customsql_capability_options(); foreach ($reports as $report) { if (!empty($report->capability) && !has_capability($report->capability, $context)) { continue; } echo html_writer::start_tag('p'); echo html_writer::tag('a', format_string($report->displayname), array('href' => report_customsql_url('view.php?id=' . $report->id))) . ' ' . report_customsql_time_note($report, 'span'); if ($canedit) { $imgedit = html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('t/edit'), 'class' => 'iconsmall', 'alt' => get_string('edit'))); $imgdelete = html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('t/delete'), 'class' => 'iconsmall', 'alt' => get_string('delete'))); echo ' ' . html_writer::tag('span', get_string('availableto', 'report_customsql', $capabilities[$report->capability]), array('class' => 'admin_note')) . ' ' . html_writer::tag('a', $imgedit, array('title' => get_string('editthisreport', 'report_customsql'), 'href' => report_customsql_url('edit.php?id=' . $report->id))) . ' ' . html_writer::tag('a', $imgdelete, array('title' => get_string('deletethisreport', 'report_customsql'), 'href' => report_customsql_url('delete.php?id=' . $report->id))); } echo html_writer::end_tag('p'); echo "\n"; } }
if (validateUrlSyntax($value, 's+H?S?F?E?u-P-a?I?p?f?q?r?')) { $rowdata[] = '<a href="' . $value . '">' . $value . '</a>'; } else { $rowdata[] = $value; } } $table->data[] = $rowdata; $count += 1; } fclose($handle); print_table($table); echo "<br/>" . get_string('recordcount', 'report_customsql') . " = {$count}<br/>"; if ($count >= REPORT_CUSTOMSQL_MAX_RECORDS) { echo '<p class="admin_note">' . get_string('recordlimitreached', 'report_customsql', REPORT_CUSTOMSQL_MAX_RECORDS) . '</p>'; } echo report_customsql_time_note($report, 'p'); echo '<p><a href="' . report_customsql_url('download.php?id=' . $id . '&timestamp=' . $cvstimestamp) . '">' . get_string('downloadthisreportascsv', 'report_customsql') . '</a></p>'; $archivetimes = report_customsql_get_archive_times($report); if (count($archivetimes) > 1) { print_heading(get_string('archivedversions', 'report_customsql'), '', 3); echo '<ul>'; foreach ($archivetimes as $time) { $formattedtime = userdate($time, get_string('strftimedate')); echo '<li>'; if ($time == $cvstimestamp) { echo '<b>' . $formattedtime . '</b>'; } else { echo '<a href="' . report_customsql_url('view.php?id=' . $id . '&timestamp=' . $time) . '">' . $formattedtime . '</a>'; } echo '</li>'; }
function report_customsql_print_reports($reports) { global $CFG; $context = get_context_instance(CONTEXT_SYSTEM); $canedit = has_capability('report/customsql:definequeries', $context); $capabilities = report_customsql_capability_options(); foreach ($reports as $report) { if (!empty($report->capability) && !has_capability($report->capability, $context)) { continue; } echo '<p><span class="reporttitle" style="background-color:HoneyDew;font-size:1.3em;"><a href="' . report_customsql_url('view.php?id=' . $report->id) . '">' . format_string($report->displayname) . '</a></span> '; if ($canedit) { echo ' <a title="' . get_string('editthisreport', 'report_customsql') . '" href="' . report_customsql_url('edit.php?id=' . $report->id) . '"><img src="' . $CFG->pixpath . '/t/edit.gif" class="iconsmall" alt="' . get_string('edit') . '" /></a>'; echo ' <a title="' . get_string('deletethisreport', 'report_customsql') . '" href="' . report_customsql_url('delete.php?id=' . $report->id) . '"><img src="' . $CFG->pixpath . '/t/delete.gif" class="iconsmall" alt="' . get_string('delete') . '" /></a>'; echo ' <br/><span class="admin_note">' . get_string('availableto', 'report_customsql', $capabilities[$report->capability]) . '</span>'; } echo '<br/>' . report_customsql_time_note($report, 'span'); echo "</p>\n"; } }
$rowdata[] = '<a href="' . $value . '">' . $value . '</a>'; } else { $rowdata[] = $value; } } $table->data[] = $rowdata; $count += 1; } fclose($handle); echo html_writer::table($table); if ($count >= REPORT_CUSTOMSQL_MAX_RECORDS) { echo html_writer::tag('p', get_string('recordlimitreached', 'report_customsql', REPORT_CUSTOMSQL_MAX_RECORDS), array('class' => 'admin_note')); } // DWE Edited by David Elliott on 28-4-2015 //Passing course id as parameter to check context for teachers echo report_customsql_time_note($report, 'p') . html_writer::start_tag('p') . html_writer::tag('a', get_string('downloadthisreportascsv', 'report_customsql'), array('href' => new moodle_url(report_customsql_url('download.php'), array('id' => $id, 'timestamp' => $csvtimestamp, 'cid' => $cid)))) . html_writer::end_tag('p'); $archivetimes = report_customsql_get_archive_times($report); if (count($archivetimes) > 1) { echo $OUTPUT->heading(get_string('archivedversions', 'report_customsql'), 3) . html_writer::start_tag('ul'); foreach ($archivetimes as $time) { $formattedtime = userdate($time, get_string('strftimedate')); echo html_writer::start_tag('li'); if ($time == $csvtimestamp) { echo html_writer::tag('b', $formattedtime); } else { echo html_writer::tag('a', $formattedtime, array('href' => new moodle_url(report_customsql_url('view.php'), array('id' => $id, 'timestamp' => $time)))); } echo '</li>'; } echo html_writer::end_tag('ul'); }