/** * 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; }
/** * 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; }
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(''); }
/** * 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; }