function fof_sidebar_tags_default() { global $sharing; global $what_a; $unread_id = fof_db_get_tag_by_name('unread'); $star_id = fof_db_get_tag_by_name('star'); $folded_id = fof_db_get_tag_by_name('folded'); $tags = fof_get_tags(fof_current_user()); $taglines = array(); $n = 0; foreach ($tags as $tag) { $tag_id = $tag['tag_id']; if ($tag_id == $unread_id || $tag_id == $star_id || $tag_id == $folded_id) { continue; } $tagline = ''; $tag_name = $tag['tag_name']; $tag_name_html = htmlentities($tag_name); $tag_name_json = htmlentities(json_encode($tag_name), ENT_QUOTES); $count = $tag['count']; $unread = $tag['unread']; $tag_classes = array(); if (++$n % 2) { $tag_classes[] = 'odd-row'; } if (in_array($tag_name, $what_a)) { $tag_classes[] = 'current-view'; } $tag_classes = implode(' ', $tag_classes); if (!empty($tag_classes)) { $tag_classes = ' class="' . $tag_classes . '"'; } $tagline .= ' <tr' . $tag_classes . '>'; $tagline .= '<td class="unread">'; if ($unread) { $tagline .= '<a class="unread" href="' . fof_url('.', array('what' => "{$tag_name} unread", 'how' => 'paged')) . "\">{$unread}</a>/"; } $tagline .= '<a href="' . fof_url('.', array('what' => $tag_name, 'how' => 'paged')) . "\">{$count}</a>"; $tagline .= '</td>'; $tagline .= '<td class="title"><b><a href="' . fof_url('.', array('what' => $tag_name, 'how' => 'paged')) . '">' . $tag_name_html . '</a></b></td>'; $tagline .= '<td class="controls"><a href="#" title="untag all items" onclick="return sb_del_tag_conf(' . $tag_name_json . ');">[x]</a></td>'; if ($sharing == 'all_tagged') { $tagline .= '<td class="sharing"><a href="' . fof_url('./shared.php', array('user' => $fof_user_id, 'which' => $tag_name, 'how' => 'paged')) . '">[' . $tag_name_html . ']</a>'; } $tagline .= '</tr>'; $taglines[] = $tagline; } if (!empty($taglines)) { ?> <div id="tags"> <table cellspacing="0" cellpadding="1" border="0" id="taglist"> <tr class="heading"><td><span class="unread">#</span></td><td class="title">tag name</td><td class="controls">untag</td><?php if ($sharing == 'all_tagged') { echo '<td class="sharing">shared page</td>'; } ?> </tr> <?php echo implode("\n", $taglines); ?> </table> </div> <!--tags end--> <?php } ?> <?php }
/* update one feed, return replacement sidebar feed list content */ if (!empty($_POST['update_feedid'])) { list($count, $error) = fof_update_feed($_POST['update_feedid']); if (!empty($error)) { //header('Status: 500'); echo '<img class="feed-icon" src="' . $fof_asset['alert_icon'] . '" title="' . htmlentities($error, ENT_QUOTES) . '" />'; } else { $feed_row = fof_get_feed(fof_current_user(), $_POST['update_feedid']); echo fof_render_feed_row($feed_row); } exit; } /* returns a script block which updates a list of the subscribed sources for a tag */ if (!empty($_POST['update_tag_sources'])) { fof_set_content_type('application/javascript'); $tag_id = fof_db_get_tag_by_name($_POST['update_tag_sources']); $subs = fof_db_subscriptions_by_tags(fof_current_user()); /* FIXME: check timeouts, like below */ if (!empty($subs[$tag_id])) { echo 'pendingUpdates.add(' . json_encode($subs[$tag_id]) . ');'; } exit; } /* returns a script block which updates all updatable subscribed feeds */ if (!empty($_POST['update_subscribed_sources'])) { fof_set_content_type('application/javascript'); $now = time(); $timeout = $fof_prefs_obj->admin_prefs['manualtimeout'] * 60; $sources = array(); $statement = fof_db_get_subscriptions(fof_current_user(), true); while (($feed = fof_db_get_row($statement)) !== false) {
function fof_untag($user_id, $tag) { $tag_id = fof_db_get_tag_by_name($user_id, $tag); $result = fof_db_get_items($user_id, $feed_id, $tag, NULL, NULL); foreach ($result as $r) { $items[] = $r['item_id']; } fof_db_untag_items($user_id, $tag_id, $items); }
function fof_db_mark_item_unread($users, $item_id) { global $FOF_ITEM_TAG_TABLE; global $fof_connection; fof_trace(); if (count($users) == 0) { return; } $tag_id = fof_db_get_tag_by_name('unread'); /* This query will need to be changed to work with a driver other than MySQL or SQLite. It simply needs to be able to insert, and ignore existing row conflicts. Perhaps someone versed in SQL has suggestions. */ if (defined('USE_SQLITE')) { $query = "INSERT OR IGNORE INTO {$FOF_ITEM_TAG_TABLE} (user_id, tag_id, item_id) VALUES (:user_id, :tag_id, :item_id)"; $statement = $fof_connection->prepare($query); $statement->bindValue(':tag_id', $tag_id); $statement->bindValue(':item_id', $item_id); $fof_connection->beginTransaction(); foreach ($users as $user_id) { $statement->bindValue(':user_id', $user_id); $result = $statement->execute(); $statement->closeCursor(); } $fof_connection->commit(); return; } if (defined('USE_MYSQL')) { $values = array(); $item_id_q = $fof_connection->quote($item_id); foreach ($users as $user) { $user_id_q = $fof_connection->quote($user); $values[] = "( {$user_id_q}, {$tag_id}, {$item_id_q} )"; } $query = "INSERT IGNORE INTO {$FOF_ITEM_TAG_TABLE} (user_id, tag_id, item_id) VALUES " . implode(', ', $values); $result = $fof_connection->exec($query); return; } }
function fof_untag_item($user_id, $item_id, $tag) { $tag_id = fof_db_get_tag_by_name($tag); fof_db_untag_items($user_id, $tag_id, $item_id); }