From 163d7d2b4b75834342891ff411ff1e8e1a0471d3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 23 Oct 2017 00:34:04 -0400 Subject: [PATCH] Add profile availability field - Add available field to profile table - Make profile unavailable in directory until update suceeds --- include/submit.php | 3 +++ mod/directory.php | 4 ++-- mod/search.php | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/submit.php b/include/submit.php index 255f6021..c454a356 100644 --- a/include/submit.php +++ b/include/submit.php @@ -31,6 +31,7 @@ function run_submit($url) { $profile_id = $r[0]['id']; $r = q("UPDATE `profile` SET + `available` = 0, `updated` = '%s' WHERE `id` = %d LIMIT 1", @@ -56,6 +57,7 @@ function run_submit($url) { //Skip the scrape? :D $noscrape = $site_health && $site_health['no_scrape_url']; + if($noscrape){ //Find out who to look up. @@ -128,6 +130,7 @@ function run_submit($url) { `nurl` = '%s', `comm` = %d, `tags` = '%s', + `available` = 1, `updated` = '%s' WHERE `id` = %d LIMIT 1", diff --git a/mod/directory.php b/mod/directory.php index 9f1aa9c3..bd3a879d 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -46,7 +46,7 @@ function directory_content(App $a) $sql_extra = str_replace('%', '%%', $sql_extra); - $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 $sql_extra "); + $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 AND `available` = 1 $sql_extra "); if (count($r)) { $total = $r[0]['total']; $a->set_pager_total($total); @@ -58,7 +58,7 @@ function directory_content(App $a) $order = ' ORDER BY `updated` DESC, `id` DESC '; } - $r = q("SELECT * FROM `profile` WHERE `censored` = 0 $sql_extra $order LIMIT %d , %d ", + $r = q("SELECT * FROM `profile` WHERE `censored` = 0 AND `available` = 1 $sql_extra $order LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage']) ); diff --git a/mod/search.php b/mod/search.php index c88795c7..ad07863b 100644 --- a/mod/search.php +++ b/mod/search.php @@ -60,7 +60,7 @@ function search_content(App $a) $sql_extra = str_replace('%', '%%', $sql_extra); $total = 0; - $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 $sql_extra "); + $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 AND `available` = 1 $sql_extra "); if (count($r)) { $total = $r[0]['total']; $a->set_pager_total($total); @@ -72,7 +72,7 @@ function search_content(App $a) $order = ' ORDER BY `updated` DESC, `id` DESC '; } - $r = q("SELECT * FROM `profile` WHERE `censored` = 0 $sql_extra $order LIMIT %d , %d ", + $r = q("SELECT * FROM `profile` WHERE `censored` = 0 AND `available` = 1 $sql_extra $order LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage']) );