Файловый менеджер - Редактировать - /home/harasnat/www/mf/communication.zip
Назад
PK q�/[�a*�u u upgrade.txtnu &1i� This file describes API changes in /communication/* Information provided here is intended especially for developers. PK q�/[Q���[ [ configure.phpnu &1i� <?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/>. /** * Configure communication for a given instance. * * @package core_communication * @copyright 2023 David Woloszyn <david.woloszyn@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once('../config.php'); require_once('lib.php'); require_login(); $contextid = required_param('contextid', PARAM_INT); $instanceid = required_param('instanceid', PARAM_INT); $instancetype = required_param('instancetype', PARAM_TEXT); $component = required_param('component', PARAM_COMPONENT); $selectedcommunication = optional_param('selectedcommunication', null, PARAM_PLUGIN); $context = \core\context::instance_by_id($contextid); $instanceinfo = [ 'contextid' => $context->id, 'instanceid' => $instanceid, 'instancetype' => $instancetype, 'component' => $component, ]; // Requires communication to be enabled. if (!core_communication\api::is_available()) { throw new \moodle_exception('communicationdisabled', 'communication'); } // Attempt to load the communication instance with the provided params. $communication = \core_communication\api::load_by_instance( context: $context, component: $component, instancetype: $instancetype, instanceid: $instanceid, provider: $selectedcommunication, ); // No communication, no way this form can be used. if (!$communication) { throw new \moodle_exception('nocommunicationinstance', 'communication'); } // Set variables according to the component callback and use them on the page. [$instance, $context, $heading, $returnurl] = component_callback( $component, 'get_communication_instance_data', [$instanceid] ); // Set up the page. $PAGE->set_context($context); $PAGE->set_url('/communication/configure.php', $instanceinfo); $PAGE->set_title(get_string('communication', 'communication')); $PAGE->set_heading($heading); $PAGE->add_body_class('limitedwidth'); // Append the instance data before passing to form object. $instanceinfo['instancedata'] = $instance; // Get our form definitions. $form = new \core_communication\form\configure_form( context: $context, instanceid: $instanceinfo['instanceid'], instancetype: $instanceinfo['instancetype'], component: $instanceinfo['component'], selectedcommunication: $selectedcommunication, instancedata: $instanceinfo['instancedata'], ); if ($form->is_cancelled()) { redirect($returnurl); } else if ($data = $form->get_data()) { component_callback($component, 'update_communication_instance_data', [$data]); redirect($returnurl); } // Display the page contents. echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('communication', 'communication'), 2); $form->display(); echo $OUTPUT->footer(); PK q�/[�b��� � 8 provider/customlink/lang/en/communication_customlink.phpnu &1i� <?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/>. /** * Strings for component communication_customlink, language 'en'. * * @package communication_customlink * @copyright 2023 Michael Hawkins <michaelh@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['cachedef_customlink'] = 'Custom link data'; $string['customlinkurl'] = 'Custom link URL'; $string['customlinkurl_help'] = 'Provide a link to an existing room from any communication service you would like to make available to participants - such as Microsoft Teams, Slack or Matrix.'; $string['customlinkurlinfo'] = 'The URL of an existing room already set up for this course.'; $string['pluginname'] = 'Custom link'; $string['privacy:metadata'] = 'Custom link communication plugin does not store any personal data.'; PK q�/[L�7$F F 0 provider/customlink/classes/privacy/provider.phpnu &1i� <?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/>. namespace communication_customlink\privacy; use core_privacy\local\metadata\null_provider; /** * Privacy Subsystem for communication_customlink implementing null_provider. * * @package communication_customlink * @copyright 2023 Michael Hawkins <michaelh@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements null_provider { /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ public static function get_reason(): string { return 'privacy:metadata'; } } PK q�/[��w� � 5 provider/customlink/classes/communication_feature.phpnu &1i� <?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/>. namespace communication_customlink; use core_communication\processor; /** * class communication_feature to handle custom link specific actions. * * @package communication_customlink * @copyright 2023 Michael Hawkins <michaelh@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class communication_feature implements \core_communication\communication_provider, \core_communication\form_provider, \core_communication\room_chat_provider { /** @var string The database table storing custom link specific data */ protected const CUSTOMLINK_TABLE = 'communication_customlink'; /** @var \cache_application $cache The application cache for this provider. */ protected \cache_application $cache; /** * Load the communication provider for the communication API. * * @param processor $communication The communication processor object. * @return communication_feature The communication provider object. */ public static function load_for_instance(processor $communication): self { return new self($communication); } /** * Constructor for communication provider. * * @param processor $communication The communication processor object. */ private function __construct( private \core_communication\processor $communication, ) { $this->cache = \cache::make('communication_customlink', 'customlink'); } /** * Create room - room existence managed externally, always return true. * * @return boolean */ public function create_chat_room(): bool { return true; } /** * Update room - room existence managed externally, always return true. * * @return boolean */ public function update_chat_room(): bool { return true; } /** * Delete room - room existence managed externally, always return true. * * @return boolean */ public function delete_chat_room(): bool { return true; } /** * Fetch the URL for this custom link provider. * * @return string|null The custom URL, or null if not found. */ public function get_chat_room_url(): ?string { global $DB; $commid = $this->communication->get_id(); $cachekey = "link_url_{$commid}"; // Attempt to fetch the room URL from the cache. if ($url = $this->cache->get($cachekey)) { return $url; } // If not found in the cache, fetch the URL from the database. $url = $DB->get_field( self::CUSTOMLINK_TABLE, 'url', ['commid' => $commid], ); // Cache the URL. $this->cache->set($cachekey, $url); return $url; } public function save_form_data(\stdClass $instance): void { global $DB; $commid = $this->communication->get_id(); $cachekey = "link_url_{$commid}"; $newrecord = new \stdClass(); $newrecord->url = $instance->customlinkurl ?? null; $existingrecord = $DB->get_record( self::CUSTOMLINK_TABLE, ['commid' => $commid], 'id, url' ); if (!$existingrecord) { // Create the record if it does not exist. $newrecord->commid = $commid; $DB->insert_record(self::CUSTOMLINK_TABLE, $newrecord); } else if ($newrecord->url !== $existingrecord->url) { // Update record if the URL has changed. $newrecord->id = $existingrecord->id; $DB->update_record(self::CUSTOMLINK_TABLE, $newrecord); } else { // No change made. return; } // Cache the new URL. $this->cache->set($cachekey, $newrecord->url); } public function set_form_data(\stdClass $instance): void { if (!empty($instance->id) && !empty($this->communication->get_id())) { $instance->customlinkurl = $this->get_chat_room_url(); } } public static function set_form_definition(\MoodleQuickForm $mform): void { // Custom link description for the communication provider. $mform->insertElementBefore($mform->createElement( 'text', 'customlinkurl', get_string('customlinkurl', 'communication_customlink'), 'maxlength="255" size="40"' ), 'addcommunicationoptionshere'); $mform->addHelpButton('customlinkurl', 'customlinkurl', 'communication_customlink'); $mform->setType('customlinkurl', PARAM_URL); $mform->addRule('customlinkurl', get_string('required'), 'required', null, 'client'); $mform->addRule('customlinkurl', get_string('maximumchars', '', 255), 'maxlength', 255); $mform->insertElementBefore($mform->createElement( 'static', 'customlinkurlinfo', '', get_string('customlinkurlinfo', 'communication_customlink'), 'addcommunicationoptionshere' ), 'addcommunicationoptionshere'); } public static function is_configured(): bool { return true; } } PK q�/[�Ӵv v ! provider/customlink/db/caches.phpnu &1i� <?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/>. /** * Defined caches used internally by the provider. * * @package communication_customlink * @copyright 2023 Michael Hawkins <michaelh@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ declare(strict_types=1); defined('MOODLE_INTERNAL') || die(); $definitions = [ 'customlink' => [ 'mode' => cache_store::MODE_APPLICATION, 'simplekeys' => true, 'simpledata' => true, ], ]; PK q�/[�\ӑG G "