Merge branch 'wip-MDL-30709-master' of git://github.com/marinaglancy/moodle
authorSam Hemelryk <sam@moodle.com>
Tue, 14 Feb 2012 04:14:05 +0000 (17:14 +1300)
committerSam Hemelryk <sam@moodle.com>
Tue, 14 Feb 2012 04:14:05 +0000 (17:14 +1300)
120 files changed:
admin/cli/install.php
admin/settings.php
admin/tool/dbtransfer/locallib.php
admin/tool/uploaduser/index.php
admin/webservice/forms.php
admin/webservice/service_functions.php
admin/webservice/service_users.php
blog/index.php
blog/lib.php
calendar/lib.php
course/renderer.php
enrol/category/db/access.php
filter/data/filter.php
filter/mediaplugin/filter.php
grade/export/grade_export_form.php
grade/grading/form/lib.php
grade/grading/form/rubric/lang/en/gradingform_rubric.php
grade/grading/form/rubric/lib.php
grade/grading/form/rubric/preview.php [new file with mode: 0644]
grade/grading/form/rubric/renderer.php
grade/grading/lib.php
grade/report/grader/lib.php
grade/report/overview/lib.php
index.php
lang/en/currencies.php
lang/en/form.php
lang/en/moodle.php
lib/accesslib.php
lib/adminlib.php
lib/completion/completion_criteria_date.php
lib/datalib.php
lib/db/log.php
lib/ddl/database_manager.php
lib/ddl/mssql_sql_generator.php
lib/ddl/mysql_sql_generator.php
lib/ddl/oracle_sql_generator.php
lib/ddl/postgres_sql_generator.php
lib/ddl/sql_generator.php
lib/ddl/sqlite_sql_generator.php
lib/form/filemanager.js
lib/formslib.php
lib/htmlpurifier/HTMLPurifier/Lexer/PH5P.php
lib/javascript-static.js
lib/moodlelib.php
lib/navigationlib.php
lib/pear/HTML/QuickForm/checkbox.php
lib/plagiarismlib.php
lib/simpletest/testmoodlelib.php
lib/textlib.class.php
lib/yui/formslib/formslib.js [new file with mode: 0644]
mod/assignment/db/log.php
mod/assignment/lib.php
mod/chat/db/log.php
mod/choice/db/log.php
mod/choice/renderer.php
mod/data/db/log.php
mod/data/export.php
mod/data/field/file/field.class.php
mod/data/lib.php
mod/feedback/db/log.php
mod/folder/db/log.php
mod/forum/db/log.php
mod/forum/unsubscribeall.php
mod/glossary/db/log.php
mod/imscp/db/log.php
mod/label/db/log.php
mod/lesson/db/log.php
mod/lti/db/log.php
mod/lti/lang/en/lti.php
mod/page/db/log.php
mod/quiz/attemptlib.php
mod/quiz/db/log.php
mod/quiz/editlib.php
mod/quiz/lib.php
mod/quiz/locallib.php
mod/quiz/override_form.php
mod/quiz/view.php
mod/resource/db/log.php
mod/resource/lang/en/resource.php
mod/scorm/db/log.php
mod/survey/db/log.php
mod/url/db/log.php
mod/url/lang/en/url.php
mod/wiki/editors/wiki_editor.php
mod/wiki/lang/en/wiki.php
mod/workshop/db/log.php
portfolio/mahara/lang/en/portfolio_mahara.php
question/engine/upgrade/upgradelib.php
report/log/db/access.php
report/log/db/install.php
report/log/graph.php
report/log/index.php
report/log/lang/en/report_log.php
report/log/lib.php
report/log/locallib.php
report/log/settings.php
report/log/user.php
report/log/version.php
report/loglive/db/access.php
report/loglive/index.php
report/loglive/lang/en/report_loglive.php
report/loglive/lib.php
report/loglive/settings.php
report/loglive/version.php
report/stats/graph.php
tag/coursetags_add.php
tag/coursetags_edit.php
tag/coursetags_more.php
tag/coursetagslib.php
tag/edit.php
tag/edit_form.php
tag/index.php
tag/lib.php
tag/locallib.php
tag/user.php
theme/formal_white/layout/report.php
theme/styles.php
user/view.php
version.php
webservice/rest/simpleserver.php

index b812aaf..dc65e31 100644 (file)
@@ -109,7 +109,7 @@ if (file_exists($configfile)) {
 
 $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.
index 3344f35..3f8d2c9 100644 (file)
@@ -131,6 +131,12 @@ if (empty($SITE->fullname)) {
     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();
index 62a34ae..f36ceef 100644 (file)
@@ -37,7 +37,7 @@ TODO:
     (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)
 
 */
 
index a0a69b0..633b5f2 100644 (file)
@@ -239,7 +239,7 @@ if ($formdata = $mform2->is_cancelled()) {
             }
         }
         if (!isset($user->username)) {
-            // prevent warnings bellow
+            // prevent warnings below
             $user->username = '';
         }
 
index dab9a42..5185b9b 100644 (file)
@@ -160,7 +160,7 @@ class external_service_functions_form extends moodleform {
             $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');
index d4f7da8..fc0e886 100644 (file)
@@ -67,7 +67,7 @@ switch ($action) {
             //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
index 9d62218..12db2b0 100644 (file)
@@ -98,7 +98,7 @@ $usersmissingcaps = $webservicemanager->get_missing_capabilities_by_users($allow
 //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]);
     }
 }
 
index e1c0c22..8d28dbc 100644 (file)
@@ -197,20 +197,18 @@ if (!empty($userid)) {
 
 $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;
index 991069c..5a92fb5 100644 (file)
@@ -314,7 +314,7 @@ function blog_get_context_url($context=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 = '';
index 046c0a9..e4e76cd 100644 (file)
 <?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');
@@ -95,13 +129,12 @@ function calendar_get_starting_weekday() {
 /**
  * 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;
@@ -375,13 +408,15 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
 }
 
 /**
- * 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;
@@ -407,6 +442,17 @@ function calendar_get_popup($is_today, $event_timestart, $popupcontent='') {
     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;
 
@@ -512,6 +558,12 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
     return $output;
 }
 
+/**
+ * Add calendar event metadata
+ *
+ * @param stdClass $event event info
+ * @return stdClass $event metadata
+ */
 function calendar_add_event_metadata($event) {
     global $CFG, $OUTPUT;
 
@@ -571,7 +623,9 @@ function calendar_add_event_metadata($event) {
 /**
  * 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;
@@ -585,15 +639,16 @@ function calendar_print_event($event, $showactions=true) {
 
 /**
  * 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;
@@ -684,6 +739,13 @@ function calendar_get_events($tstart, $tend, $users, $groups, $courses, $withdur
     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 = '';
@@ -835,6 +897,14 @@ function calendar_top_controls($type, $data) {
     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;
 
@@ -897,6 +967,14 @@ function calendar_filter_controls(moodle_url $returnurl) {
     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;
@@ -941,6 +1019,12 @@ function calendar_day_representation($tstamp, $now = false, $usecommonwords = tr
     }
 }
 
+/**
+ * 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) {
@@ -958,10 +1042,10 @@ function calendar_time_representation($time) {
  * 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)) {
@@ -985,14 +1069,15 @@ function calendar_get_link_href($linkbase, $d, $m, $y) {
 /**
  * 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) {
@@ -1008,7 +1093,9 @@ 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.
  */
@@ -1025,7 +1112,9 @@ function calendar_get_link_previous($text, $linkbase, $d, $m, $y, $accesshide=fa
  *
  * @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.
  */
@@ -1037,14 +1126,34 @@ function calendar_get_link_next($text, $linkbase, $d, $m, $y, $accesshide=false)
     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);
@@ -1080,6 +1189,16 @@ function calendar_get_block_upcoming($events, $linkhref = NULL) {
     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);
@@ -1089,6 +1208,15 @@ function calendar_add_month($month, $year) {
     }
 }
 
+/**
+ * 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);
@@ -1098,6 +1226,18 @@ function calendar_sub_month($month, $year) {
     }
 }
 
+/**
+ * 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();
@@ -1184,6 +1324,14 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
     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);
 
@@ -1194,6 +1342,13 @@ function calendar_get_module_cached(&$coursecache, $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;
 
@@ -1210,9 +1365,8 @@ function calendar_get_course_cached(&$coursecache, $courseid) {
 /**
  * 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) {
@@ -1292,6 +1446,12 @@ 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;
 
@@ -1338,8 +1498,7 @@ function calendar_edit_event_allowed($event) {
  * 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;
@@ -1367,6 +1526,12 @@ function calendar_get_default_courses() {
     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;
 
@@ -1378,6 +1543,16 @@ function calendar_preferences_button(stdClass $course) {
     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);
@@ -1467,6 +1642,12 @@ function calendar_format_event_time($event, $now, $linkparams = null, $usecommon
     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++) {
@@ -1498,13 +1679,14 @@ function calendar_show_event_type($type, $user = null) {
 
 /**
  * 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);
@@ -1538,6 +1720,12 @@ function calendar_set_event_type_display($type, $display = null, $user = null) {
     }
 }
 
+/**
+ * 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();
@@ -1569,9 +1757,11 @@ function calendar_get_allowed_types(&$allowed, $course = null) {
 }
 
 /**
- * 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()) {
@@ -1584,8 +1774,8 @@ function calendar_user_can_add_event($course) {
 /**
  * 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;
@@ -1630,13 +1820,18 @@ function calendar_add_event_allowed($event) {
 }
 
 /**
- * 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
@@ -1658,32 +1853,22 @@ function calendar_add_event_allowed($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;
 
     /**
@@ -1746,8 +1931,8 @@ class calendar_event {
      * 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)) {
@@ -1762,8 +1947,8 @@ class calendar_event {
      * 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)) {
@@ -1779,8 +1964,8 @@ class calendar_event {
      * 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});
@@ -1793,7 +1978,8 @@ class calendar_event {
      * 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;
@@ -1822,7 +2008,8 @@ class calendar_event {
     /**
      * 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;
@@ -1832,7 +2019,7 @@ class calendar_event {
      * Returns an event description: Called by __get
      * Please use $blah = $event->description;
      *
-     * @return string
+     * @return string event description
      */
     protected function get_description() {
         global $CFG;
@@ -1871,7 +2058,7 @@ class calendar_event {
     /**
      * 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;
@@ -1892,8 +2079,9 @@ class calendar_event {
      * @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;
@@ -2072,8 +2260,8 @@ class calendar_event {
      *
      * @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;
@@ -2212,6 +2400,7 @@ class calendar_event {
      * @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;
@@ -2241,11 +2430,9 @@ class calendar_event {
      * 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;
@@ -2275,8 +2462,8 @@ class calendar_event {
      * 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;
@@ -2316,51 +2503,40 @@ class calendar_event {
  *
  * 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) {
 
@@ -2384,10 +2560,11 @@ class calendar_information {
     }
 
     /**
+     * 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;
@@ -2402,8 +2579,9 @@ class calendar_information {
      * 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)) {
@@ -2421,14 +2599,16 @@ class calendar_information {
     }
     /**
      * 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);
@@ -2437,8 +2617,8 @@ class calendar_information {
      * 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) {
index 3e9898c..1e1d7ad 100644 (file)
@@ -92,8 +92,8 @@ class core_course_renderer extends plugin_renderer_base {
      */
     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';
index d18e55a..8c24b96 100644 (file)
@@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die();
 
 $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',
index 60ca85f..451c1d9 100644 (file)
@@ -71,7 +71,7 @@ class filter_data extends moodle_text_filter {
                       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;
index e1e61ca..cb4a751 100644 (file)
@@ -74,7 +74,7 @@ class filter_mediaplugin extends moodle_text_filter {
             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;
         }
@@ -281,7 +281,7 @@ function filter_mediaplugin_html5audio_callback(array $link) {
         $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') {
@@ -379,7 +379,7 @@ function filter_mediaplugin_html5video_callback(array $link) {
         }
 
         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') {
index 540694c..bd6e396 100644 (file)
@@ -115,7 +115,14 @@ class grade_export_form extends moodleform {
 
         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.']');
@@ -124,7 +131,7 @@ class grade_export_form extends moodleform {
                     $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
index 3634d37..5a27b8f 100644 (file)
@@ -202,6 +202,19 @@ abstract class gradingform_controller {
         // 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
      *
index d7f605c..527e8fb 100644 (file)
@@ -25,6 +25,7 @@
 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?';
@@ -42,11 +43,13 @@ $string['err_nodefinition'] = 'Level definition can not be empty';
 $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';
index ff24e85..98aeaf9 100644 (file)
@@ -37,8 +37,10 @@ class gradingform_rubric_controller extends gradingform_controller {
     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 */
@@ -64,6 +66,27 @@ class gradingform_rubric_controller extends gradingform_controller {
             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
      *
@@ -330,14 +353,14 @@ class gradingform_rubric_controller extends gradingform_controller {
     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;
     }
 
@@ -484,8 +507,13 @@ class gradingform_rubric_controller extends gradingform_controller {
         $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;
     }
@@ -812,6 +840,9 @@ class gradingform_rubric_instance extends gradingform_instance {
         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;
     }
diff --git a/grade/grading/form/rubric/preview.php b/grade/grading/form/rubric/preview.php
new file mode 100644 (file)
index 0000000..1a71458
--- /dev/null
@@ -0,0 +1,56 @@
+<?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();
index f037263..9469e94 100644 (file)
@@ -191,7 +191,7 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
         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) {
@@ -241,6 +241,7 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
             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;
@@ -277,7 +278,7 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
         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'));
@@ -431,10 +432,17 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
         $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) {
index e27a4ec..c6e8186 100644 (file)
@@ -454,6 +454,27 @@ class grading_manager {
         }
     }
 
+    /**
+     * 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
      *
index bcacf6d..7c9fb38 100644 (file)
@@ -163,7 +163,7 @@ class grade_report_grader extends grade_report {
             $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]);
index cf8b757..b610817 100644 (file)
@@ -119,7 +119,14 @@ class grade_report_overview extends grade_report {
                 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);
index 232abdc..99bae5f 100644 (file)
--- a/index.php
+++ b/index.php
 
     $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
index 1e0245c..eb032e8 100644 (file)
  */
 
 $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';
@@ -88,79 +92,94 @@ $string['ISK'] = 'Iceland Krona';
 $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';
index b42376e..fbd8c9d 100644 (file)
@@ -55,7 +55,7 @@ $string['security'] = 'Security';
 $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';
index 0286c52..eb14f76 100644 (file)
@@ -219,6 +219,7 @@ $string['categoryname'] = 'Category name';
 $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';
@@ -1772,9 +1773,7 @@ $string['withoutuserdata'] = 'without user data';
 $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';
index 9ca574d..29aac48 100644 (file)
@@ -7208,7 +7208,7 @@ function get_role_context_caps($roleid, context $context) {
         }
     }
 
-    // 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))) {
index 72d6df3..4025f91 100644 (file)
@@ -7575,7 +7575,7 @@ class admin_setting_managewebservicetokens extends admin_setting {
 
                 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',
index 9bd66a2..dfe1717 100644 (file)
@@ -53,7 +53,7 @@ class completion_criteria_date extends completion_criteria {
     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) {
@@ -74,8 +74,7 @@ class completion_criteria_date extends completion_criteria {
 
         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();
         }
     }
index 7cc195e..412dfa3 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
@@ -23,7 +22,6 @@
  * - 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
  */
@@ -1649,14 +1647,16 @@ function coursemodule_visible_for_user($cm, $userid=0) {
  * 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
@@ -1746,12 +1746,14 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
 /**
  * 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) {
@@ -1816,16 +1818,16 @@ 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;
@@ -1860,13 +1862,14 @@ function get_logs($select, array $params=null, $order='l.time DESC', $limitfrom=
 /**
  * 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;
@@ -1891,12 +1894,14 @@ function get_logs_usercourse($userid, $courseid, $coursestart) {
 /**
  * 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;
@@ -1925,7 +1930,7 @@ function get_logs_userday($userid, $courseid, $daystart) {
  * 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
index 2bb3222..4814f7d 100644 (file)
@@ -48,4 +48,5 @@ $logs = array(
     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'),
 );
index 13036c9..79afe2b 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 
 
 /**
- * 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;
@@ -52,7 +62,7 @@ class database_manager {
     }
 
     /**
-     * Release all resources
+     * Releases all resources
      */
     public function dispose() {
         if ($this->generator) {
@@ -65,10 +75,8 @@ class database_manager {
     /**
      * 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) {
@@ -77,12 +85,10 @@ class database_manager {
     }
 
     /**
-     * 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)) {
@@ -92,10 +98,10 @@ class database_manager {
     }
 
     /**
-     * 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)) {
@@ -106,8 +112,8 @@ class database_manager {
 
     /**
      * 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)) {
@@ -127,11 +133,12 @@ class database_manager {
     }
 
     /**
-     * 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
@@ -165,9 +172,10 @@ class database_manager {
      * 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
@@ -200,11 +208,11 @@ class database_manager {
     }
 
     /**
-     * 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)) {
@@ -219,11 +227,11 @@ class database_manager {
      * 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) {
 
@@ -256,8 +264,8 @@ class database_manager {
      *
      * 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) {
@@ -271,9 +279,9 @@ class database_manager {
      * 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) {
 
@@ -316,7 +324,7 @@ class database_manager {
     /**
      * 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) {
@@ -354,7 +362,7 @@ class database_manager {
      * 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) {
@@ -399,7 +407,7 @@ class database_manager {
     /**
      * 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) {
@@ -411,8 +419,8 @@ class database_manager {
     /**
      * 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)
      */
@@ -445,7 +453,7 @@ class database_manager {
      * 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) {
@@ -460,7 +468,7 @@ class database_manager {
      * 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) {
@@ -482,7 +490,7 @@ class database_manager {
      * 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) {
@@ -505,7 +513,7 @@ class database_manager {
      *
      * 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) {
@@ -526,8 +534,8 @@ class database_manager {
      * 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) {
@@ -563,8 +571,8 @@ class database_manager {
     /**
      * 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) {
@@ -589,8 +597,8 @@ class database_manager {
     /**
      * 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) {
@@ -614,8 +622,8 @@ class database_manager {
     /**
      * 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) {
@@ -639,8 +647,8 @@ class database_manager {
     /**
      * 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) {
@@ -651,8 +659,8 @@ class database_manager {
     /**
      * 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) {
@@ -663,8 +671,8 @@ class database_manager {
     /**
      * 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) {
@@ -676,8 +684,8 @@ class database_manager {
      * 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) {
@@ -703,8 +711,8 @@ class database_manager {
      *
      * 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) {
@@ -733,9 +741,9 @@ class database_manager {
      * 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) {
@@ -776,7 +784,12 @@ class database_manager {
     /**
      * 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) {
 
@@ -805,8 +818,8 @@ class database_manager {
     /**
      * 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) {
@@ -825,8 +838,8 @@ class database_manager {
     /**
      * 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) {
@@ -845,9 +858,9 @@ class database_manager {
      * 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) {
@@ -869,8 +882,8 @@ class database_manager {
      * 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) {
@@ -896,8 +909,8 @@ class database_manager {
      * 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) {
@@ -924,9 +937,9 @@ class database_manager {
      * 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) {
index 3c9b41d..fa7cbad 100644 (file)
@@ -20,7 +20,7 @@
  * 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
index 3004c76..5f89363 100644 (file)
@@ -20,7 +20,7 @@
  * 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
index 9450388..80039a5 100644 (file)
@@ -20,7 +20,7 @@
  * 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
index 5e2a3c8..acde9d2 100644 (file)
@@ -20,7 +20,7 @@
  * 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
index 203ccf3..f70ab21 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 
 
 /**
- * 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
@@ -34,6 +33,13 @@ defined('MOODLE_INTERNAL') || die();
 
 /**
  * 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 {
 
@@ -42,96 +48,146 @@ 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();
@@ -141,14 +197,18 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -164,9 +224,9 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
@@ -185,7 +245,11 @@ abstract class sql_generator {
     }
 
     /**
-     * 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();
@@ -200,11 +264,14 @@ abstract class sql_generator {
     }
 
     /**
-     * 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
@@ -220,7 +287,11 @@ abstract class sql_generator {
 
     /**
      * 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) {
 
@@ -345,7 +416,12 @@ abstract class sql_generator {
 
     /**
      * 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)) {
@@ -368,7 +444,17 @@ abstract class sql_generator {
     }
 
     /**
-     * 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)) {
@@ -453,7 +539,11 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -492,6 +582,9 @@ abstract class sql_generator {
 
     /**
      * 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) {
 
@@ -529,7 +622,10 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -544,7 +640,11 @@ abstract class sql_generator {
 
     /**
      * 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) {
 
@@ -566,7 +666,10 @@ abstract class sql_generator {
 
     /**
      * 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) {
 
@@ -584,7 +687,14 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -612,7 +722,11 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -629,7 +743,14 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -663,7 +784,11 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -685,7 +810,12 @@ abstract class sql_generator {
 
     /**
      * 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) {
 
@@ -717,7 +847,11 @@ abstract class sql_generator {
 
     /**
      * 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) {
 
@@ -757,7 +891,11 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -826,8 +964,12 @@ abstract class sql_generator {
     /**
      * 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();
@@ -861,7 +1003,11 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -870,7 +1016,11 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -891,6 +1041,11 @@ abstract class sql_generator {
     /**
      * 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
@@ -914,6 +1069,11 @@ abstract class sql_generator {
      *
      * 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='') {
 
@@ -985,6 +1145,9 @@ abstract class sql_generator {
     /**
      * 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) {
 
@@ -1005,7 +1168,10 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -1057,9 +1223,14 @@ abstract class sql_generator {
     }
 
     /**
-     * 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) {
 
@@ -1078,18 +1249,27 @@ abstract class sql_generator {
 
     /**
      * 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,
@@ -1101,30 +1281,46 @@ abstract class sql_generator {
 
     /**
      * 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();
@@ -1132,19 +1328,30 @@ abstract class sql_generator {
 
     /**
      * 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();
@@ -1152,6 +1359,9 @@ abstract class sql_generator {
 
     /**
      * 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();
@@ -1161,7 +1371,12 @@ abstract class sql_generator {
      * 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);
 
@@ -1169,7 +1384,12 @@ abstract class sql_generator {
      * 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);
 
@@ -1178,27 +1398,37 @@ abstract class sql_generator {
      * 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))
      */
@@ -1219,6 +1449,11 @@ abstract class sql_generator {
         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);
index d2ba790..d190d07 100644 (file)
@@ -20,7 +20,7 @@
  * 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
  */
index 18d3842..d3d237b 100644 (file)
@@ -144,6 +144,7 @@ M.form_filemanager.init = function(Y, options) {
             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);
@@ -213,6 +214,7 @@ M.form_filemanager.init = function(Y, options) {
                                 scope.mkdir_dialog.hide();
                                 scope.refresh(filepath);
                                 Y.one('#fm-newname').set('value', '');
+                                M.util.set_form_changed();
                             }
                         });
                     }
@@ -559,6 +561,7 @@ M.form_filemanager.init = function(Y, options) {
                         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');
@@ -606,6 +609,7 @@ M.form_filemanager.init = function(Y, options) {
                                 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();
@@ -683,6 +687,7 @@ M.form_filemanager.init = function(Y, options) {
                             }
                             dialog.cancel();
                             scope.refresh(p);
+                            M.util.set_form_changed();
                         }
                     });
                 }
index 0818fbe..371c2b0 100644 (file)
@@ -2229,9 +2229,9 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
         // 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}&nbsp;</div></div>',
 
@@ -2255,6 +2255,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
      * @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();
@@ -2267,7 +2268,13 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
             $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');
     }
 
     /**
@@ -2276,6 +2283,9 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
      * @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{
@@ -2299,6 +2309,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
         }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);
 
@@ -2349,6 +2360,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
         } 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')){
index faf00b8..6f3a137 100644 (file)
@@ -1113,7 +1113,7 @@ class HTML5 {
                 $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
@@ -1140,7 +1140,7 @@ class HTML5 {
                 }
 
                 $cond = isset($entity);
-                // The rest of the parsing happens bellow.
+                // The rest of the parsing happens below.
             break;
         }
 
index 07f8cfc..452be34 100644 (file)
@@ -1752,4 +1752,72 @@ M.util.load_flowplayer = function() {
         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;
+};
index e4062fe..c90b3af 100644 (file)
@@ -3814,6 +3814,12 @@ function delete_user($user) {
     // 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);
 
@@ -5895,6 +5901,7 @@ function clean_filename($string) {
 /**
  * Returns the code for the current language
  *
+ * @category string
  * @return string
  */
 function current_language() {
@@ -5924,6 +5931,7 @@ 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
@@ -5960,6 +5968,7 @@ function get_parent_language($lang=null) {
  * 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
  */
@@ -6005,10 +6014,12 @@ function get_string_manager($forcereload=false) {
 
 
 /**
+ * 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
  */
@@ -6058,11 +6069,11 @@ interface string_manager {
     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);
 
@@ -6101,7 +6112,10 @@ interface string_manager {
 /**
  * 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
  */
@@ -6122,7 +6136,7 @@ class core_string_manager implements string_manager {
     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;
@@ -6148,6 +6162,7 @@ class core_string_manager implements string_manager {
 
     /**
      * Returns dependencies of current language, en is not included.
+     *
      * @param string $lang
      * @return array all parents, the lang itself is last
      */
@@ -6172,6 +6187,7 @@ class core_string_manager implements string_manager {
 
     /**
      * 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
@@ -6294,8 +6310,7 @@ class core_string_manager implements string_manager {
      *
      * 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
@@ -6418,6 +6433,7 @@ class core_string_manager implements string_manager {
 
     /**
      * Returns information about the string_manager performance
+     *
      * @return array
      */
     public function get_performance_summary() {
@@ -6515,11 +6531,11 @@ class core_string_manager implements string_manager {
     }
 
     /**
-     * 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) {
 
@@ -6541,6 +6557,7 @@ class core_string_manager implements string_manager {
 
     /**
      * Returns localised list of installed translations
+     *
      * @param bool $returnall return all or just enabled
      * @return array moodle translation code => localised translation name
      */
@@ -6669,11 +6686,13 @@ class core_string_manager implements string_manager {
 
 
 /**
+ * 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
  */
@@ -6829,11 +6848,11 @@ class install_string_manager implements string_manager {
     }
 
     /**
-     * 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');
@@ -6941,6 +6960,7 @@ class install_string_manager implements string_manager {
  * 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
@@ -7012,8 +7032,8 @@ function get_string($identifier, $component = '', $a = NULL, $lazyload = false)
  * 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;
@@ -7042,9 +7062,10 @@ function get_strings($array, $component = '') {
  * 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);
@@ -7559,7 +7580,6 @@ function get_core_subsystems() {
             '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
@@ -7894,7 +7914,7 @@ function plugin_callback($type, $name, $feature, $action, $params = null, $defau
  * @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)) {
@@ -8273,7 +8293,8 @@ function get_device_type() {
          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';
     }
 
@@ -8604,9 +8625,7 @@ function upgrade_set_timeout($max_execution_time=300) {
 /**
  * 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='') {
@@ -8664,8 +8683,9 @@ 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.
@@ -8688,6 +8708,7 @@ function moodle_strtolower ($string, $encoding='') {
  *
  * 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
  */
@@ -8700,6 +8721,7 @@ function count_words($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.
  */
@@ -8760,12 +8782,13 @@ function complex_random_string($length=null) {
  * 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='...') {
 
@@ -8919,7 +8942,7 @@ function getweek ($startdate, $thedate) {
  * {@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
  */
@@ -8984,7 +9007,7 @@ function generate_password($maxlen=10) {
  * 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
  */
@@ -9003,7 +9026,7 @@ function format_float($float, $decimalpoints=1, $localized=true) {
  * 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) {
@@ -10562,8 +10585,8 @@ function get_home_page() {
  * 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
  */
index 600298b..8fe1042 100644 (file)
@@ -1854,6 +1854,7 @@ class global_navigation extends navigation_node {
             $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';
@@ -1863,11 +1864,18 @@ class global_navigation extends navigation_node {
             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.
@@ -1943,7 +1951,8 @@ class global_navigation extends navigation_node {
                 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();
index 8b79c12..100f8e7 100644 (file)
@@ -113,6 +113,7 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input
      */
     function toHtml()
     {
+        $this->_generateId(); // Seems to be necessary when this is used in a group.
         if (0 == strlen($this->_text)) {
             $label = '';
         } elseif ($this->_flagFrozen) {
index 2ff95ab..81ad764 100644 (file)
@@ -121,6 +121,7 @@ function plagiarism_get_form_elements_module($mform, $context) {
  *
  * @param object $course - full Course object
  * @param object $cm - full cm object
+ * @return string
  */
 function plagiarism_update_status($course, $cm) {
     global $CFG;
@@ -128,17 +129,20 @@ function plagiarism_update_status($course, $cm) {
         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;
@@ -146,12 +150,14 @@ function plagiarism_print_disclosure($cmid) {
         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.
index f620ec5..74f85cb 100644 (file)
@@ -296,6 +296,15 @@ class moodlelib_test extends UnitTestCase {
         $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));
index 9702738..6403504 100644 (file)
@@ -15,8 +15,9 @@
 // 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
  */
@@ -27,7 +28,9 @@ defined('MOODLE_INTERNAL') || die();
  * 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() {
@@ -36,6 +39,8 @@ 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
@@ -50,15 +55,16 @@ function textlib_get_instance() {
  * 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() {
@@ -184,11 +190,11 @@ class textlib {
     /**
      * 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);
@@ -228,7 +234,7 @@ class textlib {
     /**
      * 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
      */
@@ -253,7 +259,7 @@ class textlib {
     /**
      * 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
      */
@@ -274,7 +280,7 @@ class textlib {
     /**
      * 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
      */
@@ -293,12 +299,13 @@ class textlib {
     }
 
     /**
+     * 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')) {
@@ -309,11 +316,12 @@ class textlib {
     }
 
     /**
+     * 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')) {
@@ -327,9 +335,9 @@ class textlib {
      * 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);
@@ -344,9 +352,9 @@ class textlib {
      * 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)) {
@@ -432,9 +440,9 @@ class textlib {
      * 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
@@ -466,10 +474,10 @@ class textlib {
     /**
      * 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
@@ -487,9 +495,9 @@ class textlib {
     }
 
     /**
-     * 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) {
@@ -502,6 +510,7 @@ class textlib {
 
     /**
      * Returns encoding options for select boxes, utf-8 and platform encoding first
+     *
      * @return array encodings
      */
     public static function get_encodings() {
@@ -548,7 +557,7 @@ class textlib {
      * 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) {
@@ -596,8 +605,7 @@ class textlib {
 /**
  * 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
  */
@@ -697,6 +705,8 @@ abstract class collatorlib {
      *   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) {
@@ -732,11 +742,12 @@ abstract class collatorlib {
 }
 
 /**
+ * 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
  */
@@ -758,10 +769,12 @@ abstract class collatorlib_comparison {
 }
 
 /**
+ * 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
  */
@@ -771,6 +784,8 @@ class collatorlib_property_comparison extends collatorlib_comparison {
     protected $property;
 
     /**
+     * Constructor
+     *
      * @param string $property
      */
     public function __construct($property) {
@@ -795,10 +810,11 @@ class collatorlib_property_comparison extends collatorlib_comparison {
 }
 
 /**
+ * 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
  */
@@ -808,6 +824,8 @@ class collatorlib_method_comparison extends collatorlib_comparison {
     protected $method;
 
     /**
+     * Constructor
+     *
      * @param string $method The method to call against each object
      */
     public function __construct($method) {
diff --git a/lib/yui/formslib/formslib.js b/lib/yui/formslib/formslib.js
new file mode 100644 (file)
index 0000000..452b9e3
--- /dev/null
@@ -0,0 +1,59 @@
+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']
+    }
+);
index 09e6c56..62ca1fa 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 6ef703d..7a5ab20 100644 (file)
@@ -211,7 +211,7 @@ class assignment_base {
         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);
     }
 
     /**
@@ -1221,7 +1221,7 @@ class assignment_base {
         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)) {
index 4355e30..275f5f7 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index e048776..3fd3ef9 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 4ef840d..1c4da2b 100644 (file)
@@ -46,10 +46,13 @@ class mod_choice_renderer extends plugin_renderer_base {
         $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)) {
@@ -58,7 +61,7 @@ class mod_choice_renderer extends plugin_renderer_base {
             }
 
             $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'));
index 3f32f53..37235c2 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index e108b4d..e865858 100644 (file)
@@ -84,6 +84,8 @@ if($mform->is_cancelled()) {
     $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
@@ -104,7 +106,9 @@ foreach ($formdata as $key => $value) {
     }
 }
 
-$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':
index bfea754..9e9df3d 100644 (file)
@@ -167,27 +167,29 @@ class data_field_file extends data_field_base {
         $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;
                 }
             }
         }
index 2bee85b..364ad4c 100644 (file)
@@ -2804,9 +2804,11 @@ function data_export_ods($export, $dataname, $count) {
  * @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();
@@ -2826,7 +2828,15 @@ function data_get_exportdata($dataid, $fields, $selectedfields) {
     $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])) {
@@ -3144,7 +3154,7 @@ function data_presets_export($course, $cm, $data, $tostorage=false) {
     $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);
index a27ce3e..1b97e03 100644 (file)
@@ -17,8 +17,8 @@
 /**
  * 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
  */
index 37b6017..6a22bcf 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index b39f898..22ae66c 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 4bf4aa2..a425c6b 100644 (file)
@@ -27,8 +27,10 @@ require_once("lib.php");
 $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.'/';
 
index 19d77d5..8f80259 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 599b40d..5c37279 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index bc98f86..768cabc 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index c77cceb..90ace43 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index e043978..f00306e 100644 (file)
@@ -17,8 +17,8 @@
 /**
  * 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
index 37ca31d..8ecdeae 100644 (file)
@@ -121,7 +121,7 @@ real estate to the tool, and others provide a more integrated feel with the Mood
 * **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';
@@ -194,8 +194,8 @@ $string['icon_url'] = 'Icon URL';
 $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';
@@ -250,9 +250,9 @@ Tool types listed on this page are separated into three categories:
         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}"';
@@ -396,7 +396,7 @@ $string['show_in_course'] = 'Show tool type when creating tool instances';
 $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.
index e321dc2..915a5a1 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 3dbbe75..95ac3b4 100644 (file)
@@ -1165,7 +1165,7 @@ class quiz_attempt {
         $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();
index c5a31e7..f86c835 100644 (file)
@@ -17,8 +17,8 @@
 /**
  * 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
  */
index a40e9bb..ac2528c 100644 (file)
@@ -346,7 +346,7 @@ function quiz_move_question_down($layout, $questionid) {
  */
 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');
@@ -1212,7 +1212,7 @@ class quiz_question_bank_view extends question_bank_view {
  *      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;">';
index 5a0dddc..0d5539f 100644 (file)
@@ -1689,7 +1689,7 @@ function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
  */
 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);
index 63d82b6..f4bba12 100644 (file)
@@ -508,8 +508,7 @@ function quiz_set_grade($newgrade, $quiz) {
  * @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;
@@ -1149,8 +1148,6 @@ function quiz_send_confirmation($recipient, $a) {
  */
 function quiz_send_notification($recipient, $submitter, $a) {
 
-    global $USER;
-
     // Recipient info for template
     $a->useridnumber = $recipient->idnumber;
     $a->username     = fullname($recipient);
index c5e12f4..d18348a 100644 (file)
@@ -58,7 +58,7 @@ class quiz_override_form extends moodleform {
     }
 
     protected function definition() {
-        global $CFG, $USER, $DB;
+        global $CFG, $DB;
 
         $cm = $this->cm;
         $mform = $this->_form;
index 8e5d49c..f21f3d9 100644 (file)
@@ -78,11 +78,6 @@ $completion->set_module_viewed($cm);
 // 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);
@@ -221,13 +216,13 @@ if (!$viewobj->quizhasquestions) {
 
 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);
 }
index 687bc0c..4fd4d22 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 1f908fb..d675cc4 100644 (file)
@@ -80,7 +80,7 @@ $string['popupwidthexplain'] = 'Specifies default width of popup windows.';
 $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';
index 2448fb0..6e8a014 100644 (file)
@@ -17,8 +17,8 @@
 /**
  * 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
  */
index 293ffe0..c0a7917 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 9edde72..a393eb9 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index 9e954a8..b152259 100644 (file)
@@ -64,7 +64,7 @@ $string['popupwidthexplain'] = 'Specifies default width of popup windows.';
 $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';
index d206d14..06a878c 100644 (file)
@@ -74,7 +74,7 @@ function wiki_print_editor_wiki($pageid, $content, $editor, $version = -1, $sect
     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);
index 960803f..09a6c58 100644 (file)
@@ -114,7 +114,7 @@ $string['navigation'] = 'Navigation';
 $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>';
index 82627ed..19d04e4 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * 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
  */
index fdaf5ad..527eaf6 100644 (file)
@@ -27,7 +27,7 @@ $string['enableleap2a'] = 'Enable Leap2A portfolio support (requires Mahara 1.3
 $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';
index 8c6e175..b11ef48 100644 (file)
@@ -155,19 +155,19 @@ class question_engine_attempt_upgrader {
 
         $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;
index 212af73..aec7ac9 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 306b0a1..ad6057c 100644 (file)
 /**
  * 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;
 
index 5d4a980..842f847 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 08434eb..c0a94fe 100644 (file)
@@ -17,8 +17,7 @@
 /**
  * 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
  */
index 615cb96..677fab5 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index f757272..1102b8a 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
@@ -62,8 +63,8 @@ function report_log_extend_navigation_user($navigation, $user, $course) {
 /**
  * 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
@@ -117,10 +118,11 @@ function report_log_extend_navigation_module($navigation, $cm) {
 
 /**
  * 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(
@@ -131,4 +133,4 @@ function report_log_page_type_list($pagetype, $parentcontext, $currentcontext) {
         'report-log-user'  => get_string('page-report-log-user',  'report_log')
     );
     return $array;
-}
\ No newline at end of file
+}
index aa14d01..dd543b0 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
@@ -31,6 +32,16 @@ if (!defined('REPORT_LOG_MAX_DISPLAY')) {
 
 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;
 
@@ -41,7 +52,32 @@ function report_log_print_graph($course, $userid, $type, $date=0) {
              '&amp;user='.$userid.'&amp;type='.$type.'&amp;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') {
 
@@ -326,7 +362,30 @@ function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0,
     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') {
 
@@ -545,4 +604,4 @@ function report_log_print_selector_form($course, $selecteduser=0, $selecteddate=
     echo '<input type="submit" value="'.get_string('gettheselogs').'" />';
     echo '</div>';
     echo '</form>';
-}
\ No newline at end of file
+}
index 22fb794..74c22e2 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 0a51e73..32ed582 100644 (file)
@@ -17,8 +17,7 @@
 /**
  * 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
  */
index 9072eac..a1c5fba 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index a97cd3a..bc94c93 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 57ae10f..782679b 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 6d5cc0a..0b04e16 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 9d05936..b233d26 100644 (file)
@@ -19,8 +19,7 @@
  *
  * 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
  */
@@ -30,9 +29,11 @@ defined('MOODLE_INTERNAL') || die;
 /**
  * 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;
index 13de346..2966e63 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 3ea3950..8d81583 100644 (file)
@@ -17,8 +17,9 @@
 /**
  * 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
  */
index 89c1800..83411ec 100644 (file)
@@ -157,7 +157,7 @@ if (empty($param->crosstab)) {
     }
 
     $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;
index e5c316a..969dda3 100644 (file)
@@ -1,7 +1,27 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+
 /**
  * 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');
index 18d40a4..8bb33b4 100644 (file)
@@ -1,9 +1,27 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
 
 /**
- * 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');
index ee7c75c..60b1820 100644 (file)
@@ -1,8 +1,27 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+
 /**
- * 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');
index f022dfc..c83b954 100644 (file)
@@ -1,7 +1,26 @@
 <?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';
@@ -10,13 +29,15 @@ 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') {
 
@@ -93,10 +114,11 @@ function coursetag_get_tags($courseid, $userid=0, $tagtype='', $numtags=0, $sort
  * 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) {
 
@@ -135,8 +157,21 @@ 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
@@ -161,10 +196,12 @@ function coursetag_sort($a, $b) {
 /**
  * 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) {
 
@@ -237,8 +274,11 @@ function coursetag_print_cloud($tagcloud, $return=false, $max_size=180, $min_siz
 
 /**
  * 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;
@@ -263,6 +303,12 @@ function coursetag_get_jscript($coursetagdivs = '') {
 
 /**
  * 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;
@@ -279,12 +325,12 @@ function coursetag_get_jscript_links($elementid, $coursetagslinks) {
 /**
  * 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
@@ -300,12 +346,13 @@ function coursetag_get_records($courseid, $userid) {
 /**
  * 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='') {
 
@@ -348,11 +395,12 @@ function coursetag_store_keywords($tags, $courseid, $userid=0, $tagtype='officia
 /**
  * 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;
@@ -385,11 +433,12 @@ function coursetag_delete_keyword($tagid, $userid, $courseid) {
 /**
  * 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();
@@ -411,14 +460,13 @@ function coursetag_get_tagged_courses($tagid) {
 }
 
 /**
- * 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))) {
@@ -440,10 +488,9 @@ function coursetag_delete_course_tags($courseid, $showfeedback=false) {
     }
 }
 
-/**
+/*
  * Function called by cron to create/update users rss feeds
  *
- * @uses $CFG
  * @return true
  *
  * Function removed.
@@ -618,10 +665,10 @@ function coursetag_rss_feeds() {
 }
  */
 
-/**
+/*
  * 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
  *
index 66fd0fb..b71c72f 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 // 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
  */
index f1e8286..9728367 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 // 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
  */
@@ -28,8 +28,20 @@ if (!defined('MOODLE_INTERNAL')) {
 
 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;
@@ -62,4 +74,4 @@ class tag_edit_form extends moodleform {
 
     }
 
-}
+}
\ No newline at end of file
index 3a993df..56e2372 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 // 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
  */
@@ -48,7 +48,7 @@ if ($tagname) {
 } else if ($tagid) {
     $tag = tag_get('id', $tagid, '*');
 }
-
+unset($tagid);
 if (empty($tag)) {
     redirect($CFG->wwwroot.'/tag/search.php');
 }
@@ -68,7 +68,7 @@ $title = get_string('tag', 'tag') .' - '. $tagname;
 
 $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'));
index 2284a41..2859162 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 // 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):
@@ -43