$olddir = getcwd();
-// change directory so that includes bellow work properly
+// change directory so that includes below work properly
chdir(dirname($_SERVER['argv'][0]));
// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
echo '</form>';
}
-echo $OUTPUT->footer();
-
+$PAGE->requires->yui_module('moodle-core-formslib',
+ 'M.core.init_formslib',
+ array(array(
+ 'formid' => 'adminsettings'
+ ))
+);
+$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
+echo $OUTPUT->footer();
(user would need file access to dataroot which might prevent various "accidents")
- implement "Export/import running" notification in lib/setup.php (similar to new upgrade flag in config table)
- gzip compression when storing xml file - the xml is very verbose and full of repeated tags (zip is not suitable here at all)
- this could help us keep the files bellow 2G (expected ratio is >Â 10:1)
+ this could help us keep the files below 2G (expected ratio is >Â 10:1)
*/
}
}
if (!isset($user->username)) {
- // prevent warnings bellow
+ // prevent warnings below
$user->username = '';
}
$functions[$functionid] = $function->name . ':' . $function->description;
}
- $mform->addElement('searchableselector', 'fid', get_string('name'),
+ $mform->addElement('searchableselector', 'fids', get_string('name'),
$functions, array('multiple'));
$mform->addElement('hidden', 'id');
//add the function to the service then redirect to function list page
if ($data = $mform->get_data()) {
ignore_user_abort(true); // no interruption here!
- foreach ($data->fid as $fid) {
+ foreach ($data->fids as $fid) {
$function = $webservicemanager->get_external_function_by_id(
$fid, MUST_EXIST);
// make sure the function is not there yet
//add the missing capabilities to the allowed users object to be displayed by renderer
foreach ($allowedusers as &$alloweduser) {
if (!is_siteadmin($alloweduser->id) and key_exists($alloweduser->id, $usersmissingcaps)) {
- $alloweduser->missingcapabilities = implode(',', $usersmissingcaps[$alloweduser->id]);
+ $alloweduser->missingcapabilities = implode(', ', $usersmissingcaps[$alloweduser->id]);
}
}
$courseid = (empty($courseid)) ? SITEID : $courseid;
-if (!empty($courseid)) {
- $PAGE->set_context(get_context_instance(CONTEXT_COURSE, $courseid));
-}
-
-if (!empty($modid)) {
- $PAGE->set_context(get_context_instance(CONTEXT_MODULE, $modid));
+if (empty($entryid) && empty($modid) && empty($groupid)) {
+ $PAGE->set_context(context_user::instance($USER->id));
+} else if (!empty($modid)) {
+ $PAGE->set_context(context_module::instance($modid));
+} else if (!empty($courseid)) {
+ $PAGE->set_context(context_course::instance($courseid));
+} else {
+ $PAGE->set_context(context_system::instance());
}
$blogheaders = blog_get_headers();
-if (empty($entryid) && empty($modid) && empty($groupid)) {
- $PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
-}
-
if ($CFG->enablerssfeeds) {
$rsscontext = null;
$filtertype = null;
// Change contextlevel to SYSTEM if viewing the site course
if ($context->contextlevel == CONTEXT_COURSE && $context->instanceid == SITEID) {
- $context->contextlevel = CONTEXT_SYSTEM;
+ $context = context_system::instance();
}
$filterparam = '';
<?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/>.
-/////////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Calendar extension //
-// //
-// Copyright (C) 2003-2004 Greek School Network www.sch.gr //
-// //
-// Designed by: //
-// Avgoustos Tsinakos (tsinakos@teikav.edu.gr) //
-// Jon Papaioannou (pj@moodle.org) //
-// //
-// Programming and development: //
-// Jon Papaioannou (pj@moodle.org) //
-// //
-// For bugs, suggestions, etc contact: //
-// Jon Papaioannou (pj@moodle.org) //
-// //
-// The current module was developed at the University of Macedonia //
-// (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) //
-// The aim of this project is to provide additional and improved //
-// functionality to the Asynchronous Distance Education service that the //
-// Greek School Network deploys. //
-// //
-// 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 //
-// //
-/////////////////////////////////////////////////////////////////////////////
-
-// These are read by the administration component to provide default values
+/**
+ * Calendar extension
+ *
+ * @package core_calendar
+ * @copyright 2004 Greek School Network (http://www.sch.gr), Jon Papaioannou,
+ * Avgoustos Tsinakos
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * These are read by the administration component to provide default values
+ */
+
+/**
+ * CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD - default value of upcoming event preference
+ */
define('CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD', 21);
+
+/**
+ * CALENDAR_DEFAULT_UPCOMING_MAXEVENTS - default value to display the maximum number of upcoming event
+ */
define('CALENDAR_DEFAULT_UPCOMING_MAXEVENTS', 10);
-define('CALENDAR_DEFAULT_STARTING_WEEKDAY', 1);
+
+/**
+ * CALENDAR_DEFAULT_STARTING_WEEKDAY - default value to display the starting weekday
+ */
+define('CALENDAR_DEFAULT_STARTING_WEEKDAY', 1);
+
// This is a packed bitfield: day X is "weekend" if $field & (1 << X) is true
// Default value = 65 = 64 + 1 = 2^6 + 2^0 = Saturday & Sunday
-define('CALENDAR_DEFAULT_WEEKEND', 65);
+
+/**
+ * CALENDAR_DEFAULT_WEEKEND - default value for weekend (Saturday & Sunday)
+ */
+define('CALENDAR_DEFAULT_WEEKEND', 65);
+
+/**
+ * CALENDAR_URL - path to calendar's folder
+ */
define('CALENDAR_URL', $CFG->wwwroot.'/calendar/');
+
+/**
+ * CALENDAR_TF_24 - Calendar time in 24 hours format
+ */
define('CALENDAR_TF_24', '%H:%M');
+
+/**
+ * CALENDAR_TF_12 - Calendar time in 12 hours format
+ */
define('CALENDAR_TF_12', '%I:%M %p');
+/**
+ * CALENDAR_EVENT_GLOBAL - Global calendar event types
+ */
define('CALENDAR_EVENT_GLOBAL', 1);
+
+/**
+ * CALENDAR_EVENT_COURSE - Course calendar event types
+ */
define('CALENDAR_EVENT_COURSE', 2);
+
+/**
+ * CALENDAR_EVENT_GROUP - group calendar event types
+ */
define('CALENDAR_EVENT_GROUP', 4);
+
+/**
+ * CALENDAR_EVENT_USER - user calendar event types
+ */
define('CALENDAR_EVENT_USER', 8);
/**
- * CALENDAR_STARTING_WEEKDAY has since been deprecated please call calendar_get_starting_weekday() instead
- * @deprecated
+ * CALENDAR_STARTING_WEEKDAY - has since been deprecated please call calendar_get_starting_weekday() instead
+ *
+ * @deprecated Moodle 2.0 MDL-24284- please do not use this function any more.
+ * @todo MDL-31132 This will be deleted in Moodle 2.3.
+ * @see calendar_get_starting_weekday()
*/
define('CALENDAR_STARTING_WEEKDAY', CALENDAR_DEFAULT_STARTING_WEEKDAY);
/**
* Return the days of the week
*
- * @return array
+ * @return array array of days
*/
function calendar_get_days() {
return array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
/**
* Generates the HTML for a miniature calendar
*
- * @global core_renderer $OUTPUT
- * @param array $courses
- * @param array $groups
- * @param array $users
- * @param int $cal_month
- * @param int $cal_year
- * @return string
+ * @param array $courses list of course
+ * @param array $groups list of group
+ * @param array $users user's info
+ * @param int $cal_month calendar month in numeric, default is set to false
+ * @param int $cal_year calendar month in numeric, default is set to false
+ * @return string $content return html table for mini calendar
*/
function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_year = false) {
global $CFG, $USER, $OUTPUT;
}
/**
- * calendar_get_popup, called at multiple points in from calendar_get_mini.
- * Copied and modified from calendar_get_mini.
- * @global moodle_page $PAGE
- * @param $is_today bool, false except when called on the current day.
- * @param $event_timestart mixed, $events[$eventid]->timestart, OR false if there are no events.
- * @param $popupcontent string.
- * @return $popup string, contains onmousover and onmouseout events.
+ * Gets the calendar popup
+ *
+ * It called at multiple points in from calendar_get_mini.
+ * Copied and modified from calendar_get_mini.
+ *
+ * @param bool $is_today false except when called on the current day.
+ * @param mixed $event_timestart $events[$eventid]->timestart, OR false if there are no events.
+ * @param string $popupcontent content for the popup window/layout
+ * @return string of eventid for the calendar_tooltip popup window/layout
*/
function calendar_get_popup($is_today, $event_timestart, $popupcontent='') {
global $PAGE;
return 'id="'.$id.'"';
}
+/**
+ * Gets the calendar upcoming event
+ *
+ * @param array $courses array of courses
+ * @param array|int|bool $groups array of groups, group id or boolean for all/no group events
+ * @param array|int|bool $users array of users, user id or boolean for all/no user events
+ * @param int $daysinfuture number of days in the future we 'll look
+ * @param int $maxevents maximum number of events
+ * @param int $fromtime start time
+ * @return array $output array of upcoming events
+ */
function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
global $CFG, $COURSE, $DB;
return $output;
}
+/**
+ * Add calendar event metadata
+ *
+ * @param stdClass $event event info
+ * @return stdClass $event metadata
+ */
function calendar_add_event_metadata($event) {
global $CFG, $OUTPUT;
/**
* Prints a calendar event
*
- * @deprecated 2.0
+ * @deprecated Moodle 2.0 - MDL-22887 please do not use this function any more.
+ * @todo MDL-31133 - will be removed in Moodle 2.3
+ * @see core_calendar_renderer event function
*/
function calendar_print_event($event, $showactions=true) {
global $CFG, $USER, $OUTPUT, $PAGE;
/**
* Get calendar events
+ *
* @param int $tstart Start time of time range for events
- * @param int $tend End time of time range for events
- * @param array/int/boolean $users array of users, user id or boolean for all/no user events
- * @param array/int/boolean $groups array of groups, group id or boolean for all/no group events
- * @param array/int/boolean $courses array of courses, course id or boolean for all/no course events
+ * @param int $tend End time of time range for events
+ * @param array|int|boolean $users array of users, user id or boolean for all/no user events
+ * @param array|int|boolean $groups array of groups, group id or boolean for all/no group events
+ * @param array|int|boolean $courses array of courses, course id or boolean for all/no course events
* @param boolean $withduration whether only events starting within time range selected
* or events in progress/already started selected as well
* @param boolean $ignorehidden whether to select only visible events or all events
- * @return array of selected events or an empty array if there aren't any (or there was an error)
+ * @return array $events of selected events or an empty array if there aren't any (or there was an error)
*/
function calendar_get_events($tstart, $tend, $users, $groups, $courses, $withduration=true, $ignorehidden=true) {
global $DB;
return $events;
}
+/**
+ * Get control options for Calendar
+ *
+ * @param string $type of calendar
+ * @param array $data calendar information
+ * @return string $content return available control for the calender in html
+ */
function calendar_top_controls($type, $data) {
global $CFG;
$content = '';
return $content;
}
+/**
+ * Get the controls filter for calendar.
+ *
+ * Filter is used to hide calendar info from the display page
+ *
+ * @param moodle_url $returnurl return-url for filter controls
+ * @return string $content return filter controls in html
+ */
function calendar_filter_controls(moodle_url $returnurl) {
global $CFG, $USER, $OUTPUT;
return $content;
}
+/**
+ * Return the representation day
+ *
+ * @param int $tstamp Timestamp in GMT
+ * @param int $now current Unix timestamp
+ * @param bool $usecommonwords
+ * @return string the formatted date/time
+ */
function calendar_day_representation($tstamp, $now = false, $usecommonwords = true) {
static $shortformat;
}
}
+/**
+ * return the formatted representation time
+ *
+ * @param int $time the timestamp in UTC, as obtained from the database
+ * @return string the formatted date/time
+ */
function calendar_time_representation($time) {
static $langtimeformat = NULL;
if($langtimeformat === NULL) {
* Adds day, month, year arguments to a URL and returns a moodle_url object.
*
* @param string|moodle_url $linkbase
- * @param int $d
- * @param int $m
- * @param int $y
- * @return moodle_url
+ * @param int $d The number of the day.
+ * @param int $m The number of the month.
+ * @param int $y The number of the year.
+ * @return moodle_url|null $linkbase
*/
function calendar_get_link_href($linkbase, $d, $m, $y) {
if (empty($linkbase)) {
/**
* This function has been deprecated as of Moodle 2.0... DO NOT USE!!!!!
*
- * @deprecated
- * @since 2.0
+ * @deprecated Moodle 2.0 - MDL-24284 please do not use this function any more.
+ * @todo MDL-31134 - will be removed in Moodle 2.3
+ * @see calendar_get_link_href()
*
* @param string $text
* @param string|moodle_url $linkbase
- * @param int|null $d
- * @param int|null $m
- * @param int|null $y
+ * @param int|null $d The number of the day.
+ * @param int|null $m The number of the month.
+ * @param int|null $y The number of the year.
* @return string HTML link
*/
function calendar_get_link_tag($text, $linkbase, $d, $m, $y) {
*
* @param string $text The text label.
* @param string|moodle_url $linkbase The URL stub.
- * @param int $d $m $y Day of month, month and year numbers.
+ * @param int $d The number of the date.
+ * @param int $m The number of the month.
+ * @param int $y year The number of the year.
* @param bool $accesshide Default visible, or hide from all except screenreaders.
* @return string HTML string.
*/
*
* @param string $text The text label.
* @param string|moodle_url $linkbase The URL stub.
- * @param int $d $m $y Day of month, month and year numbers.
+ * @param int $d the number of the Day
+ * @param int $m The number of the month.
+ * @param int $y The number of the year.
* @param bool $accesshide Default visible, or hide from all except screenreaders.
* @return string HTML string.
*/
return link_arrow_right($text, (string)$href, $accesshide, 'next');
}
+/**
+ * Return the name of the weekday
+ *
+ * @param string $englishname
+ * @return string of the weekeday
+ */
function calendar_wday_name($englishname) {
return get_string(strtolower($englishname), 'calendar');
}
+/**
+ * Return the number of days in month
+ *
+ * @param int $month the number of the month.
+ * @param int $year the number of the year
+ * @return int
+ */
function calendar_days_in_month($month, $year) {
return intval(date('t', mktime(0, 0, 0, $month, 1, $year)));
}
+/**
+ * Get the upcoming event block
+ *
+ * @param array $events list of events
+ * @param moodle_url|string $linkhref link to event referer
+ * @return string|null $content html block content
+ */
function calendar_get_block_upcoming($events, $linkhref = NULL) {
$content = '';
$lines = count($events);
return $content;
}
+/**
+ * Get the next following month
+ *
+ * If the current month is December, it will get the first month of the following year.
+ *
+ *
+ * @param int $month the number of the month.
+ * @param int $year the number of the year.
+ * @return array the following month
+ */
function calendar_add_month($month, $year) {
if($month == 12) {
return array(1, $year + 1);
}
}
+/**
+ * Get the previous month
+ *
+ * If the current month is January, it will get the last month of the previous year.
+ *
+ * @param int $month the number of the month.
+ * @param int $year the number of the year.
+ * @return array previous month
+ */
function calendar_sub_month($month, $year) {
if($month == 1) {
return array(12, $year - 1);
}
}
+/**
+ * Get per-day basis events
+ *
+ * @param array $events list of events
+ * @param int $month the number of the month
+ * @param int $year the number of the year
+ * @param array $eventsbyday event on specific day
+ * @param array $durationbyday duration of the event in days
+ * @param array $typesbyday event type (eg: global, course, user, or group)
+ * @param array $courses list of courses
+ * @return void
+ */
function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$durationbyday, &$typesbyday, &$courses) {
$eventsbyday = array();
$typesbyday = array();
return;
}
+/**
+ * Get current module cache
+ *
+ * @param array $coursecache list of course cache
+ * @param string $modulename name of the module
+ * @param int $instance module instance number
+ * @return stdClass|bool $module information
+ */
function calendar_get_module_cached(&$coursecache, $modulename, $instance) {
$module = get_coursemodule_from_instance($modulename, $instance);
return $module;
}
+/**
+ * Get current course cache
+ *
+ * @param array $coursecache list of course cache
+ * @param int $courseid id of the course
+ * @return stdClass $coursecache[$courseid] return the specific course cache
+ */
function calendar_get_course_cached(&$coursecache, $courseid) {
global $COURSE, $DB;
/**
* Returns the courses to load events for, the
*
- * @global moodle_database $DB
* @param array $courseeventsfrom An array of courses to load calendar events for
- * @param bool $ignorefilters
+ * @param bool $ignorefilters specify the use of filters, false is set as default
* @return array An array of courses, groups, and user to load calendar events for based upon filters
*/
function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
return array($courses, $group, $user);
}
+/**
+ * Return the capability for editing calendar event
+ *
+ * @param calendar_event $event event object
+ * @return bool capability to edit event
+ */
function calendar_edit_event_allowed($event) {
global $USER, $DB;
* Returns the default courses to display on the calendar when there isn't a specific
* course to display.
*
- * @global moodle_database $DB
- * @return array Array of courses to display
+ * @return array $courses Array of courses to display
*/
function calendar_get_default_courses() {
global $CFG, $DB;
return $courses;
}
+/**
+ * Display calendar preference button
+ *
+ * @param stdClass $course course object
+ * @return string return preference button in html
+ */
function calendar_preferences_button(stdClass $course) {
global $OUTPUT;
return $OUTPUT->single_button(new moodle_url('/calendar/preferences.php', array('course' => $course->id)), get_string("preferences", "calendar"));
}
+/**
+ * Get event format time
+ *
+ * @param calendar_event $event event object
+ * @param int $now current time in gmt
+ * @param array $linkparams list of params for event link
+ * @param bool $usecommonwords the words as formatted date/time.
+ * @param int $showtime determine the show time GMT timestamp
+ * @return string $eventtime link/string for event time
+ */
function calendar_format_event_time($event, $now, $linkparams = null, $usecommonwords = true, $showtime=0) {
$startdate = usergetdate($event->timestart);
$enddate = usergetdate($event->timestart + $event->timeduration);
return $eventtime;
}
+/**
+ * Display month selector options
+ *
+ * @param string $name for the select element
+ * @param string|array $selected options for select elements
+ */
function calendar_print_month_selector($name, $selected) {
$months = array();
for ($i=1; $i<=12; $i++) {
/**
* Sets the display of the event type given $display.
+ *
* If $display = true the event type will be shown.
* If $display = false the event type will NOT be shown.
* If $display = null the current value will be toggled and saved.
*
- * @param CALENDAR_EVENT_GLOBAL|CALENDAR_EVENT_COURSE|CALENDAR_EVENT_GROUP|CALENDAR_EVENT_USER $type
- * @param true|false|null $display
- * @param stdClass|int|null $user
+ * @param CALENDAR_EVENT_GLOBAL|CALENDAR_EVENT_COURSE|CALENDAR_EVENT_GROUP|CALENDAR_EVENT_USER $type object of CALENDAR_EVENT_XXX
+ * @param bool $display option to display event type
+ * @param stdClass|int $user moodle user object or id, null means current user
*/
function calendar_set_event_type_display($type, $display = null, $user = null) {
$persist = get_user_preferences('calendar_persistflt', 0, $user);
}
}
+/**
+ * Get calendar's allowed types
+ *
+ * @param stdClass $allowed list of allowed edit for event type
+ * @param stdClass|int $course object of a course or course id
+ */
function calendar_get_allowed_types(&$allowed, $course = null) {
global $USER, $CFG, $DB;
$allowed = new stdClass();
}
/**
- * see if user can add calendar entries at all
+ * See if user can add calendar entries at all
* used to print the "New Event" button
- * @return bool
+ *
+ * @param stdClass $course object of a course or course id
+ * @return bool has the capability to add at least one event type
*/
function calendar_user_can_add_event($course) {
if (!isloggedin() || isguestuser()) {
/**
* Check wether the current user is permitted to add events
*
- * @param object $event
- * @return bool
+ * @param stdClass $event object of event
+ * @return bool has the capability to add event
*/
function calendar_add_event_allowed($event) {
global $USER, $DB;
}
/**
- * A class to manage calendar events
+ * Manage calendar events
*
* This class provides the required functionality in order to manage calendar events.
* It was introduced as part of Moodle 2.0 and was created in order to provide a
* better framework for dealing with calendar events in particular regard to file
* handling through the new file API
*
+ * @package core_calendar
+ * @category calendar
+ * @copyright 2009 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ *
* @property int $id The id within the event table
* @property string $name The name of the event
* @property string $description The description of the event
*/
class calendar_event {
- /**
- * An object containing the event properties can be accessed via the
- * magic __get/set methods
- * @var array
- */
+ /** @var array An object containing the event properties can be accessed via the magic __get/set methods */
protected $properties = null;
+
/**
- * The converted event discription with file paths resolved
- * This gets populated when someone requests description for the first time
- * @var string
- */
+ * @var string The converted event discription with file paths resolved. This gets populated when someone requests description for the first time */
protected $_description = null;
- /**
- * The options to use with this description editor
- * @var array
- */
+
+ /** @var array The options to use with this description editor */
protected $editoroptions = array(
'subdirs'=>false,
'forcehttps'=>false,
'maxfiles'=>-1,
'maxbytes'=>null,
'trusttext'=>false);
- /**
- * The context to use with the description editor
- * @var object
- */
+
+ /** @var object The context to use with the description editor */
protected $editorcontext = null;
/**
* Attempts to call a set_$key method if one exists otherwise falls back
* to simply set the property
*
- * @param string $key
- * @param mixed $value
+ * @param string $key property name
+ * @param mixed $value value of the property
*/
public function __set($key, $value) {
if (method_exists($this, 'set_'.$key)) {
* Attempts to call a get_$key method to return the property and ralls over
* to return the raw property
*
- * @param str $key
- * @return mixed
+ * @param string $key property name
+ * @return mixed property value
*/
public function __get($key) {
if (method_exists($this, 'get_'.$key)) {
* Stupid PHP needs an isset magic method if you use the get magic method and
* still want empty calls to work.... blah ~!
*
- * @param string $key
- * @return bool
+ * @param string $key $key property name
+ * @return bool|mixed property value, false if property is not exist
*/
public function __isset($key) {
return !empty($this->properties->{$key});
* the course event.
* Default value is set to CONTEXT_USER
*
- * @return stdClass
+ * @param stdClass $data information about event
+ * @return stdClass The context object.
*/
protected function calculate_context(stdClass $data) {
global $USER, $DB;
/**
* Returns an array of editoroptions for this event: Called by __get
* Please use $blah = $event->editoroptions;
- * @return array
+ *
+ * @return array event editor options
*/
protected function get_editoroptions() {
return $this->editoroptions;
* Returns an event description: Called by __get
* Please use $blah = $event->description;
*
- * @return string
+ * @return string event description
*/
protected function get_description() {
global $CFG;
/**
* Return the number of repeat events there are in this events series
*
- * @return int
+ * @return int number of event repeated
*/
public function count_repeats() {
global $DB;
* @see add_event()
* @see update_event()
*
- * @param stdClass $data
- * @param boolean $checkcapability if moodle should check calendar managing capability or not
+ * @param stdClass $data object of event
+ * @param bool $checkcapability if moodle should check calendar managing capability or not
+ * @return bool event updated
*/
public function update($data, $checkcapability=true) {
global $CFG, $DB, $USER;
*
* @see delete_event()
*
- * @param bool $deleterepeated
- * @return bool
+ * @param bool $deleterepeated delete event repeatedly
+ * @return bool succession of deleting event
*/
public function delete($deleterepeated=false) {
global $DB;
* @param null|bool $force If it is left null the events visibility is flipped,
* If it is false the event is made hidden, if it is true it
* is made visible.
+ * @return bool if event is successfully updated, toggle will be visible
*/
public function toggle_visibility($force=null) {
global $CFG, $DB;
* Attempts to call the hook for the specified action should a calendar type
* by set $CFG->calendar, and the appopriate function defined
*
- * @static
- * @staticvar bool $extcalendarinc Used to track the inclusion of the calendar lib
* @param string $action One of `update_event`, `add_event`, `delete_event`, `show_event`, `hide_event`
* @param array $args The args to pass to the hook, usually the event is the first element
- * @return bool
+ * @return bool attempts to call event hook
*/
public static function calendar_event_hook($action, array $args) {
global $CFG;
* This function makes use of MUST_EXIST, if the event id passed in is invalid
* it will result in an exception being thrown
*
- * @param int|object $param
- * @return calendar_event|false
+ * @param int|object $param event object or event id
+ * @return calendar_event|false status for loading calendar_event
*/
public static function load($param) {
global $DB;
*
* This class is used simply to organise the information pertaining to a calendar
* and is used primarily to make information easily available.
+ *
+ * @package core_calendar
+ * @category calendar
+ * @copyright 2010 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class calendar_information {
- /**
- * The day
- * @var int
- */
+ /** @var int The day */
public $day;
- /**
- * The month
- * @var int
- */
+
+ /** @var int The month */
public $month;
- /**
- * The year
- * @var int
- */
+
+ /** @var int The year */
public $year;
- /**
- * A course id
- * @var int
- */
+ /** @var int A course id */
public $courseid = null;
- /**
- * An array of courses
- * @var array
- */
+
+ /** @var array An array of courses */
public $courses = array();
- /**
- * An array of groups
- * @var array
- */
+
+ /** @var array An array of groups */
public $groups = array();
- /**
- * An array of users
- * @var array
- */
+
+ /** @var array An array of users */
public $users = array();
/**
* Creates a new instance
*
- * @param int $day
- * @param int $month
- * @param int $year
+ * @param int $day the number of the day
+ * @param int $month the number of the month
+ * @param int $year the number of the year
*/
public function __construct($day=0, $month=0, $year=0) {
}
/**
+ * Initialize calendar information
*
- * @param stdClass $course
+ * @param stdClass $course object
* @param array $coursestoload An array of courses [$course->id => $course]
- * @param type $ignorefilters
+ * @param bool $ignorefilters options to use filter
*/
public function prepare_for_view(stdClass $course, array $coursestoload, $ignorefilters = false) {
$this->courseid = $course->id;
* Ensures the date for the calendar is correct and either sets it to now
* or throws a moodle_exception if not
*
- * @param bool $defaultonow
- * @return bool
+ * @param bool $defaultonow use current time
+ * @throws moodle_exception
+ * @return bool validation of checkdate
*/
public function checkdate($defaultonow = true) {
if (!checkdate($this->month, $this->day, $this->year)) {
}
/**
* Gets todays timestamp for the calendar
- * @return int
+ *
+ * @return int today timestamp
*/
public function timestamp_today() {
return make_timestamp($this->year, $this->month, $this->day);
}
/**
* Gets tomorrows timestamp for the calendar
- * @return int
+ *
+ * @return int tomorrow timestamp
*/
public function timestamp_tomorrow() {
return make_timestamp($this->year, $this->month, $this->day+1);
* Adds the pretend blocks for teh calendar
*
* @param core_calendar_renderer $renderer
- * @param bool $showfilters
- * @param string|null $view
+ * @param bool $showfilters display filters, false is set as default
+ * @param string|null $view preference view options (eg: day, month, upcoming)
*/
public function add_sidecalendar_blocks(core_calendar_renderer $renderer, $showfilters=false, $view=null) {
if ($showfilters) {
*/
protected function course_category_tree_category(stdClass $category, $depth=1) {
$content = '';
- $hassubcategories = (count($category->categories)>0);
- $hascourses = (count($category->courses)>0);
+ $hassubcategories = (isset($category->categories) && count($category->categories)>0);
+ $hascourses = (isset($category->courses) && count($category->courses)>0);
$classes = array('category');
if ($category->parent != 0) {
$classes[] = 'subcategory';
$capabilities = array(
// marks roles that have category role assignments synchronised to course enrolments
- // overrides bellow system context are ignored (for performance reasons).
+ // overrides below system context are ignored (for performance reasons).
// by default his is not allowed in new installs, admins have to explicitly allow category enrolments
'enrol/category:synchronised' => array(
'captype' => 'write',
JOIN {data_content} dc ON dc.fieldid = df.id AND dc.recordid = dr.id
WHERE d.course ' . $coursesql . '
AND df.type = \'text\'
- AND ' . $DB->sql_compare_text('df.param1', 1) . ' = 1';
+ AND ' . $DB->sql_compare_text('df.param1', 1) . " = '1'";
if (!$contents = $DB->get_records_sql($sql, $params)) {
$nothingtodo = true;
return $text;
}
if (stripos($text, '</a>') === false) {
- // performance shortcut - all regexes bellow end with the </a> tag,
+ // performance shortcut - all regexes below end with the </a> tag,
// if not present nothing can match
return $text;
}
$sources[] = html_writer::tag('source', '', array('src' => $url, 'type' => $mimetype));
if ($fallbacklink === null) {
- $fallbacklink = html_writer::link($url.'#', $info); // the extra '#' prevents linking in mp3 filter bellow
+ $fallbacklink = html_writer::link($url.'#', $info); // the extra '#' prevents linking in mp3 filter below
}
if ($fallbackurl === null) {
if ($mimetype === 'audio/mp3' or $mimetype === 'audio/aac') {
}
if ($fallbacklink === null) {
- $fallbacklink = html_writer::link($url.'#', $info); // the extra '#' prevents linking in mp3 filter bellow
+ $fallbacklink = html_writer::link($url.'#', $info); // the extra '#' prevents linking in mp3 filter below
}
if ($fallbackurl === null) {
if ($mimetype === 'video/mp4') {
if ($grade_items = $gseq->items) {
$needs_multiselect = false;
+ $canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $COURSE->id));
+
foreach ($grade_items as $grade_item) {
+ // Is the grade_item hidden? If so, can the user see hidden grade_items?
+ if ($grade_item->is_hidden() && !$canviewhidden) {
+ continue;
+ }
+
if (!empty($features['idnumberrequired']) and empty($grade_item->idnumber)) {
$mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name(), get_string('noidnumber', 'grades'));
$mform->hardFreeze('itemids['.$grade_item->id.']');
$mform->setDefault('itemids['.$grade_item->id.']', 1);
$needs_multiselect = true;
}
- }
+ }
if ($needs_multiselect) {
$this->add_checkbox_controller(1, null, null, 1); // 1st argument is group name, 2nd is link text, 3rd is attributes and 4th is original value
// do not extend by default
}
+ /**
+ * Extends the module navigation
+ *
+ * This function is called when the context for the page is an activity module with the
+ * FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.
+ *
+ * @param global_navigation $navigation {@link global_navigation}
+ * @param navigation_node $node {@link navigation_node}
+ */
+ public function extend_navigation(global_navigation $navigation, navigation_node $node=null) {
+ // do not extend by default
+ }
+
/**
* Returns the grading form definition structure
*
defined('MOODLE_INTERNAL') || die();
$string['addcriterion'] = 'Add criterion';
+$string['alwaysshowdefinition'] = 'Allow users to preview rubric used in the module (otherwise rubric will only become visible after grading)';
$string['backtoediting'] = 'Back to editing';
$string['confirmdeletecriterion'] = 'Are you sure you want to delete this criterion?';
$string['confirmdeletelevel'] = 'Are you sure you want to delete this level?';
$string['err_nodescription'] = 'Criterion description can not be empty';
$string['err_scoreformat'] = 'Number of points for each level must be a valid non-negative number';
$string['err_totalscore'] = 'Maximum number of points possible when graded by the rubric must be more than zero';
+$string['gradingof'] = '{$a} grading';
$string['leveldelete'] = 'Delete level';
$string['levelempty'] = 'Click to edit level';
$string['name'] = 'Name';
$string['needregrademessage'] = 'The rubric definition was changed after this student had been graded. The student can not see this rubric until you check the rubric and update the grade.';
$string['pluginname'] = 'Rubric';
+$string['previewrubric'] = 'Preview rubric';
$string['regrademessage1'] = 'You are about to save changes to a rubric that has already been used for grading. Please indicate if existing grades need to be reviewed. If you set this then the rubric will be hidden from students until their item is regraded.';
$string['regrademessage5'] = 'You are about to save significant changes to a rubric that has already been used for grading. The gradebook value will be unchanged, but the rubric will be hidden from students until their item is regraded.';
$string['regradeoption0'] = 'Do not mark for regrade';
const DISPLAY_EDIT_FULL = 1;
/** Rubric display mode: Preview the rubric design with hidden fields */
const DISPLAY_EDIT_FROZEN = 2;
- /** Rubric display mode: Preview the rubric design */
+ /** Rubric display mode: Preview the rubric design (for person with manage permission) */
const DISPLAY_PREVIEW = 3;
+ /** Rubric display mode: Preview the rubric (for people being graded) */
+ const DISPLAY_PREVIEW_GRADED= 8;
/** Rubric display mode: For evaluation, enabled (teacher grades a student) */
const DISPLAY_EVAL = 4;
/** Rubric display mode: For evaluation, with hidden fields */
null, null, new pix_icon('icon', '', 'gradingform_rubric'));
}
+ /**
+ * Extends the module navigation
+ *
+ * This function is called when the context for the page is an activity module with the
+ * FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.
+ *
+ * @param global_navigation $navigation {@link global_navigation}
+ * @param navigation_node $node {@link navigation_node}
+ */
+ public function extend_navigation(global_navigation $navigation, navigation_node $node=null) {
+ if (has_capability('moodle/grade:managegradingforms', $this->get_context())) {
+ // no need for preview if user can manage forms, he will have link to manage.php in settings instead
+ return;
+ }
+ if ($this->is_form_defined() && ($options = $this->get_options()) && !empty($options['alwaysshowdefinition'])) {
+ $node->add(get_string('gradingof', 'gradingform_rubric', get_grading_manager($this->get_areaid())->get_area_title()),
+ new moodle_url('/grade/grading/form/'.$this->get_method_name().'/preview.php', array('areaid' => $this->get_areaid())),
+ settings_navigation::TYPE_CUSTOM);
+ }
+ }
+
/**
* Saves the rubric definition into the database
*
public static function get_default_options() {
$options = array(
'sortlevelsasc' => 1,
- //'showdescriptionteacher' => 1,
- //'showdescriptionstudent' => 1,
+ 'alwaysshowdefinition' => 1,
+ 'showdescriptionteacher' => 1,
+ 'showdescriptionstudent' => 1,
'showscoreteacher' => 1,
'showscorestudent' => 1,
'enableremarks' => 1,
'showremarksstudent' => 1
);
- // TODO description options
return $options;
}
$output = $this->get_renderer($page);
$criteria = $this->definition->rubric_criteria;
$options = $this->get_options();
- $rubric = $output->display_rubric_mapping_explained($this->get_min_max_score());
- $rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW, 'rubric');
+ $rubric = '';
+ if (has_capability('moodle/grade:managegradingforms', $page->context)) {
+ $rubric .= $output->display_rubric_mapping_explained($this->get_min_max_score());
+ $rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW, 'rubric');
+ } else {
+ $rubric .= $output->display_rubric($criteria, $options, self::DISPLAY_PREVIEW_GRADED, 'rubric');
+ }
return $rubric;
}
if ($this->get_data('isrestored') && $haschanges) {
$html .= html_writer::tag('div', get_string('restoredfromdraft', 'gradingform_rubric'), array('class' => 'gradingform_rubric-restored'));
}
+ if (!empty($options['showdescriptionteacher'])) {
+ $html .= html_writer::tag('div', $this->get_controller()->get_formatted_description(), array('class' => 'gradingform_rubric-description'));
+ }
$html .= $this->get_controller()->get_renderer($page)->display_rubric($criteria, $options, $mode, $gradingformelement->getName(), $value);
return $html;
}
--- /dev/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/>.
+
+/**
+ * Preview rubric page
+ *
+ * @package gradingform_rubric
+ * @copyright 2011 Marina Glancy
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+require_once(dirname(__FILE__).'/edit_form.php');
+require_once($CFG->dirroot.'/grade/grading/lib.php');
+
+$areaid = required_param('areaid', PARAM_INT);
+
+$manager = get_grading_manager($areaid);
+
+list($context, $course, $cm) = get_context_info_array($manager->get_context()->id);
+
+require_login($course, true, $cm);
+
+$controller = $manager->get_controller('rubric');
+$options = $controller->get_options();
+
+if (!$controller->is_form_defined() || empty($options['alwaysshowdefinition'])) {
+ throw new moodle_exception('nopermissions', 'error', '', get_string('previewrubric', 'gradingform_rubric'));
+}
+
+$title = get_string('gradingof', 'gradingform_rubric', $manager->get_area_title());
+$PAGE->set_url(new moodle_url('/grade/grading/form/rubric/preview.php', array('areaid' => $areaid)));
+$PAGE->set_title($title);
+$PAGE->set_heading($title);
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading($title);
+if (!empty($options['showdescriptionstudent'])) {
+ echo $OUTPUT->box($controller->get_formatted_description(), 'gradingform_rubric-description');
+}
+echo $controller->render_preview($PAGE);
+echo $OUTPUT->footer();
if (!$options['showscoreteacher'] && in_array($mode, array(gradingform_rubric_controller::DISPLAY_EVAL, gradingform_rubric_controller::DISPLAY_EVAL_FROZEN, gradingform_rubric_controller::DISPLAY_REVIEW))) {
$displayscore = false;
}
- if (!$options['showscorestudent'] && $mode == gradingform_rubric_controller::DISPLAY_VIEW) {
+ if (!$options['showscorestudent'] && in_array($mode, array(gradingform_rubric_controller::DISPLAY_VIEW, gradingform_rubric_controller::DISPLAY_PREVIEW_GRADED))) {
$displayscore = false;
}
if ($displayscore) {
case gradingform_rubric_controller::DISPLAY_EDIT_FROZEN:
$classsuffix = ' editor frozen'; break;
case gradingform_rubric_controller::DISPLAY_PREVIEW:
+ case gradingform_rubric_controller::DISPLAY_PREVIEW_GRADED:
$classsuffix = ' editor preview'; break;
case gradingform_rubric_controller::DISPLAY_EVAL:
$classsuffix = ' evaluate editable'; break;
if ($mode != gradingform_rubric_controller::DISPLAY_EDIT_FULL
&& $mode != gradingform_rubric_controller::DISPLAY_EDIT_FROZEN
&& $mode != gradingform_rubric_controller::DISPLAY_PREVIEW) {
- // Options are displayed only in edit mode
+ // Options are displayed only for people who can manage
return;
}
$html = html_writer::start_tag('div', array('class' => 'options'));
$values = $instance->get_rubric_filling();
if ($cangrade) {
$mode = gradingform_rubric_controller::DISPLAY_REVIEW;
+ $showdescription = $options['showdescriptionteacher'];
} else {
$mode = gradingform_rubric_controller::DISPLAY_VIEW;
+ $showdescription = $options['showdescriptionstudent'];
}
- return $this->display_rubric($criteria, $options, $mode, 'rubric'.$idx, $values);
+ $output = '';
+ if ($showdescription) {
+ $output .= $this->box($instance->get_controller()->get_formatted_description(), 'gradingform_rubric-description');
+ }
+ $output .= $this->display_rubric($criteria, $options, $mode, 'rubric'.$idx, $values);
+ return $output;
}
public function display_regrade_confirmation($elementname, $changelevel, $value) {
}
}
+ /**
+ * Extends the module navigation with the advanced grading information
+ *
+ * This function is called when the context for the page is an activity module with the
+ * FEATURE_ADVANCED_GRADING.
+ *
+ * @param global_navigation $navigation
+ * @param navigation_node $modulenode
+ */
+ public function extend_navigation(global_navigation $navigation, navigation_node $modulenode=null) {
+ $this->ensure_isset(array('context', 'component'));
+
+ $areas = $this->get_available_areas();
+ foreach ($areas as $areaname => $areatitle) {
+ $this->set_area($areaname);
+ if ($controller = $this->get_active_controller()) {
+ $controller->extend_navigation($navigation, $modulenode);
+ }
+ }
+ }
+
/**
* Returns the given method's controller in the gradable area
*
$separategroups = true;
$mygroups = groups_get_user_groups($this->course->id);
$mygroups = $mygroups[0]; // ignore groupings
- // reorder the groups fro better perf bellow
+ // reorder the groups fro better perf below
$current = array_search($this->currentgroup, $mygroups);
if ($current !== false) {
unset($mygroups[$current]);
if (!$course->showgrades) {
continue;
}
+
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
+ if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
+ // The course is hidden and the user isn't allowed to see it
+ continue;
+ }
+
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
$courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)), $courseshortname);
$canviewhidden = has_capability('moodle/grade:viewhidden', $coursecontext);
$hassiteconfig = has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
- $PAGE->set_url('/');
+ $urlparams = array();
+ if ($CFG->defaulthomepage == HOMEPAGE_MY && optional_param('redirect', 1, PARAM_BOOL) === 0) {
+ $urlparams['redirect'] = 0;
+ }
+ $PAGE->set_url('/', $urlparams);
$PAGE->set_course($SITE);
/// If the site is currently under maintenance, then print a message
*/
$string['AED'] = 'United Arab Emirates Dirham';
-$string['AFA'] = 'Afghanistan Afghani';
+$string['AFN'] = 'Afghanistan Afghani';
$string['ALL'] = 'Albanian Lek';
-$string['ANG'] = 'Netherlands Antillian Guilder';
-$string['AON'] = 'Angolan New Kwanza';
-$string['ARA'] = 'Argentinian Nuevo Peso';
+$string['AMD'] = 'Armenian Dram';
+$string['ANG'] = 'Netherlands Antillean Guilder';
+$string['AOA'] = 'Angolan Kwanza';
+$string['ARS'] = 'Argentine Peso';
$string['AUD'] = 'Australian Dollar';
$string['AWG'] = 'Aruban Florin';
+$string['AZN'] = 'Azerbaijanian Manat';
+$string['BAM'] = 'Bosnia and Herzegovina Convertible Mark';
$string['BBD'] = 'Barbados Dollar';
$string['BDT'] = 'Bangladeshi Taka';
-$string['BGL'] = 'Bulgarian Lev';
+$string['BGN'] = 'Bulgarian Lev';
$string['BHD'] = 'Bahraini Dinar';
$string['BIF'] = 'Burundi Franc';
$string['BMD'] = 'Bermudian Dollar';
$string['BND'] = 'Brunei Dollar';
$string['BOB'] = 'Bolivian Boliviano';
-$string['BRR'] = 'Brazilian Cruzeiro Real';
+$string['BRL'] = 'Brazilian Real';
$string['BSD'] = 'Bahamian Dollar';
-$string['BTN'] = 'Bhutan Ngultrum';
-$string['BUK'] = 'Myanmar Kyat';
-$string['BWP'] = 'Botswanian Pula';
+$string['BTN'] = 'Bhutanese Ngultrum';
+$string['BWP'] = 'Botswana Pula';
+$string['BYR'] = 'Belarusian Ruble';
$string['BZD'] = 'Belize Dollar';
$string['CAD'] = 'Canadian Dollar';
-$string['CDZ'] = 'Zaire New Zaire';
+$string['CDF'] = 'Congolese Franc';
+$string['CHF'] = 'Swiss Franc';
$string['CLF'] = 'Chilean Unidades de Fomento';
$string['CLP'] = 'Chilean Peso';
-$string['CNY'] = 'Yuan (Chinese) Renminbi';
+$string['CNY'] = 'Chinese Yuan (Renminbi)';
$string['COP'] = 'Colombian Peso';
$string['CRC'] = 'Costa Rican Colon';
-$string['CSD'] = 'Serbian Dinar';
+$string['CUC'] = 'Cuban Convertible Peso';
$string['CUP'] = 'Cuban Peso';
-$string['CVE'] = 'Escudo Caboverdiano';
-$string['CYP'] = 'Cyprus Pound';
+$string['CVE'] = 'Cape Verde Escudo';
$string['CZK'] = 'Czech Koruna';
$string['DJF'] = 'Djibouti Franc';
$string['DKK'] = 'Danish Krone';
$string['DOP'] = 'Dominican Peso';
$string['DZD'] = 'Algerian Dinar';
$string['EGP'] = 'Egyptian Pound';
+$string['ERN'] = 'Eritrean Nakfa';
$string['ETB'] = 'Ethiopian Birr';
$string['EUR'] = 'Euro';
$string['FJD'] = 'Fiji Dollar';
$string['FKP'] = 'Falkland Islands Pound';
-$string['GBP'] = 'British Pound';
-$string['GHC'] = 'Ghanaian Cedi';
+$string['GBP'] = 'British Pound Sterling';
+$string['GEL'] = 'Georgian Lari';
+$string['GHS'] = 'Ghanaian Cedi';
$string['GIP'] = 'Gibraltar Pound';
$string['GMD'] = 'Gambian Dalasi';
$string['GNF'] = 'Guinea Franc';
$string['GTQ'] = 'Guatemalan Quetzal';
-$string['GWP'] = 'Guinea-Bissau Peso';
-$string['GYD'] = 'Guyanan Dollar';
+$string['GYD'] = 'Guyanese Dollar';
$string['HKD'] = 'Hong Kong Dollar';
$string['HNL'] = 'Honduran Lempira';
+$string['HRK'] = 'Croatian Kuna';
$string['HTG'] = 'Haitian Gourde';
$string['HUF'] = 'Hungarian Forint';
-$string['CHF'] = 'Swiss Franc';
$string['IDR'] = 'Indonesian Rupiah';
-$string['ILS'] = 'Israeli Shekel';
+$string['ILS'] = 'Israeli Sheqel';
$string['INR'] = 'Indian Rupee';
$string['IQD'] = 'Iraqi Dinar';
$string['IRR'] = 'Iranian Rial';
$string['JMD'] = 'Jamaican Dollar';
$string['JOD'] = 'Jordanian Dinar';
$string['JPY'] = 'Japanese Yen';
-$string['KES'] = 'Kenyan Schilling';
+$string['KES'] = 'Kenyan Shilling';
+$string['KGS'] = 'Kyrgyzstani Som';
$string['KHR'] = 'Cambodian Riel';
$string['KMF'] = 'Comoros Franc';
$string['KPW'] = 'North Korean Won';
$string['KRW'] = 'South Korean Won';
$string['KWD'] = 'Kuwaiti Dinar';
$string['KYD'] = 'Cayman Islands Dollar';
+$string['KZT'] = 'Kazakhstani Tenge';
$string['LAK'] = 'Lao Kip';
$string['LBP'] = 'Lebanese Pound';
$string['LKR'] = 'Sri Lanka Rupee';
$string['LRD'] = 'Liberian Dollar';
$string['LSL'] = 'Lesotho Loti';
+$string['LTL'] = 'Lithuanian Litas';
+$string['LVL'] = 'Latvian Lats';
$string['LYD'] = 'Libyan Dinar';
$string['MAD'] = 'Moroccan Dirham';
-$string['MGF'] = 'Malagasy Franc';
+$string['MDL'] = 'Moldovan Leu';
+$string['MGA'] = 'Malagasy Ariary';
+$string['MKD'] = 'Makedonian Denar';
+$string['MMK'] = 'Myanmar (Burmese) Kyat';
$string['MNT'] = 'Mongolian Tugrik';
$string['MOP'] = 'Macau Pataca';
$string['MRO'] = 'Mauritanian Ouguiya';
-$string['MTL'] = 'Maltese Lira';
$string['MUR'] = 'Mauritius Rupee';
-$string['MVR'] = 'Maldive Rufiyaa';
+$string['MVR'] = 'Maldivian Rufiyaa';
$string['MWK'] = 'Malawi Kwacha';
$string['MXN'] = 'Mexican Peso';
$string['MYR'] = 'Malaysian Ringgit';
-$string['MZM'] = 'Mozambique Metical';
+$string['MZN'] = 'Mozambican Metical';
+$string['NAD'] = 'Namibian Dollar';
$string['NGN'] = 'Nigerian Naira';
-$string['NIO'] = 'Nicaraguan Cordoba';
-$string['NOK'] = 'Norwegian Kroner';
+$string['NIO'] = 'Nicaraguan Cordoba Oro';
+$string['NOK'] = 'Norwegian Krone';
$string['NPR'] = 'Nepalese Rupee';
$string['NZD'] = 'New Zealand Dollar';
$string['OMR'] = 'Omani Rial';
$string['PAB'] = 'Panamanian Balboa';
-$string['PEN'] = 'Nuevo Sol';
+$string['PEN'] = 'Peruvian Nuevo Sol';
$string['PGK'] = 'Papua New Guinea Kina';
$string['PHP'] = 'Philippine Peso';
$string['PKR'] = 'Pakistan Rupee';
-$string['PLN'] = 'Polish New Zloty';
-$string['PYG'] = 'Paraguay Guarani';
+$string['PLN'] = 'Polish Zloty';
+$string['PYG'] = 'Paraguayan Guarani';
$string['QAR'] = 'Qatari Rial';
-$string['ROL'] = 'Romanian Leu';
+$string['RON'] = 'Romanian Leu';
+$string['RSD'] = 'Serbian Dinar';
+$string['RUB'] = 'Russian Ruble';
$string['RWF'] = 'Rwanda Franc';
$string['SAR'] = 'Saudi Arabian Riyal';
$string['SBD'] = 'Solomon Islands Dollar';
$string['SCR'] = 'Seychelles Rupee';
-$string['SDP'] = 'Sudanese Pound';
+$string['SDG'] = 'Sudanese Pound';
$string['SEK'] = 'Swedish Krona';
$string['SGD'] = 'Singapore Dollar';
$string['SHP'] = 'St. Helena Pound';
-$string['SKK'] = 'Slovak Koruna';
-$string['SLL'] = 'Sierra Leone Leone';
-$string['SOS'] = 'Somali Schilling';
-$string['SRG'] = 'Suriname Guilder';
+$string['SLL'] = 'Sierra Leonean Leone';
+$string['SOS'] = 'Somali Shilling';
+$string['SRD'] = 'Surinamese Dollar';
+$string['SSP'] = 'South Sudanese Pound';
$string['STD'] = 'Sao Tome and Principe Dobra';
-$string['SUR'] = 'USSR Rouble';
$string['SVC'] = 'El Salvador Colon';
-$string['SYP'] = 'Syrian Potmd';
-$string['SZL'] = 'Swaziland Lilangeni';
-$string['THB'] = 'Thai Bhat';
+$string['SYP'] = 'Syrian Pound';
+$string['SZL'] = 'Swazi Lilangeni';
+$string['THB'] = 'Thai Baht';
+$string['TJS'] = 'Tajikistani Somoni';
+$string['TMT'] = 'Turkmenistani Manat';
$string['TND'] = 'Tunisian Dinar';
$string['TOP'] = 'Tongan Pa\'anga';
-$string['TPE'] = 'East Timor Escudo';
-$string['TRL'] = 'Turkish Lira';
+$string['TRY'] = 'Turkish Lira';
$string['TTD'] = 'Trinidad and Tobago Dollar';
$string['TWD'] = 'Taiwan Dollar';
-$string['TZS'] = 'Tanzanian Schilling';
-$string['UGS'] = 'Uganda Shilling';
+$string['TZS'] = 'Tanzanian Shilling';
+$string['UAH'] = 'Ukrainian Hryvnia';
+$string['UGX'] = 'Ugandan Shilling';
$string['USD'] = 'US Dollar';
-$string['UYU'] = 'Uruguayan New Peso';
-$string['VEB'] = 'Venezualan Bolivar';
+$string['UYU'] = 'Uruguayan Peso';
+$string['UZS'] = 'Uzbekistani Sum';
+$string['VEF'] = 'Venezuelan Bolivar Fuerte';
$string['VND'] = 'Vietnamese Dong';
$string['VUV'] = 'Vanuatu Vatu';
$string['WST'] = 'Samoan Tala';
-$string['YER'] = 'Yemeni Riyal';
+$string['XAF'] = 'CFA Franc BEAC';
+$string['XCD'] = 'East Caribbean Dollar';
+$string['XOF'] = 'CFA Franc BCEAO';
+$string['XPF'] = 'CFP Franc';
+$string['YER'] = 'Yemeni Rial';
$string['ZAR'] = 'South African Rand';
$string['ZMK'] = 'Zambian Kwacha';
-$string['ZWD'] = 'Zimbabwe Dollar';
+$string['ZWL'] = 'Zimbabwe Dollar';
$string['selectallornone'] = 'Select all/none';
$string['selected'] = 'Selected';
$string['showadvanced'] = 'Show advanced';
-$string['somefieldsrequired'] = 'There are required fields in this form marked{$a}.';
+$string['somefieldsrequired'] = 'There are required fields in this form marked {$a}.';
$string['time'] = 'Time';
$string['timeunit'] = 'Time unit';
$string['timing'] = 'Timing';
$string['idnumbercoursecategory'] = 'Category ID number';
$string['idnumbercoursecategory_help'] = 'The ID number of a course category is only used when matching the category against external systems and is not displayed anywhere on the site. If the category has an official code name it may be entered, otherwise the field can be left blank.';
$string['categoryupdated'] = 'The category \'{$a}\' was updated';
+$string['changesmadereallygoaway'] = 'You have made changes. Are you sure you want to navigate away and lose your changes?';
$string['city'] = 'City/town';
$string['clambroken'] = 'Your administrator has enabled virus checking for file uploads but has misconfigured something.<br />Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it.<br />Maybe try uploading this file later.';
$string['clamdeletedfile'] = 'The file has been deleted';
$string['withselectedusers'] = 'With selected users...';
$string['withselectedusers_help'] = '* Send message - For sending a message to one or more participants
* Add a new note - For adding a note to a selected participant
-* Add a common note - For adding the same note to more than one participant
-* Extend enrolment (individual) - For extending a selected student\'s access to the course, even when an enrolment period is set
-* Extend enrolment (common) - For extending more than one student\'s access to the course by the same amount';
+* Add a common note - For adding the same note to more than one participant';
$string['withuserdata'] = 'with user data';
$string['wordforstudent'] = 'Your word for Student';
$string['wordforstudenteg'] = 'eg Student, Participant etc';
}
}
- // now go through the contexts bellow given context
+ // now go through the contexts below given context
$searchcontexts = array_keys($context->get_child_contexts());
foreach ($searchcontexts as $cid) {
if ($capabilities = $DB->get_records('role_capabilities', array('roleid'=>$roleid, 'contextid'=>$cid))) {
if (!is_siteadmin($token->userid) and
key_exists($token->userid, $usermissingcaps)) {
- $missingcapabilities = implode(',',
+ $missingcapabilities = implode(', ',
$usermissingcaps[$token->userid]);
if (!empty($missingcapabilities)) {
$useratag .= html_writer::tag('div',
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_date', get_string('enable'));
- $mform->addElement('date', 'criteria_date_value', get_string('afterspecifieddate', 'completion'));
+ $mform->addElement('date_selector', 'criteria_date_value', get_string('afterspecifieddate', 'completion'));
// If instance of criteria exists
if ($this->id) {
if (!empty($data->criteria_date)) {
$this->course = $data->id;
- $date = $data->criteria_date_value;
- $this->timeend = strtotime($date['Y'].'-'.$date['M'].'-'.$date['d']);
+ $this->timeend = $data->criteria_date_value;
$this->insert();
}
}
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
* - moodlelib.php - general-purpose Moodle functions
*
* @package core
- * @subpackage lib
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* than web server hits, and provide a way to easily reconstruct what
* any particular student has been doing.
*
- * @global object
- * @global object
- * @global object
+ * @package core
+ * @category log
+ * @global moodle_database $DB
+ * @global stdClass $CFG
+ * @global stdClass $USER
* @uses SITEID
* @uses DEBUG_DEVELOPER
* @uses DEBUG_ALL
* @param int $courseid The course id
- * @param string $module The module name - e.g. forum, journal, resource, course, user etc
+ * @param string $module The module name e.g. forum, journal, resource, course, user etc
* @param string $action 'view', 'update', 'add' or 'delete', possibly followed by another word to clarify.
* @param string $url The file and parameters used to see the results of the action
* @param string $info Additional description information
/**
* Store user last access times - called when use enters a course or site
*
- * @global object
- * @global object
- * @global object
+ * @package core
+ * @category log
+ * @global stdClass $USER
+ * @global stdClass $CFG
+ * @global moodle_database $DB
* @uses LASTACCESS_UPDATE_SECS
* @uses SITEID
- * @param int $courseid, empty means site
+ * @param int $courseid empty courseid means site
* @return void
*/
function user_accesstime_log($courseid=0) {
/**
* Select all log records based on SQL criteria
*
- * @todo Finish documenting this function
- *
- * @global object
+ * @package core
+ * @category log
+ * @global moodle_database $DB
* @param string $select SQL select criteria
* @param array $params named sql type params
* @param string $order SQL order by clause to sort the records returned
- * @param string $limitfrom ?
- * @param int $limitnum ?
+ * @param string $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set)
+ * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set)
* @param int $totalcount Passed in by reference.
- * @return object
+ * @return array
*/
function get_logs($select, array $params=null, $order='l.time DESC', $limitfrom='', $limitnum='', &$totalcount) {
global $DB;
/**
* Select all log records for a given course and user
*
- * @todo Finish documenting this function
- *
- * @global object
+ * @package core
+ * @category log
+ * @global moodle_database $DB
* @uses DAYSECS
* @param int $userid The id of the user as found in the 'user' table.
* @param int $courseid The id of the course as found in the 'course' table.
- * @param string $coursestart ?
+ * @param string $coursestart unix timestamp representing course start date and time.
+ * @return array
*/
function get_logs_usercourse($userid, $courseid, $coursestart) {
global $DB;
/**
* Select all log records for a given course, user, and day
*
- * @global object
+ * @package core
+ * @category log
+ * @global moodle_database $DB
* @uses HOURSECS
* @param int $userid The id of the user as found in the 'user' table.
* @param int $courseid The id of the course as found in the 'course' table.
- * @param string $daystart ?
- * @return object
+ * @param string $daystart unix timestamp of the start of the day for which the logs needs to be retrived
+ * @return array
*/
function get_logs_userday($userid, $courseid, $daystart) {
global $DB;
* number of accounts. For non-admins, only the attempts on the given user
* are shown.
*
- * @global object
+ * @global moodle_database $DB
* @uses CONTEXT_SYSTEM
* @param string $mode Either 'admin' or 'everybody'
* @param string $username The username we are searching for
array('module'=>'message', 'action'=>'unblock contact', 'mtable'=>'user', 'field'=>$DB->sql_concat('firstname', "' '" , 'lastname')),
array('module'=>'group', 'action'=>'view', 'mtable'=>'groups', 'field'=>'name'),
array('module'=>'tag', 'action'=>'update', 'mtable'=>'tag', 'field'=>'name'),
+ array('module'=>'tag', 'action'=>'flag', 'mtable'=>'tag', 'field'=>'name'),
);
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
/**
- * Database manager instance is responsible for all database structure
- * modifications.
+ * Database manager instance is responsible for all database structure modifications.
*
* @package core
+ * @category ddl
* @subpackage ddl
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
defined('MOODLE_INTERNAL') || die();
/**
- * Database manager instance is responsible for all database structure
- * modifications. It is using db specific generators to find out
- * the correct SQL syntax to do that.
+ * Database manager instance is responsible for all database structure modifications.
+ *
+ * It is using db specific generators to find out the correct SQL syntax to do that.
+ *
+ * @package core
+ * @category ddl
+ * @subpackage ddl
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * 2008 Petr Skoda http://skodak.org
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class database_manager {
+ /** @var moodle_database A moodle_database driver speific instance.*/
protected $mdb;
- public $generator; // public because XMLDB editor needs to access it
+ /** @var sql_generator A driver specific SQL generator instance. Public because XMLDB editor needs to access it.*/
+ public $generator;
/**
- * Creates new database manager
- * @param object moodle_database instance
+ * Creates a new database manager instance.
+ * @param moodle_database $mdb A moodle_database driver specific instance.
+ * @param sql_generator $generator A driver specific SQL generator instance.
*/
public function __construct($mdb, $generator) {
global $CFG;
}
/**
- * Release all resources
+ * Releases all resources
*/
public function dispose() {
if ($this->generator) {
/**
* This function will execute an array of SQL commands.
*
- * @exception ddl_exception if error found
- *
- * @param array $sqlarr array of sql statements to execute
- * @return void
+ * @param array $sqlarr Array of sql statements to execute.
+ * @throws ddl_exception This exception is thrown if any error is found.
*/
protected function execute_sql_arr(array $sqlarr) {
foreach ($sqlarr as $sql) {
}
/**
- * Execute a given sql command string
- *
- * @exception ddl_exception if error found
+ * Execute a given sql command string.
*
- * @param string $command The sql string you wish to be executed.
- * @return void
+ * @param string $sql The sql string you wish to be executed.
+ * @throws ddl_exception This exception is thrown if any error is found.
*/
protected function execute_sql($sql) {
if (!$this->mdb->change_database_structure($sql)) {
}
/**
- * Given one xmldb_table, check if it exists in DB (true/false)
+ * Given one xmldb_table, check if it exists in DB (true/false).
*
- * @param mixed the table to be searched (string name or xmldb_table instance)
- * @return boolean true/false
+ * @param mixed $table The table to be searched (string name or xmldb_table instance).
+ * @return bool true/false True is a table exists, false otherwise.
*/
public function table_exists($table) {
if (!is_string($table) and !($table instanceof xmldb_table)) {
/**
* Reset a sequence to the id field of a table.
- * @param string $table name of table
- * @return success
+ * @param string $table Name of table.
+ * @throws ddl_exception|ddl_table_missing_exception Exception thrown upon reset errors.
*/
public function reset_sequence($table) {
if (!is_string($table) and !($table instanceof xmldb_table)) {
}
/**
- * Given one xmldb_field, check if it exists in DB (true/false)
+ * Given one xmldb_field, check if it exists in DB (true/false).
*
- * @param mixed the table to be searched (string name or xmldb_table instance)
- * @param mixed the field to be searched for (string name or xmldb_field instance)
- * @return boolean true/false
+ * @param mixed $table The table to be searched (string name or xmldb_table instance).
+ * @param mixed $field The field to be searched for (string name or xmldb_field instance).
+ * @return boolean true is exists false otherwise.
+ * @throws ddl_table_missing_exception
*/
public function field_exists($table, $field) {
/// Calculate the name of the table
* Given one xmldb_index, the function returns the name of the index in DB
* of false if it doesn't exist
*
- * @param object $xmldb_table table to be searched
- * @param object $xmldb_index the index to be searched
- * @return string index name of false
+ * @param xmldb_table $xmldb_table table to be searched
+ * @param xmldb_index $xmldb_index the index to be searched
+ * @return string|bool Index name or false if no indexes are found.
+ * @throws ddl_table_missing_exception Thrown when table is not found.
*/
public function find_index_name(xmldb_table $xmldb_table, xmldb_index $xmldb_index) {
/// Calculate the name of the table
}
/**
- * Given one xmldb_index, check if it exists in DB (true/false)
+ * Given one xmldb_index, check if it exists in DB (true/false).
*
- * @param object $xmldb_table the table to be searched
- * @param object $xmldb_index the index to be searched for
- * @return boolean true/false
+ * @param xmldb_table $xmldb_table The table to be searched.
+ * @param xmldb_index $xmldb_index The index to be searched for.
+ * @return boolean true id index exists, false otherwise.
*/
public function index_exists(xmldb_table $xmldb_table, xmldb_index $xmldb_index) {
if (!$this->table_exists($xmldb_table)) {
* to 1 "enum-like" constraint. So, if more than one is returned, only the first one will be
* retrieved by this function.
*
- * TODO: Moodle 2.1 - Drop find_check_constraint_name()
+ * @todo MDL-31147 Moodle 2.1 - Drop find_check_constraint_name()
*
- * @param xmldb_table the table to be searched
- * @param xmldb_field the field to be searched
- * @return string check constraint name or false
+ * @param xmldb_table $xmldb_table The table to be searched.
+ * @param xmldb_field $xmldb_field The field to be searched.
+ * @return string|bool check constraint name or false
*/
public function find_check_constraint_name(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
*
* TODO: Moodle 2.1 - Drop check_constraint_exists()
*
- * @param xmldb_table the table
- * @param xmldb_field the field to be searched for any existing constraint
+ * @param xmldb_table $xmldb_table The table.
+ * @param xmldb_field $xmldb_field The field to be searched for any existing constraint.
* @return boolean true/false
*/
public function check_constraint_exists(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
* Given one xmldb_key, the function returns the name of the key in DB (if exists)
* of false if it doesn't exist
*
- * @param xmldb_table the table to be searched
- * @param xmldb_key the key to be searched
- * @return string key name of false
+ * @param xmldb_table $xmldb_table The table to be searched.
+ * @param xmldb_key $xmldb_key The key to be searched.
+ * @return string key name if found
*/
public function find_key_name(xmldb_table $xmldb_table, xmldb_key $xmldb_key) {
/**
* This function will delete all tables found in XMLDB file from db
*
- * @param $file full path to the XML file to be used
+ * @param string $file Full path to the XML file to be used.
* @return void
*/
public function delete_tables_from_xmldb_file($file) {
* and all the associated objects (keys, indexes, constraints, sequences, triggers)
* will be dropped too.
*
- * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
* @return void
*/
public function drop_table(xmldb_table $xmldb_table) {
/**
* This function will load one entire XMLDB file and call install_from_xmldb_structure.
*
- * @param $file full path to the XML file to be used
+ * @param string $file full path to the XML file to be used
* @return void
*/
public function install_from_xmldb_file($file) {
/**
* This function will load one entire XMLDB file and call install_from_xmldb_structure.
*
- * @param $file full path to the XML file to be used
- * @param $tablename the name of the table.
+ * @param string $file full path to the XML file to be used
+ * @param string $tablename the name of the table.
* @param bool $cachestructures boolean to decide if loaded xmldb structures can be safely cached
* useful for testunits loading the enormous main xml file hundred of times (100x)
*/
* This function will generate all the needed SQL statements, specific for each
* RDBMS type and, finally, it will execute all those statements against the DB.
*
- * @param object $structure xmldb_structure object
+ * @param stdClass $xmldb_structure xmldb_structure object.
* @return void
*/
public function install_from_xmldb_structure($xmldb_structure) {
* This function will create the table passed as argument with all its
* fields/keys/indexes/sequences, everything based in the XMLDB object
*
- * @param xmldb_table table object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (full specs are required).
* @return void
*/
public function create_table(xmldb_table $xmldb_table) {
* If table already exists ddl_exception will be thrown, please make sure
* the table name does not collide with existing normal table!
*
- * @param xmldb_table table object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (full specs are required).
* @return void
*/
public function create_temp_table(xmldb_table $xmldb_table) {
*
* It is recommended to drop temp table when not used anymore.
*
- * @param xmldb_table table object
+ * @param xmldb_table $xmldb_table Table object.
* @return void
*/
public function drop_temp_table(xmldb_table $xmldb_table) {
* This function will rename the table passed as argument
* Before renaming the index, the function will check it exists
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param string new name of the index
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param string $newname New name of the index.
* @return void
*/
public function rename_table(xmldb_table $xmldb_table, $newname) {
/**
* This function will add the field to the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function add_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
/**
* This function will drop the field from the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (just the name is mandatory)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function drop_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
/**
* This function will change the type of the field in the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function change_field_type(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
/**
* This function will change the precision of the field in the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function change_field_precision(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
/**
* This function will change the unsigned/signed of the field in the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function change_field_unsigned(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
/**
* This function will change the nullability of the field in the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function change_field_notnull(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
* This function will change the default of the field in the table passed as arguments
* One null value in the default field means delete the default
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function change_field_default(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
*
* TODO: Moodle 2.1 - Drop drop_enum_from_field()
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field field object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
* @return void
*/
public function drop_enum_from_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
* This function will rename the field in the table passed as arguments
* Before renaming the field, the function will check it exists
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_field index object (full specs are required)
- * @param string new name of the field
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
+ * @param string $newname New name of the field.
* @return void
*/
public function rename_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field, $newname) {
/**
* This function will check, for the given table and field, if there there is any dependency
* preventing the field to be modified. It's used by all the public methods that perform any
- * DDL change on fields, throwing one ddl_dependency_exception if dependencies are found
+ * DDL change on fields, throwing one ddl_dependency_exception if dependencies are found.
+ *
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_field $xmldb_field Index object (full specs are required).
+ * @return void
+ * @throws ddl_dependency_exception|ddl_field_missing_exception|ddl_table_missing_exception if dependency not met.
*/
private function check_field_dependencies(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
/**
* This function will create the key in the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_key index object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_key $xmldb_key Index object (full specs are required).
* @return void
*/
public function add_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) {
/**
* This function will drop the key in the table passed as arguments
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_key key object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_key $xmldb_key Key object (full specs are required).
* @return void
*/
public function drop_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) {
* This function will rename the key in the table passed as arguments
* Experimental. Shouldn't be used at all in normal installation/upgrade!
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_key key object (full specs are required)
- * @param string new name of the key
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_key $xmldb_key key object (full specs are required).
+ * @param string $newname New name of the key.
* @return void
*/
public function rename_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key, $newname) {
* This function will create the index in the table passed as arguments
* Before creating the index, the function will check it doesn't exists
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_index index object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_index $xmldb_intex Index object (full specs are required).
* @return void
*/
public function add_index($xmldb_table, $xmldb_intex) {
* This function will drop the index in the table passed as arguments
* Before dropping the index, the function will check it exists
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_index index object (full specs are required)
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_index $xmldb_intex Index object (full specs are required).
* @return void
*/
public function drop_index($xmldb_table, $xmldb_intex) {
* Before renaming the index, the function will check it exists
* Experimental. Shouldn't be used at all!
*
- * @param xmldb_table table object (just the name is mandatory)
- * @param xmldb_index index object (full specs are required)
- * @param string new name of the index
+ * @param xmldb_table $xmldb_table Table object (just the name is mandatory).
+ * @param xmldb_index $xmldb_intex Index object (full specs are required).
+ * @param string $newname New name of the index.
* @return void
*/
public function rename_index($xmldb_table, $xmldb_intex, $newname) {
* MSSQL specific SQL code generator.
*
* @package core
- * @subpackage ddl
+ * @subpackage ddl_generator
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* Mysql specific SQL code generator.
*
* @package core
- * @subpackage ddl
+ * @subpackage ddl_generator
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* Oracle specific SQL code generator.
*
* @package core
- * @subpackage ddl
+ * @subpackage ddl_generator
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* PostgreSQL specific SQL code generator.
*
* @package core
- * @subpackage ddl
+ * @subpackage ddl_generator
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
/**
- * This class represent the base generator class where all the
- * needed functions to generate proper SQL are defined.
+ * This class represent the base generator class where all the needed functions to generate proper SQL are defined.
*
* The rest of classes will inherit, by default, the same logic.
* Functions will be overridden as needed to generate correct SQL.
*
* @package core
+ * @category ddl
* @subpackage ddl
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
/**
* Abstract sql generator class, base for all db specific implementations.
+ *
+ * @package core
+ * @category ddl
+ * @subpackage ddl
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class sql_generator {
/// that, by default, inherit this configuration.
/// To change any of them, do it in extended classes instead.
- public $quote_string = '"'; // String used to quote names
-
- public $statement_end = ';'; // String to be automatically added at the end of each statement
+ /** @var string Used to quote names. */
+ public $quote_string = '"';
- public $quote_all = false; // To decide if we want to quote all the names or only the reserved ones
+ /** @var string To be automatically added at the end of each statement. */
+ public $statement_end = ';';
- public $integer_to_number = false; // To create all the integers as NUMBER(x) (also called DECIMAL, NUMERIC...)
- public $float_to_number = false; // To create all the floats as NUMBER(x) (also called DECIMAL, NUMERIC...)
+ /** @var bool To decide if we want to quote all the names or only the reserved ones. */
+ public $quote_all = false;
- public $number_type = 'NUMERIC'; // Proper type for NUMBER(x) in this DB
+ /** @var bool To create all the integers as NUMBER(x) (also called DECIMAL, NUMERIC...). */
+ public $integer_to_number = false;
+ /** @var bool To create all the floats as NUMBER(x) (also called DECIMAL, NUMERIC...). */
+ public $float_to_number = false;
- public $unsigned_allowed = true; // To define in the generator must handle unsigned information
- public $default_for_char = null; // To define the default to set for NOT NULLs CHARs without default (null=do nothing)
+ /** @var string Proper type for NUMBER(x) in this DB. */
+ public $number_type = 'NUMERIC';
- public $drop_default_value_required = false; //To specify if the generator must use some DEFAULT clause to drop defaults
- public $drop_default_value = ''; //The DEFAULT clause required to drop defaults
+ /** @var bool To define in the generator must handle unsigned information.*/
+ public $unsigned_allowed = true;
+ /** @var string To define the default to set for NOT NULLs CHARs without default (null=do nothing).*/
+ public $default_for_char = null;
- public $default_after_null = true; //To decide if the default clause of each field must go after the null clause
+ /** @var bool To specify if the generator must use some DEFAULT clause to drop defaults.*/
+ public $drop_default_value_required = false;
+ /** @var string The DEFAULT clause required to drop defaults.*/
+ public $drop_default_value = '';
- public $specify_nulls = false; //To force the generator if NULL clauses must be specified. It shouldn't be necessary
- //but some mssql drivers require them or everything is created as NOT NULL :-(
+ /** @var bool To decide if the default clause of each field must go after the null clause.*/
+ public $default_after_null = true;
- public $primary_key_name = null; //To force primary key names to one string (null=no force)
+ /**
+ * @var bool To force the generator if NULL clauses must be specified. It shouldn't be necessary.
+ * note: some mssql drivers require them or everything is created as NOT NULL :-(
+ */
+ public $specify_nulls = false;
- public $primary_keys = true; // Does the generator build primary keys
- public $unique_keys = false; // Does the generator build unique keys
- public $foreign_keys = false; // Does the generator build foreign keys
+ /** @var string To force primary key names to one string (null=no force).*/
+ public $primary_key_name = null;
- public $drop_primary_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME'; // Template to drop PKs
- // with automatic replace for TABLENAME and KEYNAME
+ /** @var bool True if the generator builds primary keys.*/
+ public $primary_keys = true;
+ /** @var bool True if the generator builds unique keys.*/
+ public $unique_keys = false;
+ /** @var bool True if the generator builds foreign keys.*/
+ public $foreign_keys = false;
- public $drop_unique_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME'; // Template to drop UKs
- // with automatic replace for TABLENAME and KEYNAME
+ /**
+ * @var string Template to drop PKs.
+ * 'TABLENAME' and 'KEYNAME' will be replaced from this template.
+ */
+ public $drop_primary_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME';
- public $drop_foreign_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME'; // Template to drop FKs
- // with automatic replace for TABLENAME and KEYNAME
+ /**
+ * @var string Template to drop UKs.
+ * 'TABLENAME' and 'KEYNAME' will be replaced from this template.
+ */
+ public $drop_unique_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME';
- public $sequence_extra_code = true; //Does the generator need to add extra code to generate the sequence fields
- public $sequence_name = 'auto_increment'; //Particular name for inline sequences in this generator
- public $sequence_name_small = false; //Different name for small (4byte) sequences or false if same
- public $sequence_only = false; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name publiciable
+ /** @var string Template to drop FKs.
+ * 'TABLENAME' and 'KEYNAME' will be replaced from this template.
+ */
+ public $drop_foreign_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME';
+
+ /** @var bool True if the generator needs to add extra code to generate the sequence fields.*/
+ public $sequence_extra_code = true;
+ /** @var string The particular name for inline sequences in this generator.*/
+ public $sequence_name = 'auto_increment';
+ /** @var string|bool Different name for small (4byte) sequences or false if same.*/
+ public $sequence_name_small = false;
+ /**
+ * @var bool To avoid outputting the rest of the field specs, leaving only the name and the sequence_name returned.
+ * @see getFieldSQL()
+ */
+ public $sequence_only = false;
- public $add_table_comments = true; // Does the generator need to add code for table comments
+ /** @var bool True if the generator needs to add code for table comments.*/
+ public $add_table_comments = true;
- public $add_after_clause = false; // Does the generator need to add the after clause for fields
+ /** @var bool True if the generator needs to add the after clause for fields.*/
+ public $add_after_clause = false;
- public $prefix_on_names = true; //Does the generator need to prepend the prefix to all the key/index/sequence/trigger/check names
+ /**
+ * @var bool True if the generator needs to prepend the prefix to all the key/index/sequence/trigger/check names.
+ * @see $prefix
+ */
+ public $prefix_on_names = true;
- public $names_max_length = 30; //Max length for key/index/sequence/trigger/check names (keep 30 for all!)
+ /** @var int Maximum length for key/index/sequence/trigger/check names (keep 30 for all!).*/
+ public $names_max_length = 30;
- public $concat_character = '||'; //Characters to be used as concatenation operator. If not defined
- //MySQL CONCAT function will be used
+ /** @var string Characters to be used as concatenation operator.
+ * If not defined, MySQL CONCAT function will be used.
+ */
+ public $concat_character = '||';
- public $rename_table_sql = 'ALTER TABLE OLDNAME RENAME TO NEWNAME'; //SQL sentence to rename one table, both
- //OLDNAME and NEWNAME are dynamically replaced
+ /** @var string SQL sentence to rename one table, both 'OLDNAME' and 'NEWNAME' keywords are dynamically replaced.*/
+ public $rename_table_sql = 'ALTER TABLE OLDNAME RENAME TO NEWNAME';
- public $drop_table_sql = 'DROP TABLE TABLENAME'; //SQL sentence to drop one table
- //TABLENAME is dynamically replaced
+ /** @var string SQL sentence to drop one table where the 'TABLENAME' keyword is dynamically replaced.*/
+ public $drop_table_sql = 'DROP TABLE TABLENAME';
- public $alter_column_sql = 'ALTER TABLE TABLENAME ALTER COLUMN COLUMNSPECS'; //The SQL template to alter columns
+ /** @var string The SQL template to alter columns where the 'TABLENAME' and 'COLUMNSPECS' keywords are dynamically replaced.*/
+ public $alter_column_sql = 'ALTER TABLE TABLENAME ALTER COLUMN COLUMNSPECS';
- public $alter_column_skip_default = false; //The generator will skip the default clause on alter columns
+ /** @var bool The generator will skip the default clause on alter columns.*/
+ public $alter_column_skip_default = false;
- public $alter_column_skip_type = false; //The generator will skip the type clause on alter columns
+ /** @var bool The generator will skip the type clause on alter columns.*/
+ public $alter_column_skip_type = false;
- public $alter_column_skip_notnull = false; //The generator will skip the null/notnull clause on alter columns
+ /** @var bool The generator will skip the null/notnull clause on alter columns.*/
+ public $alter_column_skip_notnull = false;
+ /** @var string SQL sentence to rename one column where 'TABLENAME', 'OLDFIELDNAME' and 'NEWFIELDNAME' keywords are dynamically replaced.*/
public $rename_column_sql = 'ALTER TABLE TABLENAME RENAME COLUMN OLDFIELDNAME TO NEWFIELDNAME';
- ///TABLENAME, OLDFIELDNAME and NEWFIELDNAME are dyanmically replaced
- public $drop_index_sql = 'DROP INDEX INDEXNAME'; //SQL sentence to drop one index
- //TABLENAME, INDEXNAME are dynamically replaced
+ /** @var string SQL sentence to drop one index where 'TABLENAME', 'INDEXNAME' keywords are dynamically replaced.*/
+ public $drop_index_sql = 'DROP INDEX INDEXNAME';
- public $rename_index_sql = 'ALTER INDEX OLDINDEXNAME RENAME TO NEWINDEXNAME'; //SQL sentence to rename one index
- //TABLENAME, OLDINDEXNAME, NEWINDEXNAME are dynamically replaced
+ /** @var string SQL sentence to rename one index where 'TABLENAME', 'OLDINDEXNAME' and 'NEWINDEXNAME' are dynamically replaced.*/
+ public $rename_index_sql = 'ALTER INDEX OLDINDEXNAME RENAME TO NEWINDEXNAME';
- public $rename_key_sql = 'ALTER TABLE TABLENAME CONSTRAINT OLDKEYNAME RENAME TO NEWKEYNAME'; //SQL sentence to rename one key
- //TABLENAME, OLDKEYNAME, NEWKEYNAME are dynamically replaced
+ /** @var string SQL sentence to rename one key 'TABLENAME', 'OLDKEYNAME' and 'NEWKEYNAME' are dynamically replaced.*/
+ public $rename_key_sql = 'ALTER TABLE TABLENAME CONSTRAINT OLDKEYNAME RENAME TO NEWKEYNAME';
- public $prefix; // Prefix to be used for all the DB objects
+ /** @var string The prefix to be used for all the DB objects.*/
+ public $prefix;
- public $reserved_words; // List of reserved words (in order to quote them properly)
+ /** @var string List of reserved words (in order to quote them properly).*/
+ public $reserved_words;
+ /** @var moodle_database The moodle_database instance.*/
public $mdb;
-
- protected $temptables; // Control existing temptables
+ /** @var Control existing temptables.*/
+ protected $temptables;
/**
- * Creates new sql_generator
- * @param object moodle_database instance
+ * Creates a new sql_generator.
+ * @param moodle_database $mdb The moodle_database object instance.
+ * @param moodle_temptables $temptables The optional moodle_temptables instance, null by default.
*/
public function __construct($mdb, $temptables = null) {
$this->prefix = $mdb->get_prefix();
}
/**
- * Release all resources
+ * Releases all resources.
*/
public function dispose() {
$this->mdb = null;
}
/**
- * Given one string (or one array), ends it with statement_end
+ * Given one string (or one array), ends it with $statement_end .
+ *
+ * @see $statement_end
+ *
+ * @param array|string $input SQL statement(s).
*/
public function getEndedStatements($input) {
}
/**
- * Given one xmldb_table, check if it exists in DB (true/false)
+ * Given one xmldb_table, checks if it exists in DB (true/false).
*
- * @param mixed the table to be searched (string name or xmldb_table instance)
+ * @param mixed $table The table to be searched (string name or xmldb_table instance).
* @return boolean true/false
*/
public function table_exists($table) {
}
/**
- * This function will return the SQL code needed to create db tables and statements
+ * This function will return the SQL code needed to create db tables and statements.
+ *
+ * @param xmldb_structure $xmldb_structure An xmldb_structure instance.
+ *
+ * @see xmldb_structure
*/
public function getCreateStructureSQL($xmldb_structure) {
$results = array();
}
/**
- * Given one xmldb_table, returns it's correct name, depending of all the parametrization
+ * Given one xmldb_table, this returns it's correct name, depending of all the parameterization.
+ * eg: This appends $prefix to the table name.
+ *
+ * @see $prefix
*
- * @param xmldb_table table whose name we want
- * @param boolean to specify if the name must be quoted (if reserved word, only!)
- * @return string the correct name of the table
+ * @param xmldb_table $xmldb_table The table whose name we want.
+ * @param boolean $quoted To specify if the name must be quoted (if reserved word, only!).
+ * @return string The correct name of the table.
*/
public function getTableName(xmldb_table $xmldb_table, $quoted=true) {
/// Get the name
/**
* Given one correct xmldb_table, returns the SQL statements
- * to create it (inside one array)
+ * to create it (inside one array).
+ *
+ * @param xmldb_table $xmldb_table An xmldb_table instance.
+ * @return array An array of SQL statements, starting with the table creation SQL followed
+ * by any of its comments, indexes and sequence creation SQL statements.
*/
public function getCreateTableSQL($xmldb_table) {
/**
* Given one correct xmldb_index, returns the SQL statements
- * needed to create it (in array)
+ * needed to create it (in array).
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table instance to create the index on.
+ * @param xmldb_index $xmldb_index The xmldb_index to create.
+ * @return array An array of SQL statements to create the index.
+ * @throws coding_exception Thrown if the xmldb_index does not validate with the xmldb_table.
*/
public function getCreateIndexSQL($xmldb_table, $xmldb_index) {
if ($error = $xmldb_index->validateDefinition($xmldb_table)) {
}
/**
- * Given one correct xmldb_field, returns the complete SQL line to create it
+ * Given one correct xmldb_field, returns the complete SQL line to create it.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to create the SQL from.
+ * @param string $skip_type_clause The type clause on alter columns, NULL by default.
+ * @param string $skip_default_clause The default clause on alter columns, NULL by default.
+ * @param string $skip_notnull_clause The null/notnull clause on alter columns, NULL by default.
+ * @param string $specify_nulls_clause To force a specific null clause, NULL by default.
+ * @param bool $specify_field_name Flag to specify fieldname in return.
+ * @return string The field generating SQL statement.
+ * @throws coding_exception Thrown when xmldb_field doesn't validate with the xmldb_table.
*/
public function getFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL, $specify_nulls_clause = NULL, $specify_field_name = true) {
if ($error = $xmldb_field->validateDefinition($xmldb_table)) {
}
/**
- * Given one correct xmldb_key, returns its specs
+ * Given one correct xmldb_key, returns its specs.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_key.
+ * @param xmldb_key $xmldb_key The xmldb_key's specifications requested.
+ * @return string SQL statement about the xmldb_key.
*/
public function getKeySQL($xmldb_table, $xmldb_key) {
/**
* Give one xmldb_field, returns the correct "default value" for the current configuration
+ *
+ * @param xmldb_field $xmldb_field The field.
+ * @return The default value of the field.
*/
public function getDefaultValue($xmldb_field) {
}
/**
- * Given one xmldb_field, returns the correct "default clause" for the current configuration
+ * Given one xmldb_field, returns the correct "default clause" for the current configuration.
+ *
+ * @param xmldb_field $xmldb_field The xmldb_field.
+ * @return The SQL clause for generating the default value as in $xmldb_field.
*/
public function getDefaultClause($xmldb_field) {
/**
* Given one correct xmldb_table and the new name, returns the SQL statements
- * to rename it (inside one array)
+ * to rename it (inside one array).
+ *
+ * @param xmldb_table $xmldb_table The table to rename.
+ * @param string $newname The new name to rename the table to.
+ * @return array SQL statement(s) to rename the table.
*/
public function getRenameTableSQL($xmldb_table, $newname) {
/**
* Given one correct xmldb_table and the new name, returns the SQL statements
- * to drop it (inside one array)
+ * to drop it (inside one array).
+ *
+ * @param xmldb_table $xmldb_table The table to drop.
+ * @return array SQL statement(s) for dropping the specified table.
*/
public function getDropTableSQL($xmldb_table) {
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to add the field to the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to add the field to the table.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to create the SQL from.
+ * @param string $skip_type_clause The type clause on alter columns, NULL by default.
+ * @param string $skip_default_clause The default clause on alter columns, NULL by default.
+ * @param string $skip_notnull_clause The null/notnull clause on alter columns, NULL by default.
+ * @return array The SQL statement for adding a field to the table.
*/
public function getAddFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL) {
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop the field from the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop the field from the table.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to create the SQL from.
+ * @return array The SQL statement for dropping a field from the table.
*/
public function getDropFieldSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to create the SQL from.
+ * @param string $skip_type_clause The type clause on alter columns, NULL by default.
+ * @param string $skip_default_clause The default clause on alter columns, NULL by default.
+ * @param string $skip_notnull_clause The null/notnull clause on alter columns, NULL by default.
+ * @return string The field altering SQL statement.
*/
public function getAlterFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL) {
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to modify the default of the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to modify the default of the field in the table.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to get the modified default value from.
+ * @return array The SQL statement for modifying the default value.
*/
public function getModifyDefaultSQL($xmldb_table, $xmldb_field) {
/**
* Given one correct xmldb_field and the new name, returns the SQL statements
- * to rename it (inside one array)
+ * to rename it (inside one array).
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to get the renamed field from.
+ * @param string $newname The new name to rename the field to.
+ * @return array The SQL statements for renaming the field.
*/
public function getRenameFieldSQL($xmldb_table, $xmldb_field, $newname) {
/**
* Given one xmldb_table and one xmldb_key, return the SQL statements needed to add the key to the table
- * note that undelying indexes will be added as parametrised by $xxxx_keys and $xxxx_index parameters
+ * note that undelying indexes will be added as parametrised by $xxxx_keys and $xxxx_index parameters.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_key.
+ * @param xmldb_key $xmldb_key The xmldb_key to add.
+ * @return array SQL statement to add the xmldb_key.
*/
public function getAddKeySQL($xmldb_table, $xmldb_key) {
}
/**
- * Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table
+ * Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_key.
+ * @param xmldb_key $xmldb_key The xmldb_key to drop.
+ * @return array SQL statement to drop the xmldb_key.
*/
public function getDropKeySQL($xmldb_table, $xmldb_key) {
/**
* Given one xmldb_table and one xmldb_key, return the SQL statements needed to rename the key in the table
* Experimental! Shouldn't be used at all!
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_key.
+ * @param xmldb_key $xmldb_key The xmldb_key to rename.
+ * @param string $newname The xmldb_key's new name.
+ * @return array SQL statement to rename the xmldb_key.
*/
-
public function getRenameKeySQL($xmldb_table, $xmldb_key, $newname) {
$results = array();
}
/**
- * Given one xmldb_table and one xmldb_index, return the SQL statements needed to add the index to the table
+ * Given one xmldb_table and one xmldb_index, return the SQL statements needed to add the index to the table.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table instance to add the index on.
+ * @param xmldb_index $xmldb_index The xmldb_index to add.
+ * @return array An array of SQL statements to add the index.
*/
public function getAddIndexSQL($xmldb_table, $xmldb_index) {
}
/**
- * Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table
+ * Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table instance to drop the index on.
+ * @param xmldb_index $xmldb_index The xmldb_index to drop.
+ * @return array An array of SQL statements to drop the index.
*/
public function getDropIndexSQL($xmldb_table, $xmldb_index) {
/**
* Given one xmldb_table and one xmldb_index, return the SQL statements needed to rename the index in the table
* Experimental! Shouldn't be used at all!
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table instance to rename the index on.
+ * @param xmldb_index $xmldb_index The xmldb_index to rename.
+ * @param string $newname The xmldb_index's new name.
+ * @return array An array of SQL statements to rename the index.
*/
function getRenameIndexSQL($xmldb_table, $xmldb_index, $newname) {
/// Some DB doesn't support index renaming (MySQL) so this can be empty
*
* IMPORTANT: This function must be used to CALCULATE NAMES of objects TO BE CREATED,
* NEVER TO GUESS NAMES of EXISTING objects!!!
+ *
+ * @param string $tablename The table name.
+ * @param string $fields A list of comma separated fields.
+ * @param string $suffix A suffix for the object name.
+ * @return string Object's name.
*/
public function getNameForObject($tablename, $fields, $suffix='') {
/**
* Given any string (or one array), enclose it by the proper quotes
* if it's a reserved word
+ *
+ * @param string|array $input String to quote.
+ * @return Quoted string.
*/
public function getEncQuoted($input) {
}
/**
- * Given one XMLDB Statement, build the needed SQL insert sentences to execute it
+ * Given one XMLDB Statement, build the needed SQL insert sentences to execute it.
+ *
+ * @param string $statement SQL statement.
+ * @return array Array of sentences in the SQL statement.
*/
function getExecuteInsertSQL($statement) {
}
/**
- * Given one array of elements, build de proper CONCAT expression, based
+ * Given one array of elements, build the proper CONCAT expression, based
* in the $concat_character setting. If such setting is empty, then
- * MySQL's CONCAT function will be used instead
+ * MySQL's CONCAT function will be used instead.
+ *
+ * @param array $elements An array of elements to concatenate.
+ * @return mixed Returns the result of moodle_database::sql_concat() or false.
+ * @uses moodle_database::sql_concat()
+ * @uses call_user_func_array()
*/
public function getConcatSQL($elements) {
/**
* Returns the name (string) of the sequence used in the table for the autonumeric pk
- * Only some DB have this implemented
+ * Only some DB have this implemented.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table instance.
+ * @return bool Returns the sequence from the DB or false.
*/
public function getSequenceFromDB($xmldb_table) {
return false;
}
/**
- * Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg)
- * return if such name is currently in use (true) or no (false)
+ * Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg).
+ *
* (MySQL requires the whole xmldb_table object to be specified, so we add it always)
- * (invoked from getNameForObject()
- * Only some DB have this implemented
+ *
+ * This is invoked from getNameForObject().
+ * Only some DB have this implemented.
+ *
+ * @param string $object_name The object's name to check for.
+ * @param string $type The object's type (pk, uk, fk, ck, ix, uix, seq, trg).
+ * @param string $table_name The table's name to check in
+ * @return bool If such name is currently in use (true) or no (false)
*/
public function isNameInUse($object_name, $type, $table_name) {
return false; //For generators not implementing introspection,
/**
* Reset a sequence to the id field of a table.
- * @param string $table name of table
+ *
+ * @param string $tablename name of table.
* @return success
*/
public abstract function getResetSequenceSQL($tablename);
/**
* Given one correct xmldb_table, returns the SQL statements
- * to create temporary table (inside one array)
+ * to create temporary table (inside one array).
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @return array SQL statements.
*/
abstract public function getCreateTempTableSQL($xmldb_table);
/**
- * Given one correct xmldb_table and the new name, returns the SQL statements
- * to drop it (inside one array)
+ * Given one correct xmldb_table and the new name, returns the SQL statements.
+ * to drop it (inside one array).
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @return array SQL statements.
*/
abstract public function getDropTempTableSQL($xmldb_table);
/**
- * Given one XMLDB Type, length and decimals, returns the DB proper SQL type
+ * Given one XMLDB Type, length and decimals, returns the DB proper SQL type.
+ *
+ * @param int $xmldb_type The xmldb_type defined constant. XMLDB_TYPE_INTEGER and other XMLDB_TYPE_* constants.
+ * @param int $xmldb_length The length of that data type.
+ * @param int $xmldb_decimals The decimal places of precision of the data type.
+ * @return string The DB defined data type.
*/
public abstract function getTypeSQL($xmldb_type, $xmldb_length=null, $xmldb_decimals=null);
/**
- * Returns the code (array of statements) needed to execute extra statements on field rename
+ * Returns the code (array of statements) needed to execute extra statements on field rename.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ * @return array Array of extra SQL statements to run with a field being renamed.
*/
public function getRenameFieldExtraSQL($xmldb_table, $xmldb_field) {
return array();
/**
* Returns the code (array of statements) needed
- * to create one sequence for the xmldb_table and xmldb_field passes
+ * to create one sequence for the xmldb_table and xmldb_field passed in.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ * @return array Array of SQL statements to create the sequence.
*/
public function getCreateSequenceSQL($xmldb_table, $xmldb_field) {
return array();
}
/**
- * Returns the code (array of statements) needed to add one comment to the table
+ * Returns the code (array of statements) needed to add one comment to the table.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @return array Array of SQL statements to add one comment to the table.
*/
public abstract function getCommentSQL($xmldb_table);
/**
- * Returns the code (array of statements) needed to execute extra statements on table rename
+ * Returns the code (array of statements) needed to execute extra statements on table rename.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param string $newname The new name for the table.
+ * @return array Array of extra SQL statements to rename a table.
*/
public function getRenameTableExtraSQL($xmldb_table, $newname) {
return array();
/**
* Returns the code (array of statements) needed to execute extra statements on table drop
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @return array Array of extra SQL statements to drop a table.
*/
public function getDropTableExtraSQL($xmldb_table) {
return array();
* Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its enum
* (usually invoked from getModifyEnumSQL()
*
- * TODO: Moodle 2.1 - Drop getDropEnumSQL()
+ * Note that this method may be dropped in future.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ *
+ * @todo MDL-31147 Moodle 2.1 - Drop getDropEnumSQL()
*/
public abstract function getDropEnumSQL($xmldb_table, $xmldb_field);
* Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default
* (usually invoked from getModifyDefaultSQL()
*
- * TODO: Moodle 2.1 - Drop getDropDefaultSQL()
+ * Note that this method may be dropped in future.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ *
+ * @todo MDL-31147 Moodle 2.1 - Drop getDropDefaultSQL()
*/
public abstract function getDropDefaultSQL($xmldb_table, $xmldb_field);
* constrainst found for that table (or field). Must exist for each DB supported.
* (usually invoked from find_check_constraint_name)
*
- * TODO: Moodle 2.1 - Drop getCheckConstraintsFromDB
+ * Note that this method may be dropped in future.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ *
+ * @todo MDL-31147 Moodle 2.1 - Drop getCheckConstraintsFromDB
*/
public abstract function getCheckConstraintsFromDB($xmldb_table, $xmldb_field=null);
/**
* Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default
* (usually invoked from getModifyDefaultSQL()
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ * @return array Array of SQL statements to create a field's default.
*/
public abstract function getCreateDefaultSQL($xmldb_table, $xmldb_field);
/**
* Returns an array of reserved words (lowercase) for this DB
- * You MUST provide the real list for each DB inside every XMLDB class
- * @return array of reserved words
+ * You MUST provide the real list for each DB inside every XMLDB class.
+ * @return array An array of database specific reserved words.
+ * @throws coding_exception Thrown if not implemented for the specific DB.
*/
public static function getReservedWords() {
throw new coding_exception('getReservedWords() method needs to be overridden in each subclass of sql_generator');
}
/**
- * Returns all reserved works in supported databases.
+ * Returns all reserved words in supported databases.
* Reserved words should be lowercase.
* @return array ('word'=>array(databases))
*/
return $reserved_words;
}
+ /**
+ * Adds slashes to string.
+ * @param string $s
+ * @return string The escaped string.
+ */
public function addslashes($s) {
// do not use php addslashes() because it depends on PHP quote settings!
$s = str_replace('\\','\\\\',$s);
* Experimental SQLite specific SQL code generator.
*
* @package core
- * @subpackage ddl
+ * @subpackage ddl_generator
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
this.filecount++;
this.check_buttons();
this.refresh(this.currentpath);
+ M.util.set_form_changed();
},
check_buttons: function() {
var button_addfile = Y.one("#btnadd-"+this.client_id);
scope.mkdir_dialog.hide();
scope.refresh(filepath);
Y.one('#fm-newname').set('value', '');
+ M.util.set_form_changed();
}
});
}
callback: function(id, obj, args) {
scope.filecount--;
scope.refresh(obj.filepath);
+ M.util.set_form_changed();
if (scope.filecount < scope.maxfiles && scope.maxfiles!=-1) {
var button_addfile = Y.one("#btnadd-"+scope.client_id);
button_addfile.setStyle('display', 'inline');
alert(M.str.repository.fileexists);
} else {
scope.refresh(obj.filepath);
+ M.util.set_form_changed();
}
Y.one('#fm-rename-input').set('value', '');
scope.rename_dialog.hide();
}
dialog.cancel();
scope.refresh(p);
+ M.util.set_form_changed();
}
});
}
// switch next two lines for ol li containers for form items.
// $this->_elementTemplates=array('default'=>"\n\t\t".'<li class="fitem"><label>{label}{help}<!-- BEGIN required -->{req}<!-- END required --></label><div class="qfelement<!-- BEGIN error --> error<!-- END error --> {type}"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element}</div></li>');
$this->_elementTemplates = array(
- 'default'=>"\n\t\t".'<div class="fitem {advanced}<!-- BEGIN required --> required<!-- END required -->"><div class="fitemtitle"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</label></div><div class="felement {type}<!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element}</div></div>',
+ 'default'=>"\n\t\t".'<div id="{id}" class="fitem {advanced}<!-- BEGIN required --> required<!-- END required --> fitem_{type}"><div class="fitemtitle"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</label></div><div class="felement {type}<!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element}</div></div>',
- 'fieldset'=>"\n\t\t".'<div class="fitem {advanced}<!-- BEGIN required --> required<!-- END required -->"><div class="fitemtitle"><div class="fgrouplabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</label></div></div><fieldset class="felement {type}<!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element}</fieldset></div>',
+ 'fieldset'=>"\n\t\t".'<div id="{id}" class="fitem {advanced}<!-- BEGIN required --> required<!-- END required --> fitem_{type}"><div class="fitemtitle"><div class="fgrouplabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</label></div></div><fieldset class="felement {type}<!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element}</fieldset></div>',
'static'=>"\n\t\t".'<div class="fitem {advanced}"><div class="fitemtitle"><div class="fstaticlabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</label></div></div><div class="felement fstatic <!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element} </div></div>',
* @param object $form MoodleQuickForm
*/
function startForm(&$form){
+ global $PAGE;
$this->_reqHTML = $form->getReqHTML();
$this->_elementTemplates = str_replace('{req}', $this->_reqHTML, $this->_elementTemplates);
$this->_advancedHTML = $form->getAdvancedHTML();
$this->_hiddenHtml .= $form->_pageparams;
}
-
+ $PAGE->requires->yui_module('moodle-core-formslib',
+ 'M.core.init_formslib',
+ array(array(
+ 'formid' => $form->getAttribute('id')
+ ))
+ );
+ $PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
}
/**
* @param mixed $error
*/
function startGroup(&$group, $required, $error){
+ // Make sure the element has an id.
+ $group->_generateId();
+
if (method_exists($group, 'getElementTemplateType')){
$html = $this->_elementTemplates[$group->getElementTemplateType()];
}else{
}else{
$html =str_replace('{help}', '', $html);
}
+ $html =str_replace('{id}', 'fgroup_' . $group->getAttribute('id'), $html);
$html =str_replace('{name}', $group->getName(), $html);
$html =str_replace('{type}', 'fgroup', $html);
} else {
$html =str_replace('{advancedimg}', '', $html);
}
+ $html =str_replace('{id}', 'fitem_' . $element->getAttribute('id'), $html);
$html =str_replace('{type}', 'f'.$element->getType(), $html);
$html =str_replace('{name}', $element->getName(), $html);
if (method_exists($element, 'getHelpButton')){
$entity = $this->character($start, $this->char);
$cond = strlen($e_name) > 0;
- // The rest of the parsing happens bellow.
+ // The rest of the parsing happens below.
break;
// Anything else
}
$cond = isset($entity);
- // The rest of the parsing happens bellow.
+ // The rest of the parsing happens below.
break;
}
fileref.onreadystatechange = embed_function;
document.getElementsByTagName('head')[0].appendChild(fileref);
}
+};
+
+/**
+ * Set the form changed state to true
+ */
+M.util.set_form_changed = function() {
+ M.cfg.form_changed = 1;
+};
+
+/**
+ * Set the form submitted state to true
+ */
+M.util.set_form_submitted = function() {
+ M.cfg.form_submitted = 1;
}
+
+/**
+ * Attempt to determine whether the form has been modified in any way and
+ * is thus 'dirty'
+ *
+ * @return Integer 1 is the form is dirty; 0 if not
+ */
+M.util.get_form_dirty_state = function() {
+ // If the form was submitted, then return a non-dirty state
+ if (M.cfg.form_submitted) {
+ return 0;
+ }
+
+ // If any fields have been marked dirty, return a dirty state
+ if (M.cfg.form_changed) {
+ return 1;
+ }
+
+ // Handle TinyMCE editor instances
+ // We can't add a listener in the initializer as the editors may not have been created by that point
+ // so we do so here instead
+ if (typeof tinyMCE != 'undefined') {
+ for (var editor in tinyMCE.editors) {
+ if (tinyMCE.editors[editor].isDirty()) {
+ return 1;
+ }
+ }
+ }
+
+ // If we reached here, then the form hasn't met any of the dirty conditions
+ return 0;
+};
+
+/**
+ * Return a suitable message if changes have been made to a form
+ */
+M.util.report_form_dirty_state = function(e) {
+ if (!M.util.get_form_dirty_state()) {
+ // the form is not dirty, so don't display any message
+ return;
+ }
+
+ // This is the error message that we'll show to browsers which support it
+ var returnValue = M.util.get_string('changesmadereallygoaway', 'moodle');
+
+ // Most browsers are happy with the returnValue being set on the event
+ // But some browsers do not consistently pass the event
+ if (e) {
+ e.returnValue = returnValue;
+ }
+
+ // But some require it to be returned instead
+ return returnValue;
+};
// last course access not necessary either
$DB->delete_records('user_lastaccess', array('userid'=>$user->id));
+ // remove all user tokens
+ $DB->delete_records('external_tokens', array('userid'=>$user->id));
+
+ // unauthorise the user for all services
+ $DB->delete_records('external_services_users', array('userid'=>$user->id));
+
// force logout - may fail if file based sessions used, sorry
session_kill_user($user->id);
/**
* Returns the code for the current language
*
+ * @category string
* @return string
*/
function current_language() {
/**
* Returns parent language of current active language if defined
*
+ * @category string
* @uses COURSE
* @uses SESSION
* @param string $lang null means current language
* The param $forcereload is needed for CLI installer only where the string_manager instance
* must be replaced during the install.php script life time.
*
+ * @category string
* @param bool $forcereload shall the singleton be released and new instance created instead?
* @return string_manager
*/
/**
+ * Interface for string manager
+ *
* Interface describing class which is responsible for getting
* of localised strings from language packs.
*
- * @package moodlecore
+ * @package core
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
public function get_list_of_languages($lang = NULL, $standard = 'iso6392');
/**
- * Does the translation exist?
+ * Checks if the translation exists for the language
*
* @param string $lang moodle translation language code
- * @param bool include also disabled translations?
- * @return boot true if exists
+ * @param bool $includeall include also disabled translations
+ * @return bool true if exists
*/
public function translation_exists($lang, $includeall = true);
/**
* Standard string_manager implementation
*
- * @package moodlecore
+ * Implements string_manager with getting and printing localised strings
+ *
+ * @package core
+ * @category string
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
protected $countdiskcache = 0;
/** @var bool use disk cache */
protected $usediskcache;
- /* @var array limit list of translations */
+ /** @var array limit list of translations */
protected $translist;
/** @var string location of a file that caches the list of available translations */
protected $menucache;
/**
* Returns dependencies of current language, en is not included.
+ *
* @param string $lang
* @return array all parents, the lang itself is last
*/
/**
* Load all strings for one component
+ *
* @param string $component The module the string is associated with
* @param string $lang
* @param bool $disablecache Do not use caches, force fetching the strings from sources
*
* get_string() is throwing debug warnings, sometimes we do not want them
* or we want to display better explanation of the problem.
- *
- * Use with care!
+ * Note: Use with care!
*
* @param string $identifier The identifier of the string to search for
* @param string $component The module the string is associated with
/**
* Returns information about the string_manager performance
+ *
* @return array
*/
public function get_performance_summary() {
}
/**
- * Does the translation exist?
+ * Checks if the translation exists for the language
*
* @param string $lang moodle translation language code
- * @param bool include also disabled translations?
- * @return boot true if exists
+ * @param bool $includeall include also disabled translations
+ * @return bool true if exists
*/
public function translation_exists($lang, $includeall = true) {
/**
* Returns localised list of installed translations
+ *
* @param bool $returnall return all or just enabled
* @return array moodle translation code => localised translation name
*/
/**
+ * Fetches minimum strings for installation
+ *
* Minimalistic string fetching implementation
* that is used in installer before we fetch the wanted
* language pack from moodle.org lang download site.
*
- * @package moodlecore
+ * @package core
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
}
/**
- * Does the translation exist?
+ * Checks if the translation exists for the language
*
* @param string $lang moodle translation language code
- * @param bool include also disabled translations?
- * @return boot true if exists
+ * @param bool $includeall include also disabled translations
+ * @return bool true if exists
*/
public function translation_exists($lang, $includeall = true) {
return file_exists($this->installroot.'/'.$lang.'/langconfig.php');
* But you should never do that anyway!
* For more information {@see lang_string}
*
+ * @category string
* @param string $identifier The key identifier for the localized string
* @param string $component The module where the key identifier is stored,
* usually expressed as the filename in the language pack without the
* Converts an array of strings to their localized value.
*
* @param array $array An array of strings
- * @param string $module The language module that these strings can be found in.
- * @return array and array of translated strings.
+ * @param string $component The language module that these strings can be found in.
+ * @return stdClass translated strings.
*/
function get_strings($array, $component = '') {
$string = new stdClass;
* echo '</h1>';
* </code>
*
+ * @category string
* @param string $identifier The key identifier for the localized string
* @param string $component The module where the key identifier is stored. If none is specified then moodle.php is used.
- * @param mixed $a An object, string or number that can be used within translation strings
+ * @param string|object|array $a An object, string or number that can be used within translation strings
*/
function print_string($identifier, $component = '', $a = NULL) {
echo get_string($identifier, $component, $a);
'license' => NULL,
'mathslib' => NULL,
'message' => 'message',
- 'message' => 'message',
'mimetypes' => NULL,
'mnet' => 'mnet',
'moodle.org' => NULL, // the dot is nasty, watch out! should be renamed to moodleorg
* @return mixed
*/
function component_callback($component, $function, array $params = array(), $default = null) {
- global $CFG; // this is needed for require_once() bellow
+ global $CFG; // this is needed for require_once() below
$cleancomponent = clean_param($component, PARAM_COMPONENT);
if (empty($cleancomponent)) {
return 'tablet';
}
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== false) {
+ // Safe way to check for IE6 and not get false positives for some IE 7/8 users
+ if (substr($_SERVER['HTTP_USER_AGENT'], 0, 34) === 'Mozilla/4.0 (compatible; MSIE 6.0;') {
return 'legacy';
}
/**
* Sets the system locale
*
- * @todo Finish documenting this function
- *
- * @global object
+ * @category string
* @param string $locale Can be used to force a locale
*/
function moodle_setlocale($locale='') {
/**
* Converts string to lowercase using most compatible function available.
*
- * @todo Remove this function when no longer in use
- * @deprecated Use textlib->strtolower($text) instead.
+ * @deprecated since Moodle 2.0 use textlib::strtolower()
+ * @todo MDL-31250 Remove this function when no longer in use
+ * @see textlib::strtolower($text)
*
* @param string $string The string to convert to all lowercase characters.
* @param string $encoding The encoding on the string.
*
* Words are defined as things between whitespace.
*
+ * @category string
* @param string $string The text to be searched for words.
* @return int The count of words in the specified string
*/
*
* Letters are defined as chars not in tags and different from whitespace.
*
+ * @category string
* @param string $string The text to be searched for letters.
* @return int The count of letters in the specified text.
*/
* Given some text (which may contain HTML) and an ideal length,
* this function truncates the text neatly on a word boundary if possible
*
- * @global object
- * @param string $text - text to be shortened
- * @param int $ideal - ideal string length
+ * @category string
+ * @global stdClass $CFG
+ * @param string $text text to be shortened
+ * @param int $ideal ideal string length
* @param boolean $exact if false, $text will not be cut mid-word
* @param string $ending The string to append if the passed string is truncated
- * @return string $truncate - shortened string
+ * @return string $truncate shortened string
*/
function shorten_text($text, $ideal=30, $exact = false, $ending='...') {
* {@link http://www.phpbuilder.com/columns/jesus19990502.php3} and
* {@link http://es2.php.net/manual/en/function.str-shuffle.php#73254}
*
- * @global object
+ * @global stdClass $CFG
* @param int $maxlen The maximum size of the password being generated.
* @return string
*/
* Localized floats must not be used in calculations!
*
* @param float $float The float to print
- * @param int $places The number of decimal places to print.
+ * @param int $decimalpoints The number of decimal places to print.
* @param bool $localized use localized decimal separator
* @return string locale float
*/
* Converts locale specific floating point/comma number back to standard PHP float value
* Do NOT try to do any math operations before this conversion on any user submitted floats!
*
- * @param string $locale_float locale aware float representation
+ * @param string $locale_float locale aware float representation
* @return float
*/
function unformat_float($locale_float) {
* 1. You cannot use a lang_string object as an array offset. Doing so will
* result in PHP throwing an error. (You can use it as an object property!)
*
- * @package moodlecore
- *
+ * @package core
+ * @category string
* @copyright 2011 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$cm = $modinfo->get_cm($cm->id);
}
+ $activity->nodetype = navigation_node::NODETYPE_LEAF;
$activity->make_active();
$file = $CFG->dirroot.'/mod/'.$cm->modname.'/lib.php';
$function = $cm->modname.'_extend_navigation';
if (function_exists($function)) {
$activtyrecord = $DB->get_record($cm->modname, array('id' => $cm->instance), '*', MUST_EXIST);
$function($activity, $course, $activtyrecord, $cm);
- return true;
}
}
- $activity->nodetype = navigation_node::NODETYPE_LEAF;
- return false;
+
+ // Allow the active advanced grading method plugin to append module navigation
+ $featuresfunc = $cm->modname.'_supports';
+ if (function_exists($featuresfunc) && $featuresfunc(FEATURE_ADVANCED_GRADING)) {
+ require_once($CFG->dirroot.'/grade/grading/lib.php');
+ $gradingman = get_grading_manager($cm->context, $cm->modname);
+ $gradingman->extend_navigation($this, $activity);
+ }
+
+ return $activity->has_children();
}
/**
* Loads user specific information into the navigation in the appropriate place.
return false;
}
// Add a branch for the current user
- $usernode = $usersnode->add(fullname($user, true), $userviewurl, self::TYPE_USER, null, $user->id);
+ $canseefullname = has_capability('moodle/site:viewfullnames', $coursecontext);
+ $usernode = $usersnode->add(fullname($user, $canseefullname), $userviewurl, self::TYPE_USER, null, $user->id);
if ($this->page->context->contextlevel == CONTEXT_USER && $user->id == $this->page->context->instanceid) {
$usernode->make_active();
*/
function toHtml()
{
+ $this->_generateId(); // Seems to be necessary when this is used in a group.
if (0 == strlen($this->_text)) {
$label = '';
} elseif ($this->_flagFrozen) {
*
* @param object $course - full Course object
* @param object $cm - full cm object
+ * @return string
*/
function plagiarism_update_status($course, $cm) {
global $CFG;
return '';
}
$plagiarismplugins = plagiarism_load_available_plugins();
+ $output = '';
foreach($plagiarismplugins as $plugin => $dir) {
require_once($dir.'/lib.php');
$plagiarismclass = "plagiarism_plugin_$plugin";
$plagiarismplugin = new $plagiarismclass;
- $plagiarismplugin->update_status($course, $cm);
+ $output .= $plagiarismplugin->update_status($course, $cm);
}
+ return $output;
}
/**
* Function that prints the student disclosure notifying that the files will be checked for plagiarism
* @param integer $cmid - the cmid of this module
+* @return string
*/
function plagiarism_print_disclosure($cmid) {
global $CFG;
return '';
}
$plagiarismplugins = plagiarism_load_available_plugins();
+ $output = '';
foreach($plagiarismplugins as $plugin => $dir) {
require_once($dir.'/lib.php');
$plagiarismclass = "plagiarism_plugin_$plugin";
$plagiarismplugin = new $plagiarismclass;
- $plagiarismplugin->print_disclosure($cmid);
+ $output .= $plagiarismplugin->print_disclosure($cmid);
}
+ return $output;
}
/**
* used by admin/cron.php to get similarity scores from submitted files.
$this->assertEqual(array('gecko', 'gecko19'), get_browser_version_classes());
}
+ function test_get_device_type() {
+ // IE8 (common pattern ~1.5% of IE7/8 users have embedded IE6 agent))
+ $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BT Openworld BB; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Hotbar 10.2.197.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727)';
+ $this->assertEqual('default', get_device_type());
+ // Genuine IE6
+ $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.0.3705; Media Center PC 2.8)';
+ $this->assertEqual('legacy', get_device_type());
+ }
+
function test_fix_utf8() {
// make sure valid data including other types is not changed
$this->assertidentical(null, fix_utf8(null));
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
+ * Defines string apis
+ *
* @package core
- * @subpackage lib
* @copyright (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* Original singleton helper function, please use static methods instead,
* ex: textlib::convert()
*
- * @deprecated
+ * @deprecated since Moodle 2.1 MDL-29027 textlib contains static functions
+ * @todo MDL-31301 calling of textlib functions should be static.
+ * @see textlib
* @return textlib instance
*/
function textlib_get_instance() {
/**
+ * defines string api's for manipulating strings
+ *
* This class is used to manipulate strings under Moodle 1.6 an later. As
* utf-8 text become mandatory a pool of safe functions under this encoding
* become necessary. The name of the methods is exactly the
* its capabilities so, don't forget to make the conversion
* from every wrapper function!
*
- * @package core
- * @subpackage lib
+ * @package core
+ * @category string
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class textlib {
/**
- * Return t3lib helper class
+ * Return t3lib helper class, which is used for conversion between charsets
+ *
* @return t3lib_cs
*/
protected static function typo3() {
/**
* Multibyte safe substr() function, uses mbstring or iconv for UTF-8, falls back to typo3.
*
- * @param string $text
+ * @param string $text string to truncate
* @param int $start negative value means from end
- * @param int $len
+ * @param int $len maximum length of characters beginning from start
* @param string $charset encoding of the text
- * @return string
+ * @return string portion of string specified by the $start and $len
*/
public static function substr($text, $start, $len=null, $charset='utf-8') {
$charset = self::parse_charset($charset);
/**
* Multibyte safe strlen() function, uses mbstring or iconv for UTF-8, falls back to typo3.
*
- * @param string $text
+ * @param string $text input string
* @param string $charset encoding of the text
* @return int number of characters
*/
/**
* Multibyte safe strtolower() function, uses mbstring, falls back to typo3.
*
- * @param string $text
+ * @param string $text input string
* @param string $charset encoding of the text (may not work for all encodings)
* @return string lower case text
*/
/**
* Multibyte safe strtoupper() function, uses mbstring, falls back to typo3.
*
- * @param string $text
+ * @param string $text input string
* @param string $charset encoding of the text (may not work for all encodings)
* @return string upper case text
*/
}
/**
+ * Find the position of the first occurrence of a substring in a string.
* UTF-8 ONLY safe strpos(), uses mbstring, falls back to iconv.
*
- * @param string $haystack
- * @param string $needle
- * @param int $offset
- * @return string
+ * @param string $haystack the string to search in
+ * @param string $needle one or more charachters to search for
+ * @param int $offset offset from begining of string
+ * @return int the numeric position of the first occurrence of needle in haystack.
*/
public static function strpos($haystack, $needle, $offset=0) {
if (function_exists('mb_strpos')) {
}
/**
+ * Find the position of the last occurrence of a substring in a string
* UTF-8 ONLY safe strrpos(), uses mbstring, falls back to iconv.
*
- * @param string $haystack
- * @param string $needle
- * @return string
+ * @param string $haystack the string to search in
+ * @param string $needle one or more charachters to search for
+ * @return int the numeric position of the last occurrence of needle in haystack
*/
public static function strrpos($haystack, $needle) {
if (function_exists('mb_strpos')) {
* Try to convert upper unicode characters to plain ascii,
* the returned string may contain unconverted unicode characters.
*
- * @param string $text
+ * @param string $text input string
* @param string $charset encoding of the text
- * @return string
+ * @return string converted ascii string
*/
public static function specialtoascii($text, $charset='utf-8') {
$charset = self::parse_charset($charset);
* This function seems to be 100% compliant with RFC1342. Credits go to:
* paravoid (http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283).
*
- * @param string $text
+ * @param string $text input string
* @param string $charset encoding of the text
- * @return string
+ * @return string base64 encoded header
*/
public static function encode_mimeheader($text, $charset='utf-8') {
if (empty($text)) {
* http://php.net/manual/en/function.html-entity-decode.php#75153
* with some custom mods to provide more functionality
*
- * @param string $str input string
- * @param boolean $htmlent convert also html entities (defaults to true)
- * @return string
+ * @param string $str input string
+ * @param boolean $htmlent convert also html entities (defaults to true)
+ * @return string encoded UTF-8 string
*
* NOTE: we could have used typo3 entities_to_utf8() here
* but the direct alternative used runs 400% quicker
/**
* Converts all Unicode chars > 127 to numeric entities &#nnnn; or &#xnnn;.
*
- * @param string $str input string
- * @param boolean $dec output decadic only number entities
- * @param boolean $nonnum remove all non-numeric entities
- * @return string converted string
+ * @param string $str input string
+ * @param boolean $dec output decadic only number entities
+ * @param boolean $nonnum remove all non-numeric entities
+ * @return string converted string
*/
public static function utf8_to_entities($str, $dec=false, $nonnum=false) {
// Avoid some notices from Typo3 code
}
/**
- * Removes the BOM from unicode string - see http://unicode.org/faq/utf_bom.html
+ * Removes the BOM from unicode string {@link http://unicode.org/faq/utf_bom.html}
*
- * @param string $str
+ * @param string $str input string
* @return string
*/
public static function trim_utf8_bom($str) {
/**
* Returns encoding options for select boxes, utf-8 and platform encoding first
+ *
* @return array encodings
*/
public static function get_encodings() {
* Makes first letter of each word capital - words must be separated by spaces.
* Use with care, this function does not work properly in many locales!!!
*
- * @param string $text
+ * @param string $text input string
* @return string
*/
public static function strtotitle($text) {
/**
* A collator class with static methods that can be used for sorting.
*
- * @package core
- * @subpackage lib
+ * @package core
* @copyright 2011 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* 0 if str1 is equal to str2
* -1 if str1 is less than str2
*
+ * @param string $str1 first string to compare
+ * @param string $str2 second string to compare
* @return int
*/
public static function compare($str1, $str2) {
}
/**
+ * Object comparison using collator
+ *
* Abstract class to aid the sorting of objects with respect to proper language
* comparison using collator
*
- * @package core
- * @subpackage lib
+ * @package core
* @copyright 2011 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
}
/**
+ * Compare properties of two objects
+ *
* A comparison helper for comparing properties of two objects
*
- * @package core
- * @subpackage lib
+ * @package core
+ * @category string
* @copyright 2011 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
protected $property;
/**
+ * Constructor
+ *
* @param string $property
*/
public function __construct($property) {
}
/**
+ * Compare method of two objects
+ *
* A comparison helper for comparing the result of a method on two objects
*
- * @package core
- * @subpackage lib
+ * @package core
* @copyright 2011 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
protected $method;
/**
+ * Constructor
+ *
* @param string $method The method to call against each object
*/
public function __construct($method) {
--- /dev/null
+YUI.add('moodle-core-formslib',
+ function(Y) {
+ // The CSS selectors we use
+ var CSS = {
+ };
+
+ var FORMSLIBNAME = 'core-formslib';
+
+ var FORMSLIB = function() {
+ FORMSLIB.superclass.constructor.apply(this, arguments);
+ }
+
+ Y.extend(FORMSLIB, Y.Base, {
+ /**
+ * Initialize the module
+ */
+ initializer : function(config) {
+ var formid = 'form#' + this.get('formid');
+
+ // Add change events to the form elements
+ Y.all(formid + ' input').on('change', M.util.set_form_changed, this);
+ Y.all(formid + ' textarea').on('change', M.util.set_form_changed, this);
+ Y.all(formid + ' select').on('change', M.util.set_form_changed, this);
+
+ // We need any submit buttons on the form to set the submitted flag
+ Y.one(formid).on('submit', M.util.set_form_submitted, this);
+
+ // YUI doesn't support onbeforeunload properly so we must use the DOM to set the onbeforeunload. As
+ // a result, the has_changed must stay in the DOM too
+ window.onbeforeunload = M.util.report_form_dirty_state;
+ },
+
+ /**
+ * Unset the form dirty state and also set the form submitted flag to true
+ */
+ unset_changed : function(e) {
+ M.util.set_form_changed();
+ }
+ },
+ {
+ NAME : FORMSLIBNAME,
+ ATTRS : {
+ formid : {
+ 'value' : ''
+ }
+ }
+ }
+ );
+
+ M.core = M.core || {};
+ M.core.init_formslib = function(config) {
+ return new FORMSLIB(config);
+ }
+
+ },
+ '@VERSION@', {
+ requires : ['base']
+ }
+);
/**
* Definition of log events
*
- * @package mod
- * @subpackage assignment
+ * @package mod_assignment
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
echo $OUTPUT->box_start('generalbox boxaligncenter', 'intro');
echo format_module_intro('assignment', $this->assignment, $this->cm->id);
echo $OUTPUT->box_end();
- plagiarism_print_disclosure($this->cm->id);
+ echo plagiarism_print_disclosure($this->cm->id);
}
/**
echo '<div class="usersubmissions">';
//hook to allow plagiarism plugins to update status/print links.
- plagiarism_update_status($this->course, $this->cm);
+ echo plagiarism_update_status($this->course, $this->cm);
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
/**
* Definition of log events
*
- * @package mod
- * @subpackage chat
+ * @package mod_chat
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage choice
+ * @package mod_choice
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$html .= html_writer::start_tag('ul', array('class'=>'choices' ));
$availableoption = count($options['options']);
+ $choicecount = 0;
foreach ($options['options'] as $option) {
+ $choicecount++;
$html .= html_writer::start_tag('li', array('class'=>'option'));
$option->attributes->name = 'answer';
$option->attributes->type = 'radio';
+ $option->attributes->id = 'choice_'.$choicecount;
$labeltext = $option->text;
if (!empty($option->attributes->disabled)) {
}
$html .= html_writer::empty_tag('input', (array)$option->attributes);
- $html .= html_writer::tag('label', $labeltext, array('for'=>$option->attributes->name));
+ $html .= html_writer::tag('label', $labeltext, array('for'=>$option->attributes->id));
$html .= html_writer::end_tag('li');
}
$html .= html_writer::tag('li','', array('class'=>'clearfloat'));
/**
* Definition of log events
*
- * @package mod
- * @subpackage data
+ * @package mod_data
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$PAGE->set_title($data->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
+ $url = new moodle_url('/mod/data/export.php', array('d' => $d));
+ groups_print_activity_menu($cm, $url);
echo $OUTPUT->heading(format_string($data->name));
// these are for the tab display
}
}
-$exportdata = data_get_exportdata($data->id, $fields, $selectedfields);
+$currentgroup = groups_get_activity_group($cm);
+
+$exportdata = data_get_exportdata($data->id, $fields, $selectedfields, $currentgroup);
$count = count($exportdata);
switch ($formdata['exporttype']) {
case 'csv':
$fs->delete_area_files($this->context->id, 'mod_data', 'content', $content->id);
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
- $files = $fs->get_area_files($usercontext->id, 'user', 'draft', $value);
+ $files = $fs->get_area_files($usercontext->id, 'user', 'draft', $value, 'timecreated DESC');
if (count($files)<2) {
// no file
} else {
- $count = 0;
foreach ($files as $draftfile) {
- $file_record = array('contextid'=>$this->context->id, 'component'=>'mod_data', 'filearea'=>'content', 'itemid'=>$content->id, 'filepath'=>'/');
if (!$draftfile->is_directory()) {
- $file_record['filename'] = $draftfile->get_filename();
+ $file_record = array(
+ 'contextid' => $this->context->id,
+ 'component' => 'mod_data',
+ 'filearea' => 'content',
+ 'itemid' => $content->id,
+ 'filepath' => '/',
+ 'filename' => $draftfile->get_filename(),
+ );
- $content->content = $draftfile->get_filename();
+ $content->content = $file_record['filename'];
$fs->create_file_from_storedfile($file_record, $draftfile);
$DB->update_record('data_content', $content);
- if ($count > 0) {
- break;
- } else {
- $count++;
- }
+ // Break from the loop now to avoid overwriting the uploaded file record
+ break;
}
}
}
* @param int $dataid
* @param array $fields
* @param array $selectedfields
+ * @param int $currentgroup group ID of the current group. This is used for
+ * exporting data while maintaining group divisions.
* @return array
*/
-function data_get_exportdata($dataid, $fields, $selectedfields) {
+function data_get_exportdata($dataid, $fields, $selectedfields, $currentgroup=0) {
global $DB;
$exportdata = array();
$line = 1;
foreach($datarecords as $record) {
// get content indexed by fieldid
- if( $content = $DB->get_records('data_content', array('recordid'=>$record->id), 'fieldid', 'fieldid, content, content1, content2, content3, content4') ) {
+ if ($currentgroup) {
+ $select = 'SELECT c.fieldid, c.content, c.content1, c.content2, c.content3, c.content4 FROM {data_content} c, {data_records} r WHERE c.recordid = ? AND r.id = c.recordid AND r.groupid = ?';
+ $where = array($record->id, $currentgroup);
+ } else {
+ $select = 'SELECT fieldid, content, content1, content2, content3, content4 FROM {data_content} WHERE recordid = ?';
+ $where = array($record->id);
+ }
+
+ if( $content = $DB->get_records_sql($select, $where) ) {
foreach($fields as $field) {
$contents = '';
if(isset($content[$field->field->id])) {
$presetname = clean_filename($data->name) . '-preset-' . gmdate("Ymd_Hi");
$exportsubdir = "mod_data/presetexport/$presetname";
make_temp_directory($exportsubdir);
- $exportdir = "$CFG->dataroot/$exportsubdir";
+ $exportdir = "$CFG->tempdir/$exportsubdir";
// Assemble "preset.xml":
$presetxmldata = data_presets_generate_xml($course, $cm, $data);
/**
* Definition of log events
*
- * @package mod
- * @subpackage feedback
+ * @package mod_feedback
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage folder
+ * @package mod_folder
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage forum
+ * @package mod_forum
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$confirm = optional_param('confirm', false, PARAM_BOOL);
$PAGE->set_url('/mod/forum/unsubscribeall.php');
+$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
-require_login();
+// Do not autologin guest. Only proper users can have forum subscriptions.
+require_login(null, false);
$return = $CFG->wwwroot.'/';
/**
* Definition of log events
*
- * @package mod
- * @subpackage glossary
+ * @package mod_glossary
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage imscp
+ * @package mod_imscp
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage label
+ * @package mod_label
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage lesson
+ * @package mod_lesson
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* LTI web service endpoints
*
- * @package mod
- * @subpackage lti
+ * @package mod_lti
+ * @category log
* @copyright Copyright (c) 2011 Moodlerooms Inc. (http://www.moodlerooms.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Chris Scribner
* **New window** - The tool opens in a new window, occupying all the available space.
Depending on the browser, it will open in a new tab or a popup window.
It is possible that browsers will prevent the new window from opening.';
-$string['delegate'] = 'Delegate to Instructor';
+$string['delegate'] = 'Delegate to Teacher';
$string['delete'] = 'Delete';
$string['delete_confirmation'] = 'Are you sure you want to delete this external tool configuration?';
$string['deletetype'] = 'Delete external tool configuration';
$string['icon_url_help'] = 'The icon URL allows the icon that shows up in the course listing for this activity to be modified. Instead of using the default
LTI icon, an icon which conveys the type of activity may be specified.';
$string['id'] = 'id';
-$string['imsroleadmin'] = 'Instructor,Administrator';
-$string['imsroleinstructor'] = 'Instructor';
+$string['imsroleadmin'] = 'Teacher,Administrator';
+$string['imsroleinstructor'] = 'Teacher';
$string['imsrolelearner'] = 'Learner';
$string['invalidid'] = 'LTI ID was incorrect';
$string['launch_in_moodle'] = 'Launch tool in moodle';
course on this Moodle instance. If a consumer key and shared secret are entered, a trust relationship is established
between this Moodle instance and the remote tool, providing a secure communication channel.
* **Pending** - These tool providers came in through a package import, but have not been configured by an administrator.
- Instructors may still use tools from these providers if they have a consumer key and shared secret, or if none is required.
+ Teachers may still use tools from these providers if they have a consumer key and shared secret, or if none is required.
* **Rejected** - These tools providers are flagged as ones which an administrator has no intention of making available to the entire
- Moodle instance. Instructors may still use tools from these providers if they have a consumer key and shared secret, or if none is required.';
+ Moodle instance. Teachers may still use tools from these providers if they have a consumer key and shared secret, or if none is required.';
$string['miscellaneous'] = 'Miscellaneous';
$string['misconfiguredtools'] = 'Misconfigured tool instances were detected';
$string['missingparameterserror'] = 'The page is misconfigured: "{$a}"';
$string['show_in_course_help'] = 'If selected, this tool configuration will appear in the "External tool type" dropdown when instructors
configure external tools within courses.
-In most cases, this option does not need to be selected. Instructors can use this tool configuration
+In most cases, this option does not need to be selected. Teachers can use this tool configuration
based on the Launch URL matching the Tool base URL, which is the preferred method.
The only case in which this option should be selected is if the tool configuration is just intended for single sign on.
/**
* Definition of log events
*
- * @package mod
- * @subpackage page
+ * @package mod_page
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$DB->update_record('quiz_attempts', $this->attempt);
if (!$this->is_preview()) {
- quiz_save_best_grade($this->get_quiz());
+ quiz_save_best_grade($this->get_quiz(), $this->attempt->userid);
// Trigger event
$eventdata = new stdClass();
/**
* Definition of log events for the quiz module.
*
- * @package mod
- * @subpackage quiz
+ * @package mod_quiz
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/
function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool,
$quiz_qbanktool, $hasattempts, $defaultcategoryobj) {
- global $USER, $CFG, $DB, $OUTPUT;
+ global $CFG, $DB, $OUTPUT;
$strorder = get_string('order');
$strquestionname = get_string('questionname', 'quiz');
$strgrade = get_string('grade');
* the last value used +1.
*/
function quiz_print_grading_form($quiz, $pageurl, $tabindex) {
- global $USER, $OUTPUT;
+ global $OUTPUT;
$strsave = get_string('save', 'quiz');
echo '<form method="post" action="edit.php" class="quizsavegradesform"><div>';
echo '<fieldset class="invisiblefieldset" style="display: block;">';
*/
function mod_quiz_question_pluginfile($course, $context, $component,
$filearea, $qubaid, $slot, $args, $forcedownload) {
- global $USER, $CFG;
+ global $CFG;
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$attemptobj = quiz_attempt::create_from_usage_id($qubaid);
* @return bool Indicates success or failure.
*/
function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
- global $DB;
- global $USER, $OUTPUT;
+ global $DB, $OUTPUT, $USER;
if (empty($userid)) {
$userid = $USER->id;
*/
function quiz_send_notification($recipient, $submitter, $a) {
- global $USER;
-
// Recipient info for template
$a->useridnumber = $recipient->idnumber;
$a->username = fullname($recipient);
}
protected function definition() {
- global $CFG, $USER, $DB;
+ global $CFG, $DB;
$cm = $this->cm;
$mform = $this->_form;
// Initialize $PAGE, compute blocks
$PAGE->set_url('/mod/quiz/view.php', array('id' => $cm->id));
-$edit = optional_param('edit', -1, PARAM_BOOL);
-if ($edit != -1 && $PAGE->user_allowed_editing()) {
- $USER->editing = $edit;
-}
-
// Get this user's attempts.
$attempts = quiz_get_user_attempts($quiz->id, $USER->id, 'finished', true);
$lastfinishedattempt = end($attempts);
echo $OUTPUT->header();
-// Guests can't do a quiz, so offer them a choice of logging in or going back.
if (isguestuser()) {
- echo $output->view_page_guest($course, $quiz, $cm, $context, $infomessages, $viewobj);
+ // Guests can't do a quiz, so offer them a choice of logging in or going back.
+ echo $output->view_page_guest($course, $quiz, $cm, $context, $viewobj->infomessages);
} else if (!isguestuser() && !($canattempt || $canpreview
|| $viewobj->canreviewmine)) {
// If they are not enrolled in this course in a good enough role, tell them to enrol.
- echo $output->view_page_notenrolled($course, $quiz, $cm, $context, $infomessages, $viewobj);
+ echo $output->view_page_notenrolled($course, $quiz, $cm, $context, $viewobj->infomessages);
} else {
echo $output->view_page($course, $quiz, $cm, $context, $viewobj);
}
/**
* Definition of log events
*
- * @package mod
- * @subpackage resource
+ * @package mod_resource
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['printheading'] = 'Display resource name';
$string['printheadingexplain'] = 'Display resource name above content? Some display types may not display resource name even if enabled.';
$string['printintro'] = 'Display resource description';
-$string['printintroexplain'] = 'Display resource description bellow content? Some display types may not display description even if enabled.';
+$string['printintroexplain'] = 'Display resource description below content? Some display types may not display description even if enabled.';
$string['resourcecontent'] = 'Files and subfolders';
$string['resourcedetails_sizetype'] = '{$a->size} {$a->type}';
$string['resource:exportresource'] = 'Export resource';
/**
* Definition of log events
*
- * @package mod
- * @subpackage scorm
+ * @package mod_scorm
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage survey
+ * @package mod_survey
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Definition of log events
*
- * @package mod
- * @subpackage url
+ * @package mod_url
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['printheading'] = 'Display URL name';
$string['printheadingexplain'] = 'Display URL name above content? Some display types may not display URL name even if enabled.';
$string['printintro'] = 'Display URL description';
-$string['printintroexplain'] = 'Display URL description bellow content? Some display types may not display description even if enabled.';
+$string['printintroexplain'] = 'Display URL description below content? Some display types may not display description even if enabled.';
$string['rolesinparams'] = 'Include role names in parameters';
$string['serverurl'] = 'Server URL';
$string['url:view'] = 'View URL';
echo $OUTPUT->container_end();
echo $OUTPUT->container_start('mdl-align');
- echo '<form method="post" id="wikiform" action="' . $action . '">';
+ echo '<form method="post" id="mform1" action="' . $action . '">';
echo $OUTPUT->container(print_textarea(false, 20, 60, 0, 0, "newcontent", $content, 0, true), false, 'wiki_editor');
echo $OUTPUT->container_start();
wiki_print_edit_form_default_fields($editor, $pageid, $version, $upload, $deleteuploads);
$string['navigationfrom'] = 'This page comes from';
$string['navigationfrom_help'] = 'The wiki pages linking to this page';
$string['navigationto'] = 'This page goes to';
-$string['navigationto_help'] = 'The links that included in this page';
+$string['navigationto_help'] = 'Links to other pages';
$string['newpage'] = 'New';
$string['newpagetitle'] = 'New page title';
$string['noattachments'] = '<strong>No files attached</strong>';
/**
* Definition of log events
*
- * @package mod
- * @subpackage workshop
+ * @package mod_workshop
+ * @category log
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['err_invalidhost'] = 'Invalid MNet host';
$string['err_invalidhost_help'] = 'This plugin is misconfigured to point to an invalid (or deleted) MNet host. This plugin relies on Moodle Networking peers with SSO IDP published, SSO_SP subscribed, and portfolio subscribed <b>and</b> published.';
$string['err_networkingoff'] = 'MNet is off';
-$string['err_networkingoff_help'] = 'MNet is off entirely. Please enable it before trying to configure this pugin. Any instances of this plugin have been set to not visible until this is fixed - you will need to set them to visible again manully. They cannot be used until this happens';
+$string['err_networkingoff_help'] = 'MNet is off entirely. Please enable it before trying to configure this plugin. Any instances of this plugin have been set to not visible until this is fixed - you will need to set them to visible again manully. They cannot be used until this happens';
$string['err_nomnetauth'] = 'The MNet authentication plugin is disabled';
$string['err_nomnetauth_help'] = 'The MNet authentication plugin is disabled, but is required for this service';
$string['err_nomnethosts'] = 'Relies on MNet';
$quizattemptsrs = $DB->get_recordset_select('quiz_attempts', $where, $params, 'uniqueid');
$questionsessionsrs = $DB->get_recordset_sql("
- SELECT *
- FROM {question_sessions}
- WHERE attemptid IN (
- SELECT uniqueid FROM {quiz_attempts} WHERE $where)
- ORDER BY attemptid, questionid
+ SELECT s.*
+ FROM {question_sessions} s
+ JOIN {quiz_attempts} a ON (attemptid = uniqueid)
+ WHERE $where
+ ORDER BY attemptid, questionid
", $params);
$questionsstatesrs = $DB->get_recordset_sql("
- SELECT *
- FROM {question_states}
- WHERE attempt IN (
- SELECT uniqueid FROM {quiz_attempts} WHERE $where)
- ORDER BY attempt, question, seq_number, id
+ SELECT s.*
+ FROM {question_states} s
+ JOIN {quiz_attempts} ON (s.attempt = uniqueid)
+ WHERE $where
+ ORDER BY s.attempt, question, seq_number, s.id
", $params);
$datatodo = $quizattemptsrs && $questionsessionsrs && $questionsstatesrs;
/**
* Capabilities
*
- * @package report
- * @subpackage log
+ * Defines capablities related to logs
+ *
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Post installation and migration code.
*
- * @package report
- * @subpackage log
+ * Contains code that are run during the installation of report/logs
+ *
+ * @package report_log
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
+/**
+ * Contains codes to be run during installation of report/logs
+ *
+ * @global moodle_database $DB
+ * @return void
+ */
function xmldb_report_log_install() {
global $DB;
/**
* Produces a graph of log accesses for a user
*
- * @package report
- * @subpackage log
+ * Generates an image representing the log data in a graphical manner for a user.
+ *
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Displays different views of the logs.
*
- * @package report
- * @subpackage log
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Lang strings.
*
- * @package report
- * @subpackage log
+ * Language strings to be used by report/logs
+ *
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Public API of the log report.
*
- * @package report
- * @subpackage log
+ * Defines the APIs used by log reports
+ *
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Is current user allowed to access this report
*
- * @private defined in lib.php for performance reasons
- *
+ * @access private defined in lib.php for performance reasons
+ * @global stdClass $USER
* @param stdClass $user
* @param stdClass $course
* @return array with two elements $all, $today
/**
* Return a list of page types
+ *
* @param string $pagetype current page type
* @param stdClass $parentcontext Block's parent context
* @param stdClass $currentcontext Current context of block
- * @return array
+ * @return array a list of page types
*/
function report_log_page_type_list($pagetype, $parentcontext, $currentcontext) {
$array = array(
'report-log-user' => get_string('page-report-log-user', 'report_log')
);
return $array;
-}
\ No newline at end of file
+}
/**
* This file contains functions used by the log reports
*
- * @package report
- * @subpackage log
+ * This files lists the functions that are used during the log report generation.
+ *
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__).'/lib.php');
+/**
+ * This function is used to generate and display the log activity graph
+ *
+ * @global stdClass $CFG
+ * @param stdClass $course course instance
+ * @param int $userid id of the user whose logs are needed
+ * @param string $type type of logs graph needed (usercourse.png/userday.png)
+ * @param int $date timestamp in GMT (seconds since epoch)
+ * @return void
+ */
function report_log_print_graph($course, $userid, $type, $date=0) {
global $CFG;
'&user='.$userid.'&type='.$type.'&date='.$date.'" alt="" />';
}
}
-
+/**
+ * This function is used to generate and display Mnet selector form
+ *
+ * @global stdClass $USER
+ * @global stdClass $CFG
+ * @global stdClass $SITE
+ * @global moodle_database $DB
+ * @global core_renderer $OUTPUT
+ * @global stdClass $SESSION
+ * @uses CONTEXT_SYSTEM
+ * @uses COURSE_MAX_COURSES_PER_DROPDOWN
+ * @uses CONTEXT_COURSE
+ * @uses SEPARATEGROUPS
+ * @param int $hostid host id
+ * @param stdClass $course course instance
+ * @param int $selecteduser id of the selected user
+ * @param string $selecteddate Date selected
+ * @param string $modname course_module->id
+ * @param string $modid number or 'site_errors'
+ * @param string $modaction an action as recorded in the logs
+ * @param int $selectedgroup Group to display
+ * @param int $showcourses whether to show courses if we're over our limit.
+ * @param int $showusers whether to show users if we're over our limit.
+ * @param string $logformat Format of the logs (downloadascsv, showashtml, downloadasods, downloadasexcel)
+ * @return void
+ */
function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0, $selecteddate='today',
$modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
echo '</div>';
echo '</form>';
}
-
+/**
+ * This function is used to generate and display selector form
+ *
+ * @global stdClass $USER
+ * @global stdClass $CFG
+ * @global moodle_database $DB
+ * @global core_renderer $OUTPUT
+ * @global stdClass $SESSION
+ * @uses CONTEXT_SYSTEM
+ * @uses COURSE_MAX_COURSES_PER_DROPDOWN
+ * @uses CONTEXT_COURSE
+ * @uses SEPARATEGROUPS
+ * @param stdClass $course course instance
+ * @param int $selecteduser id of the selected user
+ * @param string $selecteddate Date selected
+ * @param string $modname course_module->id
+ * @param string $modid number or 'site_errors'
+ * @param string $modaction an action as recorded in the logs
+ * @param int $selectedgroup Group to display
+ * @param int $showcourses whether to show courses if we're over our limit.
+ * @param int $showusers whether to show users if we're over our limit.
+ * @param string $logformat Format of the logs (downloadascsv, showashtml, downloadasods, downloadasexcel)
+ * @return void
+ */
function report_log_print_selector_form($course, $selecteduser=0, $selecteddate='today',
$modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
echo '<input type="submit" value="'.get_string('gettheselogs').'" />';
echo '</div>';
echo '</form>';
-}
\ No newline at end of file
+}
/**
* Links and settings
*
- * @package report
- * @subpackage log
+ * Contains settings used by logs report.
+ *
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Display user activity reports for a course (totals)
*
- * @package report
- * @subpackage log
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Version info
*
- * @package report
- * @subpackage log
+ * This File contains information about the current version of report/logs
+ *
+ * @package report_log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Capabilities
*
- * @package report
- * @subpackage loglive
+ * This files lists capabilites related to report_logline
+ *
+ * @package report_loglive
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Displays live view of recent logs
*
- * @package report
- * @subpackage loglive
+ * This file generates live view of recent logs.
+ *
+ * @package report_loglive
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Lang strings.
*
- * @package report
- * @subpackage loglive
+ * Language strings used by report_loglive
+ *
+ * @package report_loglive
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*
* NOTE: page type not included because there can not be any blocks in popups
*
- * @package report
- * @subpackage loglive
+ * @package report_loglive
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* This function extends the navigation with the report items
*
+ * @global stdClass $CFG
+ * @global core_renderer $OUTPUT
* @param navigation_node $navigation The navigation node to extend
- * @param stdClass $course The course to object for the report
- * @param stdClass $context The context of the course
+ * @param stdClass $course The course to object for the report
+ * @param stdClass $context The context of the course
*/
function report_loglive_extend_navigation_course($navigation, $course, $context) {
global $CFG, $OUTPUT;
/**
* Links and settings
*
- * @package report
- * @subpackage loglive
+ * This file contains links and settings used by report_loglive
+ *
+ * @package report_loglive
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Version info
*
- * @package report
- * @subpackage loglive
+ * This file contains version information about report_loglive
+ *
+ * @package report_loglive
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
}
$roleid = 0;
- krsort($roles); // the same sorting as in table bellow graph
+ krsort($roles); // the same sorting as in table below graph
$colors = array('green', 'blue', 'red', 'purple', 'yellow', 'olive', 'navy', 'maroon', 'gray', 'ltred', 'ltltred', 'ltgreen', 'ltltgreen', 'orange', 'ltorange', 'ltltorange', 'lime', 'ltblue', 'ltltblue', 'fuchsia', 'aqua', 'grayF0', 'grayEE', 'grayDD', 'grayCC', 'gray33', 'gray66', 'gray99');
$colorindex = 0;
<?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/>.
+
+
/**
* coursetags_add.php
- * @author j.beedell@open.ac.uk June07
+ *
+ * @package core_tag
+ * @category tag
+ * @copyright 2007 j.beedell@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../config.php');
<?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/>.
+
/**
- * coursetags_edit.php
- * displays personal tags for a course with some editing facilites
- * @author j.beedell@open.ac.uk June07
+ * Displays personal tags for a course with some editing facilites
+ *
+ * @package core_tag
+ * @category tag
+ * @copyright 2007 j.beedell@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../config.php');
<?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/>.
+
+
/**
- * coursetags_more.php
- * a full display of tags allowing some filtering and reordering
- * @author j.beedell@open.ac.uk June07
+ * A full display of tags allowing some filtering and reordering
+ *
+ * @package core_tag
+ * @category tag
+ * @copyright 2007 j.beedell@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../config.php');
<?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/>.
+
+
/**
* coursetagslib.php
- * @author j.beedell@open.ac.uk July07
+ *
+ * @package core_tag
+ * @copyright 2007 j.beedell@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once $CFG->dirroot.'/tag/lib.php';
* Returns an ordered array of tags associated with visible courses
* (boosted replacement of get_all_tags() allowing association with user and tagtype).
*
- * @uses $CFG
- * @param int $courseid, a 0 will return all distinct tags for visible courses
- * @param int $userid optional the user id, a default of 0 will return all users tags for the course
- * @param string $tagtype optional 'official' or 'default', empty returns both tag types
- * @param int $numtags optional number of tags to display, default of 80 is set in the block, 0 returns all
- * @param string $sort optional selected sorting, default is alpha sort (name) also timemodified or popularity
- * @return array
+ * @package core_tag
+ * @category tag
+ * @param int $courseid A course id. Passing 0 will return all distinct tags for all visible courses
+ * @param int $userid (optional) the user id, a default of 0 will return all users tags for the course
+ * @param string $tagtype (optional) The type of tag, empty string returns all types. Currently (Moodle 2.2) there are two
+ * types of tags which are used within Moodle, they are 'official' and 'default'.
+ * @param int $numtags (optional) number of tags to display, default of 80 is set in the block, 0 returns all
+ * @param string $sort (optional) selected sorting, default is alpha sort (name) also timemodified or popularity
+ * @return array
*/
function coursetag_get_tags($courseid, $userid=0, $tagtype='', $numtags=0, $sort='name') {
* Returns an ordered array of tags
* (replaces popular_tags_count() allowing sorting).
*
- * @uses $CFG
- * @param string $sort optional selected sorting, default is alpha sort (name) also timemodified or popularity
- * @param int $numtags optional number of tags to display, default of 20 is set in the block, 0 returns all
- * @return array
+ * @package core_tag
+ * @category tag
+ * @param string $sort (optional) selected sorting, default is alpha sort (name) also timemodified or popularity
+ * @param int $numtags (optional) number of tags to display, default of 20 is set in the block, 0 returns all
+ * @return array
*/
function coursetag_get_all_tags($sort='name', $numtags=0) {
}
/**
- * Callback function for coursetag_get_tags() and coursetag_get_all_tags() only
- * @uses $CFG
+ * Sorting callback function for coursetag_get_tags() and coursetag_get_all_tags() only
+ *
+ * This function does a comparision on a field withing two variables, $a and $b. The field used is specified by
+ * $CFG->tagsort or we just use the 'name' field if $CFG->tagsort is empty. The comparison works as follows:
+ * If $a->$tagsort is greater than $b->$tagsort, 1 is returned.
+ * If $a->$tagsort is equal to $b->$tagsort, 0 is returned.
+ * If $a->$tagsort is less than $b->$tagsort, -1 is returned.
+ *
+ * Also if $a->$tagsort is not numeric or a string, 0 is returned.
+ *
+ * @package core_tag
+ * @access private
+ * @param int|string|mixed $a Variable to compare against $b
+ * @param int|string|mixed $b Variable to compare against $a
+ * @return int The result of the comparison/validation 1, 0 or -1
*/
function coursetag_sort($a, $b) {
// originally from block_blog_tags
/**
* Prints a tag cloud
*
- * @param array $tagcloud array of tag objects (fields: id, name, rawname, count and flag)
- * @param int $max_size maximum text size, in percentage
- * @param int $min_size minimum text size, in percentage
- * @param $return if true return html string
+ * @package core_tag
+ * @category tag
+ * @param array $tagcloud array of tag objects (fields: id, name, rawname, count and flag)
+ * @param mixed $return if true return html string
+ * @param int $max_size maximum text size, in percentage
+ * @param int $min_size minimum text size, in percentage
*/
function coursetag_print_cloud($tagcloud, $return=false, $max_size=180, $min_size=80) {
/**
* Returns javascript for use in tags block and supporting pages
- * @param string $coursetagdivs comma separated divs ids
- * @uses $CFG
+ *
+ * @package core_tag
+ * @category tag
+ * @param string $coursetagdivs comma separated divs ids
+ * @return null
*/
function coursetag_get_jscript($coursetagdivs = '') {
global $CFG, $DB, $PAGE;
/**
* Returns javascript to create the links in the tag block footer.
+ *
+ * @package core_tag
+ * @category tag
+ * @param string $elementid the element to attach the footer to
+ * @param array $coursetagslinks links arrays each consisting of 'title', 'onclick' and 'text' elements
+ * @return string always returns a blank string
*/
function coursetag_get_jscript_links($elementid, $coursetagslinks) {
global $PAGE;
/**
* Returns all tags created by a user for a course
*
- * @uses $CFG
- * @param int $courseid
- * @param int $userid
+ * @package core_tag
+ * @category tag
+ * @param int $courseid tags are returned for the course that has this courseid
+ * @param int $userid return tags which were created by this user
*/
function coursetag_get_records($courseid, $userid) {
-
global $CFG, $DB;
$sql = "SELECT t.id, name, rawname
/**
* Stores a tag for a course for a user
*
- * @uses $CFG
- * @param array $tags simple array of keywords to be stored
- * @param integer $courseid
- * @param integer $userid
- * @param string $tagtype official or default only
- * @param string $myurl optional for logging creation of course tags
+ * @package core_tag
+ * @category tag
+ * @param array $tags simple array of keywords to be stored
+ * @param int $courseid the id of the course we wish to store a tag for
+ * @param int $userid the id of the user we wish to store a tag for
+ * @param string $tagtype official or default only
+ * @param string $myurl (optional) for logging creation of course tags
*/
function coursetag_store_keywords($tags, $courseid, $userid=0, $tagtype='official', $myurl='') {
/**
* Deletes a personal tag for a user for a course.
*
- * @uses $CFG
- * @param int $tagid
- * @param int $userid
- * @param int $courseid
- */
+ * @package core_tag
+ * @category tag
+ * @param int $tagid the tag we wish to delete
+ * @param int $userid the user that the tag is associated with
+ * @param int $courseid the course that the tag is associated with
+ */
function coursetag_delete_keyword($tagid, $userid, $courseid) {
global $CFG, $DB;
/**
* Get courses tagged with a tag
*
+ * @package core_tag
+ * @category tag
* @param int $tagid
* @return array of course objects
*/
function coursetag_get_tagged_courses($tagid) {
-
global $DB;
$courses = array();
}
/**
- * Course tagging function used only during the deletion of a
- * course (called by lib/moodlelib.php) to clean up associated tags
+ * Course tagging function used only during the deletion of a course (called by lib/moodlelib.php) to clean up associated tags
*
- * @param int $courseid
- * @param bool $showfeedback
+ * @package core_tag
+ * @param int $courseid the course we wish to delete tag instances from
+ * @param bool $showfeedback if we should output a notification of the delete to the end user
*/
function coursetag_delete_course_tags($courseid, $showfeedback=false) {
-
global $DB, $OUTPUT;
if ($tags = $DB->get_records_select('tag_instance', "itemtype='course' AND itemid=:courseid", array('courseid'=>$courseid))) {
}
}
-/**
+/*
* Function called by cron to create/update users rss feeds
*
- * @uses $CFG
* @return true
*
* Function removed.
}
*/
-/**
+/*
* Get official keywords for the <meta name="keywords"> in header.html
* use: echo '<meta name="keywords" content="'.coursetag_get_official_keywords($COURSE->id).'"/>';
- * @uses $CFG
+ *
* @param int $courseid
* @return string
*
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
- * @package core
- * @subpackage tag
+ * @package core_tag
+ * @category tag
* @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
- * @package core
- * @subpackage tag
+ * @package core_tag
+ * @category tag
* @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot.'/lib/formslib.php');
+/**
+ * Defines the form for editing tags
+ *
+ * @package core_tag
+ * @category tag
+ * @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class tag_edit_form extends moodleform {
+ /**
+ * Overrides the abstract moodleform::definition method for defining what the form that is to be
+ * presented to the user.
+ */
function definition () {
$mform =& $this->_form;
}
-}
+}
\ No newline at end of file
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
- * @package core
- * @subpackage tag
+ * @package core_tag
+ * @category tag
* @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
} else if ($tagid) {
$tag = tag_get('id', $tagid, '*');
}
-
+unset($tagid);
if (empty($tag)) {
redirect($CFG->wwwroot.'/tag/search.php');
}
$button = '';
if ($PAGE->user_allowed_editing() ) {
- $button = $OUTPUT->edit_button(new moodle_url("$CFG->wwwroot/tag/index.php", array('id' => $tagid)));
+ $button = $OUTPUT->edit_button(new moodle_url("$CFG->wwwroot/tag/index.php", array('id' => $tag->id)));
}
$PAGE->navbar->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'));
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* Moodle tag library
*
- * Tag strings : you can use any character in tags, except the comma (which is
- * the separator) and the '\' (backslash). Note that many spaces (or other
- * blank characters) will get "compressed" into one. A tag string is always a
- * rawurlencode'd string. This is the same behavior as http://del.icio.us.
- *
- * A "record" is a php array (note that an object will work too) that contains
- * the following variables :
- * - type: the table containing the record that we are tagging (eg: for a
- * blog, this is table 'post', and for a user it is 'user')
- * - id: the id of the record
+ * Tag strings : you can use any character in tags, except the comma (which is the separator) and
+ * the '\' (backslash). Note that many spaces (or other blank characters) will get "compressed"
+ * into one. A tag string is always a rawurlencode'd string. This is the same behavior as
+ * http://del.icio.us.
*
- * TODO: turn this into a full-fledged categorization system. This could start
- * by modifying (removing, probably) the 'tag type' to use another table
- * describing the relationship between tags (parents, sibling, etc.), which
- * could then be merged with the 'course categorization' system...
+ * A "record" is a php array (note that an object will work too) that contains the following
+ * variables :
+ * - type: The database table containing the record that we are tagging (eg: for a blog, this is
+ * the table named 'post', and for a user it is the table name 'user')
+ * - id: The id of the record
*
* BASIC INSTRUCTIONS :
* - to "tag a blog post" (for example):