<?php  // $Id: user.php,v 1.1.2.2 2008/03/18 08:29:20 scyrma Exp $

require_once('../config.php');
require_once('lib.php');

$action = optional_param('action', '', PARAM_ALPHA);
$id = optional_param('id', 0, PARAM_INT);
$tag = optional_param('tag', '', PARAM_TAG);
// (Debug024): blogの編集時にコースIDを渡していない箇所の修正 (2009/07/21)
// (Debug024): ここから追加
$courseid = optional_param('courseid', SITEID, PARAM_INT);
course_setup($courseid);
if (isset($COURSE->id) && ($COURSE->id != SITEID)) $hcourseid = '&amp;courseid='.$COURSE->id;
    else                                           $hcourseid = '';
// (Debug024): ここまで追加
        
require_login();

if (empty($CFG->usetags)) {
    error('Tags are disabled!');
}

if (isguestuser()) {
    print_error('noguest');
}

if (!confirm_sesskey()) {
    print_error('sesskey');
}


switch ($action) {
    case 'addinterest':
        if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
            $tag = tag_get_name($id);
        } 
        
        tag_set_add('user', $USER->id, $tag);

// (Debug024): ここから修正
//      redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag));
        redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag). $hcourseid);
// (Debug024): ここまで修正
        break;

    case 'removeinterest':
        if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
            $tag = tag_get_name($id);
        } 

        tag_set_delete('user', $USER->id, $tag);

// (Debug024): ここから修正
//      redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag));
        redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag). $hcourseid);
// (Debug024): ここまで修正
        break;

    case 'flaginappropriate':
        
        tag_set_flag(tag_get_id($tag));
        
// (Debug024): ここから修正
//      redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag), get_string('responsiblewillbenotified', 'tag'));
        redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag). $hcourseid, get_string('responsiblewillbenotified', 'tag'));
// (Debug024): ここまで修正
        break;

    default:
        error('No action was specified');
        break;
}

?>
