Add table to doc util script

- Remove db parameter from several places
- Add constructors for document types
This commit is contained in:
2024-06-01 23:17:29 -04:00
parent 610ab67475
commit b88ad1f268
26 changed files with 306 additions and 262 deletions

View File

@@ -7,24 +7,23 @@
use BitBadger\Documents\DocumentException;
use BitBadger\Documents\Field;
use BitBadger\Documents\SQLite\Configuration;
use BitBadger\Documents\SQLite\Delete;
use FeedReaderCentral\Data;
use FeedReaderCentral\Feed;
use FeedReaderCentral\Security;
use FeedReaderCentral\Table;
include '../../start.php';
$db = Data::getConnection();
Security::verifyUser($db);
Security::verifyUser();
$feedId = $_GET['id'] ?? '';
if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
try {
if (!($feed = Feed::retrieveById($feedId))) not_found();
Delete::byFields(Table::ITEM, [Field::EQ('feed_id', $feed->id)], $db);
Delete::byId(Table::FEED, $feed->id, $db);
Delete::byFields(Table::ITEM, [Field::EQ('feed_id', $feed->id)]);
Delete::byId(Table::FEED, $feed->id);
add_info('Feed “' . htmlentities($feed->title) . '” deleted successfully');
$db->close();
frc_redirect('/feeds');
@@ -33,6 +32,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
}
}
$db = Configuration::dbConn();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
try {
$isNew = $_POST['id'] == 'new';

View File

@@ -5,18 +5,18 @@
* Lists items in a given feed (all, unread, or bookmarked)
*/
use FeedReaderCentral\Data;
use BitBadger\Documents\SQLite\Configuration;
use FeedReaderCentral\Feed;
use FeedReaderCentral\ItemList;
use FeedReaderCentral\Security;
include '../../start.php';
$db = Data::getConnection();
Security::verifyUser($db);
Security::verifyUser();
if (!($feed = Feed::retrieveById($_GET['id']))) not_found();
$db = Configuration::dbConn();
$list = match (true) {
key_exists('unread', $_GET) => ItemList::unreadForFeed($feed->id, $db),
key_exists('bookmarked', $_GET) => ItemList::bookmarkedForFeed($feed->id, $db),