Vanilla commit.
[tinybbs.git] / watchlist.php
blob13fe6d771005510e9b7a18cfb0f43884dbd819f3
1 <?php
3 require('includes/header.php');
4 force_id();
5 update_activity('watchlist');
6 $page_title = 'Your watchlist';
8 if( is_array($_POST['rejects']) )
10 $remove_topic = $link->prepare('DELETE FROM watchlists WHERE uid = ? AND topic_id = ?');
11 foreach($_POST['rejects'] as $reject_id)
13 $remove_topic->bind_param('si', $_SESSION['UID'], $reject_id);
14 $remove_topic->execute();
16 $remove_topic->close();
18 $_SESSION['notice'] = 'Selected topics unwatched.';
21 echo '<form name="fuck_off" action="" method="post">';
23 $stmt = $link->prepare('SELECT watchlists.topic_id, topics.headline, topics.replies, topics.visits, topics.time FROM watchlists INNER JOIN topics ON watchlists.topic_id = topics.id WHERE watchlists.uid = ? ORDER BY last_post DESC');
24 $stmt->bind_param('s', $_SESSION['UID']);
25 $stmt->execute();
26 $stmt->bind_result($topic_id, $topic_headline, $topic_replies, $topic_visits, $topic_time);
28 $topics = new table();
29 $topic_column = '<script type="text/javascript"> document.write(\'<input type="checkbox" name="master_checkbox" class="inline" onclick="checkOrUncheckAllCheckboxes()" title="Check/uncheck all" /> \');</script>Topic';
30 $columns = array
32 $topic_column,
33 'Replies',
34 'Visits',
35 'Age ▼'
37 $topics->define_columns($columns, $topic_column);
38 $topics->add_td_class($topic_column, 'topic_headline');
40 while($stmt->fetch())
42 $values = array
44 '<input type="checkbox" name="rejects[]" value="' . $topic_id . '" class="inline" /> <a href="/topic/' . $topic_id . '">' . htmlspecialchars($topic_headline) . '</a>',
45 replies($topic_id, $topic_replies),
46 format_number($topic_visits),
47 '<span class="help" title="' . format_date($topic_time) . '">' . calculate_age($topic_time) . '</span>'
50 $topics->row($values);
52 $stmt->close();
53 $num_topics_fetched = $topics->num_rows_fetched;
54 echo $topics->output();
56 if($num_topics_fetched !== 0)
58 echo '<div class="row"><input type="submit" value="Unwatch selected" onclick="return confirm(\'Really remove selected topic(s) from your watchlist?\');" class="inline" /></div>';
60 echo '</form>';
62 require('includes/footer.php');