-<?php // $Id$
+<?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/>.
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/** @see lexer.php */
require_once($CFG->libdir.'/lexer.php');
-// Constants for the various types of tokens
+/** Constants for the various types of tokens */
define("TOKEN_USER","0");
define("TOKEN_META","1");
define("TOKEN_DATETO","7");
define("TOKEN_INSTANCE","8");
-// Class to hold token/value pairs after they're parsed.
-
+/**
+ * Class to hold token/value pairs after they're parsed.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class search_token {
private $value;
private $type;
* This class does the heavy lifting of lexing the search string into tokens.
* Using a full-blown lexer is probably overkill for this application, but
* might be useful for other tasks.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class search_lexer extends Lexer{
* the parsed token array.
* Most functions in this class should only be called by the lexer, the
* one exception being getParseArray() which returns the result.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class search_parser {
private $tokens;
* $parsetree should be a parse tree generated by a
* search_lexer/search_parser combination.
* Other fields are database table names to search.
+ *
+ * @global object
+ * @global object
*/
function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,
$userfirstnamefield, $userlastnamefield, $timefield, $instancefield) {
* $parsetree should be a parse tree generated by a
* search_lexer/search_parser combination.
* Other fields are database table names to search.
+ *
+ * @global object
+ * @global object
*/
function search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,
$userfirstnamefield, $userlastnamefield, $timefield, $instancefield) {
<?php
-/// This is a tiny standalone diagnostic script to test that sessions
-/// are working correctly on a given server.
-///
-/// Just run it from a browser. The first time you run it will
-/// set a new variable, and after that it will try to find it again.
-/// The random number is just to prevent browser caching.
+// 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 is a tiny standalone diagnostic script to test that sessions
+ * are working correctly on a given server.
+ *
+ * Just run it from a browser. The first time you run it will
+ * set a new variable, and after that it will try to find it again.
+ * The random number is just to prevent browser caching.
+ *
+ * @todo add code that actually tests moodle sessions, the old one only tested
+ * PHP sessions used from installer, not the real moodle sessions
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/** Include config {@see config.php} */
require '../config.php';
error('session test not reimplemented yet');
-<?php //$Id$
+<?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/>.
/**
- * Factory method returning moodle_session object.
- * @return moodle_session
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+
+/**
+ * Factory method returning moodle_session object.
+ * @return moodle_session
+ */
function session_get_instance() {
global $CFG, $DB;
return $session;
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
interface moodle_session {
/**
* Terminate current session
/**
* Class handling all session and cookies related stuff.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class session_stub implements moodle_session {
protected $justloggedout;
/**
* Legacy moodle sessions stored in files, not recommended any more.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class legacy_file_session extends session_stub {
protected function init_session_storage() {
/**
* Recommended moodle session storage.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class database_session extends session_stub {
protected $record = null;
<?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/>.
+
/**
* setup.php - Sets up sessions, connects to databases and so on
*
* Normally this is only called by the main config.php file
* Normally this file does not need to be edited.
- * @author Martin Dougiamas
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* - $CFG->libdir - Path to moodle's library folder on server's filesystem.
*
* @global object $CFG
+ * @name $CFG
*/
global $CFG;
/**
* Database connection. Used for all access to the database.
* @global moodle_database $DB
+ * @name $DB
*/
global $DB;
* Moodle's wrapper round PHP's $_SESSION.
*
* @global object $SESSION
+ * @name $SESSION
*/
global $SESSION;
* - $USER->lang - The user's language choice.
*
* @global object $USER
+ * @name $USER
*/
global $USER;
* generating in response to the user's request.
*
* @global moodle_page $PAGE
+ * @name $PAGE
*/
global $PAGE;
/**
* The current course. An alias for $PAGE->course.
* @global object $COURSE
+ * @name $COURSE
*/
global $COURSE;
* - $THEME->cellheading2 - Alternate cell colors.
*
* @global object $THEME
+ * @name THEME
*/
global $THEME;
/**
* Shared memory cache.
* @global object $MCACHE
+ * @name $MCACHE
*/
global $MCACHE;
*
* Its primary goal is to allow 100% HTTPS pages when $CFG->loginhttps is enabled. Default to false.
* Its enabled only by the httpsrequired() function and used in some pages to update some URLs
-*/
+ *
+ * @global bool $HTTPSPAGEREQUIRED
+ * @name $HTTPSPAGEREQUIRED
+ */
global $HTTPSPAGEREQUIRED;
-/** Full script path including all params, slash arguments, scheme and host.*/
+/**
+ * Full script path including all params, slash arguments, scheme and host.
+ * @global string $FULLME
+ * @name $FULLME
+ */
global $FULLME;
-/** Script path including query string and slash arguments without host. */
+/**
+ * Script path including query string and slash arguments without host.
+ * @global string $ME
+ * @name $ME
+ */
global $ME;
-/** $FULLME without slasharguments and query string.*/
+/**
+ * $FULLME without slasharguments and query string.
+ * @global string $FULLSCRIPT
+ * @name $FULLSCRIPT
+ */
global $FULLSCRIPT;
-/** Relative moodle script path '/course/view.php' */
+/**
+ * Relative moodle script path '/course/view.php'
+ * @global string $SCRIPT
+ * @name $SCRIPT
+ */
global $SCRIPT;
if (!isset($CFG->wwwroot)) {
if (isset($_SERVER['REMOTE_ADDR'])) {
define('CLI_SCRIPT', false);
} else {
+ /** @ignore */
define('CLI_SCRIPT', true);
}
}
-<?php // $Id$
- // These functions are required very early in the Moodle
- // setup process, before any of the main libraries are
- // loaded.
+<?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/>.
+/**
+ * These functions are required very early in the Moodle
+ * setup process, before any of the main libraries are
+ * loaded.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
/**
* Simple class
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class object {};
/**
* Base Moodle Exception class
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class moodle_exception extends Exception {
public $errorcode;
/**
* Exception indicating programming error, must be fixed by a programer. For example
* a core API might throw this type of exception if a plugin calls it incorrectly.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class coding_exception extends moodle_exception {
/**
* CONTEXT_... constant. You might throw an invalid_state_exception in the
* default case, to just in case something really weird is going on, and
* $context->contextlevel is invalid - rather than ignoring this possibility.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class invalid_state_exception extends moodle_exception {
/**
-<?php // $Id$
+<?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/>.
+
/**
* Utility functions to make unit testing easier.
*
* dirty methods for getting things done in test cases. None of these
* methods should be used outside test code.
*
+ * Major Contirbutors
+ * - T.J.Hunt@open.ac.uk
+ *
+ * @package moodlecore
+ * @subpackage simpletestex
* @copyright © 2006 The Open University
- * @author T.J.Hunt@open.ac.uk
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @version $Id$
- * @package SimpleTestEx
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+/**
+ * Includes
+ */
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/simpletestlib/simpletest.php');
require_once($CFG->libdir . '/simpletestlib/unit_tester.php');
/**
* An expectation for comparing strings ignoring whitespace.
+ *
+ * @package moodlecore
+ * @subpackage simpletestex
+ * @copyright © 2006 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class IgnoreWhitespaceExpectation extends SimpleExpectation {
var $expect;
/**
* An Expectation that two arrays contain the same list of values.
+ *
+ * @package moodlecore
+ * @subpackage simpletestex
+ * @copyright © 2006 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class ArraysHaveSameValuesExpectation extends SimpleExpectation {
var $expect;
* An Expectation that compares to objects, and ensures that for every field in the
* expected object, there is a key of the same name in the actual object, with
* the same value. (The actual object may have other fields to, but we ignore them.)
+ *
+ * @package moodlecore
+ * @subpackage simpletestex
+ * @copyright © 2006 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class CheckSpecifiedFieldsExpectation extends SimpleExpectation {
var $expect;
* The tear-down method for this class should automatically revert any changes
* you make during test set-up using the metods defined here. That is, it will
* drop tables for you automatically and revert to the real $DB and $USER->id.
+ *
+ * @package moodlecore
+ * @subpackage simpletestex
+ * @copyright © 2006 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class UnitTestCaseUsingDatabase extends UnitTestCase {
private $realdb;
}
}
+/**
+ * @package moodlecore
+ * @subpackage simpletestex
+ * @copyright © 2006 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class FakeDBUnitTestCase extends UnitTestCase {
public $tables = array();
public $pkfile;
* If this file already exists, it means that a previous run of unit tests
* did not complete, and has left data undeleted in the DB. This data is then
* deleted and the file is retained. Otherwise it is created.
- * @throws moodle_exception if CSV file cannot be created
+ *
+ * throws moodle_exception if CSV file cannot be created
*/
public function __construct($label = false) {
global $DB, $CFG;
* Given a filename, opens it and parses the csv contained therein. It expects two fields per line:
* 1. Table name
* 2. Max id
+ *
+ * throws moodle_exception if file doesn't exist
+ *
* @param string $filename
- * @throws moodle_exception if file doesn't exist
*/
public function get_table_data($filename) {
global $CFG;
/**
* Method called before each test method. Replaces the real $DB with the one configured for unit tests (different prefix, $CFG->unittestprefix).
* Also detects if this config setting is properly set, and if the user table exists.
- * TODO Improve detection of incorrectly built DB test tables (e.g. detect version discrepancy and offer to upgrade/rebuild)
+ * @todo Improve detection of incorrectly built DB test tables (e.g. detect version discrepancy and offer to upgrade/rebuild)
*/
public function setUp() {
global $DB, $CFG;
* Internally, it routes all calls to $DB to a real instance of the database engine (aggregated as a member variable),
* except those that are defined in this proxy class. This makes it possible to add extra code to the database engine
* without subclassing it.
+ *
+ * @package moodlecore
+ * @subpackage simpletestex
+ * @copyright © 2006 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class UnitTestDB {
public static $DB;
/**
* Overriding update_record: If we are updating a record that was NOT inserted by unit tests,
* throw an exception and cancel update.
- * @throws moodle_exception If trying to update a record not inserted by unit tests.
+ *
+ * throws moodle_exception If trying to update a record not inserted by unit tests.
*/
public function update_record($table, $dataobject, $bulk=false) {
global $DB;
/**
* Overriding delete_record: If we are deleting a record that was NOT inserted by unit tests,
* throw an exception and cancel delete.
- * @throws moodle_exception If trying to delete a record not inserted by unit tests.
+ *
+ * throws moodle_exception If trying to delete a record not inserted by unit tests.
*/
public function delete_records($table, array $conditions=array()) {
global $DB;
/**
* Overriding delete_records_select: If we are deleting a record that was NOT inserted by unit tests,
* throw an exception and cancel delete.
- * @throws moodle_exception If trying to delete a record not inserted by unit tests.
+ *
+ * throws moodle_exception If trying to delete a record not inserted by unit tests.
*/
public function delete_records_select($table, $select, array $params=null) {
global $DB;
<?php
-// Web services wrapper library script
+// 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/>.
+
+/**
+ * Web services wrapper library script
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
if (check_php_version('5') && class_exists('SoapClient')) {
- // Use the native PHP5 support
+ /** Use the native PHP5 support */
require_once($CFG->libdir . '/soap/phpsoap.php');
}
else{
- // Use nuSOAP instead
+ /** Use nuSOAP instead */
require_once($CFG->libdir . '/soap/nusoap.php');
function make_soap_fault($faultcode, $faultstring, $faultactor='', $detail='', $faultname='', $headerfault='') {
}
}
else {
+ /** @ignore */
function soap_connect($wsdl, $trace=false) {
return new soapclient($wsdl, 'wsdl');
}
<?php
- // THESE CONSTANTS ARE USED FOR THE REPORTING PAGE.
+// 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/>.
+
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+ /** THESE CONSTANTS ARE USED FOR THE REPORTING PAGE. */
define('STATS_REPORT_LOGINS',1); // double impose logins and unqiue logins on a line graph. site course only.
define('STATS_REPORT_READS',2); // double impose student reads and teacher reads on a line graph.