See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This file contains the form definition for discussion export. 19 * 20 * @package mod_forum 21 * @copyright 2019 Simey Lameze <simey@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace mod_forum\form; 26 27 defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); 28 29 require_once($CFG->dirroot.'/mod/forum/lib.php'); 30 require_once($CFG->libdir.'/formslib.php'); 31 32 /** 33 * Export discussion form. 34 * 35 * @package mod_forum 36 * @copyright 2019 Simey Lameze <simey@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL Juv3 or later 38 */ 39 class export_form extends \moodleform { 40 41 /** 42 * Define the form - called by parent constructor 43 */ 44 public function definition() { 45 $mform = $this->_form; 46 $forum = $this->_customdata['forum']; 47 48 $mform->addElement('hidden', 'id'); 49 $mform->setType('id', PARAM_INT); 50 $mform->setDefault('id', $forum->get_id()); 51 52 $options = [ 53 'ajax' => 'mod_forum/form-user-selector', 54 'multiple' => true, 55 'noselectionstring' => get_string('allusers', 'mod_forum'), 56 'courseid' => $forum->get_course_id(), 57 'valuehtmlcallback' => function($value) { 58 global $OUTPUT; 59 60 $allusernames = get_all_user_name_fields(true); 61 $fields = 'id, ' . $allusernames; 62 $user = \core_user::get_user($value, $fields); 63 $useroptiondata = [ 64 'fullname' => fullname($user), 65 ]; 66 return $OUTPUT->render_from_template('mod_forum/form-user-selector-suggestion', $useroptiondata); 67 } 68 ]; 69 $mform->addElement('autocomplete', 'useridsselected', get_string('users'), [], $options); 70 71 // Get the discussions on this forum. 72 $vaultfactory = \mod_forum\local\container::get_vault_factory(); 73 $discussionvault = $vaultfactory->get_discussion_vault(); 74 $discussions = array_map(function($discussion) { 75 return $discussion->get_name(); 76 }, $discussionvault->get_all_discussions_in_forum($forum)); 77 $options = [ 78 'multiple' => true, 79 'noselectionstring' => get_string('alldiscussions', 'mod_forum'), 80 ]; 81 $mform->addElement('autocomplete', 'discussionids', get_string('discussions', 'mod_forum'), $discussions, $options); 82 83 // Date fields. 84 $mform->addElement('date_time_selector', 'from', get_string('postsfrom', 'mod_forum'), 85 ['optional' => true]); 86 $mform->addElement('date_time_selector', 'to', get_string('poststo', 'mod_forum'), 87 ['optional' => true]); 88 89 // Export formats. 90 $formats = \core_plugin_manager::instance()->get_plugins_of_type('dataformat'); 91 $options = []; 92 foreach ($formats as $format) { 93 $options[$format->name] = $format->displayname; 94 } 95 $mform->addElement('select', 'format', 'Format', $options); 96 97 $mform->addElement('header', 'optionsheader', get_string('exportoptions', 'mod_forum')); 98 99 $mform->addElement('checkbox', 'striphtml', '', get_string('exportstriphtml', 'mod_forum')); 100 $mform->addHelpButton('striphtml', 'exportstriphtml', 'mod_forum'); 101 102 $mform->addElement('checkbox', 'humandates', '', get_string('exporthumandates', 'mod_forum')); 103 $mform->addHelpButton('humandates', 'exporthumandates', 'mod_forum'); 104 105 $this->add_action_buttons(true, get_string('export', 'mod_forum')); 106 } 107 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body