files added.
0 parents
Showing
7 changed files
with
336 additions
and
0 deletions
block_log.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Log block caps. | ||
19 | * | ||
20 | * @package block_log | ||
21 | * @copyright Vanisha <vanisha@teknoturf.com> | ||
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
23 | */ | ||
24 | |||
25 | defined('MOODLE_INTERNAL') || die(); | ||
26 | |||
27 | class block_log extends block_base { | ||
28 | public function init() { | ||
29 | $this->title = get_string('pluginname', 'block_fn_mentor'); | ||
30 | } | ||
31 | |||
32 | public function specialization() { | ||
33 | $isadmin = has_capability('block/log:manageall', context_system::instance()); | ||
34 | if($isadmin) { | ||
35 | $this->title = get_string('pluginname', 'block_log'); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | public function get_content() { | ||
40 | global $CFG; | ||
41 | |||
42 | $this->content = new stdClass(); | ||
43 | $this->content->items = array(); | ||
44 | $this->content->icons = array(); | ||
45 | $this->content->footer = ''; | ||
46 | $this->content->text = ''; | ||
47 | |||
48 | $this->content->text = 'This block shows all cron entries logs.'; | ||
49 | $isadmin = has_capability('block/log:manageall', context_system::instance()); | ||
50 | if($isadmin) { | ||
51 | $this->content->text .= '<br><div><a href="'.$CFG->wwwroot.'/blocks/log/view.php">View cron logs</a></div>'; | ||
52 | } | ||
53 | |||
54 | return $this->content; | ||
55 | } | ||
56 | |||
57 | public function applicable_formats() { | ||
58 | return array( | ||
59 | 'all' => false, | ||
60 | 'site' => true, | ||
61 | 'course-*' => false, | ||
62 | 'my' => true | ||
63 | ); | ||
64 | } | ||
65 | |||
66 | public function instance_allow_multiple() { | ||
67 | return false; | ||
68 | } | ||
69 | |||
70 | public function has_config() { | ||
71 | return true; | ||
72 | } | ||
73 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
db/access.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Log block caps. | ||
19 | * | ||
20 | * @package block_log | ||
21 | * @copyright Vanisha <vanisha@teknoturf.com> | ||
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
23 | */ | ||
24 | |||
25 | defined('MOODLE_INTERNAL') || die(); | ||
26 | |||
27 | $capabilities = array( | ||
28 | |||
29 | 'block/log:myaddinstance' => array( | ||
30 | 'captype' => 'write', | ||
31 | 'contextlevel' => CONTEXT_SYSTEM, | ||
32 | 'archetypes' => array( | ||
33 | 'manager' => CAP_ALLOW, | ||
34 | 'user' => CAP_ALLOW | ||
35 | ), | ||
36 | |||
37 | 'clonepermissionsfrom' => 'moodle/my:manageblocks' | ||
38 | ), | ||
39 | |||
40 | 'block/log:addinstance' => array( | ||
41 | 'riskbitmask' => RISK_SPAM | RISK_XSS, | ||
42 | |||
43 | 'captype' => 'write', | ||
44 | 'contextlevel' => CONTEXT_BLOCK, | ||
45 | 'archetypes' => array( | ||
46 | 'manager' => CAP_ALLOW | ||
47 | ), | ||
48 | |||
49 | 'clonepermissionsfrom' => 'moodle/site:manageblocks' | ||
50 | ), | ||
51 | 'block/log:manageall' => array( | ||
52 | 'captype' => 'write', | ||
53 | 'contextlevel' => CONTEXT_SYSTEM, | ||
54 | 'archetypes' => array( | ||
55 | 'manager' => CAP_ALLOW | ||
56 | ) | ||
57 | ) | ||
58 | ); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
lang/en/block_log.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Log block caps. | ||
19 | * | ||
20 | * @package block_log | ||
21 | * @copyright Vanisha <vanisha@teknoturf.com> | ||
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
23 | */ | ||
24 | |||
25 | $string['pluginname'] = 'Cron entry logs view'; | ||
26 | $string['title'] = 'Cron log path'; | ||
27 | $string['block_log_path_info_head'] = 'Paths'; | ||
28 | $string['block_log_path_info_desc'] = 'Provide log paths separated by commas, where the log files should be taken.'; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
settings.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Log block caps. | ||
19 | * | ||
20 | * @package block_log | ||
21 | * @copyright Vanisha <vanisha@teknoturf.com> | ||
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
23 | */ | ||
24 | |||
25 | defined('MOODLE_INTERNAL') || die(); | ||
26 | |||
27 | $settings->add( | ||
28 | new admin_setting_heading('title', get_string('terminology', 'block_fn_mentor'), '') | ||
29 | ); | ||
30 | |||
31 | $settings->add( | ||
32 | new admin_setting_configtext('block_log_path_info', | ||
33 | get_string('block_log_path_info_head', 'block_log'), | ||
34 | get_string('block_log_path_info_desc', 'block_log'), | ||
35 | "/var/log, /var/log/foldername",PARAM_TEXT)); |
templates/cron_logs_view.mustache
0 → 100644
1 | <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css"> | ||
2 | <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script> | ||
3 | |||
4 | <div class="container"> | ||
5 | <div class="cardtitle"> | ||
6 | <p class="banner-title mb-0 pb-0 bold">Cron logs view</p> | ||
7 | <p class="dasboard_margin">It shows all cron entries that should be ran today. We can fliter the cron details based on the date filter</p> | ||
8 | </div> | ||
9 | </div> | ||
10 | |||
11 | <div class="container"> | ||
12 | <div class="input-group mb-3"> | ||
13 | <div class="input-group-prepend" style="display: block;padding: 10px;text-align: justify;width: 25em;"> | ||
14 | <label for="date_filter">Date</label> | ||
15 | <input type="date" id="date_filter" class="form-control" aria-label="Default" aria-describedby="date_filter"> | ||
16 | </div> | ||
17 | </div> | ||
18 | </div> | ||
19 | |||
20 | <div class="container"> | ||
21 | <table id="view_logs_entries_table" class="compact table table-bordered table-striped table-hover"> | ||
22 | <thead><tr><th class="center-class">Sno</th><th class="center-class">Cron file</th><th class="center-class">Cron timing</th><th class="center-class">Cron log</th></tr></thead> | ||
23 | <tbody> | ||
24 | {{#tablecontents}} | ||
25 | <tr> | ||
26 | <td class="center-class">{{sno}}</td> | ||
27 | <td class="center-class">{{{name}}}</td> | ||
28 | <td>{{{time}}}</td> | ||
29 | <td class="center-class">{{log}}</td> | ||
30 | </tr> | ||
31 | {{/tablecontents}} | ||
32 | {{^tablecontents}} | ||
33 | <tr><td colspan="4"><center>No cron files were run today!!!</center></td></tr> | ||
34 | {{/tablecontents}} | ||
35 | </tbody> | ||
36 | </table> | ||
37 | </div> | ||
38 | |||
39 | <script> | ||
40 | $('#view_logs_entries_table').dataTable({ | ||
41 | "pageLength": 30, | ||
42 | "lengthChange": false, | ||
43 | lengthMenu: [[30, 50, 100], [30, 50, 100]] | ||
44 | }); | ||
45 | |||
46 | </script> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
version.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Log block caps. | ||
19 | * | ||
20 | * @package block_log | ||
21 | * @copyright Vanisha <vanisha@teknoturf.com> | ||
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
23 | */ | ||
24 | |||
25 | defined('MOODLE_INTERNAL') || die(); | ||
26 | |||
27 | $plugin->version = 2023060101; | ||
28 | $plugin->requires = 2015111600; | ||
29 | $plugin->component = 'block_log'; | ||
30 | $plugin->cron = 30; | ||
31 | $plugin->release = '3.3.0'; | ||
32 | $plugin->maturity = MATURITY_STABLE; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
view.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Log block caps. | ||
19 | * | ||
20 | * @package block_log | ||
21 | * @copyright Vanisha <vanisha@teknoturf.com> | ||
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
23 | */ | ||
24 | |||
25 | require_once('../../../config.php'); | ||
26 | |||
27 | require_login(null, false); | ||
28 | |||
29 | global $PAGE,$OUTPUT,$CFG; | ||
30 | |||
31 | $pluginname = get_string('pluginname', 'block_fn_mentor'); | ||
32 | |||
33 | $thispageurl = new moodle_url('/blocks/log/view.php'); | ||
34 | $PAGE->set_url($thispageurl); | ||
35 | |||
36 | $contextsystem = context_system::instance(); | ||
37 | $PAGE->set_context($contextsystem); | ||
38 | |||
39 | $PAGE->navbar->add($pluginname); | ||
40 | $PAGE->set_title($pluginname); | ||
41 | $PAGE->set_heading($pluginname); | ||
42 | |||
43 | echo $OUTPUT->header(); | ||
44 | |||
45 | $templatecontext = array(); | ||
46 | |||
47 | // breadcrumb template | ||
48 | $templatecontext['breadcrumb_navbar'] = $OUTPUT->navbar(); | ||
49 | |||
50 | $configpaths = get_config('block_log', 'block_log_path_info'); | ||
51 | |||
52 | $isadmin = has_capability('block/log:manageall', context_system::instance()); | ||
53 | |||
54 | if($isadmin) { | ||
55 | $templatecontext['tablecontents'] = ''; | ||
56 | |||
57 | echo $OUTPUT->render_from_template('block_log/cron_logs_view', $templatecontext); | ||
58 | } | ||
59 | |||
60 | else { | ||
61 | echo '<center><div class="alert alert-info"><b>You cannot view this page.</b></div><center>'; | ||
62 | } | ||
63 | |||
64 | echo $OUTPUT->footer(); |
-
Please register or sign in to post a comment