MDL-12945 disabled mods are not returned from get_course_mods() anymore, the results...
[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.
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,
27/// (defined by the form in mod.html) this function
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
8dddba42 67function label_get_coursemodule_info($coursemodule) {
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///
72/// See get_array_of_activities() in course/lib.php
dd97c328 73 if ($label = get_record("label", "id", $coursemodule->instance)) {
74 $info = new object();
75 $info->extra = urlencode($label->content);
76 return $info;
77 } else {
78 return null;
79 }
8dddba42 80}
81
f3221af9 82function label_get_view_actions() {
83 return array();
84}
85
86function label_get_post_actions() {
87 return array();
88}
89
89bfeee0 90function label_get_types() {
91 $types = array();
92
93 $type = new object();
94 $type->modclass = MOD_CLASS_RESOURCE;
95 $type->type = "label";
96 $type->typestr = get_string('resourcetypelabel', 'resource');
97 $types[] = $type;
98
99 return $types;
100}
0b5a80a1 101
102/**
103 * This function is used by the reset_course_userdata function in moodlelib.
104 * @param $data the data submitted from the reset course.
105 * @return array status array
106 */
107function label_reset_userdata($data) {
108 return array();
109}
110
2c5c3e62 111?>