Файловый менеджер - Редактировать - /home/harasnat/www/mf/export.php.tar
Назад
home/harasnat/www/learning/calendar/export.php 0000604 00000021023 15062106003 0015506 0 ustar 00 <?php ///////////////////////////////////////////////////////////////////////////// // // // NOTICE OF COPYRIGHT // // // // Moodle - Calendar extension // // // // Copyright (C) 2003-2004 Greek School Network www.sch.gr // // // // Designed by: // // Avgoustos Tsinakos (tsinakos@teikav.edu.gr) // // Jon Papaioannou (pj@moodle.org) // // // // Programming and development: // // Jon Papaioannou (pj@moodle.org) // // // // For bugs, suggestions, etc contact: // // Jon Papaioannou (pj@moodle.org) // // // // The current module was developed at the University of Macedonia // // (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) // // The aim of this project is to provide additional and improved // // functionality to the Asynchronous Distance Education service that the // // Greek School Network deploys. // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details: // // // // http://www.gnu.org/copyleft/gpl.html // // // ///////////////////////////////////////////////////////////////////////////// /** * This file is part of the User section Moodle * * @copyright 2003-2004 Jon Papaioannou (pj@moodle.org) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later * @package calendar */ require_once('../config.php'); require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/calendar/lib.php'); if (empty($CFG->enablecalendarexport)) { die('no export'); } $courseid = optional_param('course', SITEID, PARAM_INT); $categoryid = optional_param('category', null, PARAM_INT); $action = optional_param('action', '', PARAM_ALPHA); $day = optional_param('cal_d', 0, PARAM_INT); $mon = optional_param('cal_m', 0, PARAM_INT); $year = optional_param('cal_y', 0, PARAM_INT); $time = optional_param('time', 0, PARAM_INT); $generateurl = optional_param('generateurl', 0, PARAM_BOOL); // If a day, month and year were passed then convert it to a timestamp. If these were passed // then we can assume the day, month and year are passed as Gregorian, as no where in core // should we be passing these values rather than the time. This is done for BC. if (!empty($day) && !empty($mon) && !empty($year)) { if (checkdate($mon, $day, $year)) { $time = make_timestamp($year, $mon, $day); } else { $time = time(); } } else if (empty($time)) { $time = time(); } $url = new moodle_url('/calendar/export.php', array('time' => $time)); $managesubscriptionsurl = new moodle_url('/calendar/managesubscriptions.php'); if ($courseid != SITEID && !empty($courseid)) { // Course ID must be valid and existing. $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $courses = array($course->id => $course); $url->param('course', $course->id); $managesubscriptionsurl->param('course', $course->id); navigation_node::override_active_url(new moodle_url('/course/view.php', ['id' => $course->id])); $PAGE->navbar->add( get_string('calendar', 'calendar'), new moodle_url('/calendar/view.php', ['view' => 'month', 'course' => $course->id]) ); } else { $course = get_site(); $courses = calendar_get_default_courses(); if (!empty($categoryid)) { $managesubscriptionsurl->param('category', $categoryid); navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $categoryid])); $PAGE->set_category_by_id($categoryid); $PAGE->navbar->add( get_string('calendar', 'calendar'), new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $categoryid]) ); } else { $PAGE->navbar->add(get_string('calendar', 'calendar'), new moodle_url('/calendar/view.php', ['view' => 'month'])); } } require_login($course, false); if ($action !== '') { $url->param('action', $action); } $PAGE->set_url($url); $calendar = new calendar_information(0, 0, 0, $time); $calendar->set_sources($course, $courses); $pagetitle = get_string('export', 'calendar'); $PAGE->navbar->add(get_string('managesubscriptions', 'calendar'), $managesubscriptionsurl); $PAGE->navbar->add(get_string('exportcalendar', 'calendar'), $url); // Print title and header. $headingstr = get_string('calendar', 'core_calendar'); $headingstr = ($courseid != SITEID && !empty($courseid)) ? "{$headingstr}: {$COURSE->shortname}" : $headingstr; $PAGE->set_title($course->shortname.': '.get_string('calendar', 'calendar').': '.$pagetitle); $PAGE->set_heading($headingstr); $PAGE->set_pagelayout('standard'); $PAGE->set_secondary_navigation(false); $renderer = $PAGE->get_renderer('core_calendar'); $calendar->add_sidecalendar_blocks($renderer); // Get the calendar type we are using. $calendartype = \core_calendar\type_factory::get_calendar_instance(); $now = $calendartype->timestamp_to_date_array($time); $weekend = CALENDAR_DEFAULT_WEEKEND; if (isset($CFG->calendar_weekend)) { $weekend = intval($CFG->calendar_weekend); } $numberofdaysinweek = $calendartype->get_num_weekdays(); $formdata = array( // Let's populate some vars to let "common tasks" be somewhat smart... // If today it's weekend, give the "next week" option. 'allownextweek' => $weekend & (1 << $now['wday']), // If it's the last week of the month, give the "next month" option. 'allownextmonth' => calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < $numberofdaysinweek, // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option. 'allowthisweek' => !(($weekend & (1 << $now['wday'])) && !($weekend & (1 << (($now['wday'] + 1) % $numberofdaysinweek)))) ); // Disable submit protection so that the submit buttons continue working after being pressed. $exportform = new core_calendar_export_form($FULLME, $formdata, 'POST', '', ['data-double-submit-protection' => 'off']); $calendarurl = ''; if ($data = $exportform->get_data()) { $params = array(); $params['userid'] = $USER->id; $params['authtoken'] = calendar_get_export_token($USER); $params['preset_what'] = $data->events['exportevents']; $params['preset_time'] = $data->period['timeperiod']; $link = new moodle_url('/calendar/export_execute.php', $params); if (!empty($data->generateurl)) { $exporturlcontext = ['calendarexporturl' => $link->out(false)]; $exporturl = $OUTPUT->render_from_template('core_calendar/export_calendar_url', $exporturlcontext); $calendarurl = html_writer::div($exporturl, 'generalbox calendarurl mt-3'); } if (!empty($data->export)) { redirect($link); } } echo $OUTPUT->header(); echo $renderer->start_layout(); echo $OUTPUT->heading(get_string('exportcalendar', 'calendar')); if ($action != 'advanced') { $exportform->display(); } echo $calendarurl; echo $renderer->complete_layout(); echo $OUTPUT->footer(); home/harasnat/www/learning/mod/forum/export.php 0000604 00000016537 15062124344 0015672 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Page to export forum discussions. * * @package mod_forum * @copyright 2019 Simey Lameze <simey@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('NO_OUTPUT_BUFFERING', true); require_once(__DIR__ . '/../../config.php'); require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->dirroot . '/calendar/externallib.php'); $forumid = required_param('id', PARAM_INT); $userids = optional_param_array('userids', [], PARAM_INT); $discussionids = optional_param_array('discids', [], PARAM_INT); $from = optional_param_array('from', [], PARAM_INT); $to = optional_param_array('to', [], PARAM_INT); $fromtimestamp = optional_param('timestampfrom', '', PARAM_INT); $totimestamp = optional_param('timestampto', '', PARAM_INT); if (!empty($from['enabled'])) { unset($from['enabled']); $from = core_calendar_external::get_timestamps([$from])['timestamps'][0]['timestamp']; } else { $from = $fromtimestamp; } if (!empty($to['enabled'])) { unset($to['enabled']); $to = core_calendar_external::get_timestamps([$to])['timestamps'][0]['timestamp']; } else { $to = $totimestamp; } $vaultfactory = mod_forum\local\container::get_vault_factory(); $managerfactory = mod_forum\local\container::get_manager_factory(); $legacydatamapperfactory = mod_forum\local\container::get_legacy_data_mapper_factory(); $forumvault = $vaultfactory->get_forum_vault(); $forum = $forumvault->get_from_id($forumid); if (empty($forum)) { throw new moodle_exception('Unable to find forum with id ' . $forumid); } $capabilitymanager = $managerfactory->get_capability_manager($forum); if (!$capabilitymanager->can_export_forum($USER)) { throw new moodle_exception('cannotexportforum', 'forum'); } $course = $forum->get_course_record(); $coursemodule = $forum->get_course_module_record(); $cm = cm_info::create($coursemodule); require_course_login($course, true, $cm); $url = new moodle_url('/mod/forum/export.php'); $pagetitle = get_string('export', 'mod_forum'); $context = $forum->get_context(); $form = new mod_forum\form\export_form($url->out(false), [ 'forum' => $forum ]); if ($form->is_cancelled()) { redirect(new moodle_url('/mod/forum/view.php', ['id' => $cm->id])); } else if ($data = $form->get_data()) { $dataformat = $data->format; // This may take a very long time and extra memory. \core_php_time_limit::raise(); raise_memory_limit(MEMORY_HUGE); $discussionvault = $vaultfactory->get_discussion_vault(); if ($data->discussionids) { $discussionids = $data->discussionids; } else if (empty($discussionids)) { $discussions = $discussionvault->get_all_discussions_in_forum($forum); $discussionids = array_map(function ($discussion) { return $discussion->get_id(); }, $discussions); } $filters = ['discussionids' => $discussionids]; if ($data->useridsselected) { $filters['userids'] = $data->useridsselected; } if ($data->from) { $filters['from'] = $data->from; } if ($data->to) { $filters['to'] = $data->to; } // Retrieve posts based on the selected filters, note if forum has no discussions then there is nothing to export. if (!empty($filters['discussionids'])) { $postvault = $vaultfactory->get_post_vault(); $posts = $postvault->get_from_filters($USER, $filters, $capabilitymanager->can_view_any_private_reply($USER)); } else { $posts = []; } $striphtml = !empty($data->striphtml); $humandates = !empty($data->humandates); $fields = ['id', 'discussion', 'parent', 'userid', 'userfullname', 'created', 'modified', 'mailed', 'subject', 'message', 'messageformat', 'messagetrust', 'attachment', 'totalscore', 'mailnow', 'deleted', 'privatereplyto', 'privatereplytofullname', 'wordcount', 'charcount']; $canviewfullname = has_capability('moodle/site:viewfullnames', $context); $datamapper = $legacydatamapperfactory->get_post_data_mapper(); $exportdata = new ArrayObject($datamapper->to_legacy_objects($posts)); $iterator = $exportdata->getIterator(); $filename = clean_filename('discussion'); \core\dataformat::download_data( $filename, $dataformat, $fields, $iterator, function($exportdata) use ($fields, $striphtml, $humandates, $canviewfullname, $context) { $data = new stdClass(); foreach ($fields as $field) { // Set data field's value from the export data's equivalent field by default. $data->$field = $exportdata->$field ?? null; if ($field == 'userfullname') { $user = \core_user::get_user($data->userid); $data->userfullname = fullname($user, $canviewfullname); } if ($field == 'privatereplytofullname' && !empty($data->privatereplyto)) { $user = \core_user::get_user($data->privatereplyto); $data->privatereplytofullname = fullname($user, $canviewfullname); } if ($field == 'message') { $data->message = file_rewrite_pluginfile_urls($data->message, 'pluginfile.php', $context->id, 'mod_forum', 'post', $data->id); } // Convert any boolean fields to their integer equivalent for output. if (is_bool($data->$field)) { $data->$field = (int) $data->$field; } } if ($striphtml) { $data->message = html_to_text(format_text($data->message, $data->messageformat), 0, false); $data->messageformat = FORMAT_PLAIN; } if ($humandates) { $data->created = userdate($data->created); $data->modified = userdate($data->modified); } return $data; }); die; } $PAGE->set_context($context); $PAGE->set_url($url); $PAGE->set_title($pagetitle); $PAGE->set_pagelayout('admin'); $PAGE->add_body_class('limitedwidth'); $PAGE->set_heading($pagetitle); $PAGE->activityheader->disable(); echo $OUTPUT->header(); if (!$PAGE->has_secondary_navigation()) { echo $OUTPUT->heading($pagetitle); } // It is possible that the following fields have been provided in the URL. $userids = array_filter($userids, static function(int $userid) use ($course, $cm): bool { $user = core_user::get_user($userid, '*', MUST_EXIST); return $cm->effectivegroupmode != SEPARATEGROUPS || user_can_view_profile($user, $course); }); $form->set_data(['useridsselected' => $userids, 'discussionids' => $discussionids, 'from' => $from, 'to' => $to]); $form->display(); echo $OUTPUT->footer();
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка