-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wip-MSFTMPP-426-m28' into MOODLE_28_STABLE
- Loading branch information
Showing
12 changed files
with
184 additions
and
28 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
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,92 @@ | ||
<?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/>. | ||
|
||
/** | ||
* @package local_o365 | ||
* @author James McQuillan <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @copyright (C) 2014 onwards Microsoft Open Technologies, Inc. (http://msopentech.com/) | ||
*/ | ||
|
||
namespace local_o365\healthcheck; | ||
|
||
/** | ||
* Checks current recorded rate limit | ||
*/ | ||
class ratelimit implements \local_o365\healthcheck\healthcheckinterface { | ||
/** | ||
* Run the health check. | ||
* | ||
* @return array Array of result data. Must include: | ||
* bool result Whether the health check passed or not. | ||
* int severity If the health check failed, how bad a problem is it? This is one of the SEVERITY_* constants. | ||
* string message A message to show the user. | ||
* string fixlink If the healthcheck failed, a link to help resolve the problem. | ||
*/ | ||
public function run() { | ||
$ratelimitdisabled = get_config('local_o365', 'ratelimitdisabled'); | ||
if (!empty($ratelimitdisabled)) { | ||
return [ | ||
'result' => false, | ||
'severity' => static::SEVERITY_TRIVIAL, | ||
'message' => get_string('healthcheck_ratelimit_result_disabled', 'local_o365'), | ||
]; | ||
} | ||
|
||
$ratelimit = get_config('local_o365', 'ratelimit'); | ||
$ratelimit = explode(':', $ratelimit, 2); | ||
|
||
if (!empty($ratelimit[0]) && $ratelimit[1] > (time() - (10 * MINSECS))) { | ||
$a = new \stdClass; | ||
$a->level = $ratelimit[0]; | ||
$a->timestart = date('c', $ratelimit[1]); | ||
if ($ratelimit[0] < 4) { | ||
return [ | ||
'result' => false, | ||
'severity' => static::SEVERITY_TRIVIAL, | ||
'message' => get_string('healthcheck_ratelimit_result_notice', 'local_o365', $a), | ||
]; | ||
} else { | ||
return [ | ||
'result' => false, | ||
'severity' => static::SEVERITY_TRIVIAL, | ||
'message' => get_string('healthcheck_ratelimit_result_warning', 'local_o365', $a), | ||
]; | ||
} | ||
} else { | ||
return [ | ||
'result' => true, | ||
'severity' => static::SEVERITY_OK, | ||
'message' => get_string('healthcheck_ratelimit_result_passed', 'local_o365'), | ||
]; | ||
} | ||
|
||
if (empty($systemtoken)) { | ||
|
||
} else { | ||
|
||
} | ||
} | ||
|
||
/** | ||
* Get a human-readable name for the health check. | ||
* | ||
* @return string A name for the health check. | ||
*/ | ||
public function get_name() { | ||
return get_string('healthcheck_ratelimit_title', 'local_o365'); | ||
} | ||
} |
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
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