Add table to doc util script
- Remove db parameter from several places - Add constructors for document types
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user