.
/**
* Library of functions and constants for module glossary
* (replace glossary with the name of your module and delete this line)
*
* @package mod-glossary
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot . '/rating/lib.php');
require_once($CFG->libdir . '/completionlib.php');
define("GLOSSARY_SHOW_ALL_CATEGORIES", 0);
define("GLOSSARY_SHOW_NOT_CATEGORISED", -1);
define("GLOSSARY_NO_VIEW", -1);
define("GLOSSARY_STANDARD_VIEW", 0);
define("GLOSSARY_CATEGORY_VIEW", 1);
define("GLOSSARY_DATE_VIEW", 2);
define("GLOSSARY_AUTHOR_VIEW", 3);
define("GLOSSARY_ADDENTRY_VIEW", 4);
define("GLOSSARY_IMPORT_VIEW", 5);
define("GLOSSARY_EXPORT_VIEW", 6);
define("GLOSSARY_APPROVAL_VIEW", 7);
/// STANDARD FUNCTIONS ///////////////////////////////////////////////////////////
/**
* @global object
* @param object $glossary
* @return int
*/
function glossary_add_instance($glossary) {
global $DB;
/// Given an object containing all the necessary data,
/// (defined by the form in mod_form.php) this function
/// will create a new instance and return the id number
/// of the new instance.
if (empty($glossary->ratingtime) or empty($glossary->assessed)) {
$glossary->assesstimestart = 0;
$glossary->assesstimefinish = 0;
}
if (empty($glossary->globalglossary) ) {
$glossary->globalglossary = 0;
}
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
$glossary->globalglossary = 0;
}
$glossary->timecreated = time();
$glossary->timemodified = $glossary->timecreated;
//Check displayformat is a valid one
$formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
if (!in_array($glossary->displayformat, $formats)) {
print_error('unknowformat', '', '', $glossary->displayformat);
}
$returnid = $DB->insert_record("glossary", $glossary);
$glossary->id = $returnid;
glossary_grade_item_update($glossary);
return $returnid;
}
/**
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
* will update an existing instance with new data.
*
* @global object
* @global object
* @param object $glossary
* @return bool
*/
function glossary_update_instance($glossary) {
global $CFG, $DB;
if (empty($glossary->globalglossary)) {
$glossary->globalglossary = 0;
}
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
// keep previous
unset($glossary->globalglossary);
}
$glossary->timemodified = time();
$glossary->id = $glossary->instance;
if (empty($glossary->ratingtime) or empty($glossary->assessed)) {
$glossary->assesstimestart = 0;
$glossary->assesstimefinish = 0;
}
//Check displayformat is a valid one
$formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
if (!in_array($glossary->displayformat, $formats)) {
print_error('unknowformat', '', '', $glossary->displayformat);
}
$DB->update_record("glossary", $glossary);
if ($glossary->defaultapproval) {
$DB->execute("UPDATE {glossary_entries} SET approved = 1 where approved <> 1 and glossaryid = ?", array($glossary->id));
}
glossary_grade_item_update($glossary);
return true;
}
/**
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
*
* @global object
* @param int $id glossary id
* @return bool success
*/
function glossary_delete_instance($id) {
global $DB, $CFG;
if (!$glossary = $DB->get_record('glossary', array('id'=>$id))) {
return false;
}
if (!$cm = get_coursemodule_from_instance('glossary', $id)) {
return false;
}
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
return false;
}
$fs = get_file_storage();
if ($glossary->mainglossary) {
// unexport entries
$sql = "SELECT ge.id, ge.sourceglossaryid, cm.id AS sourcecmid
FROM {glossary_entries} ge
JOIN {modules} m ON m.name = 'glossary'
JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = ge.sourceglossaryid)
WHERE ge.glossaryid = ? AND ge.sourceglossaryid > 0";
if ($exported = $DB->get_records_sql($sql, array($id))) {
foreach ($exported as $entry) {
$entry->glossaryid = $entry->sourceglossaryid;
$entry->sourceglossaryid = 0;
$newcontext = get_context_instance(CONTEXT_MODULE, $entry->sourcecmid);
if ($oldfiles = $fs->get_area_files($context->id, 'mod_glossary', 'attachment', $entry->id)) {
foreach ($oldfiles as $oldfile) {
$file_record = new stdClass();
$file_record->contextid = $newcontext->id;
$fs->create_file_from_storedfile($file_record, $oldfile);
}
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment', $entry->id);
$entry->attachment = '1';
} else {
$entry->attachment = '0';
}
$DB->update_record('glossary_entries', $entry);
}
}
} else {
// move exported entries to main glossary
$sql = "UPDATE {glossary_entries}
SET sourceglossaryid = 0
WHERE sourceglossaryid = ?";
$DB->execute($sql, array($id));
}
// Delete any dependent records
$entry_select = "SELECT id FROM {glossary_entries} WHERE glossaryid = ?";
$DB->delete_records_select('comments', "contextid=? AND commentarea=? AND itemid IN ($entry_select)", array($id, 'glossary_entry', $context->id));
$DB->delete_records_select('glossary_alias', "entryid IN ($entry_select)", array($id));
$category_select = "SELECT id FROM {glossary_categories} WHERE glossaryid = ?";
$DB->delete_records_select('glossary_entries_categories', "categoryid IN ($category_select)", array($id));
$DB->delete_records('glossary_categories', array('glossaryid'=>$id));
$DB->delete_records('glossary_entries', array('glossaryid'=>$id));
// delete all files
$fs->delete_area_files($context->id);
glossary_grade_item_delete($glossary);
return $DB->delete_records('glossary', array('id'=>$id));
}
/**
* Return a small object with summary information about what a
* user has done with a given particular instance of this module
* Used for user activity reports.
* $return->time = the time they did it
* $return->info = a short text description
*
* @param object $course
* @param object $user
* @param object $mod
* @param object $glossary
* @return object|null
*/
function glossary_user_outline($course, $user, $mod, $glossary) {
global $CFG;
require_once("$CFG->libdir/gradelib.php");
$grades = grade_get_grades($course->id, 'mod', 'glossary', $glossary->id, $user->id);
if (empty($grades->items[0]->grades)) {
$grade = false;
} else {
$grade = reset($grades->items[0]->grades);
}
if ($entries = glossary_get_user_entries($glossary->id, $user->id)) {
$result = new stdClass();
$result->info = count($entries) . ' ' . get_string("entries", "glossary");
$lastentry = array_pop($entries);
$result->time = $lastentry->timemodified;
if ($grade) {
$result->info .= ', ' . get_string('grade') . ': ' . $grade->str_long_grade;
}
return $result;
} else if ($grade) {
$result = new stdClass();
$result->info = get_string('grade') . ': ' . $grade->str_long_grade;
//datesubmitted == time created. dategraded == time modified or time overridden
//if grade was last modified by the user themselves use date graded. Otherwise use date submitted
//TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704
if ($grade->usermodified == $user->id || empty($grade->datesubmitted)) {
$result->time = $grade->dategraded;
} else {
$result->time = $grade->datesubmitted;
}
return $result;
}
return NULL;
}
/**
* @global object
* @param int $glossaryid
* @param int $userid
* @return array
*/
function glossary_get_user_entries($glossaryid, $userid) {
/// Get all the entries for a user in a glossary
global $DB;
return $DB->get_records_sql("SELECT e.*, u.firstname, u.lastname, u.email, u.picture
FROM {glossary} g, {glossary_entries} e, {user} u
WHERE g.id = ?
AND e.glossaryid = g.id
AND e.userid = ?
AND e.userid = u.id
ORDER BY e.timemodified ASC", array($glossaryid, $userid));
}
/**
* Print a detailed representation of what a user has done with
* a given particular instance of this module, for user activity reports.
*
* @global object
* @param object $course
* @param object $user
* @param object $mod
* @param object $glossary
*/
function glossary_user_complete($course, $user, $mod, $glossary) {
global $CFG, $OUTPUT;
require_once("$CFG->libdir/gradelib.php");
$grades = grade_get_grades($course->id, 'mod', 'glossary', $glossary->id, $user->id);
if (!empty($grades->items[0]->grades)) {
$grade = reset($grades->items[0]->grades);
echo $OUTPUT->container(get_string('grade').': '.$grade->str_long_grade);
if ($grade->str_feedback) {
echo $OUTPUT->container(get_string('feedback').': '.$grade->str_feedback);
}
}
if ($entries = glossary_get_user_entries($glossary->id, $user->id)) {
echo '
';
break;
}
}
return true;
}
/**
* @global object
* @param object $log
*/
function glossary_log_info($log) {
global $DB;
return $DB->get_record_sql("SELECT e.*, u.firstname, u.lastname
FROM {glossary_entries} e, {user} u
WHERE e.id = ? AND u.id = ?", array($log->info, $log->userid));
}
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
* @return bool
*/
function glossary_cron () {
return true;
}
/**
* Return grade for given user or all users.
*
* @global object
* @param int $glossaryid id of glossary
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
*/
function glossary_get_user_grades($glossary, $userid=0) {
global $CFG;
require_once($CFG->dirroot.'/rating/lib.php');
$rm = new rating_manager();
$ratingoptions = new stdclass();
//need these to work backwards to get a context id. Is there a better way to get contextid from a module instance?
$ratingoptions->modulename = 'glossary';
$ratingoptions->moduleid = $glossary->id;
$ratingoptions->userid = $userid;
$ratingoptions->aggregationmethod = $glossary->assessed;
$ratingoptions->scaleid = $glossary->scale;
$ratingoptions->itemtable = 'glossary_entries';
$ratingoptions->itemtableusercolumn = 'userid';
return $rm->get_user_grades($ratingoptions);
}
/**
* Return rating related permissions
* @param string $options the context id
* @return array an associative array of the user's rating permissions
*/
function glossary_rating_permissions($options) {
$contextid = $options;
$context = get_context_instance_by_id($contextid);
if (!$context) {
print_error('invalidcontext');
return null;
} else {
return array('view'=>has_capability('mod/glossary:viewrating',$context), 'viewany'=>has_capability('mod/glossary:viewanyrating',$context), 'viewall'=>has_capability('mod/glossary:viewallratings',$context), 'rate'=>has_capability('mod/glossary:rate',$context));
}
}
/**
* Validates a submitted rating
* @param array $params submitted data
* context => object the context in which the rated items exists [required]
* itemid => int the ID of the object being rated
* scaleid => int the scale from which the user can select a rating. Used for bounds checking. [required]
* rating => int the submitted rating
* rateduserid => int the id of the user whose items have been rated. NOT the user who submitted the ratings. 0 to update all. [required]
* aggregation => int the aggregation method to apply when calculating grades ie RATING_AGGREGATE_AVERAGE [optional]
* @return boolean true if the rating is valid. Will throw rating_exception if not
*/
function glossary_rating_validate($params) {
global $DB, $USER;
if (!array_key_exists('itemid', $params)
|| !array_key_exists('context', $params)
|| !array_key_exists('rateduserid', $params)
|| !array_key_exists('scaleid', $params)) {
throw new rating_exception('missingparameter');
}
$glossarysql = "SELECT g.id as gid, g.scale, e.userid as userid, e.approved, e.timecreated, g.assesstimestart, g.assesstimefinish
FROM {glossary_entries} e
JOIN {glossary} g ON e.glossaryid = g.id
WHERE e.id = :itemid";
$glossaryparams = array('itemid'=>$params['itemid']);
if (!$info = $DB->get_record_sql($glossarysql, $glossaryparams)) {
//item doesn't exist
throw new rating_exception('invaliditemid');
}
if ($info->scale != $params['scaleid']) {
//the scale being submitted doesnt match the one in the database
throw new rating_exception('invalidscaleid');
}
if ($info->userid == $USER->id) {
//user is attempting to rate their own glossary entry
throw new rating_exception('nopermissiontorate');
}
if ($info->userid != $params['rateduserid']) {
//supplied user ID doesnt match the user ID from the database
throw new rating_exception('invaliduserid');
}
//check that the submitted rating is valid for the scale
if ($params['rating'] < 0) {
throw new rating_exception('invalidnum');
} else if ($info->scale < 0) {
//its a custom scale
$scalerecord = $DB->get_record('scale', array('id' => -$params['scaleid']));
if ($scalerecord) {
$scalearray = explode(',', $scalerecord->scale);
if ($params['rating'] > count($scalearray)) {
throw new rating_exception('invalidnum');
}
} else {
throw new rating_exception('invalidscaleid');
}
} else if ($params['rating'] > $info->scale) {
//if its numeric and submitted rating is above maximum
throw new rating_exception('invalidnum');
}
if (!$info->approved) {
//item isnt approved
throw new rating_exception('nopermissiontorate');
}
//check the item we're rating was created in the assessable time window
if (!empty($info->assesstimestart) && !empty($info->assesstimefinish)) {
if ($info->timecreated < $info->assesstimestart || $info->timecreated > $info->assesstimefinish) {
throw new rating_exception('notavailable');
}
}
$glossaryid = $info->gid;
$cm = get_coursemodule_from_instance('glossary', $glossaryid);
if (empty($cm)) {
throw new rating_exception('unknowncontext');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
//if the supplied context doesnt match the item's context
if (empty($context) || $context->id != $params['context']->id) {
throw new rating_exception('invalidcontext');
}
return true;
}
/**
* Update activity grades
*
* @global object
* @global object
* @param object $glossary null means all glossaries (with extra cmidnumber property)
* @param int $userid specific user only, 0 means all
*/
function glossary_update_grades($glossary=null, $userid=0, $nullifnone=true) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
if (!$glossary->assessed) {
glossary_grade_item_update($glossary);
} else if ($grades = glossary_get_user_grades($glossary, $userid)) {
glossary_grade_item_update($glossary, $grades);
} else if ($userid and $nullifnone) {
$grade = new stdClass();
$grade->userid = $userid;
$grade->rawgrade = NULL;
glossary_grade_item_update($glossary, $grade);
} else {
glossary_grade_item_update($glossary);
}
}
/**
* Update all grades in gradebook.
*
* @global object
*/
function glossary_upgrade_grades() {
global $DB;
$sql = "SELECT COUNT('x')
FROM {glossary} g, {course_modules} cm, {modules} m
WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
$count = $DB->count_records_sql($sql);
$sql = "SELECT g.*, cm.idnumber AS cmidnumber, g.course AS courseid
FROM {glossary} g, {course_modules} cm, {modules} m
WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('glossaryupgradegrades', 500, true);
$i=0;
foreach ($rs as $glossary) {
$i++;
upgrade_set_timeout(60*5); // set up timeout, may also abort execution
glossary_update_grades($glossary, 0, false);
$pbar->update($i, $count, "Updating Glossary grades ($i/$count).");
}
}
$rs->close();
}
/**
* Create/update grade item for given glossary
*
* @global object
* @param object $glossary object with extra cmidnumber
* @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int, 0 if ok, error code otherwise
*/
function glossary_grade_item_update($glossary, $grades=NULL) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');
$params = array('itemname'=>$glossary->name, 'idnumber'=>$glossary->cmidnumber);
if (!$glossary->assessed or $glossary->scale == 0) {
$params['gradetype'] = GRADE_TYPE_NONE;
} else if ($glossary->scale > 0) {
$params['gradetype'] = GRADE_TYPE_VALUE;
$params['grademax'] = $glossary->scale;
$params['grademin'] = 0;
} else if ($glossary->scale < 0) {
$params['gradetype'] = GRADE_TYPE_SCALE;
$params['scaleid'] = -$glossary->scale;
}
if ($grades === 'reset') {
$params['reset'] = true;
$grades = NULL;
}
return grade_update('mod/glossary', $glossary->course, 'mod', 'glossary', $glossary->id, 0, $grades, $params);
}
/**
* Delete grade item for given glossary
*
* @global object
* @param object $glossary object
*/
function glossary_grade_item_delete($glossary) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');
return grade_update('mod/glossary', $glossary->course, 'mod', 'glossary', $glossary->id, 0, NULL, array('deleted'=>1));
}
/**
* Returns the users with data in one glossary
* (users with records in glossary_entries, students)
*
* @global object
* @param int $glossaryid
* @return array
*/
function glossary_get_participants($glossaryid) {
global $DB;
//Get students
$students = $DB->get_records_sql("SELECT DISTINCT u.id, u.id
FROM {user} u, {glossary_entries} g
WHERE g.glossaryid = ? AND u.id = g.userid", array($glossaryid));
//Return students array (it contains an array of unique users)
return $students;
}
/**
* @global object
* @param int $gloassryid
* @param int $scaleid
* @return bool
*/
function glossary_scale_used ($glossaryid,$scaleid) {
//This function returns if a scale is being used by one glossary
global $DB;
$return = false;
$rec = $DB->get_record("glossary", array("id"=>$glossaryid, "scale"=>-$scaleid));
if (!empty($rec) && !empty($scaleid)) {
$return = true;
}
return $return;
}
/**
* Checks if scale is being used by any instance of glossary
*
* This is used to find out if scale used anywhere
*
* @global object
* @param int $scaleid
* @return boolean True if the scale is used by any glossary
*/
function glossary_scale_used_anywhere($scaleid) {
global $DB;
if ($scaleid and $DB->record_exists('glossary', array('scale'=>-$scaleid))) {
return true;
} else {
return false;
}
}
//////////////////////////////////////////////////////////////////////////////////////
/// Any other glossary functions go here. Each of them must have a name that
/// starts with glossary_
/**
* This function return an array of valid glossary_formats records
* Everytime it's called, every existing format is checked, new formats
* are included if detected and old formats are deleted and any glossary
* using an invalid format is updated to the default (dictionary).
*
* @global object
* @global object
* @return array
*/
function glossary_get_available_formats() {
global $CFG, $DB;
//Get available formats (plugin) and insert (if necessary) them into glossary_formats
$formats = get_list_of_plugins('mod/glossary/formats', 'TEMPLATE');
$pluginformats = array();
foreach ($formats as $format) {
//If the format file exists
if (file_exists($CFG->dirroot.'/mod/glossary/formats/'.$format.'/'.$format.'_format.php')) {
include_once($CFG->dirroot.'/mod/glossary/formats/'.$format.'/'.$format.'_format.php');
//If the function exists
if (function_exists('glossary_show_entry_'.$format)) {
//Acummulate it as a valid format
$pluginformats[] = $format;
//If the format doesn't exist in the table
if (!$rec = $DB->get_record('glossary_formats', array('name'=>$format))) {
//Insert the record in glossary_formats
$gf = new stdClass();
$gf->name = $format;
$gf->popupformatname = $format;
$gf->visible = 1;
$DB->insert_record("glossary_formats",$gf);
}
}
}
}
//Delete non_existent formats from glossary_formats table
$formats = $DB->get_records("glossary_formats");
foreach ($formats as $format) {
$todelete = false;
//If the format in DB isn't a valid previously detected format then delete the record
if (!in_array($format->name,$pluginformats)) {
$todelete = true;
}
if ($todelete) {
//Delete the format
$DB->delete_records('glossary_formats', array('name'=>$format->name));
//Reasign existing glossaries to default (dictionary) format
if ($glossaries = $DB->get_records('glossary', array('displayformat'=>$format->name))) {
foreach($glossaries as $glossary) {
$DB->set_field('glossary','displayformat','dictionary', array('id'=>$glossary->id));
}
}
}
}
//Now everything is ready in glossary_formats table
$formats = $DB->get_records("glossary_formats");
return $formats;
}
/**
* @param bool $debug
* @param string $text
* @param int $br
*/
function glossary_debug($debug,$text,$br=1) {
if ( $debug ) {
echo '' . $text . '';
if ( $br ) {
echo ' ';
}
}
}
/**
*
* @global object
* @param int $glossaryid
* @param string $entrylist
* @param string $pivot
* @return array
*/
function glossary_get_entries($glossaryid, $entrylist, $pivot = "") {
global $DB;
if ($pivot) {
$pivot .= ",";
}
return $DB->get_records_sql("SELECT $pivot id,userid,concept,definition,format
FROM {glossary_entries}
WHERE glossaryid = ?
AND id IN ($entrylist)", array($glossaryid));
}
/**
* @global object
* @global object
* @param object $concept
* @param string $courseid
* @return array
*/
function glossary_get_entries_search($concept, $courseid) {
global $CFG, $DB;
//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))) {
$bypassadmin = 0; //This means YES
}
//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));
$params = array('courseid1'=>$courseid, 'courseid2'=>$courseid, 'conceptlower'=>$conceptlower, 'concept'=>$concept);
return $DB->get_records_sql("SELECT e.*, g.name as glossaryname, cm.id as cmid, cm.course as courseid
FROM {glossary_entries} e, {glossary} g,
{course_modules} cm, {modules} m
WHERE m.name = 'glossary' AND
cm.module = m.id AND
(cm.visible = 1 OR cm.visible = $bypassadmin OR
(cm.course = :courseid1 AND cm.visible = $bypassteacher)) AND
g.id = cm.instance AND
e.glossaryid = g.id AND
( (e.casesensitive != 0 AND LOWER(concept) = :conceptlower) OR
(e.casesensitive = 0 and concept = :concept)) AND
(g.course = :courseid2 OR g.globalglossary = 1) AND
e.usedynalink != 0 AND
g.usedynalink != 0", $params);
}
/**
* @global object
* @global object
* @param object $course
* @param object $course
* @param object $glossary
* @param object $entry
* @param string $mode
* @param string $hook
* @param int $printicons
* @param int $displayformat
* @param bool $printview
* @return mixed
*/
function glossary_print_entry($course, $cm, $glossary, $entry, $mode='',$hook='',$printicons = 1, $displayformat = -1, $printview = false) {
global $USER, $CFG;
$return = false;
if ( $displayformat < 0 ) {
$displayformat = $glossary->displayformat;
}
if ($entry->approved or ($USER->id == $entry->userid) or ($mode == 'approval' and !$entry->approved) ) {
$formatfile = $CFG->dirroot.'/mod/glossary/formats/'.$displayformat.'/'.$displayformat.'_format.php';
if ($printview) {
$functionname = 'glossary_print_entry_'.$displayformat;
} else {
$functionname = 'glossary_show_entry_'.$displayformat;
}
if (file_exists($formatfile)) {
include_once($formatfile);
if (function_exists($functionname)) {
$return = $functionname($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
} else if ($printview) {
//If the glossary_print_entry_XXXX function doesn't exist, print default (old) print format
$return = glossary_print_entry_default($entry, $glossary, $cm);
}
}
}
return $return;
}
/**
* Default (old) print format used if custom function doesn't exist in format
*
* @param object $entry
* @param object $glossary
* @param object $cm
* @return void Output is echo'd
*/
function glossary_print_entry_default ($entry, $glossary, $cm) {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
echo '
';
}
}
/**
* @todo Document this function
*/
function glossary_print_entry_attachment($entry, $cm, $format=NULL, $align="right", $insidetable=true) {
/// valid format values: html : Return the HTML link for the attachment as an icon
/// text : Return the HTML link for tha attachment as text
/// blank : Print the output to the screen
if ($entry->attachment) {
if ($insidetable) {
echo "