Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / mod / label / lib.php
blobb55a66055e051075a0defc08150d4263ba94d4a0
1 <?php // $Id$
3 /// Library of functions and constants for module label
6 define("LABEL_MAX_NAME_LENGTH", 50);
8 function 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 $textlib = textlib_get_instance();
15 $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
16 if ($textlib->strlen($label->name) > LABEL_MAX_NAME_LENGTH) {
17 $label->name = $textlib->substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";
19 $label->timemodified = time();
21 return insert_record("label", $label);
25 function 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.
29 $textlib = textlib_get_instance();
31 $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true)));
32 if ($textlib->strlen($label->name) > LABEL_MAX_NAME_LENGTH) {
33 $label->name = $textlib->substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";
35 $label->timemodified = time();
36 $label->id = $label->instance;
38 return update_record("label", $label);
42 function 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.
47 if (! $label = get_record("label", "id", "$id")) {
48 return false;
51 $result = true;
53 if (! delete_records("label", "id", "$label->id")) {
54 $result = false;
57 return $result;
60 function label_get_participants($labelid) {
61 //Returns the users with data in one resource
62 //(NONE, but must exist on EVERY mod !!)
64 return false;
67 function 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
74 $info = NULL;
76 if ($label = get_record("label", "id", $coursemodule->instance)) {
77 $info->extra = urlencode($label->content);
80 return $info;
83 function label_get_view_actions() {
84 return array();
87 function label_get_post_actions() {
88 return array();
91 function label_get_types() {
92 $types = array();
94 $type = new object();
95 $type->modclass = MOD_CLASS_RESOURCE;
96 $type->type = "label";
97 $type->typestr = get_string('resourcetypelabel', 'resource');
98 $types[] = $type;
100 return $types;