Skip to content

Commit

Permalink
Merge pull request #27 from catalyst/upgrade
Browse files Browse the repository at this point in the history
Upgrade to support the latest versions of Moodle
  • Loading branch information
dmitriim authored May 8, 2020
2 parents 3dd7d91 + 78d49ca commit b36d4a2
Show file tree
Hide file tree
Showing 29 changed files with 303 additions and 148 deletions.
70 changes: 21 additions & 49 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,32 @@ cache:
- $HOME/.composer/cache

addons:
postgresql: "9.4"
postgresql: "9.6"

services:
- mysql

php:
- 7.2
- 7.3

env:
global:
- DB=pgsql
matrix:
- MOODLE_BRANCH=MOODLE_34_STABLE
- MOODLE_BRANCH=MOODLE_35_STABLE
- MOODLE_BRANCH=MOODLE_36_STABLE
- MOODLE_BRANCH=MOODLE_37_STABLE
- MOODLE_BRANCH=master

matrix:
include:
# PHP 7.0
- php: 7.0
env: DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE
- php: 7.0
env: DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE
- php: 7.0
env: DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE
- php: 7.0
env: DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE
- php: 7.0
env: DB=mysqli MOODLE_BRANCH=MOODLE_36_STABLE
- php: 7.0
env: DB=pgsql MOODLE_BRANCH=MOODLE_36_STABLE
# PHP 7.1
- php: 7.1
env: DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE
- php: 7.1
env: DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE
- php: 7.1
env: DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE
- php: 7.1
env: DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE
- php: 7.1
env: DB=mysqli MOODLE_BRANCH=MOODLE_36_STABLE
- php: 7.1
env: DB=pgsql MOODLE_BRANCH=MOODLE_36_STABLE
- php: 7.1
env: DB=mysqli MOODLE_BRANCH=master
- php: 7.1
env: DB=pgsql MOODLE_BRANCH=master
# PHP 7.2
- php: 7.2
env: DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE
- php: 7.2
env: DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE
- php: 7.2
env: DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE
- php: 7.2
env: DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE
- php: 7.2
env: DB=mysqli MOODLE_BRANCH=MOODLE_36_STABLE
- php: 7.2
env: DB=pgsql MOODLE_BRANCH=MOODLE_36_STABLE
- php: 7.2
env: DB=mysqli MOODLE_BRANCH=master
- php: 7.2
env: DB=pgsql MOODLE_BRANCH=master
exclude:
- php: 7.3
env: MOODLE_BRANCH=MOODLE_34_STABLE
- php: 7.3
env: MOODLE_BRANCH=MOODLE_35_STABLE


before_install:
- cd ../..
Expand Down
35 changes: 24 additions & 11 deletions classes/form/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@

defined('MOODLE_INTERNAL') || die();


/**
* Edit form.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit extends moodleform {
/**
* Web analytics type.
Expand Down Expand Up @@ -60,7 +65,7 @@ public function get_form() {
}

/**
* @inheritdoc
* Form definition.
*
* @see moodleform::definition()
*/
Expand Down Expand Up @@ -114,9 +119,12 @@ public function definition() {
}

/**
* @inheritdoc
* Server side validation.
*
* @see moodleform::validation()
* @param array $data array of ("fieldname"=>value) of submitted data
* @param array $files array of uploaded files "element_name"=>tmp_file_path
* @return array of "element_name"=>"error_description" if there are errors,
* or an empty array if everything is OK (true allowed for backwards compatibility too).
*/
public function validation($data, $files) {
$errors = parent::validation($data, $files);
Expand All @@ -126,9 +134,12 @@ public function validation($data, $files) {
}

/**
* @inheritdoc
* Return submitted data if properly submitted or returns NULL if validation fails or
* if there is no submitted data.
*
* note: $slashed param removed
*
* @see moodleform::get_data()
* @return object submitted data; NULL if not valid or not submitted or cancelled
*/
public function get_data() {
$data = parent::get_data();
Expand All @@ -141,19 +152,21 @@ public function get_data() {
}

/**
* @inheritdoc
* Load in existing data as form defaults. Usually new entry defaults are stored directly in
* form definition (new entry form); this function is used to load in data where values
* already exist and data is being edited (edit entry form).
*
* @see moodleform::set_data()
* note: $slashed param removed
*
* @param \stdClass|array $default_values object or array of default values
*/
public function set_data($defaultvalues) {
$this->tool->form_set_data($defaultvalues);
parent::set_data($defaultvalues);
}

/**
* @inheritdoc
*
* @see moodleform::definition_after_data()
* Setup the form depending on current values.
*/
public function definition_after_data() {
parent::definition_after_data();
Expand Down
6 changes: 6 additions & 0 deletions classes/injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

defined('MOODLE_INTERNAL') || die;

/**
* Injector class.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class injector {
/**
* @var bool
Expand Down
6 changes: 6 additions & 0 deletions classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@

defined('MOODLE_INTERNAL') || die;

/**
* Plugin manager.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class plugin_manager {
/**
* Plugins type.
Expand Down
6 changes: 6 additions & 0 deletions classes/plugininfo/watool.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

defined('MOODLE_INTERNAL') || die();

/**
* Sub plugin class.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class watool extends base {

/**
Expand Down
6 changes: 4 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
use core_privacy\local\legacy_polyfill;

/**
* Class provider
* @package tool_webanalytics\privacy
* Privacy provider.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {

Expand Down
4 changes: 3 additions & 1 deletion classes/record.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@

defined('MOODLE_INTERNAL') || die();


/**
* Class analytics described single analytics built from DB record.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class record implements record_interface {

Expand Down
13 changes: 9 additions & 4 deletions classes/record_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Version information.
* Interface to describe records.
*
* @package tool_webanalytics
* @author Dmitrii Metelkin ([email protected])
Expand All @@ -27,6 +27,12 @@

defined('MOODLE_INTERNAL') || die();

/**
* Interface to describe records.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface record_interface {

/**
Expand All @@ -40,14 +46,13 @@ public function is_enabled();
* Return property value.
*
* @param string $name Property name.
*
* @return mixed Property value.
*
* @throws \coding_exception If invalid property requested.
*/
public function get_property($name);

/**
* Export the record.
*
* @return mixed
*/
public function export();
Expand Down
3 changes: 3 additions & 0 deletions classes/records_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

/**
* Class manages records in DB.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class records_manager implements records_manager_interface {
/**
Expand Down
5 changes: 4 additions & 1 deletion classes/records_manager_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Version information.
* Interface describes records manager behaviour.
*
* @package tool_webanalytics
* @author Dmitrii Metelkin ([email protected])
Expand All @@ -29,6 +29,9 @@

/**
* Interface describes records manager behaviour.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface records_manager_interface {

Expand Down
5 changes: 4 additions & 1 deletion classes/table/tools_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

/**
* Class tools_table
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tools_table extends flexible_table {
/**
Expand Down Expand Up @@ -203,7 +206,7 @@ public function display(array $records) {


/**
* @inheritdoc
* Display no results.
*/
public function print_nothing_to_display() {
echo html_writer::div(get_string('no_analytics', 'tool_webanalytics'));
Expand Down
25 changes: 20 additions & 5 deletions classes/tool/tool_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,31 @@

defined('MOODLE_INTERNAL') || die();


/**
* Web analytics abstract tool class.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class tool_base implements tool_interface {
/**
* @var \tool_webanalytics\record
*/
protected $record;

/**
* @inheritdoc
* Constructor.
*
* @param \tool_webanalytics\record_interface $record
*/
public function __construct(record_interface $record) {
$this->record = $record;
}

/**
* @inheritdoc
* Check if we should track.
*
* @return bool
*/
public function should_track() {
if (!is_siteadmin()) {
Expand All @@ -55,7 +64,11 @@ public function should_track() {
}

/**
* @inheritdoc
* Add settings elements to Web Analytics Tool form.
*
* @param \MoodleQuickForm $mform Web Analytics Tool form.
*
* @return void
*/
public function form_definition_after_data(\MoodleQuickForm &$mform) {

Expand All @@ -71,7 +84,9 @@ protected final function build_location() {
}

/**
* @inheritdoc
* Insert tracking code.
*
* @return void
*/
public final function insert_tracking() {
global $CFG;
Expand Down
8 changes: 7 additions & 1 deletion classes/tool/tool_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

defined('MOODLE_INTERNAL') || die();

/**
* Interface to describe WA tools.
*
* @copyright 2020 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface tool_interface {
/**
* Constructor.
Expand Down Expand Up @@ -99,7 +105,7 @@ public function form_build_settings(\stdClass $data);
/**
* Set form data.
*
* @param $data
* @param \stdClass $data Form data.
*
* @return void
*/
Expand Down
Loading

0 comments on commit b36d4a2

Please sign in to comment.