MDL-14679 fixed references to mod.html
[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,
7cac0c4b 10/// (defined by the form in mod_form.php) this function
2c5c3e62 11/// will create a new instance and return the id number
12/// of the new instance.
a8f5a8a2 13 $textlib = textlib_get_instance();
2c5c3e62 14
2bf5b5d4 15 $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
810944af 16 if ($textlib->strlen($label->name) > LABEL_MAX_NAME_LENGTH) {
17 $label->name = $textlib->substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";
2c5c3e62 18 }
19 $label->timemodified = time();
20
21 return insert_record("label", $label);
22}
23
24
25function label_update_instance($label) {
26/// Given an object containing all the necessary data,
7cac0c4b 27/// (defined by the form in mod_form.php) this function
2c5c3e62 28/// will update an existing instance with new data.
a8f5a8a2 29 $textlib = textlib_get_instance();
2bf5b5d4 30
31 $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
810944af 32 if ($textlib->strlen($label->name) > LABEL_MAX_NAME_LENGTH) {
33 $label->name = $textlib->substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";
2c5c3e62 34 }
35 $label->timemodified = time();
36 $label->id = $label->instance;
37
38 return update_record("label", $label);
39}
40
41
42function label_delete_instance($id) {
43/// Given an ID of an instance of this module,
44/// this function will permanently delete the instance
45/// and any data that depends on it.
46
47 if (! $label = get_record("label", "id", "$id")) {
48 return false;
49 }
50
51 $result = true;
52
53 if (! delete_records("label", "id", "$label->id")) {
54 $result = false;
55 }
56
57 return $result;
58}
59
2b9f0625 60function label_get_participants($labelid) {
61//Returns the users with data in one resource
2185622e 62//(NONE, but must exist on EVERY mod !!)
2b9f0625 63
64 return false;
65}
66
f36cbf1d 67/**
68 * Given a course_module object, this function returns any
69 * "extra" information that may be needed when printing
70 * this activity in a course listing.
71 * See get_array_of_activities() in course/lib.php
72 */
8dddba42 73function label_get_coursemodule_info($coursemodule) {
1ea543df 74 if ($label = get_record('label', 'id', $coursemodule->instance, '', '', '', '', 'id, content, name')) {
dd97c328 75 $info = new object();
1ea543df 76 $info->extra = urlencode($label->content);
77 $info->name = urlencode($label->name);
dd97c328 78 return $info;
79 } else {
80 return null;
81 }
8dddba42 82}
83
f3221af9 84function label_get_view_actions() {
85 return array();
86}
87
88function label_get_post_actions() {
89 return array();
90}
91
89bfeee0 92function label_get_types() {
93 $types = array();
94
95 $type = new object();
96 $type->modclass = MOD_CLASS_RESOURCE;
97 $type->type = "label";
98 $type->typestr = get_string('resourcetypelabel', 'resource');
99 $types[] = $type;
100
101 return $types;
102}
0b5a80a1 103
104/**
105 * This function is used by the reset_course_userdata function in moodlelib.
106 * @param $data the data submitted from the reset course.
107 * @return array status array
108 */
109function label_reset_userdata($data) {
110 return array();
111}
112
2c5c3e62 113?>