Ejemplo n.º 1
0
<?php

/*
 * This file is part of FEED ON FEEDS - http://feedonfeeds.com/
 *
 * add-tag.php - adds (or removes) a tag to an item
 *
 *
 * Copyright (C) 2004-2007 Stephen Minutillo
 * steve@minutillo.com - http://minutillo.com/steve/
 *
 * Distributed under the GPL - see LICENSE
 *
 */
include_once "fof-main.php";
$tags = $_GET['tag'];
$item = $_GET['item'];
$remove = $_GET['remove'];
foreach (explode(" ", $tags) as $tag) {
    if ($remove == 'true') {
        fof_untag_item(fof_current_user(), $item, $tag);
    } else {
        fof_tag_item(fof_current_user(), $item, $tag);
    }
}
Ejemplo n.º 2
0
function fof_tag_item($user_id, $item_id, $tag)
{
    $tags = is_array($tag) ? $tag : array($tag);
    foreach ($tags as $tag) {
        // remove tag, if it starts with '-'
        if ($tag[0] == '-') {
            fof_untag_item($user_id, $item_id, substr($tag, 1));
            continue;
        }
        $tag_id = fof_db_get_tag_by_name($tag);
        if ($tag_id == NULL) {
            $tag_id = fof_db_create_tag($tag);
        }
        fof_db_tag_items($user_id, $tag_id, $item_id);
    }
}