Possible fix to MDL-12093 : give window without heading and navigation special css...
[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
73
9d361034 74 $info = NULL;
75
8dddba42 76 if ($label = get_record("label", "id", $coursemodule->instance)) {
9d361034 77 $info->extra = urlencode($label->content);
8dddba42 78 }
79
9d361034 80 return $info;
8dddba42 81}
82
f3221af9 83function label_get_view_actions() {
84 return array();
85}
86
87function label_get_post_actions() {
88 return array();
89}
90
89bfeee0 91function label_get_types() {
92 $types = array();
93
94 $type = new object();
95 $type->modclass = MOD_CLASS_RESOURCE;
96 $type->type = "label";
97 $type->typestr = get_string('resourcetypelabel', 'resource');
98 $types[] = $type;
99
100 return $types;
101}
2c5c3e62 102?>