|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 require_once('../config.php'); 00004 require_once('lib.php'); 00005 00006 $action = optional_param('action', '', PARAM_ALPHA); 00007 $id = optional_param('id', 0, PARAM_INT); 00008 $tag = optional_param('tag', '', PARAM_TAG); 00009 00010 require_login(); 00011 00012 if (empty($CFG->usetags)) { 00013 print_error('tagdisabled'); 00014 } 00015 00016 if (isguestuser()) { 00017 print_error('noguest'); 00018 } 00019 00020 if (!confirm_sesskey()) { 00021 print_error('sesskey'); 00022 } 00023 00024 00025 switch ($action) { 00026 case 'addinterest': 00027 if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..) 00028 $tag = tag_get_name($id); 00029 } 00030 00031 tag_set_add('user', $USER->id, $tag); 00032 00033 redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag)); 00034 break; 00035 00036 case 'removeinterest': 00037 if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..) 00038 $tag = tag_get_name($id); 00039 } 00040 00041 tag_set_delete('user', $USER->id, $tag); 00042 00043 redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag)); 00044 break; 00045 00046 case 'flaginappropriate': 00047 00048 $tagid = tag_get_id($tag); 00049 // Add flaging action to logs 00050 add_to_log(SITEID, 'tag', 'flag', 'index.php?id='. $tagid, $tagid, '', $USER->id); 00051 00052 tag_set_flag($tagid); 00053 00054 redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag), get_string('responsiblewillbenotified', 'tag')); 00055 break; 00056 00057 default: 00058 print_error('unknowaction'); 00059 break; 00060 }