-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// //
-// This program 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 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program 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: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
-
-/// This library contains all the Data Manipulation Language (DML) functions
-/// used to interact with the DB. All the dunctions in this library must be
-/// generic and work against the major number of RDBMS possible. This is the
-/// list of currently supported and tested DBs: mysql, postresql, mssql, oracle
-
-/// This library is automatically included by Moodle core so you never need to
-/// include it yourself.
-
-/// For more info about the functions available in this library, please visit:
-/// http://docs.moodle.org/en/DML_functions
-/// (feel free to modify, improve and document such page, thanks!)
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// 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.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * This library contains all the Data Manipulation Language (DML) functions
+ * used to interact with the DB
+ *
+ * This library contains all the Data Manipulation Language (DML) functions
+ * used to interact with the DB. All the dunctions in this library must be
+ * generic and work against the major number of RDBMS possible. This is the
+ * list of currently supported and tested DBs: mysql, postresql, mssql, oracle
+
+ * This library is automatically included by Moodle core so you never need to
+ * include it yourself.
+
+ * For more info about the functions available in this library, please visit:
+ * http://docs.moodle.org/en/DML_functions
+ * (feel free to modify, improve and document such page, thanks!)
+ *
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
+
+ /** Require the essential */
require_once($CFG->libdir.'/dml/moodle_database.php');
/**
* DML exception class, use instead of error() in dml code.
+ *
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class dml_exception extends moodle_exception {
+ /**
+ * @param string $errorcode
+ * @param string $a
+ * @param string $debuginfo
+ */
function __construct($errorcode, $a=NULL, $debuginfo=null) {
parent::__construct($errorcode, '', '', $a, $debuginfo);
}
/**
* DML db connection exception - triggered if database not accessible.
+ *
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class dml_connection_exception extends dml_exception {
+ /**
+ * @param string $error
+ */
function __construct($error) {
$errorinfo = '<em>'.s($error).'</em>';
parent::__construct('dbconnectionfailed', NULL, $errorinfo);
/**
* DML read exception - triggered by SQL syntax errors, missing tables, etc.
+ *
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class dml_read_exception extends dml_exception {
+ /** @var string */
public $error;
public $sql;
+ /** @var array */
public $params;
-
+
+ /**
+ * @param string $error
+ * @param string $sql
+ * @param array $params
+ */
function __construct($error, $sql=null, array $params=null) {
$this->error = $error;
$this->sql = $sql;
/**
* DML read exception - triggered by SQL syntax errors, missing tables, etc.
+ *
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class dml_write_exception extends dml_exception {
+ /** @var string */
public $error;
public $sql;
+ /** @var array */
public $params;
+ /**
+ * @param string $error
+ * @param string $sql
+ * @param array $params
+ */
function __construct($error, $sql=null, array $params=null) {
$this->error = $error;
$this->sql = $sql;
/**
* Sets up global $DB moodle_database instance
+ *
+ * @global object
+ * @global object
* @return void
*/
function setup_DB() {
<?php
-/**
- ** This class abstracts eaccelerator/turckmmcache
- ** API to provide
- **
- ** - get()
- ** - set()
- ** - delete()
- ** - getforfill()
- ** - releaseforfill()
- **
- ** Author: Martin Langhoff <martin@catalyst.net.nz>
- **
- ** Note: do NOT store booleans here. For compatibility with
- ** memcached, a false value is indistinguisable from a
- ** "not found in cache" response.
- **/
+// This file is part of Moodle - http://moodle.org/
+//
+// 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.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This class abstracts eaccelerator/turckmmcache
+ * API to provide
+ *
+ * - get()
+ * - set()
+ * - delete()
+ * - getforfill()
+ * - releaseforfill()
+ *
+ * Note: do NOT store booleans here. For compatibility with
+ * memcached, a false value is indistinguisable from a
+ * "not found in cache" response.
+ *
+ * @copyright Martin Langhoff <martin@catalyst.net.nz>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
+/**
+ *
+ * @copyright Martin Langhoff <martin@catalyst.net.nz>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class eaccelerator {
+ /**
+ * @todo Document this function
+ *
+ * @global object
+ */
function eaccelerator() {
global $CFG;
if ( function_exists('eaccelerator_get')) {
$this->prefix = $CFG->dbname .'|' . $CFG->prefix . '|';
}
+ /**
+ * The status of the eaccelerator, if it has been established
+ * this will return true
+ *
+ * @return bool
+ */
function status() {
if (isset($this->mode)) {
return true;
return false;
}
+ /**
+ * @todo Document this function
+ *
+ * @param string $key
+ * @param string $value
+ * @param int $ttl
+ * @return mixed
+ */
function set($key, $value, $ttl=0) {
$set = $this->mode . '_put';
$unlock = $this->mode . '_unlock';
return $set($this->prefix . $key, serialize($value), $ttl);
}
+ /**
+ * @todo Document this function
+ *
+ * @param string $key
+ * @return string|bool String if success else false
+ */
function get($key) {
$fn = $this->mode . '_get';
$rec = $fn($this->prefix . $key);
}
return unserialize($rec);
}
-
+
+ /**
+ * @todo Document this function
+ *
+ * @param string $key
+ * @return mixed
+ */
function delete($key) {
$fn = $this->mode . '_rm';
return $fn($this->prefix . $key);
*
* @package moodlecore
* @subpackage editor
- * @copyright 2009 Petr Skoda (http://skodak.org)
+ * @copyright 2009 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Returns users preferred editor for given format
+ *
+ * @todo implement user preferences for text editors
+ *
+ * @global object
+ * @global object
* @param int $format text format or null of none
- * @return texeditor object
+ * @return object texteditor object
*/
function get_preferred_texteditor($format=null) {
global $CFG, $USER;
/**
* Returns instance of text editor
+ *
+ * @global object
* @param string $editorname name of editor (textarea, tinymce, ...)
- * @return mixed texeditor instance or false if does not exist
+ * @return object|bool texeditor instance or false if does not exist
*/
function get_texteditor($editorname) {
global $CFG;
/**
* Get the list of available editors
- * @return array ('editorname'=>'localised editor name')
+ *
+ * @return array Array ('editorname'=>'localised editor name')
*/
function get_available_editors() {
$editors = array();
/**
* Base abstract text editor class.
+ *
+ * @copyright 2009 Petr Skoda {@link http://skodak.org}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
abstract class texteditor {
/**
/**
* Returns list of supported text formats
- * @return array(FORMAT=>FORMAT)
+ * @return array Array (FORMAT=>FORMAT)
*/
public abstract function get_supported_formats();
/**
* Supports file picker and repos?
- * @return book
+ * @return object book object
*/
public abstract function supports_repositories();
//=== DEPRECATED =====================
/**
* can_use_html_editor is deprecated...
+ * @deprecated
+ * @todo Deprecated: eradicate completely, replace with something else
+ * @return bool
*/
function can_use_html_editor() {
//TODO: eradicate completely, replace with something else
<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// 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.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* Library of functions for events manipulation.
*
* The public API is all at the end of this file.
*
- * @author Martin Dougiamas and many others
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
-
/**
* Loads the events definitions for the component (from file). If no
* events are defined for the component, we simply return an empty array.
- * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
- * @return array of capabilities or empty array if not exists
*
* INTERNAL - to be used from eventslib only
+ *
+ * @global object
+ * @param string $component examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @return array of capabilities or empty array if not exists
*/
function events_load_def($component) {
global $CFG;
/**
* Gets the capabilities that have been cached in the database for this
* component.
- * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
- * @return array of events
*
* INTERNAL - to be used from eventslib only
+ *
+ * @global object
+ * @param string $component examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @return array of events
*/
function events_get_cached($component) {
global $DB;
* will cause any queued events for the component to be removed from
* the database.
*
- * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @global object
+ * @param string $component examples: 'moodle', 'mod/forum', 'block/quiz_results'
* @return boolean
*/
function events_update_definition($component='moodle') {
/**
* Remove all event handlers and queued events
- * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ *
+ * @param string $component examples: 'moodle', 'mod/forum', 'block/quiz_results'
*/
function events_uninstall($component) {
$cachedhandlers = events_get_cached($component);
/**
* Deletes cached events that are no longer needed by the component.
- * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
- * @param $chachedevents - array of the cached events definitions that will be
- * @return int - number of deprecated capabilities that have been removed
*
* INTERNAL - to be used from eventslib only
+ *
+ * @global object
+ * @param string $component examples: 'moodle', 'mod/forum', 'block/quiz_results'
+ * @param array $chachedevents array of the cached events definitions that will be
+ * @return int number of deprecated capabilities that have been removed
*/
function events_cleanup($component, $cachedhandlers) {
global $DB;
/**
* puts a handler on queue
- * @param object handler - event handler object from db
- * @param object eventdata - event data object
- * @return id number of new queue handler
*
* INTERNAL - to be used from eventslib only
+ *
+ * @global object
+ * @param object $handler event handler object from db
+ * @param object $event event data object
+ * @param string $errormessage The error message indicating the problem
+ * @return id number of new queue handler
*/
function events_queue_handler($handler, $event, $errormessage) {
global $DB;
/**
* trigger a single event with a specified handler
- * @param handler - hander object from db
- * @param eventdata - event dataobject
- * @param errormessage - error message indicating problem
- * @return bool - success or fail
*
* INTERNAL - to be used from eventslib only
+ *
+ * @param handler $hander object from db
+ * @param eventdata $eventdata dataobject
+ * @param string $errormessage error message indicating problem
+ * @return bool success or fail
*/
function events_dispatch($handler, $eventdata, &$errormessage) {
global $CFG;
/**
* given a queued handler, call the respective event handler to process the event
- * @param object qhandler - events_queued_handler object from db
- * @return boolean meaning success, or NULL on fatal failure
*
* INTERNAL - to be used from eventslib only
+ *
+ * @global object
+ * @global object
+ * @param object $qhandler events_queued_handler object from db
+ * @return boolean meaning success, or NULL on fatal failure
*/
function events_process_queued_handler($qhandler) {
global $CFG, $DB;
/**
* removes this queued handler from the events_queued_handler table
+ *
* removes events_queue record from events_queue if no more references to this event object exists
- * @param object qhandler - events_queued_handler object from db
*
* INTERNAL - to be used from eventslib only
+ *
+ * @global object
+ * @param object $qhandler events_queued_handler object from db
*/
function events_dequeue($qhandler) {
global $DB;
/**
* Returns hanflers for given event. Uses caching for better perf.
- * @param string $eventanme name of even or 'reset'
- * @return mixed array of handlers or false otherwise
*
* INTERNAL - to be used from eventslib only
+ *
+ * @global object
+ * @staticvar array $handlers
+ * @param string $eventanme name of even or 'reset'
+ * @return mixed array of handlers or false otherwise
*/
function events_get_handlers($eventname) {
global $DB;
/**
* Events cron will try to empty the events queue by processing all the queued events handlers
- * @param string eventname - empty means all
- * @return number of dispatched+removed broken events
*
* PUBLIC
+ *
+ * @global object
+ * @param string $eventname empty means all
+ * @return number of dispatched+removed broken events
*/
function events_cron($eventname='') {
global $DB;
/**
* Function to call all eventhandlers when triggering an event
- * @param eventname - name of the event
- * @param eventdata - event data object
- * @return number of failed events
*
* PUBLIC
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @param string $eventname name of the event
+ * @param object $eventdata event data object
+ * @return int number of failed events
*/
function events_trigger($eventname, $eventdata) {
global $CFG, $USER, $DB;
/**
* checks if an event is registered for this component
- * @param string eventname - name of the event
- * @param string component - component name, can be mod/data or moodle
- * @return bool
*
- * PUBLIC
+ * @global object
+ * @param string $eventname name of the event
+ * @param string $component component name, can be mod/data or moodle
+ * @return bool
*/
function events_is_registered($eventname, $component) {
global $DB;
/**
* checks if an event is queued for processing - either cron handlers attached or failed instant handlers
- * @param string eventname - name of the event
- * @return int number of queued events
*
* PUBLIC
+ *
+ * @global object
+ * @global object
+ * @param string $eventname name of the event
+ * @return int number of queued events
*/
function events_pending_count($eventname) {
global $CFG, $DB;
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * This script serves users private files
+ * This script serves user's private files
*
* @package moodlecore
* @subpackage file