-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dc18fa
commit 3d0710b
Showing
5 changed files
with
108 additions
and
2 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,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/>. | ||
|
||
/** | ||
* Check env refresh age | ||
* | ||
* @package tool_task | ||
* @author 2021 Brendan Heywood ([email protected]) | ||
* @copyright Catalyst IT Pty Ltd | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace local_envbar\check; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
use core\check\check; | ||
use core\check\result; | ||
use local_envbar\local\envbarlib; | ||
|
||
/** | ||
* Check env refresh age | ||
* | ||
* @package tool_task | ||
* @author 2021 Brendan Heywood ([email protected]) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class envage extends check { | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() { | ||
global $CFG; | ||
$this->id = 'envage'; | ||
$this->name = get_string('checkenvage', 'local_envbar'); | ||
} | ||
|
||
/** | ||
* A link to a place to action this | ||
* | ||
* @return action_link|null | ||
*/ | ||
public function get_action_link(): ?\action_link { | ||
return new \action_link( | ||
new \moodle_url('/local/envbar/index.php'), | ||
get_string('menuenvsettings', 'local_envbar')); | ||
} | ||
|
||
/** | ||
* Return result | ||
* @return result | ||
*/ | ||
public function get_result() : result { | ||
global $CFG; | ||
|
||
if (envbarlib::getprodwwwroot() === $CFG->wwwroot) { | ||
return new result(result::NA, get_string('prodwwwroottext', 'local_envbar'), ''); | ||
} | ||
|
||
$lastrefresh = get_config('local_envbar', 'prodlastcheck'); | ||
|
||
if ($lastrefresh && $lastrefresh > 0) { | ||
$format = get_string('strftimedatemonthabbr', 'langconfig'); | ||
$summary = userdate($lastrefresh, get_string('strftimedaydate', 'langconfig')); | ||
|
||
$show = format_time(time() - $lastrefresh); | ||
$num = strtok($show, ' '); | ||
$unit = strtok(' '); | ||
$show = "$num $unit"; | ||
$summary .= ' - ' . get_string('refreshedago', 'local_envbar', $show); | ||
} else { | ||
$summary = get_string('refreshednever', 'local_envbar'); | ||
} | ||
|
||
return new result(result::INFO, $summary, ''); | ||
} | ||
} | ||
|
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