Пример #1
0
 */
include_once "fof-main.php";
$items = array();
while (list($key, $val) = each($_POST)) {
    if ($val == "checked") {
        $key = substr($key, 1);
        $items[] = $key;
    }
}
/* update a view's sorting settings, removes the view if it matches user's current default */
if (!empty($_POST['view_order'])) {
    $feed = empty($_POST['view_feed']) ? NULL : $_POST['view_feed'];
    $what = empty($_POST['view_what']) ? NULL : $_POST['view_what'];
    $prefs =& FoF_Prefs::instance();
    $order = $prefs->get('order');
    $tag_ids = fof_db_get_tag_name_map(explode(' ', $what));
    $feed_ids = array_filter(array($feed));
    $settings = fof_db_view_settings_get(fof_current_user(), $tag_ids, $feed_ids);
    $settings['order'] = $_POST['view_order'];
    if ($order == $_POST['view_order']) {
        /* As there's only one view option currently, just remove view entirely if desired order matches default. */
        fof_db_view_expunge(fof_current_user(), $tag_ids, $feed_ids);
        echo '<span title="Your default sort order has been reinstated for viewing this collection of items.">&hearts;</span>';
    } else {
        fof_db_view_settings_set(fof_current_user(), $tag_ids, $feed_ids, $settings);
        echo '<span title="The current sort order will now be used for viewing this collection of items.">&hearts;</span>';
    }
    exit;
}
if (!empty($_POST['deltag'])) {
    fof_untag(fof_current_user(), $_POST['deltag']);
Пример #2
0
/* default to viewing unread items */
if (empty($what)) {
    $what = 'unread';
    /* default to page view only if we defaulted on what to view */
    if (empty($how)) {
        $how = 'paged';
    }
}
$which = isset($_GET['which']) ? $_GET['which'] : NULL;
if (isset($how) && $how == 'paged' && !isset($which)) {
    $which = 0;
}
/*  Sort items as specified in url parameters, or view settings,
or as per user preferences, or descending if something is really amiss.
 */
$view_settings = fof_db_view_settings_get(fof_current_user(), fof_db_get_tag_name_map(explode(' ', $what)), $feed);
if (empty($order)) {
    if (!empty($view_settings['order'])) {
        $order = $view_settings['order'];
    } else {
        $order = $fof_prefs_obj->get('order');
    }
}
if (empty($order)) {
    $order = 'desc';
}
$itemcount = 0;
$statement = fof_db_get_item_count(fof_current_user(), $what, $feed, $search);
while (($row = fof_db_get_row($statement)) !== false) {
    // fof_log('feed:' . $row['feed_id'] . ' count:' . $row['count']);
    $itemcount += $row['count'];
Пример #3
0
/** Store a new tag name, and return its id.
 */
function fof_db_create_tag($tag_name)
{
    global $FOF_TAG_TABLE;
    global $fof_connection;
    fof_trace();
    $query = "INSERT INTO {$FOF_TAG_TABLE} (tag_name) VALUES (:tag_name)";
    $statement = $fof_connection->prepare($query);
    $statement->bindValue(':tag_name', $tag_name);
    $result = $statement->execute();
    $tag_id = $fof_connection->lastInsertId();
    /* Invalidate any currently-loaded tag maps. */
    fof_db_get_tag_id_map(null, TRUE);
    fof_db_get_tag_name_map(null, TRUE);
    return $tag_id;
}
Пример #4
0
function fof_untag($user_id, $tag)
{
    $tag_ids = fof_db_get_tag_name_map(array($tag));
    if (empty($tag_ids)) {
        fof_log('non-existent tag "' . $tag . '"');
        return false;
    }
    return fof_db_untag_user_all($user_id, $tag_ids);
}