/** * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually. * * @param core_plugin_manager $pluginman * @param \core\plugininfo\base $pluginfo * @param progress_trace_buffer $progress * @return string */ public function plugin_uninstall_results_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, progress_trace_buffer $progress) { $output = ''; $pluginname = $pluginfo->component; $output .= $this->output->header(); $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname))); $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage'); $output .= $this->output->box(get_string('uninstalldelete', 'core_plugin', array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete'); $output .= $this->output->continue_button(new moodle_url('/admin/index.php')); $output .= $this->output->footer(); return $output; }
public function test_combined_progres_trace() { $this->resetAfterTest(false); $trace1 = new progress_trace_buffer(new html_progress_trace(), false); $trace2 = new progress_trace_buffer(new text_progress_trace(), false); $trace = new combined_progress_trace(array($trace1, $trace2)); $trace->output('do'); $trace->output('re', 1); $trace->output('mi', 2); $trace->finished(); $this->assertSame("<p>do</p>\n<p>  re</p>\n<p>    mi</p>\n", $trace1->get_buffer()); $this->assertSame("do\n re\n mi\n", $trace2->get_buffer()); $this->expectOutputString(''); }
/** * Execute synchronisation. * @param progress_trace * @return int exit code, 0 means ok, 2 means plugin disabled */ public function sync(progress_trace $trace) { if (!enrol_is_enabled('flatfile')) { return 2; } $mailadmins = $this->get_config('mailadmins', 0); if ($mailadmins) { $buffer = new progress_trace_buffer(new text_progress_trace(), false); $trace = new combined_progress_trace(array($trace, $buffer)); } $processed = false; $processed = $this->process_file($trace) || $processed; $processed = $this->process_buffer($trace) || $processed; $processed = $this->process_expirations($trace) || $processed; if ($processed and $mailadmins) { if ($log = $buffer->get_buffer()) { $eventdata = new stdClass(); $eventdata->modulename = 'moodle'; $eventdata->component = 'enrol_flatfile'; $eventdata->name = 'flatfile_enrolment'; $eventdata->userfrom = get_admin(); $eventdata->userto = get_admin(); $eventdata->subject = 'Flatfile Enrolment Log'; $eventdata->fullmessage = $log; $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; $eventdata->smallmessage = ''; message_send($eventdata); } $buffer->reset_buffer(); } return 0; }
/** * Output the results. * * @param int $total total courses. * @param int $created count of courses created. * @param int $updated count of courses updated. * @param int $deleted count of courses deleted. * @param int $errors count of errors. * @return void */ public function results($total, $created, $updated, $deleted, $errors) { if ($this->outputmode == self::NO_OUTPUT) { return; } $message = array(get_string('coursestotal', 'tool_uploadcourse', $total), get_string('coursescreated', 'tool_uploadcourse', $created), get_string('coursesupdated', 'tool_uploadcourse', $updated), get_string('coursesdeleted', 'tool_uploadcourse', $deleted), get_string('courseserrors', 'tool_uploadcourse', $errors)); if ($this->outputmode == self::OUTPUT_PLAIN) { foreach ($message as $msg) { $this->buffer->output($msg); } } else { if ($this->outputmode == self::OUTPUT_HTML) { $buffer = new progress_trace_buffer(new html_list_progress_trace()); foreach ($message as $msg) { $buffer->output($msg); } $buffer->finished(); } } }
/** * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually. * * @param plugin_manager $pluginman * @param plugin_info $pluginfo * @param progress_trace_buffer $progress * @return string */ public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) { $output = ''; $pluginname = $pluginman->plugin_name($pluginfo->component); $output .= $this->output->header(); $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname))); $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage'); $output .= $this->output->box(get_string('uninstalldelete', 'core_plugin', array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete'); $output .= $this->output->continue_button($this->page->url); $output .= $this->output->footer(); return $output; }
/** * Start the output. * * @return void */ public function start() { if ($this->outputmode == self::NO_OUTPUT) { return; } if ($this->outputmode == self::OUTPUT_CLI) { switch ($this->mode) { case tool_coursearchiver_processor::MODE_COURSELIST: $this->buffer->output("\n\n" . str_repeat('-', 50)); $this->buffer->output("Search Results"); $this->buffer->output(sprintf($this->maskcourses, 'Status', 'ID', 'Shortname', 'Fullname', 'Last Use')); break; case tool_coursearchiver_processor::MODE_GETEMAILS: $this->buffer->output("\n\n" . str_repeat('-', 50)); $this->buffer->output("Course Owners"); $this->buffer->output(sprintf($this->maskusers, 'Firstname', 'Lastname', 'Email')); break; case tool_coursearchiver_processor::MODE_HIDE: case tool_coursearchiver_processor::MODE_ARCHIVE: case tool_coursearchiver_processor::MODE_HIDEEMAIL: case tool_coursearchiver_processor::MODE_ARCHIVEEMAIL: break; } } else { if ($this->outputmode == self::OUTPUT_HTML) { switch ($this->mode) { case tool_coursearchiver_processor::MODE_COURSELIST: $style = '<style> .fitemtitle { width: auto !important; } .felement { margin: 0 !important; display: inline; } th .fitem { display: inline-block; } </style>'; $this->mform->addElement('html', $style . html_writer::start_tag('table', array('style' => 'width:100%')) . html_writer::start_tag('tr', array('style' => 'text-align:left;')) . html_writer::tag('th', get_string('outselected', 'tool_coursearchiver'), array('style' => 'width:10%;text-align:center;')) . html_writer::tag('th', get_string('outid', 'tool_coursearchiver'), array('style' => 'width:10%')) . html_writer::tag('th', get_string('outfullname', 'tool_coursearchiver'), array('style' => 'width:38%')) . html_writer::tag('th', get_string('outshortname', 'tool_coursearchiver'), array('style' => 'width:22%')) . html_writer::tag('th', get_string('outidnumber', 'tool_coursearchiver'), array('style' => 'width:10%')) . html_writer::tag('th', get_string('outaccess', 'tool_coursearchiver'), array('style' => 'width:10%;text-align:center;')) . html_writer::end_tag('tr') . html_writer::end_tag('table')); break; case tool_coursearchiver_processor::MODE_GETEMAILS: $style = '<style> .fitemtitle { width: auto !important; } .felement { margin: 0 !important; display: inline; } th .fitem { display: inline-block; } .courseheader td { background-color: #F5F5F5; color: #7D7D7D; padding: 10px; } </style>'; $this->mform->addElement('html', $style . html_writer::start_tag('table', array('style' => 'width:100%')) . html_writer::start_tag('tr', array('style' => 'text-align:left;')) . html_writer::tag('th', get_string('outselected', 'tool_coursearchiver'), array('style' => 'width:10%;text-align:center;')) . html_writer::tag('th', get_string('outemail', 'tool_coursearchiver'), array('style' => 'width:40%')) . html_writer::tag('th', get_string('outfirstname', 'tool_coursearchiver'), array('style' => 'width:15%')) . html_writer::tag('th', get_string('outlastname', 'tool_coursearchiver')) . html_writer::end_tag('tr') . html_writer::end_tag('table')); break; case tool_coursearchiver_processor::MODE_HIDE: $buffer = new progress_trace_buffer(new text_progress_trace()); $buffer->output('<h3>Hiding selected courses</h3><div style="margin-bottom: 60px;"></div><br />'); $buffer->finished(); break; case tool_coursearchiver_processor::MODE_ARCHIVE: $buffer = new progress_trace_buffer(new text_progress_trace()); $buffer->output('<h3>Archiving selected courses</h3><div style="margin-bottom: 60px;"></div><br />'); $buffer->finished(); break; case tool_coursearchiver_processor::MODE_HIDEEMAIL: case tool_coursearchiver_processor::MODE_ARCHIVEEMAIL: $buffer = new progress_trace_buffer(new text_progress_trace()); $buffer->output('<h3>Sending Emails</h3><div style="margin-bottom: 60px;"></div><br />'); $buffer->finished(); break; } } } }