diff --git a/mod/data/mod_form.php b/mod/data/mod_form.php
index 585e16bfa6e..047a9c3d6bf 100644
--- a/mod/data/mod_form.php
+++ b/mod/data/mod_form.php
@@ -7,7 +7,6 @@ class data_mod_form extends moodleform_mod {
global $CFG;
$mform =& $this->_form;
$renderer =& $mform->defaultRenderer();
- $course=$this->_customdata['course'];
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
@@ -64,16 +63,7 @@ class data_mod_form extends moodleform_mod {
$mform->addElement('checkbox', 'assessed', get_string("allowratings", "data") , get_string('ratingsuse', 'data'));
- $strscale = get_string('scale');
- $strscales = get_string('scales');
- $scales = get_scales_menu($course->id);
- foreach ($scales as $i => $scalename) {
- $grades[-$i] = $strscale .': '. $scalename;
- }
- for ($i=100; $i>=1; $i--) {
- $grades[$i] = $i;
- }
- $mform->addElement('select', 'scale', get_string('grade') , $grades);
+ $mform->addElement('modgrade', 'scale', get_string('grade'), false);
$this->standard_coursemodule_elements();
diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php
index 3b7ebf64909..92107245621 100644
--- a/mod/forum/mod_form.php
+++ b/mod/forum/mod_form.php
@@ -4,10 +4,9 @@ class forum_mod_form extends moodleform_mod {
function definition() {
- global $CFG, $FORUM_TYPES;
+ global $CFG, $FORUM_TYPES, $COURSE;
$mform =& $this->_form;
$renderer =& $mform->defaultRenderer();
- $course=$this->_customdata['course'];
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
@@ -40,14 +39,15 @@ class forum_mod_form extends moodleform_mod {
$mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options);
$mform->setHelpButton('trackingtype', array('trackingtype', get_string('trackingtype', 'forum'), 'forum'));
- $choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes);
+ $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
$choices[1] = get_string('uploadnotallowed');
- $choices[0] = get_string('courseuploadlimit') . ' ('.display_size($course->maxbytes).')';
+ $choices[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
$mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices);
$mform->setHelpButton('maxbytes', array('maxattachmentsize', get_string('maxattachmentsize', 'forum'), 'forum'));
$mform->setDefault('maxbytes', $CFG->forum_maxbytes);
if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
+//-------------------------------------------------------------------------------
$mform->addElement('header', '', get_string('rss'));
$choices = array();
$choices[0] = get_string('none');
@@ -74,24 +74,17 @@ class forum_mod_form extends moodleform_mod {
$mform->setHelpButton('rssarticles', array('rssarticles', get_string('rssarticles'), 'forum'));
}
+//-------------------------------------------------------------------------------
$mform->addElement('header', '', get_string('grade'));
- $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'data') , get_string('ratingsuse', 'data'));
+ $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'forum') , get_string('ratingsuse', 'forum'));
- $strscale = get_string('scale');
- $strscales = get_string('scales');
- $scales = get_scales_menu($course->id);
- foreach ($scales as $i => $scalename) {
- $grades[-$i] = $strscale .': '. $scalename;
- }
- for ($i=100; $i>=1; $i--) {
- $grades[$i] = $i;
- }
- $mform->addElement('select', 'scale', get_string('grade') , $grades);
+ $mform->addElement('modgrade', 'scale', get_string('grade'), false);
$mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
$mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
+//-------------------------------------------------------------------------------
$mform->addElement('header', '', get_string('blockafter', 'forum'));
$mform->addElement('text', 'warnafter', get_string('warnafter', 'forum'));
$mform->setType('warnafter', PARAM_INT);
@@ -119,6 +112,7 @@ class forum_mod_form extends moodleform_mod {
$mform->addElement('select', 'blockperiod', get_string("blockperiod", "forum") , $options);
$mform->setHelpButton('blockperiod', array('manageposts', get_string('blockperiod', 'forum'),'forum'));
+//-------------------------------------------------------------------------------
$this->standard_coursemodule_elements();
$buttonarray=array();
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php
index 757b12b3bd7..9f5b7ba2913 100644
--- a/mod/glossary/lib.php
+++ b/mod/glossary/lib.php
@@ -56,12 +56,7 @@ function glossary_add_instance($glossary) {
$glossary->assessed = 0;
}
- if (!empty($glossary->ratingtime)) {
- $glossary->assesstimestart = make_timestamp($glossary->startyear, $glossary->startmonth, $glossary->startday,
- $glossary->starthour, $glossary->startminute, 0);
- $glossary->assesstimefinish = make_timestamp($glossary->finishyear, $glossary->finishmonth, $glossary->finishday,
- $glossary->finishhour, $glossary->finishminute, 0);
- } else {
+ if (empty($glossary->ratingtime)) {
$glossary->assesstimestart = 0;
$glossary->assesstimefinish = 0;
}
@@ -79,10 +74,7 @@ function glossary_add_instance($glossary) {
$formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
if (!in_array($glossary->displayformat, $formats)) {
error("This format doesn't exist!");
- }
-
- //sanitize submitted values a bit
- $glossary->entbypage = clean_param($glossary->entbypage, PARAM_INT);
+ }
return insert_record("glossary", $glossary);
}
@@ -93,7 +85,7 @@ function glossary_update_instance($glossary) {
/// (defined by the form in mod.html) this function
/// will update an existing instance with new data.
global $CFG;
-
+
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
unset($glossary->globalglossary);
}
@@ -108,12 +100,7 @@ function glossary_update_instance($glossary) {
$glossary->assessed = 0;
}
- if (!empty($glossary->ratingtime)) {
- $glossary->assesstimestart = make_timestamp($glossary->startyear, $glossary->startmonth, $glossary->startday,
- $glossary->starthour, $glossary->startminute, 0);
- $glossary->assesstimefinish = make_timestamp($glossary->finishyear, $glossary->finishmonth, $glossary->finishday,
- $glossary->finishhour, $glossary->finishminute, 0);
- } else {
+ if (empty($glossary->ratingtime)) {
$glossary->assesstimestart = 0;
$glossary->assesstimefinish = 0;
}
@@ -207,12 +194,12 @@ function glossary_get_user_entries($glossaryid, $userid) {
global $CFG;
return get_records_sql("SELECT e.*, u.firstname, u.lastname, u.email, u.picture
- FROM {$CFG->prefix}glossary g,
- {$CFG->prefix}glossary_entries e,
- {$CFG->prefix}user u
- WHERE g.id = '$glossaryid'
- AND e.glossaryid = g.id
- AND e.userid = '$userid'
+ FROM {$CFG->prefix}glossary g,
+ {$CFG->prefix}glossary_entries e,
+ {$CFG->prefix}user u
+ WHERE g.id = '$glossaryid'
+ AND e.glossaryid = g.id
+ AND e.userid = '$userid'
AND e.userid = u.id
ORDER BY e.timemodified ASC");
}
@@ -252,13 +239,13 @@ function glossary_print_recent_activity($course, $isteacher, $timestart) {
foreach ($logs as $log) {
//Create a temp valid module structure (course,id)
- $tempmod->course = $log->course;
+ $tempmod->course = $log->course;
$entry = get_record('glossary_entries','id',$log->info);
if (!$entry) {
continue;
}
$tempmod->id = $entry->glossaryid;
- //Obtain the visible property from the instance
+ //Obtain the visible property from the instance
$modvisible = instance_is_visible($log->module,$tempmod);
//Only if the mod is visible
@@ -359,7 +346,7 @@ function glossary_grades($glossaryid) {
$count ++;
}
$return->grades[$currentuser] = (string) format_float((float)$total/(float)$count, 2);
-
+
if ( count($ratingsuser) > 1 ) {
$return->grades[$currentuser] .= " (" . count($ratingsuser) . ")";
}
@@ -398,15 +385,15 @@ function glossary_get_participants($glossaryid) {
function glossary_scale_used ($glossaryid,$scaleid) {
//This function returns if a scale is being used by one glossary
-
+
$return = false;
$rec = get_record("glossary","id","$glossaryid","scale","-$scaleid");
if (!empty($rec) && !empty($scaleid)) {
- $return = true;
- }
-
+ $return = true;
+ }
+
return $return;
}
@@ -497,22 +484,22 @@ function glossary_get_entries_search($concept, $courseid) {
global $CFG;
- //Check if the user is an admin
+ //Check if the user is an admin
$bypassadmin = 1; //This means NO (by default)
if (has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
$bypassadmin = 0; //This means YES
- }
+ }
- //Check if the user is a teacher
+ //Check if the user is a teacher
$bypassteacher = 1; //This means NO (by default)
if (has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_COURSE, $courseid))) {
$bypassteacher = 0; //This means YES
- }
+ }
$conceptlower = moodle_strtolower(trim($concept));
return get_records_sql("SELECT e.*, g.name as glossaryname, cm.id as cmid, cm.course as courseid
- FROM {$CFG->prefix}glossary_entries e,
+ FROM {$CFG->prefix}glossary_entries e,
{$CFG->prefix}glossary g,
{$CFG->prefix}course_modules cm,
{$CFG->prefix}modules m
@@ -541,7 +528,7 @@ global $CFG;
$pivot .= ",";
}
return get_records_sql("SELECT $pivot *
- FROM {$CFG->prefix}glossary_entries
+ FROM {$CFG->prefix}glossary_entries
WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby");
}
@@ -661,10 +648,10 @@ function glossary_print_entry_definition($entry) {
}
}
-
+
//Extract ..> tags from definition
preg_match_all('/]+?>(.*?)<\/a>/is',$definition,$list_of_a);
-
+
//Save them into links array to use them later
foreach (array_unique($list_of_a[0]) as $key=>$value) {
$links['<#'.$key.'#>'] = $value;
@@ -772,7 +759,7 @@ function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',
if ($return != '') {
$return .= '';
}
- }
+ }
if ($type == 'print') {
echo $return;
} else {
@@ -782,7 +769,7 @@ function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',
function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$hook='', $type = 'print') {
global $USER, $CFG;
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$output = false; //To decide if we must really return text in "return". Activate when needed only!
@@ -796,7 +783,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
$return .= get_string('entryishidden','glossary');
}
$return .= glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook,'html');
-
+
if (has_capability('mod/glossary:comment', $context)) {
$output = true;
$return .= '
';
@@ -828,7 +815,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
$return .= " id&mode=delete&entry=$entry->id&prevmode=$mode&hook=$hook\"> ";
-
+
$return .= " id&e=$entry->id&mode=$mode&hook=$hook\">
pixpath/t/edit.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" />";
} elseif ( $importedentry ) {
$return .= " " . get_string("exportedentry","glossary") . "";
@@ -837,7 +824,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
$return .= " "; // just to make up a little the output in Mozilla ;)
$return .= '';
-
+
//If we haven't calculated any REAL thing, delete result ($return)
if (!$output) {
$return = '';
@@ -931,7 +918,7 @@ function glossary_print_entry_approval($cm, $entry, $mode,$align="right",$insid
}
function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL) {
-// It returns all entries from all glossaries that matches the specified criteria
+// It returns all entries from all glossaries that matches the specified criteria
// within a given $course. It performs an $extended search if necessary.
// It restrict the search to only one $glossary if the $glossary parameter is set.
@@ -947,7 +934,7 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
} else {
$glos = $glossary->id;
}
-
+
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_COURSE, $glossary->course))) {
$glossarymodule = get_record("modules", "name", "glossary");
$onlyvisible = " AND g.id = cm.instance AND cm.visible = 1 AND cm.module = $glossarymodule->id";
@@ -973,7 +960,7 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
$REGEXP = "REGEXP";
$NOTREGEXP = "NOT REGEXP";
break;
- }
+ }
$conceptsearch = "";
$definitionsearch = "";
@@ -1017,7 +1004,7 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible
AND g.id IN ($glos) AND e.approved != 0";
- return get_records_sql("SELECT e.*
+ return get_records_sql("SELECT e.*
FROM $selectsql ORDER BY e.concept ASC");
}
@@ -1030,7 +1017,7 @@ function glossary_file_area_name($entry) {
global $CFG;
// Creates a directory file name, suitable for make_upload_directory()
- // I'm doing this workaround for make it works for delete_instance also
+ // I'm doing this workaround for make it works for delete_instance also
// (when called from delete_instance, glossary is already deleted so
// getting the course from mdl_glossary does not work)
$module = get_record("modules","name","glossary");
@@ -1049,7 +1036,7 @@ function glossary_main_file_area($glossary) {
function glossary_mod_file_area($glossary) {
global $CFG;
-
+
return make_upload_directory( "$glossary->course/$CFG->moddata/glossary" );
}
@@ -1086,17 +1073,17 @@ function glossary_delete_attachments($glossary) {
rmdir("$basedir");
$deleted++;
}
- }
+ }
}
if ( $deleted ) {
$attachmentdir = glossary_main_file_area($glossary);
$glossarydir = glossary_mod_file_area($glossary);
-
+
rmdir("$attachmentdir");
if (!$files = get_directory_list($glossarydir) ) {
rmdir( "$glossarydir" );
}
- }
+ }
}
}
@@ -1155,7 +1142,7 @@ function glossary_move_attachments($entry, $glossaryid) {
}
foreach ($files as $file) {
// this is not tested as I can't find anywhere that calls this function, grepping the source.
- clam_change_log($oldentrydir.'/'.$file,$newentrydir.'/'.$file);
+ clam_change_log($oldentrydir.'/'.$file,$newentrydir.'/'.$file);
}
}
}
@@ -1173,7 +1160,7 @@ function glossary_add_attachment($entry, $inputname) {
if (!$glossary = get_record("glossary","id",$entry->glossaryid)) {
return false;
}
-
+
if (!$course = get_record("course","id",$glossary->course)) {
return false;
}
@@ -1194,7 +1181,7 @@ function glossary_print_attachments($entry, $return=NULL, $align="left") {
// otherwise, print HTML for non-images, and return image HTML
// if attachment is an image, $align set its aligment.
global $CFG;
-
+
$newentry = $entry;
if ( $newentry->sourceglossaryid ) {
$newentry->glossaryid = $newentry->sourceglossaryid;
@@ -1352,9 +1339,9 @@ function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '',
}
function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
-
+
global $CFG;
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
echo '