blog / tags: MDL-17900 Use the new tags field type to tag users' interests.
authortjhunt <tjhunt>
Fri, 16 Jan 2009 07:14:39 +0000 (07:14 +0000)
committertjhunt <tjhunt>
Fri, 16 Jan 2009 07:14:39 +0000 (07:14 +0000)
user/edit.php
user/editadvanced.php
user/editlib.php

index 15172d3d2a3004a72a98e140124d42573836bcc3..0caeb37395be486d6ac1c0518ff026c615c47af9 100644 (file)
@@ -43,7 +43,7 @@
     // User interests separated by commas
     if (!empty($CFG->usetags)) {
         require_once($CFG->dirroot.'/tag/lib.php');
-        $user->interests = tag_get_tags_csv('user', $user->id, TAG_RETURN_TEXT);
+        $user->interests = tag_get_tags_array('user', $id);
     }
 
     // remote users cannot be edited
index 6c4af3137477cce71041e734fbadc1b7eb627528..6236facd7320fc48e89ed1f89e76616a17bb072d 100644 (file)
     //Load custom profile fields data
     profile_load_data($user);
 
-    //user interests separated by commas
+    //User interests
     if (!empty($CFG->usetags)) {
         require_once($CFG->dirroot.'/tag/lib.php');
-        $user->interests = tag_get_tags_csv('user', $id, TAG_RETURN_TEXT); // formslib uses htmlentities itself
+        $user->interests = tag_get_tags_array('user', $id);
     }
 
     //create form
index c9c1a596fc715b3d1a149b1196d228b4ac618e61..aaa4a70936cdbd572d2ca426d7f9346280507dad 100644 (file)
@@ -70,8 +70,8 @@ function useredit_update_trackforums($user, $usernew) {
     }
 }
 
-function useredit_update_interests($user, $csv_tag_names) {
-    tag_set('user', $user->id, explode(',', $csv_tag_names));
+function useredit_update_interests($user, $interests) {
+    tag_set('user', $user->id, $interests);
 }
 
 function useredit_shared_definition(&$mform) {
@@ -248,11 +248,10 @@ function useredit_shared_definition(&$mform) {
 
     }
 
-    if ( !empty($CFG->usetags) && has_capability('moodle/tag:create', get_context_instance(CONTEXT_SYSTEM)) ) {
+    if (!empty($CFG->usetags)) {
         $mform->addElement('header', 'moodle_interests', get_string('interests'));
-        $mform->addElement('textarea', 'interests', get_string('interestslist'), 'cols="45" rows="3"');
-        $mform->setHelpButton('interests', array('interestslist', get_string('helpinterestslist'),
-                          false, true, false));
+        $mform->addElement('tags', 'interests', get_string('interestslist'), array('display' => 'noofficial'));
+        $mform->setHelpButton('interests', array('interestslist', get_string('helpinterestslist'), false, true, false));
     }
 
     /// Moodle optional fields