forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-80960 core_sms: Add new subsystem and plugintype
- Loading branch information
1 parent
62ab88f
commit 11f00f0
Showing
24 changed files
with
2,392 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
issueNumber: MDL-80960 | ||
notes: | ||
core: | ||
- message: | | ||
A new `\core_sms` subsystem has been created | ||
type: improved |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
issueNumber: MDL-80960 | ||
notes: | ||
core_sms: | ||
- message: A new `\core_sms` subsystem has been created | ||
type: improved |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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 'sms', language 'en' | ||
* | ||
* @package core | ||
* @category string | ||
* @copyright 2024 Andrew Lyons <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
$string['phonenumbernotvalid'] = 'Format of phone number not recognised: {$a->message}'; | ||
$string['privacy:metadata:sms_messages'] = 'Stores messages sent via SMS'; | ||
$string['privacy:metadata:sms_messages:content'] = 'The message text'; | ||
$string['privacy:metadata:sms_messages:id'] = 'The ID of the message'; | ||
$string['privacy:metadata:sms_messages:recipient'] = 'The phone number that the message was sent to'; | ||
$string['privacy:metadata:sms_messages:recipientuserid'] = 'The user who the message was sent to, if known'; | ||
$string['privacy:metadata:sms_messages:status'] = 'The status of the message'; | ||
$string['privacy:metadata:sms_messages:timecreated'] = 'The time the message was created'; | ||
$string['privacy:sms:sensitive_not_shown'] = 'The content of this message was not stored as it was marked as containing sensitive content.'; | ||
$string['sms'] = 'SMS'; | ||
$string['status:gateway_not_available'] = 'The gateway is not available to send the message'; | ||
$string['status:gateway_failed'] = 'The gateway has failed to send the message'; | ||
$string['status:gateway_queued'] = 'The message is queued to be sent by the gateway'; | ||
$string['status:gateway_rejected'] = 'The gateway has rejected the message'; | ||
$string['status:gateway_sent'] = 'The message has been sent by the gateway'; | ||
$string['status:message_over_size'] = 'The message is too large to be sent by the gateway'; | ||
$string['status:unknown'] = 'Unable to determine the status of the message'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?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 core\plugininfo; | ||
|
||
use moodle_url; | ||
|
||
/** | ||
* SMS gateway subplugin info class. | ||
* | ||
* @package core | ||
* @copyright 2024 Andrew Lyons <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class smsgateway extends base { | ||
public function is_uninstall_allowed(): bool { | ||
return true; | ||
} | ||
|
||
public function get_settings_section_name(): string { | ||
return "smsgateway{$this->name}"; | ||
} | ||
|
||
public function load_settings( | ||
\part_of_admin_tree $adminroot, | ||
$parentnodename, | ||
$hassiteconfig, | ||
): void { | ||
global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them. | ||
/** @var \admin_root $ADMIN */ | ||
$ADMIN = $adminroot; // May be used in settings.php. | ||
$plugininfo = $this; // Also can be used inside settings.php. | ||
|
||
if (!$this->is_installed_and_upgraded()) { | ||
return; | ||
} | ||
|
||
if (!$hassiteconfig) { | ||
return; | ||
} | ||
|
||
$section = $this->get_settings_section_name(); | ||
|
||
$settings = null; | ||
if (file_exists($this->full_path('settings.php'))) { | ||
$settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false); | ||
include($this->full_path('settings.php')); // This may also set $settings to null. | ||
} | ||
if ($settings) { | ||
$ADMIN->add($parentnodename, $settings); | ||
} | ||
} | ||
|
||
public static function get_manage_url(): moodle_url { | ||
return new \moodle_url('/admin/settings.php', [ | ||
'section' => 'smsgateway', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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 core_sms; | ||
|
||
/** | ||
* A language string attribute used for a description. | ||
* | ||
* @package core_sms | ||
* @copyright 2024 Andrew Lyons <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
#[\Attribute] | ||
class description extends \lang_string { | ||
} |
Oops, something went wrong.