From 5b4a78e28146c4b83e68bf22588fd575b8efde47 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Tue, 3 Aug 2010 08:07:49 +0000 Subject: [PATCH] improved docs and license headers, adding direct access protection --- lib/db/access.php | 73 ++++++++++++++++++++++++++++--------------- lib/db/events.php | 50 ++++++++++++++--------------- lib/db/install.php | 25 ++++++++++++++- lib/db/messages.php | 48 ++++++++++++++-------------- lib/db/services.php | 4 +-- lib/db/upgrade.php | 58 ++++++++++++++++++++++++---------- lib/db/upgradelib.php | 26 ++++++++++++++- 7 files changed, 189 insertions(+), 95 deletions(-) diff --git a/lib/db/access.php b/lib/db/access.php index f941eec609e..d7ca05c5b22 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -1,32 +1,55 @@ : -// -// component_name should be the same as the directory name of the mod or block. -// -// Core moodle capabilities are defined thus: -// moodle/: +// 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. // -// Examples: mod/forum:viewpost -// block/recent_activity:view -// moodle/site:deleteuser +// 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. // -// The variable name for the capability definitions array is $capabilities - +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Capability definitions for Moodle core. + * + * The capabilities are loaded into the database table when the module is + * installed or updated. Whenever the capability definitions are updated, + * the module version number should be bumped up. + * + * The system has four possible values for a capability: + * CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set). + * + * + * CAPABILITY NAMING CONVENTION + * + * It is important that capability names are unique. The naming convention + * for capabilities that are specific to modules and blocks is as follows: + * [mod/block]/: + * + * component_name should be the same as the directory name of the mod or block. + * + * Core moodle capabilities are defined thus: + * moodle/: + * + * Examples: mod/forum:viewpost + * block/recent_activity:view + * moodle/site:deleteuser + * + * The variable name for the capability definitions array is $capabilities + * + * @package core + * @subpackage role + * @copyright 2006 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'moodle/site:config' => array( diff --git a/lib/db/events.php b/lib/db/events.php index 9ba02a60db4..bf281ea716c 100644 --- a/lib/db/events.php +++ b/lib/db/events.php @@ -1,31 +1,31 @@ . + +/** + * Definition of core event handler + * and description of all events throws from core. + * + * @package core + * @subpackage event + * @copyright 2007 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); /* List of handlers */ diff --git a/lib/db/install.php b/lib/db/install.php index e2ff91731c2..053a2af7545 100644 --- a/lib/db/install.php +++ b/lib/db/install.php @@ -1,7 +1,30 @@ . + +/** + * This file is executed right after the install.xml + * + * @package core + * @subpackage admin + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); function xmldb_main_install() { global $CFG, $DB, $SITE; diff --git a/lib/db/messages.php b/lib/db/messages.php index 2b1e4dc2f44..e38ccd0c4aa 100644 --- a/lib/db/messages.php +++ b/lib/db/messages.php @@ -1,30 +1,30 @@ . +/** + * Defines message providers (types of messages being sent) + * + * @package core + * @subpackage message + * @copyright 2008 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); $messageproviders = array ( diff --git a/lib/db/services.php b/lib/db/services.php index 4b4b9753924..660677806b1 100644 --- a/lib/db/services.php +++ b/lib/db/services.php @@ -18,7 +18,7 @@ /** * Core external functions and service definitions. * - * @package moodlecore + * @package core * @subpackage webservice * @copyright 2009 Petr Skoda (http://skodak.org) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -176,5 +176,5 @@ $functions = array( 'type' => 'write', 'capabilities'=> 'moodle/role:assign', ), - + ); diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 02d07f1769b..5ab7837d9f5 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1,23 +1,47 @@ -. + +/** + * This file keeps track of upgrades to Moodle. + * + * Sometimes, changes between versions involve + * alterations to database structures and other + * major things that may break installations. + * + * The upgrade function in this file will attempt + * to perform all the necessary actions to upgrade + * your older installation to the current version. + * + * If there's something it cannot do itself, it + * will tell you what you need to do. + * + * The commands in here will all be database-neutral, + * using the methods of database_manager class + * + * Please do not forget to use upgrade_set_timeout() + * before any action that may take longer time to finish. + * + * @package core + * @subpackage admin + * @copyright 2006 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); /** * @@ -26,7 +50,7 @@ * @global moodle_database $DB * @global core_renderer $OUTPUT * @param int $oldversion - * @return bool + * @return bool always true */ function xmldb_main_upgrade($oldversion) { global $CFG, $USER, $DB, $OUTPUT; diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 5895b432a31..8029650740b 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -1,12 +1,36 @@ . + +/** + * Upgrade helper functions + * * This file is used for special upgrade functions - for example groups and gradebook. * These functions must use SQL and database related functions only- no other Moodle API, * because it might depend on db structures that are not yet present during upgrade. * (Do not use functions from accesslib.php, grades classes or group functions at all!) + * + * @package core + * @subpackage admin + * @copyright 2007 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + function upgrade_fix_category_depths() { global $CFG, $DB; -- 2.43.0