Exemplo n.º 1
0
require_once '../tag/lib.php';
$action = optional_param('action', '', PARAM_ALPHA);
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':
        $id = optional_param('id', 0, PARAM_INT);
        $name = optional_param('name', '', PARAM_TEXT);
        if (empty($name) && $id) {
            $name = tag_name($id);
        }
        tag_an_item('user', $USER->id, $name);
        if (!empty($name) && !$id) {
            $id = tag_id(tag_normalize($name));
        }
        redirect($CFG->wwwroot . '/tag/index.php?id=' . $id);
        break;
    case 'flaginappropriate':
        $id = required_param('id', PARAM_INT);
        tag_flag_inappropriate($id);
        redirect($CFG->wwwroot . '/tag/index.php?id=' . $id, get_string('responsiblewillbenotified', 'tag'));
        break;
}
Exemplo n.º 2
0
        } else {
            if (!empty($instanceid)) {
                $instance = blocks_find_instance($instanceid, $pageblocks);
                blocks_execute_action($PAGE, $pageblocks, strtolower($blockaction), $instance);
            }
        }
        // This re-query could be eliminated by judicious programming in blocks_execute_action(),
        // but I'm not sure if it's worth the complexity increase...
        $pageblocks = blocks_get_by_page($PAGE);
    }
    $missingblocks = blocks_get_missing($PAGE, $pageblocks);
}
if (!empty($tagid)) {
    $taginstance = get_record('tag', 'id', $tagid);
} elseif (!empty($tag)) {
    $taginstance = tag_id($tag);
}
/// navigations
/// site blogs - sitefullname -> blogs -> (?tag)
/// course blogs - sitefullname -> course fullname ->blogs ->(?tag)
/// group blogs - sitefullname -> course fullname ->group ->(?tag)
/// user blogs - sitefullname -> (?coursefullname) -> participants -> blogs -> (?tag)
$blogstring = get_string('blogs', 'blog');
$tagstring = get_string('tag');
// needed also for user tabs later
if (!($course = get_record('course', 'id', $courseid))) {
    error('Wrong course id');
}
$navlinks = array();
/// This is very messy atm.
switch ($filtertype) {
Exemplo n.º 3
0
/**
 * In a comma separated string of ids or names of tags, replaces all tag names with their correspoding ids
 *
 * Ex:
 *  Suppose the DB contains only the following entries in the tags table:
 *      id    name
 *      10    moodle
 *      12    science
 *      22    education
 *
 * tag_id_from_string('moodle, 12, education, programming, 33, 11')
 *    will return '10,12,22,,33,11'
 *
 * This is a helper function used by functions of this API to process function arguments ($tag_name_or_id)
 *
 * @param string $tag_names_or_ids_csv comma separated **normalized** names or ids of tags
 * @return int comma separated ids of the tags
 */
function tag_id_from_string($tag_names_or_ids_csv)
{
    $tag_names_or_ids = explode(',', $tag_names_or_ids_csv);
    $tag_ids = array();
    foreach ($tag_names_or_ids as $name_or_id) {
        if (is_numeric($name_or_id)) {
            $tag_ids[] = trim($name_or_id);
        } elseif (is_string($name_or_id)) {
            $tag_ids[] = tag_id($name_or_id);
        }
    }
    $tag_ids_csv = implode(',', $tag_ids);
    $tag_ids_csv = str_replace(' ', '', $tag_ids_csv);
    return $tag_ids_csv;
}