3 function bookmark_add($zid, $uid)
5 $query = sprintf("INSERT INTO bookmarks (uid,zeitung) VALUES (%d,%d)",
8 # Ignore potentially existing bookmark
12 function bookmark_delete($zid, $uid)
14 $query = sprintf("DELETE FROM bookmarks " .
15 "WHERE uid = %d AND zeitung = %d",
18 # Ignore potentially non-existing bookmark
22 function bookmark_up($zid, $uid)
24 $query = sprintf("UPDATE bookmarks SET priority = priority - 1 " .
25 "WHERE uid = %d AND zeitung = %d",
28 # Ignore potentially non-existing bookmark
32 function bookmark_down($zid, $uid)
34 $query = sprintf("UPDATE bookmarks SET priority = priority + 1 " .
35 "WHERE uid = %d AND zeitung = %d",
38 # Ignore potentially non-existing bookmark
42 function format_bookmarks()
46 if (!isset($_SESSION['uid']))
49 $query = sprintf("SELECT zeitung,name,priority FROM bookmarks " .
50 "JOIN zeitungen ON zeitungen.id = zeitung " .
52 "ORDER BY priority,name LIMIT 20",
55 $sth = db_query($query);
57 if ($sth === false || pg_num_rows ($sth) == 0)
62 <a %s><img src="up.png" width="16" height="16" alt="up" title="Nach oben schieben" border="0"></a>
64 <a %s><img src="down.png" width="16" height="16" alt="up" title="Nach unten schieben" border="0"></a>
65 <a %s><img src="delete.gif" width="16" height="16" alt="delete" title="Lesezeichen löschen" border="0"></a>
68 <a href="zeitung/%d.html">%s</a></td>
71 $ret .= '<table class="bookmarks" width="100%", alt="">';
72 for ($n=0; $n < pg_num_rows ($sth); $n++) {
73 $row = pg_fetch_array ($sth, $n);
75 if (javascript_ok()) {
76 $link_up = sprintf('href="bookmark.html" onclick="return bookmark_action(\'up\',%d);"', $row['zeitung']);
77 $link_down = sprintf('href="bookmark.html" onclick="return bookmark_action(\'down\',%d);"', $row['zeitung']);
78 $link_del = sprintf('href="bookmark.html" onclick="return bookmark_action(\'del\',%d);"', $row['zeitung']);
80 $link_up = sprintf('href="bookmark.html?zeitung=%d&action=up"', $row['zeitung']);
81 $link_down = sprintf('href="bookmark.html?zeitung=%d&action=down"', $row['zeitung']);
82 $link_del = sprintf('href="bookmark.html?zeitung=%d&action=delete"', $row['zeitung']);
85 $ret .= sprintf($rowf,
86 $link_up, $row['priority'], $link_down, $link_del,
87 $row['zeitung'], $row['name']);
95 function bookmarks_manage()
99 if (!isset($_SESSION['uid']))
102 $ret = '<h3>Verwaltung der persönlichen Lesezeichen</h3>';
104 $ret .= '<div id="bookmarks">';
105 $ret .= load_javascript('bookmarks.js');
106 $ret .= format_bookmarks();
112 function process_bookmark()
120 if (!isset($_SESSION['uid']))
123 if (empty($_SERVER['QUERY_STRING'])) {
124 return bookmarks_manage();
125 } elseif (!isset($_GET['zeitung']) || !is_numeric($_GET['zeitung'])) {
126 if (isset($_SERVER['HTTP_REFERER']))
127 $zlist['redirect'] = substr($_SERVER['HTTP_REFERER'], strlen($zlist['home']));
128 return warning('Keine Zeitung oder Magazin gefunden.');
129 } elseif (isset($_GET['action'])) {
130 if ($_GET['action'] == 'up')
131 bookmark_up($_GET['zeitung'], $_SESSION['uid']);
132 elseif ($_GET['action'] == 'down')
133 bookmark_down($_GET['zeitung'], $_SESSION['uid']);
134 elseif ($_GET['action'] == 'delete')
135 bookmark_delete($_GET['zeitung'], $_SESSION['uid']);
138 header('Location: ' . $cfg['home'] . 'bookmark.html');
141 bookmark_add($_GET['zeitung'], $_SESSION['uid']);
142 if (isset($_SERVER['HTTP_REFERER'])) {
143 header('Location: ' . $_SERVER['HTTP_REFERER']);
146 return information('Ihr Lesezeichen wurde hinzugefügt');
150 function ajax_bookmark_check()
155 if (!isset($_POST['zeitung']) || !is_numeric($_POST['zeitung']) ||
156 !isset($_SESSION['uid']))
162 function ajax_bookmark_up()
167 if (!ajax_bookmark_check())
170 bookmark_up($_POST['zeitung'], $_SESSION['uid']);
172 return format_bookmarks();
175 function ajax_bookmark_down()
180 if (!ajax_bookmark_check())
183 bookmark_down($_POST['zeitung'], $_SESSION['uid']);
185 return format_bookmarks();
188 function ajax_bookmark_del()
193 if (!ajax_bookmark_check())
196 bookmark_delete($_POST['zeitung'], $_SESSION['uid']);
198 return format_bookmarks();
201 function ajax_bookmark_add()
206 if (!ajax_bookmark_check())
209 bookmark_add($_POST['zeitung'], $_SESSION['uid']);
211 return format_info_bookmarks();