Skip to content

valentineus/moodle-tool_apisiteadmins

Repository files navigation

Advanced API administration management

GitHub Release Build Status Codacy Badge

The plug-in extends and complements the system API for managing administrators. Main library is well documented and tested. Can be used by third-party developers for development.

In addition, the plugin adds functions for Web services that interact with the list of administrators. For documentation on Web services, see Moodle: https://example.domain/admin/webservice/documentation.php

Installation

Get the installation package in any of the available methods:

In Moodle in the administration panel go to the "Plugins" section and make a standard installation of the plug-in.

Testing

  • Perform the installation of PHPUnit and configure the test environment. Use the official guide for detailed information.

  • To run the plugin test, use the following commands:

# Run all tests
php vendor/bin/phpunit --testdox --group tool_apisiteadmins

# Or running individual tests
php vendor/bin/phpunit --testdox tool_apisiteadmins_api_testcase admin/tool/apisiteadmins/tests/api_test.php
php vendor/bin/phpunit --testdox tool_apisiteadmins_external_testcase admin/tool/apisiteadmins/tests/external_test.php

Build

Self-assembly package is as follows:

  • Clone the repository:
git clone https://github.com/valentineus/moodle-tool_apisiteadmins.git apisiteadmins
  • Run the build script:
cd ./apisiteadmins
/bin/sh build.sh

API

tool_apisiteadmins::add_user( $userid ) ⇒Boolean

Adds a user to the list of administrators.

Param Type Description
$userid Number System user ID

Example:

require_once($CFG->dirroot . "/admin/tool/apisiteadmins/lib.php");

$userid = 2;
tool_apisiteadmins::add_user($userid);
// result: true

tool_apisiteadmins::remove_user( $userid ) ⇒Boolean

Removes a user from the list of administrators.

Param Type Description
$userid Number System user ID

Example:

require_once($CFG->dirroot . "/admin/tool/apisiteadmins/lib.php");

$userid = 2;
tool_apisiteadmins::remove_user($userid);
// result: true

tool_apisiteadmins::set_main( $userid ) ⇒Boolean

Registers the user as the primary administrator.

Param Type Description
$userid Number System user ID

Example:

require_once($CFG->dirroot . "/admin/tool/apisiteadmins/lib.php");

$userid = 2;
tool_apisiteadmins::set_main($userid);
// result: true

License

GNU Banner

GNU GPLv3. Copyright (c) Valentin Popov.