Skip to content

Commit

Permalink
MDL-30985 Fixed up event API phpdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Feb 27, 2012
1 parent c4a12af commit 1d1719f
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 87 deletions.
13 changes: 6 additions & 7 deletions enrol/category/db/events.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -16,12 +15,12 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* category enrolment plugin event handler definition.
* Category enrolment plugin event handler definition.
*
* @package enrol
* @subpackage category
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package enrol_category
* @category event
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
Expand All @@ -42,4 +41,4 @@
'internal' => 1,
),

);
);
9 changes: 4 additions & 5 deletions enrol/cohort/db/events.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -18,10 +17,10 @@
/**
* Cohort enrolment plugin event handler definition.
*
* @package enrol
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package enrol_cohort
* @category event
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
Expand Down
9 changes: 4 additions & 5 deletions enrol/meta/db/events.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -18,10 +17,10 @@
/**
* Meta course enrolment plugin event handler definition.
*
* @package enrol
* @subpackage meta
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package enrol_meta
* @category event
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
Expand Down
9 changes: 4 additions & 5 deletions lib/db/events.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -19,10 +18,10 @@
* 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
* @package core_event
* @category 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();
Expand Down
61 changes: 33 additions & 28 deletions lib/eventslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -20,10 +19,9 @@
*
* The public API is all at the end of this file.
*
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core
* @subpackage event
* @package core_event
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
Expand All @@ -32,7 +30,7 @@
* Loads the events definitions for the component (from file). If no
* events are defined for the component, we simply return an empty array.
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
* @return array of capabilities or empty array if not exists
Expand Down Expand Up @@ -94,7 +92,7 @@ function events_load_def($component) {
* Gets the capabilities that have been cached in the database for this
* component.
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
* @return array of events
Expand Down Expand Up @@ -126,6 +124,8 @@ function events_get_cached($component) {
* will cause any queued events for the component to be removed from
* the database.
*
* @category event
*
* @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
* @return boolean always returns true
*/
Expand Down Expand Up @@ -194,6 +194,7 @@ function events_update_definition($component='moodle') {
/**
* Remove all event handlers and queued events
*
* @category event
* @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
*/
function events_uninstall($component) {
Expand All @@ -206,7 +207,7 @@ function events_uninstall($component) {
/**
* Deletes cached events that are no longer needed by the component.
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
* @param array $cachedhandlers array of the cached events definitions that will be
Expand All @@ -233,14 +234,14 @@ function events_cleanup($component, $cachedhandlers) {
/****************** End of Events handler Definition code *******************/

/**
* puts a handler on queue
* Puts a handler on queue
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @param object $handler event handler object from db
* @param object $event event data object
* @param stdClass $handler event handler object from db
* @param stdClass $event event data object
* @param string $errormessage The error message indicating the problem
* @return id number of new queue handler
* @return int id number of new queue handler
*/
function events_queue_handler($handler, $event, $errormessage) {
global $DB;
Expand Down Expand Up @@ -268,12 +269,12 @@ function events_queue_handler($handler, $event, $errormessage) {
/**
* trigger a single event with a specified handler
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @param handler $hander object from db
* @param eventdata $eventdata dataobject
* @param stdClass $hander Row from db
* @param stdClass $eventdata dataobject
* @param string $errormessage error message indicating problem
* @return bool true means event processed, false means retry event later; may throw exception, NULL means internal error
* @return bool|null True means event processed, false means retry event later; may throw exception, NULL means internal error
*/
function events_dispatch($handler, $eventdata, &$errormessage) {
global $CFG;
Expand Down Expand Up @@ -309,9 +310,9 @@ function events_dispatch($handler, $eventdata, &$errormessage) {
/**
* given a queued handler, call the respective event handler to process the event
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @param object $qhandler events_queued_handler object from db
* @param stdClass $qhandler events_queued_handler row from db
* @return boolean true means event processed, false means retry later, NULL means fatal failure
*/
function events_process_queued_handler($qhandler) {
Expand Down Expand Up @@ -368,9 +369,9 @@ function events_process_queued_handler($qhandler) {
*
* Removes events_queue record from events_queue if no more references to this event object exists
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @param object $qhandler events_queued_handler object from db
* @param stdClass $qhandler events_queued_handler row from db
*/
function events_dequeue($qhandler) {
global $DB;
Expand All @@ -387,11 +388,11 @@ function events_dequeue($qhandler) {
/**
* Returns handlers for given event. Uses caching for better perf.
*
* INTERNAL - to be used from eventslib only
* @access protected INTERNAL - to be used from eventslib only
*
* @staticvar array $handlers
* @param string $eventanme name of even or 'reset'
* @return mixed array of handlers or false otherwise
* @return array|false array of handlers or false otherwise
*/
function events_get_handlers($eventname) {
global $DB;
Expand All @@ -415,10 +416,11 @@ function events_get_handlers($eventname) {
/**
* Events cron will try to empty the events queue by processing all the queued events handlers
*
* PUBLIC
* @access public Part of the public API
* @category event
*
* @param string $eventname empty means all
* @return number of dispatched events
* @return int number of dispatched events
*/
function events_cron($eventname='') {
global $DB;
Expand Down Expand Up @@ -477,7 +479,8 @@ function events_cron($eventname='') {
/**
* Function to call all event handlers when triggering an event
*
* PUBLIC
* @access public Part of the public API.
* @category event
*
* @param string $eventname name of the event
* @param object $eventdata event data object
Expand Down Expand Up @@ -586,6 +589,8 @@ function events_trigger($eventname, $eventdata) {
/**
* checks if an event is registered for this component
*
* @access public Part of the public API
*
* @param string $eventname name of the event
* @param string $component component name, can be mod/data or moodle
* @return bool
Expand All @@ -598,7 +603,7 @@ function events_is_registered($eventname, $component) {
/**
* checks if an event is queued for processing - either cron handlers attached or failed instant handlers
*
* PUBLIC
* @access public Part of the public API
*
* @param string $eventname name of the event
* @return int number of queued events
Expand All @@ -612,4 +617,4 @@ function events_pending_count($eventname) {
WHERE h.eventname = ?";

return $DB->count_records_sql($sql, array($eventname));
}
}
47 changes: 22 additions & 25 deletions mod/assignment/db/events.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
<?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/>.

///////////////////////////////////////////////////////////////////////////
// Defines core event handlers //
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.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 3 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 //
// //
///////////////////////////////////////////////////////////////////////////

/**
* Definition of assignment event handlers
*
* @package mod_assignment
* @category event
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$handlers = array();

Expand Down
6 changes: 3 additions & 3 deletions mod/chat/db/events.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -18,9 +17,10 @@
/**
* User logout event handler definition.
*
* @package mod_chat
* @package mod_chat
* @category event
* @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/* List of handlers */
Expand Down
6 changes: 3 additions & 3 deletions mod/forum/db/events.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -18,9 +17,10 @@
/**
* Meta course enrolment plugin event handler definition.
*
* @package enrol_meta
* @package enrol_meta
* @category event
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/* List of handlers */
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Post-install code for the quiz module.
* Add event handlers for the quiz
*
* @package mod
* @subpackage quiz
* @package mod_quiz
* @category event
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand Down
Loading

0 comments on commit 1d1719f

Please sign in to comment.