Skip to content

Commit

Permalink
Changes to user profile pages to edit/display interest tags
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Jul 31, 2007
1 parent d5581d9 commit 1e1c51a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
15 changes: 14 additions & 1 deletion user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
error('User ID was incorrect');
}

//user interests separated by commas
if (!empty($CFG->usetags)) {
require_once($CFG->dirroot.'/tag/lib.php');
$user->interests = tag_names_csv(get_item_tags('user',$userid));
}

// remote users cannot be edited
if (is_mnet_remote_user($user)) {
redirect($CFG->wwwroot . "/user/view.php?course={$course->id}");
Expand Down Expand Up @@ -65,11 +71,13 @@
//Load custom profile fields data
profile_load_data($user);


//create form
$userform = new user_edit_form();
$userform->set_data($user);

if ($usernew = $userform->get_data()) {

add_to_log($course->id, 'user', 'update', "view.php?id=$user->id&course=$course->id", '');

$authplugin = get_auth_plugin($user->auth);
Expand All @@ -90,7 +98,12 @@

//update preferences
useredit_update_user_preference($usernew);


//update interests
if (!empty($CFG->usetags)) {
useredit_update_interests($usernew, $usernew->interests);
}

//update user picture
if (!empty($CFG->gdversion) and empty($CFG->disableuserimages)) {
useredit_update_picture($usernew, $userform);
Expand Down
13 changes: 12 additions & 1 deletion user/editadvanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
//Load custom profile fields data
profile_load_data($user);

//user interests separated by commas
if (!empty($CFG->usetags)) {
require_once($CFG->dirroot.'/tag/lib.php');
$user->interests = tag_names_csv(get_item_tags('user',$userid));
}

//create form
$userform = new user_editadvanced_form();
$userform->set_data($user);
Expand Down Expand Up @@ -108,6 +114,11 @@
//update preferences
useredit_update_user_preference($usernew);

// update tags
if (!empty($CFG->usetags)) {
useredit_update_interests($usernew, $usernew->interests);
}

//update user picture
if (!empty($CFG->gdversion)) {
useredit_update_picture($usernew, $userform);
Expand All @@ -116,7 +127,7 @@
// update mail bounces
useredit_update_bounces($user, $usernew);

/// update forum track preference
// update forum track preference
useredit_update_trackforums($user, $usernew);

// save custom profile fields data
Expand Down
13 changes: 13 additions & 0 deletions user/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ function useredit_update_trackforums($user, $usernew) {
}
}

function useredit_update_interests($user, $cvs_tag_names)
{
update_item_tags('user', $user->id, $cvs_tag_names);
}

function useredit_shared_definition(&$mform) {
global $CFG;

Expand Down Expand Up @@ -216,6 +221,12 @@ function useredit_shared_definition(&$mform) {

}

if( !empty($CFG->usetags)) {
$mform->addElement('header', 'moodle_interests', get_string('interests'));
$mform->addElement('static', 'helptextinterests', '' , get_string('enteryourinterests'));
$mform->addElement('textarea', 'interests', get_string('interests'), 'cols="45" rows="3"');
}

/// Moodle optional fields
$mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
$mform->setAdvanced('moodle_optional');
Expand Down Expand Up @@ -255,6 +266,8 @@ function useredit_shared_definition(&$mform) {

$mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
$mform->setType('address', PARAM_MULTILANG);


}

?>
14 changes: 14 additions & 0 deletions user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

require_once("../config.php");
require_once($CFG->dirroot.'/user/profile/lib.php');
require_once($CFG->dirroot.'/tag/lib.php');

$id = optional_param('id', 0, PARAM_INT); // user id
$course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site)
$enable = optional_param('enable', ''); // enable email
Expand Down Expand Up @@ -371,6 +373,18 @@
}
/// End of printing groups

/// Printing Interests
if( !empty($CFG->usetags)) {
$interests = get_item_tags('user', $user->id);

$instereststr = tag_links_csv($interests);

if ($interests) {
print_row(get_string('interests').": ",rtrim($instereststr));
}
}
/// End of Printing Interests

echo "</table>";

echo "</td></tr></table>";
Expand Down

0 comments on commit 1e1c51a

Please sign in to comment.