]>
Commit | Line | Data |
---|---|---|
afcfe6ca | 1 | <?php |
369dbc19 | 2 | class Pref_Feeds extends Handler_Protected { |
df659891 AD |
3 | public static $feed_languages = array("English", "Danish", "Dutch", "Finnish", "French", "German", "Hungarian", "Italian", "Norwegian", |
4 | "Portuguese", "Russian", "Spanish", "Swedish", "Turkish", "Simple"); | |
8484ce22 AD |
5 | |
6 | function csrf_ignore($method) { | |
f6cd767b | 7 | $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed", |
201bb1ca AD |
8 | "savefeedorder", "uploadicon", "feedswitherrors", "inactivefeeds", |
9 | "batchsubscribe"); | |
8484ce22 AD |
10 | |
11 | return array_search($method, $csrf_ignored) !== false; | |
12 | } | |
13 | ||
afcfe6ca AD |
14 | function batch_edit_cbox($elem, $label = false) { |
15 | print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\" | |
16 | onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">"; | |
17 | } | |
18 | ||
19 | function renamecat() { | |
bf4a79ea AD |
20 | $title = $_REQUEST['title']; |
21 | $id = $_REQUEST['id']; | |
afcfe6ca AD |
22 | |
23 | if ($title) { | |
bf4a79ea AD |
24 | $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories SET |
25 | title = ? WHERE id = ? AND owner_uid = ?"); | |
26 | $sth->execute([$title, $id, $_SESSION['uid']]); | |
afcfe6ca | 27 | } |
afcfe6ca AD |
28 | } |
29 | ||
2a060a94 | 30 | private function get_category_items($cat_id) { |
6e0ee833 AD |
31 | |
32 | if ($_REQUEST['mode'] != 2) | |
33 | $search = $_SESSION["prefs_feed_search"]; | |
34 | else | |
35 | $search = ""; | |
17c755f0 | 36 | |
66ca7c30 AD |
37 | // first one is set by API |
38 | $show_empty_cats = $_REQUEST['force_show_empty'] || | |
e5e6cde0 | 39 | ($_REQUEST['mode'] != 2 && !$search); |
2a060a94 AD |
40 | |
41 | $items = array(); | |
42 | ||
bf4a79ea AD |
43 | $sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories |
44 | WHERE owner_uid = ? AND parent_cat = ? ORDER BY order_id, title"); | |
45 | $sth->execute([$_SESSION['uid'], $cat_id]); | |
2a060a94 | 46 | |
bf4a79ea | 47 | while ($line = $sth->fetch()) { |
2a060a94 AD |
48 | |
49 | $cat = array(); | |
50 | $cat['id'] = 'CAT:' . $line['id']; | |
2ecd2df5 | 51 | $cat['bare_id'] = (int)$line['id']; |
2a060a94 AD |
52 | $cat['name'] = $line['title']; |
53 | $cat['items'] = array(); | |
54 | $cat['checkbox'] = false; | |
55 | $cat['type'] = 'category'; | |
2ecd2df5 | 56 | $cat['unread'] = 0; |
2c5f231e | 57 | $cat['child_unread'] = 0; |
c594eca0 | 58 | $cat['auxcounter'] = 0; |
d922b09c | 59 | $cat['parent_id'] = $cat_id; |
2a060a94 AD |
60 | |
61 | $cat['items'] = $this->get_category_items($line['id']); | |
62 | ||
496195db | 63 | $num_children = $this->calculate_children_count($cat); |
967f0619 | 64 | $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); |
2a060a94 | 65 | |
496195db | 66 | if ($num_children > 0 || $show_empty_cats) |
2a060a94 AD |
67 | array_push($items, $cat); |
68 | ||
69 | } | |
70 | ||
bf4a79ea | 71 | $fsth = $this->pdo->prepare("SELECT id, title, last_error, |
2a060a94 AD |
72 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
73 | FROM ttrss_feeds | |
bf4a79ea AD |
74 | WHERE cat_id = :cat AND |
75 | owner_uid = :uid AND | |
76 | (:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search)) | |
77 | ORDER BY order_id, title"); | |
78 | ||
79 | $fsth->execute([":cat" => $cat_id, ":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]); | |
2a060a94 | 80 | |
bf4a79ea | 81 | while ($feed_line = $fsth->fetch()) { |
2a060a94 AD |
82 | $feed = array(); |
83 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
2ecd2df5 | 84 | $feed['bare_id'] = (int)$feed_line['id']; |
c594eca0 | 85 | $feed['auxcounter'] = 0; |
2a060a94 AD |
86 | $feed['name'] = $feed_line['title']; |
87 | $feed['checkbox'] = false; | |
2ecd2df5 | 88 | $feed['unread'] = 0; |
2a060a94 | 89 | $feed['error'] = $feed_line['last_error']; |
86a8351c | 90 | $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); |
6322ac79 | 91 | $feed['param'] = make_local_datetime( |
2a060a94 AD |
92 | $feed_line['last_updated'], true); |
93 | ||
94 | array_push($items, $feed); | |
95 | } | |
96 | ||
97 | return $items; | |
98 | } | |
99 | ||
afcfe6ca | 100 | function getfeedtree() { |
0bb5833b AD |
101 | print json_encode($this->makefeedtree()); |
102 | } | |
103 | ||
104 | function makefeedtree() { | |
afcfe6ca | 105 | |
6e0ee833 AD |
106 | if ($_REQUEST['mode'] != 2) |
107 | $search = $_SESSION["prefs_feed_search"]; | |
108 | else | |
109 | $search = ""; | |
afcfe6ca | 110 | |
afcfe6ca AD |
111 | $root = array(); |
112 | $root['id'] = 'root'; | |
113 | $root['name'] = __('Feeds'); | |
114 | $root['items'] = array(); | |
115 | $root['type'] = 'category'; | |
116 | ||
a42c55f0 | 117 | $enable_cats = get_pref('ENABLE_FEED_CATS'); |
2ecd2df5 AD |
118 | |
119 | if ($_REQUEST['mode'] == 2) { | |
120 | ||
121 | if ($enable_cats) { | |
88918ca6 | 122 | $cat = $this->feedlist_init_cat(-1); |
2ecd2df5 AD |
123 | } else { |
124 | $cat['items'] = array(); | |
125 | } | |
126 | ||
5417fbd7 | 127 | foreach (array(-4, -3, -1, -2, 0, -6) as $i) { |
2ecd2df5 AD |
128 | array_push($cat['items'], $this->feedlist_init_feed($i)); |
129 | } | |
130 | ||
a413f53e AD |
131 | /* Plugin feeds for -1 */ |
132 | ||
1ffe3391 | 133 | $feeds = PluginHost::getInstance()->get_feeds(-1); |
a413f53e AD |
134 | |
135 | if ($feeds) { | |
136 | foreach ($feeds as $feed) { | |
137 | $feed_id = PluginHost::pfeed_to_feed_id($feed['id']); | |
138 | ||
139 | $item = array(); | |
140 | $item['id'] = 'FEED:' . $feed_id; | |
141 | $item['bare_id'] = (int)$feed_id; | |
c594eca0 | 142 | $item['auxcounter'] = 0; |
a413f53e AD |
143 | $item['name'] = $feed['title']; |
144 | $item['checkbox'] = false; | |
145 | $item['error'] = ''; | |
146 | $item['icon'] = $feed['icon']; | |
147 | ||
148 | $item['param'] = ''; | |
149 | $item['unread'] = 0; //$feed['sender']->get_unread($feed['id']); | |
150 | $item['type'] = 'feed'; | |
151 | ||
152 | array_push($cat['items'], $item); | |
153 | } | |
154 | } | |
155 | ||
2ecd2df5 AD |
156 | if ($enable_cats) { |
157 | array_push($root['items'], $cat); | |
158 | } else { | |
159 | $root['items'] = array_merge($root['items'], $cat['items']); | |
160 | } | |
afcfe6ca | 161 | |
91d67966 AD |
162 | $sth = $this->pdo->prepare("SELECT * FROM |
163 | ttrss_labels2 WHERE owner_uid = ? ORDER by caption"); | |
164 | $sth->execute([$_SESSION['uid']]); | |
2ecd2df5 | 165 | |
91d67966 AD |
166 | if (get_pref('ENABLE_FEED_CATS')) { |
167 | $cat = $this->feedlist_init_cat(-2); | |
168 | } else { | |
169 | $cat['items'] = array(); | |
170 | } | |
2ecd2df5 | 171 | |
91d67966 AD |
172 | $num_labels = 0; |
173 | while ($line = $sth->fetch()) { | |
174 | ++$num_labels; | |
2ecd2df5 | 175 | |
91d67966 | 176 | $label_id = Labels::label_to_feed_id($line['id']); |
2ecd2df5 | 177 | |
91d67966 | 178 | $feed = $this->feedlist_init_feed($label_id, false, 0); |
2ecd2df5 | 179 | |
91d67966 AD |
180 | $feed['fg_color'] = $line['fg_color']; |
181 | $feed['bg_color'] = $line['bg_color']; | |
2ecd2df5 | 182 | |
91d67966 AD |
183 | array_push($cat['items'], $feed); |
184 | } | |
2ecd2df5 | 185 | |
91d67966 | 186 | if ($num_labels) { |
2ecd2df5 AD |
187 | if ($enable_cats) { |
188 | array_push($root['items'], $cat); | |
189 | } else { | |
190 | $root['items'] = array_merge($root['items'], $cat['items']); | |
191 | } | |
192 | } | |
193 | } | |
194 | ||
195 | if ($enable_cats) { | |
66ca7c30 | 196 | $show_empty_cats = $_REQUEST['force_show_empty'] || |
e5e6cde0 | 197 | ($_REQUEST['mode'] != 2 && !$search); |
2ecd2df5 | 198 | |
91d67966 AD |
199 | $sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories |
200 | WHERE owner_uid = ? AND parent_cat IS NULL ORDER BY order_id, title"); | |
201 | $sth->execute([$_SESSION['uid']]); | |
afcfe6ca | 202 | |
91d67966 | 203 | while ($line = $sth->fetch()) { |
afcfe6ca AD |
204 | $cat = array(); |
205 | $cat['id'] = 'CAT:' . $line['id']; | |
2ecd2df5 | 206 | $cat['bare_id'] = (int)$line['id']; |
c594eca0 | 207 | $cat['auxcounter'] = 0; |
afcfe6ca AD |
208 | $cat['name'] = $line['title']; |
209 | $cat['items'] = array(); | |
210 | $cat['checkbox'] = false; | |
211 | $cat['type'] = 'category'; | |
2ecd2df5 | 212 | $cat['unread'] = 0; |
2c5f231e | 213 | $cat['child_unread'] = 0; |
afcfe6ca | 214 | |
2a060a94 | 215 | $cat['items'] = $this->get_category_items($line['id']); |
afcfe6ca | 216 | |
496195db | 217 | $num_children = $this->calculate_children_count($cat); |
967f0619 | 218 | $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); |
afcfe6ca | 219 | |
496195db | 220 | if ($num_children > 0 || $show_empty_cats) |
afcfe6ca AD |
221 | array_push($root['items'], $cat); |
222 | ||
223 | $root['param'] += count($cat['items']); | |
224 | } | |
225 | ||
226 | /* Uncategorized is a special case */ | |
227 | ||
228 | $cat = array(); | |
229 | $cat['id'] = 'CAT:0'; | |
230 | $cat['bare_id'] = 0; | |
c594eca0 | 231 | $cat['auxcounter'] = 0; |
afcfe6ca AD |
232 | $cat['name'] = __("Uncategorized"); |
233 | $cat['items'] = array(); | |
234 | $cat['type'] = 'category'; | |
235 | $cat['checkbox'] = false; | |
2ecd2df5 | 236 | $cat['unread'] = 0; |
2c5f231e | 237 | $cat['child_unread'] = 0; |
afcfe6ca | 238 | |
91d67966 | 239 | $fsth = $this->pdo->prepare("SELECT id, title,last_error, |
afcfe6ca AD |
240 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
241 | FROM ttrss_feeds | |
91d67966 AD |
242 | WHERE cat_id IS NULL AND |
243 | owner_uid = :uid AND | |
244 | (:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search)) | |
245 | ORDER BY order_id, title"); | |
246 | $fsth->execute([":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]); | |
afcfe6ca | 247 | |
91d67966 | 248 | while ($feed_line = $fsth->fetch()) { |
afcfe6ca AD |
249 | $feed = array(); |
250 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
2ecd2df5 | 251 | $feed['bare_id'] = (int)$feed_line['id']; |
c594eca0 | 252 | $feed['auxcounter'] = 0; |
afcfe6ca AD |
253 | $feed['name'] = $feed_line['title']; |
254 | $feed['checkbox'] = false; | |
255 | $feed['error'] = $feed_line['last_error']; | |
86a8351c | 256 | $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); |
6322ac79 | 257 | $feed['param'] = make_local_datetime( |
afcfe6ca | 258 | $feed_line['last_updated'], true); |
2ecd2df5 AD |
259 | $feed['unread'] = 0; |
260 | $feed['type'] = 'feed'; | |
afcfe6ca AD |
261 | |
262 | array_push($cat['items'], $feed); | |
263 | } | |
264 | ||
1a293f10 | 265 | $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items'])); |
afcfe6ca | 266 | |
5b7bd238 | 267 | if (count($cat['items']) > 0 || $show_empty_cats) |
afcfe6ca AD |
268 | array_push($root['items'], $cat); |
269 | ||
496195db | 270 | $num_children = $this->calculate_children_count($root); |
967f0619 | 271 | $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); |
afcfe6ca AD |
272 | |
273 | } else { | |
91d67966 | 274 | $fsth = $this->pdo->prepare("SELECT id, title, last_error, |
afcfe6ca AD |
275 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
276 | FROM ttrss_feeds | |
91d67966 AD |
277 | WHERE owner_uid = :uid AND |
278 | (:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search)) | |
279 | ORDER BY order_id, title"); | |
280 | $fsth->execute([":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]); | |
afcfe6ca | 281 | |
91d67966 | 282 | while ($feed_line = $fsth->fetch()) { |
afcfe6ca AD |
283 | $feed = array(); |
284 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
2ecd2df5 | 285 | $feed['bare_id'] = (int)$feed_line['id']; |
c594eca0 | 286 | $feed['auxcounter'] = 0; |
afcfe6ca AD |
287 | $feed['name'] = $feed_line['title']; |
288 | $feed['checkbox'] = false; | |
289 | $feed['error'] = $feed_line['last_error']; | |
86a8351c | 290 | $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); |
6322ac79 | 291 | $feed['param'] = make_local_datetime( |
afcfe6ca | 292 | $feed_line['last_updated'], true); |
2ecd2df5 AD |
293 | $feed['unread'] = 0; |
294 | $feed['type'] = 'feed'; | |
afcfe6ca AD |
295 | |
296 | array_push($root['items'], $feed); | |
297 | } | |
298 | ||
1a293f10 | 299 | $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items'])); |
afcfe6ca AD |
300 | } |
301 | ||
302 | $fl = array(); | |
303 | $fl['identifier'] = 'id'; | |
304 | $fl['label'] = 'name'; | |
2ecd2df5 AD |
305 | |
306 | if ($_REQUEST['mode'] != 2) { | |
307 | $fl['items'] = array($root); | |
308 | } else { | |
1bd552ee | 309 | $fl['items'] = $root['items']; |
2ecd2df5 | 310 | } |
afcfe6ca | 311 | |
0bb5833b | 312 | return $fl; |
afcfe6ca AD |
313 | } |
314 | ||
315 | function catsortreset() { | |
91d67966 AD |
316 | $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories |
317 | SET order_id = 0 WHERE owner_uid = ?"); | |
318 | $sth->execute([$_SESSION['uid']]); | |
afcfe6ca AD |
319 | } |
320 | ||
321 | function feedsortreset() { | |
91d67966 AD |
322 | $sth = $this->pdo->prepare("UPDATE ttrss_feeds |
323 | SET order_id = 0 WHERE owner_uid = ?"); | |
324 | $sth->execute([$_SESSION['uid']]); | |
afcfe6ca AD |
325 | } |
326 | ||
95ee44b3 AD |
327 | private function process_category_order(&$data_map, $item_id, $parent_id = false, $nest_level = 0) { |
328 | $debug = isset($_REQUEST["debug"]); | |
329 | ||
330 | $prefix = ""; | |
331 | for ($i = 0; $i < $nest_level; $i++) | |
332 | $prefix .= " "; | |
333 | ||
334 | if ($debug) _debug("$prefix C: $item_id P: $parent_id"); | |
335 | ||
bf4a79ea | 336 | $bare_item_id = substr($item_id, strpos($item_id, ':')+1); |
2a060a94 AD |
337 | |
338 | if ($item_id != 'root') { | |
339 | if ($parent_id && $parent_id != 'root') { | |
340 | $parent_bare_id = substr($parent_id, strpos($parent_id, ':')+1); | |
bf4a79ea | 341 | $parent_qpart = $parent_bare_id; |
2a060a94 | 342 | } else { |
91d67966 | 343 | $parent_qpart = null; |
2a060a94 AD |
344 | } |
345 | ||
91d67966 AD |
346 | $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories |
347 | SET parent_cat = ? WHERE id = ? AND | |
348 | owner_uid = ?"); | |
349 | $sth->execute([$parent_qpart, $bare_item_id, $_SESSION['uid']]); | |
2a060a94 AD |
350 | } |
351 | ||
c053b976 | 352 | $order_id = 1; |
2a060a94 AD |
353 | |
354 | $cat = $data_map[$item_id]; | |
355 | ||
356 | if ($cat && is_array($cat)) { | |
357 | foreach ($cat as $item) { | |
358 | $id = $item['_reference']; | |
bf4a79ea | 359 | $bare_id = substr($id, strpos($id, ':')+1); |
2a060a94 | 360 | |
95ee44b3 | 361 | if ($debug) _debug("$prefix [$order_id] $id/$bare_id"); |
2a060a94 AD |
362 | |
363 | if ($item['_reference']) { | |
364 | ||
365 | if (strpos($id, "FEED") === 0) { | |
366 | ||
91d67966 | 367 | $cat_id = ($item_id != "root") ? $bare_item_id : null; |
95ee44b3 | 368 | |
91d67966 AD |
369 | $sth = $this->pdo->prepare("UPDATE ttrss_feeds |
370 | SET order_id = ?, cat_id = ? | |
371 | WHERE id = ? AND owner_uid = ?"); | |
49b2401e | 372 | |
91d67966 | 373 | $sth->execute([$order_id, $cat_id ? $cat_id : null, $bare_id, $_SESSION['uid']]); |
2a060a94 AD |
374 | |
375 | } else if (strpos($id, "CAT:") === 0) { | |
95ee44b3 AD |
376 | $this->process_category_order($data_map, $item['_reference'], $item_id, |
377 | $nest_level+1); | |
2a060a94 | 378 | |
91d67966 AD |
379 | $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories |
380 | SET order_id = ? WHERE id = ? AND | |
381 | owner_uid = ?"); | |
382 | $sth->execute([$order_id, $bare_id, $_SESSION['uid']]); | |
2a060a94 AD |
383 | } |
384 | } | |
385 | ||
386 | ++$order_id; | |
387 | } | |
388 | } | |
389 | } | |
390 | ||
afcfe6ca AD |
391 | function savefeedorder() { |
392 | $data = json_decode($_POST['payload'], true); | |
393 | ||
2a060a94 AD |
394 | #file_put_contents("/tmp/saveorder.json", $_POST['payload']); |
395 | #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true); | |
a26f57e6 | 396 | |
95ee44b3 AD |
397 | if (!is_array($data['items'])) |
398 | $data['items'] = json_decode($data['items'], true); | |
399 | ||
400 | # print_r($data['items']); | |
2a060a94 | 401 | |
afcfe6ca | 402 | if (is_array($data) && is_array($data['items'])) { |
4a80c57c | 403 | # $cat_order_id = 0; |
afcfe6ca AD |
404 | |
405 | $data_map = array(); | |
2a060a94 | 406 | $root_item = false; |
afcfe6ca AD |
407 | |
408 | foreach ($data['items'] as $item) { | |
409 | ||
2a060a94 | 410 | # if ($item['id'] != 'root') { |
afcfe6ca AD |
411 | if (is_array($item['items'])) { |
412 | if (isset($item['items']['_reference'])) { | |
413 | $data_map[$item['id']] = array($item['items']); | |
414 | } else { | |
1bd552ee | 415 | $data_map[$item['id']] = $item['items']; |
afcfe6ca AD |
416 | } |
417 | } | |
2a060a94 AD |
418 | if ($item['id'] == 'root') { |
419 | $root_item = $item['id']; | |
afcfe6ca AD |
420 | } |
421 | } | |
422 | ||
d04f8c82 | 423 | $this->process_category_order($data_map, $root_item); |
afcfe6ca | 424 | } |
afcfe6ca AD |
425 | } |
426 | ||
427 | function removeicon() { | |
bf4a79ea | 428 | $feed_id = $_REQUEST["feed_id"]; |
afcfe6ca | 429 | |
91d67966 AD |
430 | $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds |
431 | WHERE id = ? AND owner_uid = ?"); | |
432 | $sth->execute([$feed_id, $_SESSION['uid']]); | |
afcfe6ca | 433 | |
91d67966 | 434 | if ($row = $sth->fetch()) { |
3306daec | 435 | @unlink(ICONS_DIR . "/$feed_id.ico"); |
bc7a144d | 436 | |
91d67966 AD |
437 | $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = NULL |
438 | where id = ?"); | |
439 | $sth->execute([$feed_id]); | |
afcfe6ca | 440 | } |
afcfe6ca AD |
441 | } |
442 | ||
443 | function uploadicon() { | |
350e3944 AD |
444 | header("Content-type: text/html"); |
445 | ||
3306daec AD |
446 | if (is_uploaded_file($_FILES['icon_file']['tmp_name'])) { |
447 | $tmp_file = tempnam(CACHE_DIR . '/upload', 'icon'); | |
448 | ||
449 | $result = move_uploaded_file($_FILES['icon_file']['tmp_name'], | |
450 | $tmp_file); | |
451 | ||
452 | if (!$result) { | |
453 | return; | |
454 | } | |
455 | } else { | |
456 | return; | |
457 | } | |
458 | ||
459 | $icon_file = $tmp_file; | |
bf4a79ea | 460 | $feed_id = $_REQUEST["feed_id"]; |
afcfe6ca AD |
461 | |
462 | if (is_file($icon_file) && $feed_id) { | |
4a1d122c | 463 | if (filesize($icon_file) < 65535) { |
afcfe6ca | 464 | |
91d67966 AD |
465 | $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds |
466 | WHERE id = ? AND owner_uid = ?"); | |
467 | $sth->execute([$feed_id, $_SESSION['uid']]); | |
afcfe6ca | 468 | |
91d67966 | 469 | if ($row = $sth->fetch()) { |
3306daec | 470 | @unlink(ICONS_DIR . "/$feed_id.ico"); |
bc7a144d | 471 | if (rename($icon_file, ICONS_DIR . "/$feed_id.ico")) { |
91d67966 AD |
472 | |
473 | $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET | |
258068b3 | 474 | favicon_avg_color = '' |
91d67966 AD |
475 | WHERE id = ?"); |
476 | $sth->execute([$feed_id]); | |
bc7a144d AD |
477 | |
478 | $rc = 0; | |
479 | } | |
afcfe6ca AD |
480 | } else { |
481 | $rc = 2; | |
482 | } | |
483 | } else { | |
484 | $rc = 1; | |
485 | } | |
486 | } else { | |
487 | $rc = 2; | |
488 | } | |
489 | ||
3306daec AD |
490 | @unlink($icon_file); |
491 | ||
afcfe6ca AD |
492 | print "<script type=\"text/javascript\">"; |
493 | print "parent.uploadIconHandler($rc);"; | |
494 | print "</script>"; | |
495 | return; | |
496 | } | |
497 | ||
498 | function editfeed() { | |
499 | global $purge_intervals; | |
500 | global $update_intervals; | |
afcfe6ca | 501 | |
d9877997 | 502 | |
bf4a79ea | 503 | $feed_id = $_REQUEST["id"]; |
afcfe6ca | 504 | |
bf6db17b AD |
505 | $sth = $this->pdo->prepare("SELECT * FROM ttrss_feeds WHERE id = ? AND |
506 | owner_uid = ?"); | |
507 | $sth->execute([$feed_id, $_SESSION['uid']]); | |
afcfe6ca | 508 | |
bf6db17b AD |
509 | if ($row = $sth->fetch()) { |
510 | print '<div dojoType="dijit.layout.TabContainer" style="height : 450px"> | |
511 | <div dojoType="dijit.layout.ContentPane" title="'.__('General').'">'; | |
044cff2d | 512 | |
bf6db17b | 513 | $auth_pass_encrypted = sql_bool_to_bool($row["auth_pass_encrypted"]); |
afcfe6ca | 514 | |
bf6db17b | 515 | $title = htmlspecialchars($row["title"]); |
afcfe6ca | 516 | |
bf6db17b AD |
517 | print_hidden("id", "$feed_id"); |
518 | print_hidden("op", "pref-feeds"); | |
519 | print_hidden("method", "editSave"); | |
520 | ||
521 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
522 | print "<div class=\"dlgSecCont\">"; | |
afcfe6ca | 523 | |
bf6db17b | 524 | /* Title */ |
afcfe6ca | 525 | |
bf6db17b | 526 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" |
afcfe6ca AD |
527 | placeHolder=\"".__("Feed Title")."\" |
528 | style=\"font-size : 16px; width: 20em\" name=\"title\" value=\"$title\">"; | |
529 | ||
bf6db17b | 530 | /* Feed URL */ |
afcfe6ca | 531 | |
bf6db17b | 532 | $feed_url = htmlspecialchars($row["feed_url"]); |
afcfe6ca | 533 | |
bf6db17b | 534 | print "<hr/>"; |
afcfe6ca | 535 | |
bf6db17b AD |
536 | print __('URL:') . " "; |
537 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" | |
afcfe6ca AD |
538 | placeHolder=\"".__("Feed URL")."\" |
539 | regExp='^(http|https)://.*' style=\"width : 20em\" | |
540 | name=\"feed_url\" value=\"$feed_url\">"; | |
541 | ||
bf6db17b | 542 | $last_error = $row["last_error"]; |
afcfe6ca | 543 | |
bf6db17b AD |
544 | if ($last_error) { |
545 | print " <img src=\"images/error.png\" alt=\"(error)\" | |
1a545dcb AD |
546 | style=\"vertical-align : middle\" |
547 | title=\"".htmlspecialchars($last_error)."\">"; | |
afcfe6ca | 548 | |
bf6db17b | 549 | } |
afcfe6ca | 550 | |
bf6db17b | 551 | /* Category */ |
afcfe6ca | 552 | |
bf6db17b | 553 | if (get_pref('ENABLE_FEED_CATS')) { |
afcfe6ca | 554 | |
bf6db17b | 555 | $cat_id = $row["cat_id"]; |
afcfe6ca | 556 | |
bf6db17b | 557 | print "<hr/>"; |
afcfe6ca | 558 | |
bf6db17b | 559 | print __('Place in category:') . " "; |
afcfe6ca | 560 | |
bf6db17b AD |
561 | print_feed_cat_select("cat_id", $cat_id, |
562 | 'dojoType="dijit.form.Select"'); | |
563 | } | |
afcfe6ca | 564 | |
bf6db17b | 565 | /* FTS Stemming Language */ |
df659891 | 566 | |
bf6db17b AD |
567 | if (DB_TYPE == "pgsql") { |
568 | $feed_language = $row["feed_language"]; | |
df659891 | 569 | |
bf6db17b | 570 | print "<hr/>"; |
df659891 | 571 | |
bf6db17b AD |
572 | print __('Language:') . " "; |
573 | print_select("feed_language", $feed_language, $this::$feed_languages, | |
574 | 'dojoType="dijit.form.Select"'); | |
575 | } | |
df659891 | 576 | |
bf6db17b | 577 | print "</div>"; |
afcfe6ca | 578 | |
bf6db17b AD |
579 | print "<div class=\"dlgSec\">".__("Update")."</div>"; |
580 | print "<div class=\"dlgSecCont\">"; | |
afcfe6ca | 581 | |
bf6db17b | 582 | /* Update Interval */ |
afcfe6ca | 583 | |
bf6db17b | 584 | $update_interval = $row["update_interval"]; |
afcfe6ca | 585 | |
bf6db17b AD |
586 | print_select_hash("update_interval", $update_interval, $update_intervals, |
587 | 'dojoType="dijit.form.Select"'); | |
afcfe6ca | 588 | |
bf6db17b | 589 | /* Purge intl */ |
afcfe6ca | 590 | |
bf6db17b | 591 | $purge_interval = $row["purge_interval"]; |
afcfe6ca | 592 | |
bf6db17b AD |
593 | print "<hr/>"; |
594 | print __('Article purging:') . " "; | |
afcfe6ca | 595 | |
bf6db17b AD |
596 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, |
597 | 'dojoType="dijit.form.Select" ' . | |
afcfe6ca AD |
598 | ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"')); |
599 | ||
bf6db17b | 600 | print "</div>"; |
afcfe6ca | 601 | |
bf6db17b AD |
602 | $auth_login = htmlspecialchars($row["auth_login"]); |
603 | $auth_pass = $row["auth_pass"]; | |
044cff2d | 604 | |
bf6db17b AD |
605 | if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) { |
606 | require_once "crypt.php"; | |
607 | $auth_pass = decrypt_string($auth_pass); | |
608 | } | |
044cff2d | 609 | |
bf6db17b AD |
610 | $auth_pass = htmlspecialchars($auth_pass); |
611 | $auth_enabled = $auth_login !== '' || $auth_pass !== ''; | |
cc50affb | 612 | |
bf6db17b AD |
613 | $auth_style = $auth_enabled ? '' : 'display: none'; |
614 | print "<div id='feedEditDlg_loginContainer' style='$auth_style'>"; | |
615 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
616 | print "<div class=\"dlgSecCont\">"; | |
cc50affb | 617 | |
bf6db17b | 618 | print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\" |
cc50affb FE |
619 | placeHolder=\"".__("Login")."\" |
620 | autocomplete=\"new-password\" | |
621 | name=\"auth_login\" value=\"$auth_login\"><hr/>"; | |
622 | ||
afcfe6ca | 623 | |
bf6db17b | 624 | print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" |
ec21abb8 | 625 | autocomplete=\"new-password\" |
afcfe6ca AD |
626 | placeHolder=\"".__("Password")."\" |
627 | value=\"$auth_pass\">"; | |
628 | ||
bf6db17b | 629 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedEditDlg_login\" position=\"below\"> |
afcfe6ca AD |
630 | ".__('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.')." |
631 | </div>"; | |
632 | ||
bf6db17b | 633 | print "</div></div>"; |
cc50affb | 634 | |
bf6db17b AD |
635 | $auth_checked = $auth_enabled ? 'checked' : ''; |
636 | print "<div style=\"clear : both\"> | |
cc50affb FE |
637 | <input type=\"checkbox\" $auth_checked name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedEditDlg_loginCheck\" |
638 | onclick='checkboxToggleElement(this, \"feedEditDlg_loginContainer\")'> | |
639 | <label for=\"feedEditDlg_loginCheck\">". | |
bf6db17b | 640 | __('This feed requires authentication.')."</div>"; |
d9877997 | 641 | |
bf6db17b | 642 | print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">'; |
d9877997 | 643 | |
bf6db17b AD |
644 | //print "<div class=\"dlgSec\">".__("Options")."</div>"; |
645 | print "<div class=\"dlgSecSimple\">"; | |
afcfe6ca | 646 | |
bf6db17b | 647 | $private = sql_bool_to_bool($row["private"]); |
afcfe6ca | 648 | |
bf6db17b AD |
649 | if ($private) { |
650 | $checked = "checked=\"1\""; | |
651 | } else { | |
652 | $checked = ""; | |
653 | } | |
afcfe6ca | 654 | |
bf6db17b | 655 | print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\" |
afcfe6ca AD |
656 | $checked> <label for=\"private\">".__('Hide from Popular feeds')."</label>"; |
657 | ||
bf6db17b | 658 | $include_in_digest = sql_bool_to_bool($row["include_in_digest"]); |
afcfe6ca | 659 | |
bf6db17b AD |
660 | if ($include_in_digest) { |
661 | $checked = "checked=\"1\""; | |
662 | } else { | |
663 | $checked = ""; | |
664 | } | |
afcfe6ca | 665 | |
bf6db17b | 666 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\" |
afcfe6ca AD |
667 | name=\"include_in_digest\" |
668 | $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; | |
669 | ||
670 | ||
bf6db17b | 671 | $always_display_enclosures = sql_bool_to_bool($row["always_display_enclosures"]); |
afcfe6ca | 672 | |
bf6db17b AD |
673 | if ($always_display_enclosures) { |
674 | $checked = "checked"; | |
675 | } else { | |
676 | $checked = ""; | |
677 | } | |
afcfe6ca | 678 | |
bf6db17b | 679 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\" |
afcfe6ca AD |
680 | name=\"always_display_enclosures\" |
681 | $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
682 | ||
bf6db17b | 683 | $hide_images = sql_bool_to_bool($row["hide_images"]); |
bfd61d3f | 684 | |
bf6db17b AD |
685 | if ($hide_images) { |
686 | $checked = "checked=\"1\""; | |
687 | } else { | |
688 | $checked = ""; | |
689 | } | |
bfd61d3f | 690 | |
bf6db17b | 691 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"hide_images\" |
bfd61d3f AD |
692 | name=\"hide_images\" |
693 | $checked> <label for=\"hide_images\">". | |
bf6db17b | 694 | __('Do not embed images')."</label>"; |
afcfe6ca | 695 | |
bf6db17b | 696 | $cache_images = sql_bool_to_bool($row["cache_images"]); |
afcfe6ca | 697 | |
bf6db17b AD |
698 | if ($cache_images) { |
699 | $checked = "checked=\"1\""; | |
700 | } else { | |
701 | $checked = ""; | |
702 | } | |
afcfe6ca | 703 | |
bf6db17b | 704 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\" |
3c696512 | 705 | name=\"cache_images\" |
afcfe6ca | 706 | $checked> <label for=\"cache_images\">". |
bf6db17b | 707 | __('Cache media')."</label>"; |
afcfe6ca | 708 | |
bf6db17b | 709 | $mark_unread_on_update = sql_bool_to_bool($row["mark_unread_on_update"]); |
afcfe6ca | 710 | |
bf6db17b AD |
711 | if ($mark_unread_on_update) { |
712 | $checked = "checked"; | |
713 | } else { | |
714 | $checked = ""; | |
715 | } | |
afcfe6ca | 716 | |
bf6db17b | 717 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\" |
afcfe6ca AD |
718 | name=\"mark_unread_on_update\" |
719 | $checked> <label for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
720 | ||
bf6db17b | 721 | print "</div>"; |
afcfe6ca | 722 | |
bf6db17b | 723 | print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Icon').'">'; |
d9877997 | 724 | |
bf6db17b | 725 | /* Icon */ |
afcfe6ca | 726 | |
bf6db17b | 727 | print "<div class=\"dlgSecSimple\">"; |
afcfe6ca | 728 | |
bf6db17b | 729 | print "<iframe name=\"icon_upload_iframe\" |
afcfe6ca AD |
730 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; |
731 | ||
bf6db17b | 732 | print "<form style='display : block' target=\"icon_upload_iframe\" |
afcfe6ca AD |
733 | enctype=\"multipart/form-data\" method=\"POST\" |
734 | action=\"backend.php\"> | |
735 | <input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\"> | |
736 | <input type=\"hidden\" name=\"op\" value=\"pref-feeds\"> | |
737 | <input type=\"hidden\" name=\"feed_id\" value=\"$feed_id\"> | |
d9877997 AD |
738 | <input type=\"hidden\" name=\"method\" value=\"uploadicon\"><p> |
739 | <button class=\"\" dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\" | |
afcfe6ca | 740 | type=\"submit\">".__('Replace')."</button> |
d9877997 | 741 | <button class=\"\" dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon($feed_id);\" |
afcfe6ca AD |
742 | type=\"submit\">".__('Remove')."</button> |
743 | </form>"; | |
744 | ||
bf6db17b | 745 | print "</div>"; |
afcfe6ca | 746 | |
bf6db17b | 747 | print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Plugins').'">'; |
d9877997 | 748 | |
bf6db17b AD |
749 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_EDIT_FEED, |
750 | "hook_prefs_edit_feed", $feed_id); | |
057177eb | 751 | |
d9877997 | 752 | |
bf6db17b | 753 | print "</div></div>"; |
d9877997 | 754 | |
bf6db17b | 755 | $title = htmlspecialchars($title, ENT_QUOTES); |
afcfe6ca | 756 | |
bf6db17b | 757 | print "<div class='dlgButtons'> |
afcfe6ca | 758 | <div style=\"float : left\"> |
73dfda1d | 759 | <button class=\"danger\" dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>". |
afcfe6ca AD |
760 | __('Unsubscribe')."</button>"; |
761 | ||
bf6db17b | 762 | print "</div>"; |
afcfe6ca | 763 | |
bf6db17b AD |
764 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button> |
765 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button> | |
766 | </div>"; | |
767 | } | |
afcfe6ca AD |
768 | } |
769 | ||
770 | function editfeeds() { | |
771 | global $purge_intervals; | |
772 | global $update_intervals; | |
46da73c2 | 773 | |
bf4a79ea | 774 | $feed_ids = $_REQUEST["ids"]; |
afcfe6ca | 775 | |
fcef9eea AD |
776 | print_notice("Enable the options you wish to apply using checkboxes on the right:"); |
777 | ||
778 | print "<p>"; | |
ca6a0741 | 779 | |
328118d1 AD |
780 | print_hidden("ids", "$feed_ids"); |
781 | print_hidden("op", "pref-feeds"); | |
782 | print_hidden("method", "batchEditSave"); | |
afcfe6ca AD |
783 | |
784 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
785 | print "<div class=\"dlgSecCont\">"; | |
786 | ||
afcfe6ca AD |
787 | /* Category */ |
788 | ||
a42c55f0 | 789 | if (get_pref('ENABLE_FEED_CATS')) { |
afcfe6ca | 790 | |
afcfe6ca AD |
791 | print __('Place in category:') . " "; |
792 | ||
d29357fa | 793 | print_feed_cat_select("cat_id", false, |
afcfe6ca AD |
794 | 'disabled="1" dojoType="dijit.form.Select"'); |
795 | ||
796 | $this->batch_edit_cbox("cat_id"); | |
797 | ||
798 | } | |
799 | ||
df659891 AD |
800 | /* FTS Stemming Language */ |
801 | ||
802 | if (DB_TYPE == "pgsql") { | |
803 | print "<hr/>"; | |
804 | ||
805 | print __('Language:') . " "; | |
806 | print_select("feed_language", "", $this::$feed_languages, | |
807 | 'disabled="1" dojoType="dijit.form.Select"'); | |
808 | ||
809 | $this->batch_edit_cbox("feed_language"); | |
810 | } | |
811 | ||
afcfe6ca AD |
812 | print "</div>"; |
813 | ||
814 | print "<div class=\"dlgSec\">".__("Update")."</div>"; | |
815 | print "<div class=\"dlgSecCont\">"; | |
816 | ||
817 | /* Update Interval */ | |
818 | ||
d29357fa | 819 | print_select_hash("update_interval", "", $update_intervals, |
afcfe6ca AD |
820 | 'disabled="1" dojoType="dijit.form.Select"'); |
821 | ||
822 | $this->batch_edit_cbox("update_interval"); | |
823 | ||
afcfe6ca AD |
824 | /* Purge intl */ |
825 | ||
826 | if (FORCE_ARTICLE_PURGE == 0) { | |
827 | ||
828 | print "<br/>"; | |
829 | ||
830 | print __('Article purging:') . " "; | |
831 | ||
d29357fa | 832 | print_select_hash("purge_interval", "", $purge_intervals, |
afcfe6ca AD |
833 | 'disabled="1" dojoType="dijit.form.Select"'); |
834 | ||
835 | $this->batch_edit_cbox("purge_interval"); | |
836 | } | |
837 | ||
838 | print "</div>"; | |
839 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
840 | print "<div class=\"dlgSecCont\">"; | |
841 | ||
842 | print "<input dojoType=\"dijit.form.TextBox\" | |
843 | placeHolder=\"".__("Login")."\" disabled=\"1\" | |
ec21abb8 | 844 | autocomplete=\"new-password\" |
d29357fa | 845 | name=\"auth_login\" value=\"\">"; |
afcfe6ca AD |
846 | |
847 | $this->batch_edit_cbox("auth_login"); | |
848 | ||
44727c79 | 849 | print "<hr/> <input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" |
ec21abb8 | 850 | autocomplete=\"new-password\" |
afcfe6ca | 851 | placeHolder=\"".__("Password")."\" disabled=\"1\" |
d29357fa | 852 | value=\"\">"; |
afcfe6ca AD |
853 | |
854 | $this->batch_edit_cbox("auth_pass"); | |
855 | ||
856 | print "</div>"; | |
857 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
858 | print "<div class=\"dlgSecCont\">"; | |
859 | ||
860 | print "<input disabled=\"1\" type=\"checkbox\" name=\"private\" id=\"private\" | |
861 | dojoType=\"dijit.form.CheckBox\"> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>"; | |
862 | ||
863 | print " "; $this->batch_edit_cbox("private", "private_l"); | |
864 | ||
afcfe6ca AD |
865 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"include_in_digest\" |
866 | name=\"include_in_digest\" | |
867 | dojoType=\"dijit.form.CheckBox\"> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; | |
868 | ||
869 | print " "; $this->batch_edit_cbox("include_in_digest", "include_in_digest_l"); | |
870 | ||
871 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"always_display_enclosures\" | |
872 | name=\"always_display_enclosures\" | |
873 | dojoType=\"dijit.form.CheckBox\"> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
874 | ||
875 | print " "; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l"); | |
876 | ||
bfd61d3f AD |
877 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"hide_images\" |
878 | name=\"hide_images\" | |
879 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"hide_images_l\" | |
880 | for=\"hide_images\">". | |
881 | __('Do not embed images')."</label>"; | |
882 | ||
883 | print " "; $this->batch_edit_cbox("hide_images", "hide_images_l"); | |
884 | ||
3c696512 AD |
885 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\" |
886 | name=\"cache_images\" | |
887 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"cache_images_l\" | |
888 | for=\"cache_images\">". | |
9c3c0ace | 889 | __('Cache media')."</label>"; |
afcfe6ca | 890 | |
3c696512 | 891 | print " "; $this->batch_edit_cbox("cache_images", "cache_images_l"); |
afcfe6ca AD |
892 | |
893 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"mark_unread_on_update\" | |
894 | name=\"mark_unread_on_update\" | |
895 | dojoType=\"dijit.form.CheckBox\"> <label id=\"mark_unread_on_update_l\" class='insensitive' for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
896 | ||
897 | print " "; $this->batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l"); | |
898 | ||
afcfe6ca AD |
899 | print "</div>"; |
900 | ||
901 | print "<div class='dlgButtons'> | |
902 | <button dojoType=\"dijit.form.Button\" | |
903 | onclick=\"return dijit.byId('feedEditDlg').execute()\">". | |
904 | __('Save')."</button> | |
905 | <button dojoType=\"dijit.form.Button\" | |
906 | onclick=\"return dijit.byId('feedEditDlg').hide()\">". | |
907 | __('Cancel')."</button> | |
908 | </div>"; | |
909 | ||
910 | return; | |
911 | } | |
912 | ||
913 | function batchEditSave() { | |
3a76e2a2 | 914 | return $this->editsaveops(true); |
afcfe6ca | 915 | } |
46da73c2 | 916 | |
afcfe6ca | 917 | function editSave() { |
3a76e2a2 | 918 | return $this->editsaveops(false); |
afcfe6ca | 919 | } |
46da73c2 AD |
920 | |
921 | function editsaveops($batch) { | |
922 | ||
bf4a79ea | 923 | $feed_title = trim($_POST["title"]); |
91d67966 | 924 | $feed_url = trim($_POST["feed_url"]); |
bf4a79ea AD |
925 | $upd_intl = (int) $_POST["update_interval"]; |
926 | $purge_intl = (int) $_POST["purge_interval"]; | |
927 | $feed_id = (int) $_POST["id"]; /* editSave */ | |
91d67966 | 928 | $feed_ids = explode(",", $_POST["ids"]); /* batchEditSave */ |
bf4a79ea AD |
929 | $cat_id = (int) $_POST["cat_id"]; |
930 | $auth_login = trim($_POST["auth_login"]); | |
41694a95 | 931 | $auth_pass = trim($_POST["auth_pass"]); |
bf4a79ea | 932 | $private = checkbox_to_sql_bool($_POST["private"]); |
afcfe6ca | 933 | $include_in_digest = checkbox_to_sql_bool( |
bf4a79ea | 934 | $_POST["include_in_digest"]); |
afcfe6ca | 935 | $cache_images = checkbox_to_sql_bool( |
bf4a79ea | 936 | $_POST["cache_images"]); |
bfd61d3f | 937 | $hide_images = checkbox_to_sql_bool( |
bf4a79ea | 938 | $_POST["hide_images"]); |
afcfe6ca | 939 | $always_display_enclosures = checkbox_to_sql_bool( |
bf4a79ea | 940 | $_POST["always_display_enclosures"]); |
afcfe6ca AD |
941 | |
942 | $mark_unread_on_update = checkbox_to_sql_bool( | |
bf4a79ea | 943 | $_POST["mark_unread_on_update"]); |
afcfe6ca | 944 | |
bf4a79ea | 945 | $feed_language = trim($_POST["feed_language"]); |
df659891 | 946 | |
3a76e2a2 | 947 | if (!$batch) { |
cc50affb FE |
948 | if ($_POST["need_auth"] !== 'on') { |
949 | $auth_login = ''; | |
950 | $auth_pass = ''; | |
951 | } | |
afcfe6ca | 952 | |
91d67966 AD |
953 | $sth = $this->pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?"); |
954 | $sth->execute([$feed_id]); | |
955 | $row = $sth->fetch(); | |
956 | $orig_feed_url = $row["feed_url"]; | |
957 | ||
958 | $reset_basic_info = $orig_feed_url != $feed_url; | |
959 | ||
960 | $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET | |
961 | cat_id = :cat_id, | |
962 | title = :title, | |
963 | feed_url = :feed_url, | |
964 | update_interval = :upd_intl, | |
965 | purge_interval = :purge_intl, | |
966 | auth_login = :auth_login, | |
967 | auth_pass = :auth_pass, | |
51b521c3 | 968 | auth_pass_encrypted = false, |
91d67966 AD |
969 | private = :private, |
970 | cache_images = :cache_images, | |
971 | hide_images = :hide_images, | |
972 | include_in_digest = :include_in_digest, | |
973 | always_display_enclosures = :always_display_enclosures, | |
974 | mark_unread_on_update = :mark_unread_on_update, | |
975 | feed_language = :feed_language | |
976 | WHERE id = :id AND owner_uid = :uid"); | |
977 | ||
978 | $sth->execute([":title" => $feed_title, | |
979 | ":cat_id" => $cat_id ? $cat_id : null, | |
980 | ":feed_url" => $feed_url, | |
981 | ":upd_intl" => $upd_intl, | |
982 | ":purge_intl" => $purge_intl, | |
983 | ":auth_login" => $auth_login, | |
984 | ":auth_pass" => $auth_pass, | |
985 | ":private" => (int)$private, | |
986 | ":cache_images" => (int)$cache_images, | |
987 | ":hide_images" => (int)$hide_images, | |
988 | ":include_in_digest" => (int)$include_in_digest, | |
989 | ":always_display_enclosures" => (int)$always_display_enclosures, | |
990 | ":mark_unread_on_update" => (int)$mark_unread_on_update, | |
991 | ":feed_language" => $feed_language, | |
992 | ":id" => $feed_id, | |
993 | ":uid" => $_SESSION['uid']]); | |
afcfe6ca | 994 | |
91837f0a | 995 | if ($reset_basic_info) { |
e6c886bf | 996 | RSSUtils::set_basic_feed_info($feed_id); |
91837f0a AD |
997 | } |
998 | ||
8cefe38a AD |
999 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_SAVE_FEED, |
1000 | "hook_prefs_save_feed", $feed_id); | |
1001 | ||
3a76e2a2 | 1002 | } else { |
afcfe6ca AD |
1003 | $feed_data = array(); |
1004 | ||
1005 | foreach (array_keys($_POST) as $k) { | |
1006 | if ($k != "op" && $k != "method" && $k != "ids") { | |
1007 | $feed_data[$k] = $_POST[$k]; | |
1008 | } | |
1009 | } | |
1010 | ||
91d67966 AD |
1011 | $this->pdo->beginTransaction(); |
1012 | ||
1013 | $feed_ids_qmarks = arr_qmarks($feed_ids); | |
afcfe6ca AD |
1014 | |
1015 | foreach (array_keys($feed_data) as $k) { | |
1016 | ||
1017 | $qpart = ""; | |
1018 | ||
1019 | switch ($k) { | |
1020 | case "title": | |
91d67966 | 1021 | $qpart = "title = " . $this->pdo->quote($feed_title); |
afcfe6ca AD |
1022 | break; |
1023 | ||
1024 | case "feed_url": | |
91d67966 | 1025 | $qpart = "feed_url = " . $this->pdo->quote($feed_url); |
afcfe6ca AD |
1026 | break; |
1027 | ||
1028 | case "update_interval": | |
91d67966 | 1029 | $qpart = "update_interval = " . $this->pdo->quote($upd_intl); |
afcfe6ca AD |
1030 | break; |
1031 | ||
1032 | case "purge_interval": | |
91d67966 | 1033 | $qpart = "purge_interval =" . $this->pdo->quote($purge_intl); |
afcfe6ca AD |
1034 | break; |
1035 | ||
1036 | case "auth_login": | |
91d67966 | 1037 | $qpart = "auth_login = " . $this->pdo->quote($auth_login); |
afcfe6ca AD |
1038 | break; |
1039 | ||
1040 | case "auth_pass": | |
91d67966 | 1041 | $qpart = "auth_pass =" . $this->pdo->quote($auth_pass). ", auth_pass_encrypted = false"; |
afcfe6ca AD |
1042 | break; |
1043 | ||
1044 | case "private": | |
91d67966 | 1045 | $qpart = "private = " . $this->pdo->quote($private); |
afcfe6ca AD |
1046 | break; |
1047 | ||
1048 | case "include_in_digest": | |
91d67966 | 1049 | $qpart = "include_in_digest = " . $this->pdo->quote($include_in_digest); |
afcfe6ca AD |
1050 | break; |
1051 | ||
1052 | case "always_display_enclosures": | |
91d67966 | 1053 | $qpart = "always_display_enclosures = " . $this->pdo->quote($always_display_enclosures); |
afcfe6ca AD |
1054 | break; |
1055 | ||
1056 | case "mark_unread_on_update": | |
91d67966 | 1057 | $qpart = "mark_unread_on_update = " . $this->pdo->quote($mark_unread_on_update); |
afcfe6ca AD |
1058 | break; |
1059 | ||
afcfe6ca | 1060 | case "cache_images": |
91d67966 | 1061 | $qpart = "cache_images = " . $this->pdo->quote($cache_images); |
afcfe6ca AD |
1062 | break; |
1063 | ||
bfd61d3f | 1064 | case "hide_images": |
91d67966 | 1065 | $qpart = "hide_images = " . $this->pdo->quote($hide_images); |
bfd61d3f AD |
1066 | break; |
1067 | ||
afcfe6ca | 1068 | case "cat_id": |
91d67966 AD |
1069 | if (get_pref('ENABLE_FEED_CATS')) { |
1070 | if ($cat_id) { | |
1071 | $qpart = "cat_id = " . $this->pdo->quote($cat_id); | |
1072 | } else { | |
1073 | $qpart = 'cat_id = NULL'; | |
1074 | } | |
1075 | } else { | |
1076 | $qpart = ""; | |
1077 | } | |
1078 | ||
afcfe6ca AD |
1079 | break; |
1080 | ||
df659891 | 1081 | case "feed_language": |
91d67966 | 1082 | $qpart = "feed_language = " . $this->pdo->quote($feed_language); |
df659891 AD |
1083 | break; |
1084 | ||
afcfe6ca AD |
1085 | } |
1086 | ||
1087 | if ($qpart) { | |
91d67966 AD |
1088 | $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids_qmarks) |
1089 | AND owner_uid = ?"); | |
1090 | $sth->execute(array_merge($feed_ids, [$_SESSION['uid']])); | |
afcfe6ca AD |
1091 | } |
1092 | } | |
1093 | ||
91d67966 | 1094 | $this->pdo->commit(); |
afcfe6ca AD |
1095 | } |
1096 | return; | |
1097 | } | |
1098 | ||
afcfe6ca AD |
1099 | function remove() { |
1100 | ||
bf4a79ea | 1101 | $ids = explode(",", $_REQUEST["ids"]); |
afcfe6ca AD |
1102 | |
1103 | foreach ($ids as $id) { | |
a42c55f0 | 1104 | Pref_Feeds::remove_feed($id, $_SESSION["uid"]); |
afcfe6ca AD |
1105 | } |
1106 | ||
1107 | return; | |
1108 | } | |
1109 | ||
28537341 | 1110 | function removeCat() { |
bf4a79ea | 1111 | $ids = explode(",", $_REQUEST["ids"]); |
28537341 | 1112 | foreach ($ids as $id) { |
a42c55f0 | 1113 | $this->remove_feed_category($id, $_SESSION["uid"]); |
28537341 AD |
1114 | } |
1115 | } | |
1116 | ||
1117 | function addCat() { | |
bf4a79ea | 1118 | $feed_cat = trim($_REQUEST["cat"]); |
28537341 | 1119 | |
a42c55f0 | 1120 | add_feed_category($feed_cat); |
28537341 AD |
1121 | } |
1122 | ||
afcfe6ca AD |
1123 | function index() { |
1124 | ||
1125 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; | |
1126 | print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">"; | |
1127 | ||
bf6db17b AD |
1128 | $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors |
1129 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?"); | |
1130 | $sth->execute([$_SESSION['uid']]); | |
afcfe6ca | 1131 | |
bf6db17b AD |
1132 | if ($row = $sth->fetch()) { |
1133 | $num_errors = $row["num_errors"]; | |
1134 | } else { | |
1135 | $num_errors = 0; | |
1136 | } | |
afcfe6ca AD |
1137 | |
1138 | if ($num_errors > 0) { | |
1139 | ||
1140 | $error_button = "<button dojoType=\"dijit.form.Button\" | |
1141 | onclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . | |
1142 | __("Feeds with errors") . "</button>"; | |
1143 | } | |
1144 | ||
f9c1f8b0 AD |
1145 | $inactive_button = "<button dojoType=\"dijit.form.Button\" |
1146 | id=\"pref_feeds_inactive_btn\" | |
1147 | style=\"display : none\" | |
1148 | onclick=\"showInactiveFeeds()\">" . | |
1149 | __("Inactive feeds") . "</button>"; | |
afcfe6ca | 1150 | |
bf4a79ea | 1151 | $feed_search = $_REQUEST["search"]; |
afcfe6ca AD |
1152 | |
1153 | if (array_key_exists("search", $_REQUEST)) { | |
1154 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1155 | } else { | |
1156 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1157 | } | |
1158 | ||
1159 | print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; | |
1160 | ||
1161 | print "<div region='top' dojoType=\"dijit.Toolbar\">"; #toolbar | |
1162 | ||
1163 | print "<div style='float : right; padding-right : 4px;'> | |
1164 | <input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\" | |
1165 | value=\"$feed_search\"> | |
1166 | <button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">". | |
1167 | __('Search')."</button> | |
1168 | </div>"; | |
1169 | ||
1170 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1171 | "<span>" . __('Select')."</span>"; | |
1172 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1173 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\" | |
1174 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1175 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\" | |
1176 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1177 | print "</div></div>"; | |
1178 | ||
1179 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1180 | "<span>" . __('Feeds')."</span>"; | |
1181 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1182 | print "<div onclick=\"quickAddFeed()\" | |
1183 | dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>"; | |
1184 | print "<div onclick=\"editSelectedFeed()\" | |
1185 | dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>"; | |
1186 | print "<div onclick=\"resetFeedOrder()\" | |
1187 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
33f0fdd0 AD |
1188 | print "<div onclick=\"batchSubscribe()\" |
1189 | dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>"; | |
0671359f AD |
1190 | print "<div dojoType=\"dijit.MenuItem\" onclick=\"removeSelectedFeeds()\">" |
1191 | .__('Unsubscribe')."</div> "; | |
afcfe6ca AD |
1192 | print "</div></div>"; |
1193 | ||
a42c55f0 | 1194 | if (get_pref('ENABLE_FEED_CATS')) { |
afcfe6ca AD |
1195 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
1196 | "<span>" . __('Categories')."</span>"; | |
1197 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
5ef071e0 AD |
1198 | print "<div onclick=\"createCategory()\" |
1199 | dojoType=\"dijit.MenuItem\">".__('Add category')."</div>"; | |
afcfe6ca AD |
1200 | print "<div onclick=\"resetCatOrder()\" |
1201 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
fd26d5bf AD |
1202 | print "<div onclick=\"removeSelectedCategories()\" |
1203 | dojoType=\"dijit.MenuItem\">".__('Remove selected')."</div>"; | |
afcfe6ca AD |
1204 | print "</div></div>"; |
1205 | ||
1206 | } | |
1207 | ||
1208 | print $error_button; | |
1209 | print $inactive_button; | |
1210 | ||
afcfe6ca AD |
1211 | if (defined('_ENABLE_FEED_DEBUGGING')) { |
1212 | ||
1213 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> | |
1214 | <option value=\"facDefault\" selected>".__('More actions...')."</option>"; | |
1215 | ||
1216 | if (FORCE_ARTICLE_PURGE == 0) { | |
1217 | ||
1218 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; | |
1219 | } | |
1220 | ||
1221 | print " | |
1222 | <option value=\"facClear\">".__('Clear feed data')."</option> | |
1223 | <option value=\"facRescore\">".__('Rescore articles')."</option>"; | |
1224 | ||
1225 | print "</select>"; | |
1226 | ||
1227 | } | |
1228 | ||
1229 | print "</div>"; # toolbar | |
1230 | ||
1231 | //print '</div>'; | |
1232 | print '<div dojoType="dijit.layout.ContentPane" region="center">'; | |
1233 | ||
1234 | print "<div id=\"feedlistLoading\"> | |
1235 | <img src='images/indicator_tiny.gif'>". | |
1236 | __("Loading, please wait...")."</div>"; | |
1237 | ||
1238 | print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\" | |
1239 | url=\"backend.php?op=pref-feeds&method=getfeedtree\"> | |
1240 | </div> | |
1241 | <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\" | |
1242 | query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\" | |
1243 | childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\"> | |
1244 | </div> | |
1245 | <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\" | |
1246 | dndController=\"dijit.tree.dndSource\" | |
1247 | betweenThreshold=\"5\" | |
84012df5 | 1248 | autoExpand='true' |
afcfe6ca AD |
1249 | model=\"feedModel\" openOnClick=\"false\"> |
1250 | <script type=\"dojo/method\" event=\"onClick\" args=\"item\"> | |
1251 | var id = String(item.id); | |
1252 | var bare_id = id.substr(id.indexOf(':')+1); | |
1253 | ||
1254 | if (id.match('FEED:')) { | |
1255 | editFeed(bare_id); | |
1256 | } else if (id.match('CAT:')) { | |
1257 | editCat(bare_id, item); | |
1258 | } | |
1259 | </script> | |
1260 | <script type=\"dojo/method\" event=\"onLoad\" args=\"item\"> | |
1261 | Element.hide(\"feedlistLoading\"); | |
f9c1f8b0 AD |
1262 | |
1263 | checkInactiveFeeds(); | |
afcfe6ca AD |
1264 | </script> |
1265 | </div>"; | |
1266 | ||
ba5296a1 AD |
1267 | # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\"> |
1268 | # ".__('<b>Hint:</b> you can drag feeds and categories around.')." | |
1269 | # </div>"; | |
afcfe6ca AD |
1270 | |
1271 | print '</div>'; | |
1272 | print '</div>'; | |
1273 | ||
1274 | print "</div>"; # feeds pane | |
1275 | ||
6c2637d9 | 1276 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">"; |
afcfe6ca | 1277 | |
73dfda1d AD |
1278 | print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . |
1279 | __("Only main settings profile can be migrated using OPML.") . "</p>"; | |
afcfe6ca | 1280 | |
55f34b81 | 1281 | print "<iframe id=\"upload_iframe\" |
afcfe6ca AD |
1282 | name=\"upload_iframe\" onload=\"opmlImportComplete(this)\" |
1283 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; | |
1284 | ||
1285 | print "<form name=\"opml_form\" style='display : block' target=\"upload_iframe\" | |
1286 | enctype=\"multipart/form-data\" method=\"POST\" | |
55f34b81 | 1287 | action=\"backend.php\"> |
afcfe6ca AD |
1288 | <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> |
1289 | <input type=\"hidden\" name=\"op\" value=\"dlg\"> | |
c4c74732 | 1290 | <input type=\"hidden\" name=\"method\" value=\"importOpml\"> |
afcfe6ca | 1291 | <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . |
a1159c01 | 1292 | __('Import my OPML') . "</button>"; |
afcfe6ca | 1293 | |
a1159c01 | 1294 | print "<hr>"; |
afcfe6ca | 1295 | |
77e81006 AD |
1296 | $opml_export_filename = "TinyTinyRSS_".date("Y-m-d").".opml"; |
1297 | ||
afcfe6ca | 1298 | print "<p>" . __('Filename:') . |
77e81006 | 1299 | " <input type=\"text\" id=\"filename\" value=\"$opml_export_filename\" /> " . |
a1159c01 | 1300 | __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>"; |
afcfe6ca | 1301 | |
a1159c01 | 1302 | print "</p><button dojoType=\"dijit.form.Button\" |
afcfe6ca | 1303 | onclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . |
a1159c01 | 1304 | __('Export OPML') . "</button></p></form>"; |
afcfe6ca | 1305 | |
a1159c01 | 1306 | print "<hr>"; |
afcfe6ca | 1307 | |
73dfda1d | 1308 | print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . "</p>"; |
afcfe6ca | 1309 | |
73dfda1d | 1310 | print_warning("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds."); |
afcfe6ca | 1311 | |
fb54e3b1 | 1312 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">". |
a1159c01 | 1313 | __('Display published OPML URL')."</button> "; |
afcfe6ca | 1314 | |
1ffe3391 | 1315 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
699daf58 AD |
1316 | "hook_prefs_tab_section", "prefFeedsOPML"); |
1317 | ||
afcfe6ca AD |
1318 | print "</div>"; # pane |
1319 | ||
1320 | if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) { | |
1321 | ||
1322 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">"; | |
1323 | ||
11334fdf | 1324 | print_notice(__('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.')); |
afcfe6ca AD |
1325 | |
1326 | print "<p>"; | |
1327 | ||
1328 | print "<button onclick='window.navigator.registerContentHandler(" . | |
1329 | "\"application/vnd.mozilla.maybe.feed\", " . | |
c114a259 | 1330 | "\"" . $this->subscribe_to_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . |
afcfe6ca AD |
1331 | __('Click here to register this site as a feed reader.') . |
1332 | "</button>"; | |
1333 | ||
1334 | print "</p>"; | |
1335 | ||
1336 | print "</div>"; # pane | |
1337 | } | |
1338 | ||
e95e7819 | 1339 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles / Generated feeds')."\">"; |
afcfe6ca | 1340 | |
73dfda1d | 1341 | print "<p>" . __('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.') . "</p>"; |
afcfe6ca AD |
1342 | |
1343 | $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . | |
1344 | "/public.php?op=rss&id=-2&view-mode=all_articles");; | |
1345 | ||
11334fdf AD |
1346 | print "<p>"; |
1347 | ||
fb54e3b1 | 1348 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("View as RSS")."','generatedFeed', '$rss_url')\">". |
afcfe6ca AD |
1349 | __('Display URL')."</button> "; |
1350 | ||
73dfda1d | 1351 | print "<button class=\"warning\" dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">". |
afcfe6ca AD |
1352 | __('Clear all generated URLs')."</button> "; |
1353 | ||
11334fdf | 1354 | print "</p>"; |
afcfe6ca | 1355 | |
1ffe3391 | 1356 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
699daf58 AD |
1357 | "hook_prefs_tab_section", "prefFeedsPublishedGenerated"); |
1358 | ||
afcfe6ca AD |
1359 | print "</div>"; #pane |
1360 | ||
1ffe3391 | 1361 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
6065f3ad AD |
1362 | "hook_prefs_tab", "prefFeeds"); |
1363 | ||
afcfe6ca | 1364 | print "</div>"; #container |
afcfe6ca | 1365 | } |
2ecd2df5 | 1366 | |
88918ca6 | 1367 | private function feedlist_init_cat($cat_id) { |
2ecd2df5 AD |
1368 | $obj = array(); |
1369 | $cat_id = (int) $cat_id; | |
1370 | ||
1371 | if ($cat_id > 0) { | |
2ed0d6c4 | 1372 | $cat_unread = CCache::find($cat_id, $_SESSION["uid"], true); |
2ecd2df5 | 1373 | } else if ($cat_id == 0 || $cat_id == -2) { |
86a8351c | 1374 | $cat_unread = Feeds::getCategoryUnread($cat_id); |
2ecd2df5 AD |
1375 | } |
1376 | ||
1377 | $obj['id'] = 'CAT:' . $cat_id; | |
1378 | $obj['items'] = array(); | |
a230bf88 | 1379 | $obj['name'] = Feeds::getCategoryTitle($cat_id); |
2ecd2df5 AD |
1380 | $obj['type'] = 'category'; |
1381 | $obj['unread'] = (int) $cat_unread; | |
2ecd2df5 AD |
1382 | $obj['bare_id'] = $cat_id; |
1383 | ||
1384 | return $obj; | |
1385 | } | |
1386 | ||
1387 | private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') { | |
1388 | $obj = array(); | |
1389 | $feed_id = (int) $feed_id; | |
1390 | ||
1391 | if (!$title) | |
86a8351c | 1392 | $title = Feeds::getFeedTitle($feed_id, false); |
2ecd2df5 AD |
1393 | |
1394 | if ($unread === false) | |
a42c55f0 | 1395 | $unread = getFeedUnread($feed_id, false); |
2ecd2df5 AD |
1396 | |
1397 | $obj['id'] = 'FEED:' . $feed_id; | |
1398 | $obj['name'] = $title; | |
1399 | $obj['unread'] = (int) $unread; | |
1400 | $obj['type'] = 'feed'; | |
1401 | $obj['error'] = $error; | |
1402 | $obj['updated'] = $updated; | |
86a8351c | 1403 | $obj['icon'] = Feeds::getFeedIcon($feed_id); |
2ecd2df5 | 1404 | $obj['bare_id'] = $feed_id; |
c594eca0 | 1405 | $obj['auxcounter'] = 0; |
2ecd2df5 AD |
1406 | |
1407 | return $obj; | |
1408 | } | |
1409 | ||
bc6fa236 AD |
1410 | function inactiveFeeds() { |
1411 | ||
1412 | if (DB_TYPE == "pgsql") { | |
1413 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1414 | } else { | |
1415 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1416 | } | |
1417 | ||
7a1872c1 | 1418 | $sth = $this->pdo->prepare("SELECT ttrss_feeds.title, ttrss_feeds.site_url, |
bc6fa236 AD |
1419 | ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article |
1420 | FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE | |
1421 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
1422 | ttrss_entries.id = ref_id AND | |
1423 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart | |
7a1872c1 | 1424 | AND ttrss_feeds.owner_uid = ? AND |
bc6fa236 AD |
1425 | ttrss_user_entries.feed_id = ttrss_feeds.id AND |
1426 | ttrss_entries.id = ref_id | |
1427 | GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url | |
1428 | ORDER BY last_article"); | |
7a1872c1 | 1429 | $sth->execute([$_SESSION['uid']]); |
bc6fa236 | 1430 | |
11334fdf | 1431 | print "<p" .__("These feeds have not been updated with new content for 3 months (oldest first):") . "</p>"; |
bc6fa236 AD |
1432 | |
1433 | print "<div dojoType=\"dijit.Toolbar\">"; | |
1434 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1435 | "<span>" . __('Select')."</span>"; | |
1436 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1437 | print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\" | |
1438 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1439 | print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\" | |
1440 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1441 | print "</div></div>"; | |
1442 | print "</div>"; #toolbar | |
1443 | ||
1444 | print "<div class=\"inactiveFeedHolder\">"; | |
1445 | ||
1446 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">"; | |
1447 | ||
1448 | $lnum = 1; | |
1449 | ||
7a1872c1 | 1450 | while ($line = $sth->fetch()) { |
bc6fa236 | 1451 | |
bc6fa236 AD |
1452 | $feed_id = $line["id"]; |
1453 | $this_row_id = "id=\"FUPDD-$feed_id\""; | |
1454 | ||
1455 | # class needed for selectTableRows() | |
1456 | print "<tr class=\"placeholder\" $this_row_id>"; | |
1457 | ||
bc6fa236 AD |
1458 | # id needed for selectTableRows() |
1459 | print "<td width='5%' align='center'><input | |
1460 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
1461 | type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>"; | |
1462 | print "<td>"; | |
1463 | ||
1464 | print "<a class=\"visibleLink\" href=\"#\" ". | |
1465 | "title=\"".__("Click to edit feed")."\" ". | |
1466 | "onclick=\"editFeed(".$line["id"].")\">". | |
1467 | htmlspecialchars($line["title"])."</a>"; | |
1468 | ||
1469 | print "</td><td class=\"insensitive\" align='right'>"; | |
a42c55f0 | 1470 | print make_local_datetime($line['last_article'], false); |
bc6fa236 AD |
1471 | print "</td>"; |
1472 | print "</tr>"; | |
1473 | ||
1474 | ++$lnum; | |
1475 | } | |
1476 | ||
1477 | print "</table>"; | |
1478 | print "</div>"; | |
1479 | ||
1480 | print "<div class='dlgButtons'>"; | |
1481 | print "<div style='float : left'>"; | |
73dfda1d | 1482 | print "<button class=\"danger\" dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">" |
bc6fa236 AD |
1483 | .__('Unsubscribe from selected feeds')."</button> "; |
1484 | print "</div>"; | |
1485 | ||
1486 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">". | |
1487 | __('Close this window')."</button>"; | |
1488 | ||
1489 | print "</div>"; | |
1490 | ||
1491 | } | |
1492 | ||
1493 | function feedsWithErrors() { | |
7a1872c1 AD |
1494 | $sth = $this->pdo->prepare("SELECT id,title,feed_url,last_error,site_url |
1495 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?"); | |
1496 | $sth->execute([$_SESSION['uid']]); | |
bc6fa236 AD |
1497 | |
1498 | print "<div dojoType=\"dijit.Toolbar\">"; | |
1499 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
1500 | "<span>" . __('Select')."</span>"; | |
1501 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1502 | print "<div onclick=\"selectTableRows('prefErrorFeedList', 'all')\" | |
1503 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1504 | print "<div onclick=\"selectTableRows('prefErrorFeedList', 'none')\" | |
1505 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
1506 | print "</div></div>"; | |
1507 | print "</div>"; #toolbar | |
1508 | ||
1509 | print "<div class=\"inactiveFeedHolder\">"; | |
1510 | ||
1511 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">"; | |
1512 | ||
1513 | $lnum = 1; | |
1514 | ||
7a1872c1 | 1515 | while ($line = $sth->fetch()) { |
bc6fa236 | 1516 | |
bc6fa236 AD |
1517 | $feed_id = $line["id"]; |
1518 | $this_row_id = "id=\"FERDD-$feed_id\""; | |
1519 | ||
1520 | # class needed for selectTableRows() | |
1521 | print "<tr class=\"placeholder\" $this_row_id>"; | |
1522 | ||
bc6fa236 AD |
1523 | # id needed for selectTableRows() |
1524 | print "<td width='5%' align='center'><input | |
1525 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
1526 | type=\"checkbox\" id=\"FERDC-$feed_id\"></td>"; | |
1527 | print "<td>"; | |
1528 | ||
1529 | print "<a class=\"visibleLink\" href=\"#\" ". | |
1530 | "title=\"".__("Click to edit feed")."\" ". | |
1531 | "onclick=\"editFeed(".$line["id"].")\">". | |
1532 | htmlspecialchars($line["title"])."</a>: "; | |
1533 | ||
1534 | print "<span class=\"insensitive\">"; | |
1535 | print htmlspecialchars($line["last_error"]); | |
1536 | print "</span>"; | |
1537 | ||
1538 | print "</td>"; | |
1539 | print "</tr>"; | |
1540 | ||
1541 | ++$lnum; | |
1542 | } | |
1543 | ||
1544 | print "</table>"; | |
1545 | print "</div>"; | |
1546 | ||
1547 | print "<div class='dlgButtons'>"; | |
1548 | print "<div style='float : left'>"; | |
73dfda1d | 1549 | print "<button class=\"danger\" dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">" |
bc6fa236 AD |
1550 | .__('Unsubscribe from selected feeds')."</button> "; |
1551 | print "</div>"; | |
1552 | ||
1553 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">". | |
1554 | __('Close this window')."</button>"; | |
1555 | ||
1556 | print "</div>"; | |
1557 | } | |
1558 | ||
a42c55f0 | 1559 | private function remove_feed_category($id, $owner_uid) { |
a6a9b812 | 1560 | |
7a1872c1 AD |
1561 | $sth = $this->pdo->prepare("DELETE FROM ttrss_feed_categories |
1562 | WHERE id = ? AND owner_uid = ?"); | |
1563 | $sth->execute([$id, $owner_uid]); | |
a6a9b812 | 1564 | |
2ed0d6c4 | 1565 | CCache::remove($id, $owner_uid, true); |
a6a9b812 AD |
1566 | } |
1567 | ||
a42c55f0 | 1568 | static function remove_feed($id, $owner_uid) { |
a6a9b812 | 1569 | |
7a1872c1 AD |
1570 | $pdo = Db::pdo(); |
1571 | ||
a6a9b812 | 1572 | if ($id > 0) { |
7a1872c1 | 1573 | $pdo->beginTransaction(); |
a6a9b812 AD |
1574 | |
1575 | /* save starred articles in Archived feed */ | |
1576 | ||
a6a9b812 AD |
1577 | /* prepare feed if necessary */ |
1578 | ||
7a1872c1 AD |
1579 | $sth = $pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ? |
1580 | AND owner_uid = ?"); | |
1581 | $sth->execute([$id, $owner_uid]); | |
aa5ac2cd | 1582 | |
7a1872c1 AD |
1583 | if ($row = $sth->fetch()) { |
1584 | $feed_url = $row["feed_url"]; | |
aa5ac2cd | 1585 | |
7a1872c1 AD |
1586 | $sth = $pdo->prepare("SELECT id FROM ttrss_archived_feeds |
1587 | WHERE feed_url = ? AND owner_uid = ?"); | |
1588 | $sth->execute([$feed_url, $owner_uid]); | |
a6a9b812 | 1589 | |
7a1872c1 AD |
1590 | if ($row = $sth->fetch()) { |
1591 | $archive_id = $row["id"]; | |
1592 | } else { | |
1593 | $res = $pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds"); | |
1594 | $row = $res->fetch(); | |
b1df14d0 | 1595 | |
7a1872c1 | 1596 | $new_feed_id = (int)$row['id'] + 1; |
aa5ac2cd | 1597 | |
7a1872c1 AD |
1598 | $sth = $pdo->prepare("INSERT INTO ttrss_archived_feeds |
1599 | (id, owner_uid, title, feed_url, site_url) | |
1600 | SELECT ?, owner_uid, title, feed_url, site_url from ttrss_feeds | |
1601 | WHERE id = ?"); | |
1602 | $sth->execute([$new_feed_id, $id]); | |
1603 | ||
1604 | $archive_id = $new_feed_id; | |
1605 | } | |
a6a9b812 | 1606 | |
7a1872c1 AD |
1607 | $sth = $pdo->prepare("UPDATE ttrss_user_entries SET feed_id = NULL, |
1608 | orig_feed_id = ? WHERE feed_id = ? AND | |
1609 | marked = true AND owner_uid = ?"); | |
a6a9b812 | 1610 | |
7a1872c1 | 1611 | $sth->execute([$archive_id, $id, $owner_uid]); |
a6a9b812 | 1612 | |
7a1872c1 | 1613 | /* Remove access key for the feed */ |
a6a9b812 | 1614 | |
7a1872c1 AD |
1615 | $sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE |
1616 | feed_id = ? AND owner_uid = ?"); | |
1617 | $sth->execute([$id, $owner_uid]); | |
a6a9b812 | 1618 | |
7a1872c1 AD |
1619 | /* remove the feed */ |
1620 | ||
1621 | $sth = $pdo->prepare("DELETE FROM ttrss_feeds | |
1622 | WHERE id = ? AND owner_uid = ?"); | |
1623 | $sth->execute([$id, $owner_uid]); | |
1624 | } | |
a6a9b812 | 1625 | |
7a1872c1 | 1626 | $pdo->commit(); |
a6a9b812 AD |
1627 | |
1628 | if (file_exists(ICONS_DIR . "/$id.ico")) { | |
1629 | unlink(ICONS_DIR . "/$id.ico"); | |
1630 | } | |
1631 | ||
2ed0d6c4 | 1632 | CCache::remove($id, $owner_uid); |
a6a9b812 AD |
1633 | |
1634 | } else { | |
7c9b5a3f | 1635 | Labels::remove(Labels::feed_to_label_id($id), $owner_uid); |
2ed0d6c4 | 1636 | //CCache::remove($id, $owner_uid); don't think labels are cached |
a6a9b812 AD |
1637 | } |
1638 | } | |
87d7e850 | 1639 | |
201bb1ca | 1640 | function batchSubscribe() { |
328118d1 AD |
1641 | print_hidden("op", "pref-feeds"); |
1642 | print_hidden("method", "batchaddfeeds"); | |
201bb1ca AD |
1643 | |
1644 | print "<table width='100%'><tr><td> | |
1645 | ".__("Add one valid RSS feed per line (no feed detection is done)")." | |
1646 | </td><td align='right'>"; | |
a42c55f0 | 1647 | if (get_pref('ENABLE_FEED_CATS')) { |
201bb1ca | 1648 | print __('Place in category:') . " "; |
a42c55f0 | 1649 | print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"'); |
201bb1ca AD |
1650 | } |
1651 | print "</td></tr><tr><td colspan='2'>"; | |
1652 | print "<textarea | |
fb8a032a | 1653 | style='font-size : 12px; width : 98%; height: 200px;' |
201bb1ca AD |
1654 | placeHolder=\"".__("Feeds to subscribe, One per line")."\" |
1655 | dojoType=\"dijit.form.SimpleTextarea\" required=\"1\" name=\"feeds\"></textarea>"; | |
1656 | ||
1657 | print "</td></tr><tr><td colspan='2'>"; | |
1658 | ||
1659 | print "<div id='feedDlg_loginContainer' style='display : none'> | |
1660 | " . | |
1661 | " <input dojoType=\"dijit.form.TextBox\" name='login'\" | |
1662 | placeHolder=\"".__("Login")."\" | |
1663 | style=\"width : 10em;\"> ". | |
1664 | " <input | |
1665 | placeHolder=\"".__("Password")."\" | |
1666 | dojoType=\"dijit.form.TextBox\" type='password' | |
ec21abb8 | 1667 | autocomplete=\"new-password\" |
201bb1ca AD |
1668 | style=\"width : 10em;\" name='pass'\">". |
1669 | "</div>"; | |
1670 | ||
1671 | print "</td></tr><tr><td colspan='2'>"; | |
1672 | ||
1673 | print "<div style=\"clear : both\"> | |
1674 | <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\" | |
1675 | onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'> | |
1676 | <label for=\"feedDlg_loginCheck\">". | |
1677 | __('Feeds require authentication.')."</div>"; | |
1678 | ||
1679 | print "</form>"; | |
1680 | ||
1681 | print "</td></tr></table>"; | |
1682 | ||
1683 | print "<div class=\"dlgButtons\"> | |
1684 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').execute()\">".__('Subscribe')."</button> | |
1685 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button> | |
1686 | </div>"; | |
1687 | } | |
1688 | ||
96e3ae8c | 1689 | function batchAddFeeds() { |
bf4a79ea | 1690 | $cat_id = $_REQUEST['cat']; |
2714d5ca | 1691 | $feeds = explode("\n", $_REQUEST['feeds']); |
bf4a79ea | 1692 | $login = $_REQUEST['login']; |
41694a95 | 1693 | $pass = trim($_REQUEST['pass']); |
96e3ae8c AD |
1694 | |
1695 | foreach ($feeds as $feed) { | |
bf4a79ea | 1696 | $feed = trim($feed); |
96e3ae8c AD |
1697 | |
1698 | if (validate_feed_url($feed)) { | |
1699 | ||
2e52e4fd | 1700 | $this->pdo->beginTransaction(); |
96e3ae8c | 1701 | |
2e52e4fd AD |
1702 | $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds |
1703 | WHERE feed_url = ? AND owner_uid = ?"); | |
1704 | $sth->execute([$feed, $_SESSION['uid']]); | |
41694a95 | 1705 | |
2e52e4fd AD |
1706 | if (!$sth->fetch()) { |
1707 | $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds | |
044cff2d | 1708 | (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted) |
2e52e4fd AD |
1709 | VALUES (?, ?, '[Unknown]', ?, ?, ?, 0, false)"); |
1710 | ||
1711 | $sth->execute([$_SESSION['uid'], $feed, $cat_id ? $cat_id : null, $login, $pass]); | |
96e3ae8c AD |
1712 | } |
1713 | ||
2e52e4fd | 1714 | $this->pdo->commit(); |
96e3ae8c AD |
1715 | } |
1716 | } | |
1717 | } | |
201bb1ca | 1718 | |
195187c4 | 1719 | function regenOPMLKey() { |
a42c55f0 | 1720 | $this->update_feed_access_key('OPML:Publish', |
195187c4 AD |
1721 | false, $_SESSION["uid"]); |
1722 | ||
6322ac79 | 1723 | $new_link = Opml::opml_publish_url(); |
195187c4 AD |
1724 | |
1725 | print json_encode(array("link" => $new_link)); | |
1726 | } | |
1727 | ||
1728 | function regenFeedKey() { | |
bf4a79ea AD |
1729 | $feed_id = $_REQUEST['id']; |
1730 | $is_cat = $_REQUEST['is_cat'] == "true"; | |
195187c4 | 1731 | |
a42c55f0 | 1732 | $new_key = $this->update_feed_access_key($feed_id, $is_cat); |
195187c4 AD |
1733 | |
1734 | print json_encode(array("link" => $new_key)); | |
1735 | } | |
1736 | ||
1737 | ||
a42c55f0 | 1738 | private function update_feed_access_key($feed_id, $is_cat, $owner_uid = false) { |
195187c4 AD |
1739 | if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
1740 | ||
bf6db17b AD |
1741 | // clear old value and generate new one |
1742 | $sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys | |
1743 | WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?"); | |
1744 | $sth->execute([$feed_id, $is_cat, $owner_uid]); | |
195187c4 | 1745 | |
bf6db17b | 1746 | return get_feed_access_key($feed_id, $is_cat, $owner_uid); |
195187c4 AD |
1747 | } |
1748 | ||
1749 | // Silent | |
1750 | function clearKeys() { | |
2e52e4fd AD |
1751 | $sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys WHERE |
1752 | owner_uid = ?"); | |
1753 | $sth->execute([$_SESSION['uid']]); | |
195187c4 AD |
1754 | } |
1755 | ||
496195db AD |
1756 | private function calculate_children_count($cat) { |
1757 | $c = 0; | |
1758 | ||
1759 | foreach ($cat['items'] as $child) { | |
1760 | if ($child['type'] == 'category') { | |
1761 | $c += $this->calculate_children_count($child); | |
1762 | } else { | |
1763 | $c += 1; | |
1764 | } | |
1765 | } | |
1766 | ||
1767 | return $c; | |
1768 | } | |
195187c4 | 1769 | |
f9c1f8b0 AD |
1770 | function getinactivefeeds() { |
1771 | if (DB_TYPE == "pgsql") { | |
1772 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1773 | } else { | |
1774 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1775 | } | |
1776 | ||
2e52e4fd | 1777 | $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_inactive FROM ttrss_feeds WHERE |
f9c1f8b0 AD |
1778 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE |
1779 | ttrss_entries.id = ref_id AND | |
1780 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND | |
2e52e4fd AD |
1781 | ttrss_feeds.owner_uid = ?"); |
1782 | $sth->execute([$_SESSION['uid']]); | |
f9c1f8b0 | 1783 | |
2e52e4fd AD |
1784 | if ($row = $sth->fetch()) { |
1785 | print (int)$row["num_inactive"]; | |
1786 | } | |
f9c1f8b0 | 1787 | } |
c114a259 AD |
1788 | |
1789 | static function subscribe_to_feed_url() { | |
1790 | $url_path = get_self_url_prefix() . | |
1791 | "/public.php?op=subscribe&feed_url=%s"; | |
1792 | return $url_path; | |
1793 | } | |
1794 | ||
ea79a0e0 | 1795 | } |