Example #1
0
function save_prefs_adv_autotag($post)
{
    if (!isset($post['aa_autotag']) && !isset($post['aa_apply_u']) && !isset($post['aa_apply_a'])) {
        return;
    }
    global $prefs;
    foreach ($post['aa_pref'] as $key => $val) {
        if (empty($val['filter']) || empty($val['tag'])) {
            unset($post['aa_pref'][$key]);
        }
    }
    usort($post['aa_pref'], '_cb_prefsort');
    $prefs->set('adv_autotag', array_values($post['aa_pref']));
    $prefs->save();
    // apply?
    if (isset($post['aa_apply_u']) || isset($post['aa_apply_a'])) {
        if (isset($post['aa_apply_u'])) {
            $items = fof_get_items(fof_current_user());
        } else {
            $items = fof_get_items(fof_current_user(), null, 'all');
        }
        foreach ($items as $item) {
            $tags = fof_adv_autotag(null, $item['item_title'], $item['item_content'], $item);
            if (count($tags)) {
                fof_tag_item(fof_current_user(), $item['item_id'], $tags);
            }
        }
    }
}
Example #2
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);
    }
}
Example #3
0
function fof_apply_plugin_tags($feed_id, $item_id = NULL, $user_id = NULL)
{
    $users = array();
    if ($user_id) {
        $users[] = $user_id;
    } else {
        $result = fof_get_subscribed_users($feed_id);
        while ($row = fof_db_get_row($result)) {
            $users[] = $row['user_id'];
        }
    }
    $items = array();
    if ($item_id) {
        $items[] = fof_db_get_item($user_id, $item_id);
    } else {
        $result = fof_db_get_items($user_id, $feed_id, $what = "all", NULL, NULL);
        foreach ($result as $r) {
            $items[] = $r;
        }
    }
    $userdata = fof_get_users();
    foreach ($users as $user) {
        fof_log("tagging for {$user}");
        global $fof_tag_prefilters;
        foreach ($fof_tag_prefilters as $plugin => $filter) {
            fof_log("considering {$plugin} {$filter}");
            if (!$userdata[$user]['prefs']['plugin_' . $plugin]) {
                foreach ($items as $item) {
                    $tags = $filter($item['item_link'], $item['item_title'], $item['item_content']);
                    fof_tag_item($user, $item['item_id'], $tags);
                }
            }
        }
    }
}