$table->width = '98%'; foreach ($vmoodles as $vmoodle) { $vmoodlecheck = '<input type="checkbox" name="vmoodleids[]" value="' . $vmoodle->id . '" />'; $vmoodlecmd = ''; $editurl = new moodle_url('/local/vmoodle/view.php', array('view' => 'management', 'what' => 'edit', 'id' => $vmoodle->id)); $vmoodlecmd .= '<a href="' . $editurl . '"><img src="' . $OUTPUT->pix_url('t/edit', 'core') . '" title="' . get_string('edithost', 'local_vmoodle') . '" /></a>'; if ($vmoodle->enabled == 1) { $deleteurl = new moodle_url('/local/vmoodle/view.php', array('view' => 'management', 'what' => 'delete', 'id' => $vmoodle->id)); $vmoodlecmd .= ' <a href="' . $deleteurl . '" onclick="return confirm(\'' . get_string('confirmdelete', 'local_vmoodle') . '\');"><img src="' . $OUTPUT->pix_url('t/delete') . '" title="' . get_string('deletehost', 'local_vmoodle') . '" /></a>'; } else { $fulldeleteurl = new moodle_url('/local/vmoodle/view.php', array('view' => 'management', 'what' => 'fulldelete', 'id' => $vmoodle->id)); $vmoodlecmd .= ' <a href="' . $fulldemeteurl . '" onclick="return confirm(\'' . get_string('confirmfulldelete', 'local_vmoodle') . '\');"><img src="' . $OUTPUT->pix_url('t/delete') . '" title="' . get_string('fulldeletehost', 'local_vmoodle') . '" /></a>'; } $nsapshoturl = new moodle_url('/local/vmoodle/view.php', array('view' => 'management', 'what' => 'snapshot', 'wwwroot' => $vmoodle->vhostname)); $vmoodlecmd .= ' <a href="' . $snapshoturl . '"><img src="' . $OUTPUT->pix_url('snapshot', 'local_vmoodle') . '" title="' . get_string('snapshothost', 'local_vmoodle') . '" /></a>'; $vmoodlestatus = vmoodle_print_status($vmoodle, true); $strmnet = $vmoodle->mnet; if ($strmnet < 0) { $strmnet = get_string('mnetdisabled', 'local_vmoodle'); } elseif ($strmnet == 0) { $strmnet = get_string('mnetfree', 'local_vmoodle'); } $vmoodleurl = new moodle_url('/auth/mnet/jump.php', array('hostwwwroot' => urlencode($vmoodle->vhostname))); $vmoodlelnk = '<a href="' . $vmoodleurl . '" target="_blank" >' . $vmoodle->name . '</a>'; $hostlnk = '<a href="' . $vmoodle->vhostname . '" target="_blank">' . $vmoodle->vhostname . '</a>'; $crongap = $vmoodle->lastcrongap > DAYSECS ? '<span style="color:red">' . $vmoodle->lastcrongap . ' s.</span>' : $vmoodle->lastcrongap . ' s.'; $table->data[] = array($vmoodlecheck, $vmoodlelnk, $hostlnk, $vmoodlestatus, $strmnet, $vmoodle->croncount, userdate($vmoodle->lastcron), $crongap, $vmoodlecmd); } $returnurl = new moodle_url('/local/vmoodle/view.php', array('view' => $view, 'what' => $action)); echo '<center>'; echo '<p>' . $OUTPUT->paging_bar($totalcount, $page, $perpage, $returnurl, 'vpage') . '</p>';
/** * Return status for all defined virtual moodles. * @return string Status for all defined virtual moodles. */ private function _print_status() { global $DB; // Initializing $str = ''; // Getting virtual moodles $vmoodles = $DB->get_records('local_vmoodle'); // Creating table if ($vmoodles) { $str = '<table>'; foreach ($vmoodles as $vmoodle) { $str .= '<tr><td><a href="' . $vmoodle->vhostname . '" target="_blank">' . $vmoodle->shortname . ' - ' . $vmoodle->name . '</a></td><td>' . vmoodle_print_status($vmoodle, true) . '</td></tr>'; } $str .= '</table>'; } // Returning table return $str; }