Skip to content

Commit 7faae68

Browse files
committed
Initial commit
0 parents  commit 7faae68

File tree

8 files changed

+369
-0
lines changed

8 files changed

+369
-0
lines changed

README.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

block_featured_courses.php

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
* Newblock block caps.
19+
*
20+
* @package block_featured_courses
21+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
defined('MOODLE_INTERNAL') || die();
26+
27+
/**
28+
* Class block_featured_courses
29+
*
30+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
31+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32+
*/
33+
class block_featured_courses extends block_base {
34+
35+
/**
36+
* Init function
37+
*
38+
* @throws coding_exception
39+
*/
40+
public function init() {
41+
$this->title = get_string('pluginname', 'block_featured_courses');
42+
}
43+
44+
/**
45+
* Content for the block
46+
*
47+
* @return \stdClass|string|null
48+
* @throws coding_exception
49+
*/
50+
public function get_content() {
51+
52+
if ($this->content !== null) {
53+
return $this->content;
54+
}
55+
56+
if (empty($this->instance)) {
57+
$this->content = '';
58+
return $this->content;
59+
}
60+
61+
$this->content = new stdClass();
62+
$this->content->items = array();
63+
$this->content->icons = array();
64+
$this->content->footer = '';
65+
66+
// User/index.php expect course context, so get one if page has module context.
67+
$currentcontext = $this->page->context->get_course_context(false);
68+
69+
if (!empty($this->config->text)) {
70+
$this->content->text = $this->config->text;
71+
}
72+
73+
$this->content = '';
74+
if (empty($currentcontext)) {
75+
return $this->content;
76+
}
77+
if ($this->page->course->id == SITEID) {
78+
$this->context->text .= "site context";
79+
}
80+
81+
if (!empty($this->config->text)) {
82+
$this->content->text .= $this->config->text;
83+
}
84+
85+
return $this->content;
86+
}
87+
88+
/**
89+
* All applicable formats
90+
*
91+
* @return array
92+
*/
93+
public function applicable_formats() {
94+
return array('all' => true);
95+
}
96+
97+
/**
98+
* Multiple blocks ?
99+
*
100+
* @return bool
101+
*/
102+
public function instance_allow_multiple() {
103+
return true;
104+
}
105+
106+
/**
107+
* Has configuration ?
108+
*
109+
* @return bool
110+
*/
111+
public function has_config() {
112+
return true;
113+
}
114+
115+
/**
116+
* Cron Job
117+
*
118+
* @return bool
119+
*/
120+
public function cron() {
121+
mtrace("Hey, my cron script is running");
122+
123+
// Do something.
124+
125+
return true;
126+
}
127+
}

classes/privacy/provider.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
* Privacy Subsystem implementation for block_featured_courses.
19+
*
20+
* @package block_featured_courses
21+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
namespace block_course_summary\privacy;
25+
26+
defined('MOODLE_INTERNAL') || die();
27+
28+
/**
29+
* Privacy Subsystem for block_featured_courses implementing null_provider.
30+
*
31+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
32+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33+
*/
34+
class provider implements \core_privacy\local\metadata\null_provider {
35+
36+
/**
37+
* Get the language string identifier with the component's language
38+
* file to explain why this plugin stores no data.
39+
*
40+
* @return string
41+
*/
42+
public static function get_reason() : string {
43+
return 'privacy:metadata';
44+
}
45+
}

db/access.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
* Version details
19+
*
20+
* @package block_featured_courses
21+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
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/featured_courses:myaddinstance' => array(
30+
'captype' => 'write',
31+
'contextlevel' => CONTEXT_SYSTEM,
32+
'archetypes' => array(
33+
'user' => CAP_ALLOW
34+
),
35+
36+
'clonepermissionsfrom' => 'moodle/my:manageblocks'
37+
),
38+
39+
'block/featured_courses:addinstance' => array(
40+
'riskbitmask' => RISK_SPAM | RISK_XSS,
41+
42+
'captype' => 'write',
43+
'contextlevel' => CONTEXT_BLOCK,
44+
'archetypes' => array(
45+
'editingteacher' => CAP_ALLOW,
46+
'manager' => CAP_ALLOW
47+
),
48+
49+
'clonepermissionsfrom' => 'moodle/site:manageblocks'
50+
),
51+
);

edit_form.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
* Edit Form
19+
*
20+
* @package block_featured_courses
21+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
/**
26+
* Class block_featured_courses_edit_form
27+
* @package block_vetagro_news
28+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
29+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30+
*/
31+
class block_featured_courses_edit_form extends block_edit_form {
32+
33+
/**
34+
* Form definition
35+
*
36+
* @param object $mform
37+
* @throws coding_exception
38+
*/
39+
protected function specific_definition($mform) {
40+
41+
// Section header title according to language file.
42+
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
43+
44+
// A sample string variable with a default value.
45+
$mform->addElement('text', 'config_text', get_string('blockstring', 'block_featured_courses'));
46+
$mform->setDefault('config_text', 'default value');
47+
$mform->setType('config_text', PARAM_MULTILANG);
48+
49+
}
50+
}

lang/en/block_featured_courses.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
* Strings for component 'block_featured_courses', language 'en'
19+
*
20+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
21+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22+
*/
23+
24+
$string['blockstring'] = 'Block string';
25+
$string['descconfig'] = 'Description of the config section';
26+
$string['descfoo'] = 'Config description';
27+
$string['headerconfig'] = 'Config section header';
28+
$string['labelfoo'] = 'Config label';
29+
$string['featured_courses:addinstance'] = 'Add a featured_courses block';
30+
$string['featured_courses:myaddinstance'] = 'Add a featured_courses block to my moodle';
31+
$string['pluginname'] = 'Featured Courses';

settings.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
* Newblock block caps.
19+
*
20+
* @package block_featured_courses
21+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
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(new admin_setting_heading('sampleheader',
28+
get_string('headerconfig', 'block_featured_courses'),
29+
get_string('descconfig', 'block_featured_courses')));
30+
31+
$settings->add(new admin_setting_configcheckbox('featured_courses/foo',
32+
get_string('labelfoo', 'block_featured_courses'),
33+
get_string('descfoo', 'block_featured_courses'),
34+
'0'));

version.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
* Version details
19+
*
20+
* @package block_featured_courses
21+
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
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 = 2013011300; // The current plugin version (Date: YYYYMMDDXX).
28+
$plugin->requires = 2012112900; // Requires this Moodle version.
29+
$plugin->component = 'block_featured_courses'; // Full name of the plugin (used for diagnostics).
30+
$plugin->cron = 300;

0 commit comments

Comments
 (0)