Merged from MOODLE_15_STABLE: merging check_db_compat function for backwards compatab...
[moodle.git] / mod / label / lib.php
CommitLineData
41905731 1<?php // $Id$
2c5c3e62 2
3/// Library of functions and constants for module label
4
5
6define("LABEL_MAX_NAME_LENGTH", 50);
7
8function label_add_instance($label) {
9/// Given an object containing all the necessary data,
10/// (defined by the form in mod.html) this function
11/// will create a new instance and return the id number
12/// of the new instance.
13
2bf5b5d4 14 $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
2c5c3e62 15 if (strlen($label->name) > LABEL_MAX_NAME_LENGTH) {
16 $label->name = substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";
17 }
18 $label->timemodified = time();
19
20 return insert_record("label", $label);
21}
22
23
24function label_update_instance($label) {
25/// Given an object containing all the necessary data,
26/// (defined by the form in mod.html) this function
27/// will update an existing instance with new data.
2bf5b5d4 28
29 $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
2c5c3e62 30 if (strlen($label->name) > LABEL_MAX_NAME_LENGTH) {
31 $label->name = substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";
32 }
33 $label->timemodified = time();
34 $label->id = $label->instance;
35
36 return update_record("label", $label);
37}
38
39
40function label_delete_instance($id) {
41/// Given an ID of an instance of this module,
42/// this function will permanently delete the instance
43/// and any data that depends on it.
44
45 if (! $label = get_record("label", "id", "$id")) {
46 return false;
47 }
48
49 $result = true;
50
51 if (! delete_records("label", "id", "$label->id")) {
52 $result = false;
53 }
54
55 return $result;
56}
57
2b9f0625 58function label_get_participants($labelid) {
59//Returns the users with data in one resource
2185622e 60//(NONE, but must exist on EVERY mod !!)
2b9f0625 61
62 return false;
63}
64
8dddba42 65function label_get_coursemodule_info($coursemodule) {
66/// Given a course_module object, this function returns any
67/// "extra" information that may be needed when printing
68/// this activity in a course listing.
69///
70/// See get_array_of_activities() in course/lib.php
71
9d361034 72 $info = NULL;
73
8dddba42 74 if ($label = get_record("label", "id", $coursemodule->instance)) {
9d361034 75 $info->extra = urlencode($label->content);
8dddba42 76 }
77
9d361034 78 return $info;
8dddba42 79}
80
2c5c3e62 81?>