New module: Label.
[moodle.git] / mod / label / lib.php
CommitLineData
2c5c3e62 1<?PHP // $Id$
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
14 $label->name = strip_tags($label->content);
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.
28
29 $label->name = strip_tags($label->content);
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
58function label_user_outline($course, $user, $mod, $label) {
59/// Return a small object with summary information about what a
60/// user has done with a given particular instance of this module
61/// Used for user activity reports.
62/// $return->time = the time they did it
63/// $return->info = a short text description
64
65 return NULL;
66}
67
68function label_user_complete($course, $user, $mod, $label) {
69/// Print a detailed representation of what a user has done with
70/// a given particular instance of this module, for user activity reports.
71
72 return false;
73}
74
75?>